llvm.org GIT mirror llvm / 392c102
[DAGCombiner] Do not generate ISD::ADDE node if adde is not legal for the target when combine ISD::TRUNC node Do not combine (trunc adde(X, Y, Carry)) into (adde trunc(X), trunc(Y), Carry), if adde is not legal for the target. Even it's at type-legalize phase. Because adde is special and will not be legalized at operation-legalize phase later. This fixes: PR40922 https://bugs.llvm.org/show_bug.cgi?id=40922 Differential Revision: https://reviews.llvm.org//D60854 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359532 91177308-0d34-0410-b5e6-96231b3b80d8 Zi Xuan Wu 1 year, 4 months ago
3 changed file(s) with 41 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1025610256 // When the adde's carry is not used.
1025710257 if ((N0.getOpcode() == ISD::ADDE || N0.getOpcode() == ISD::ADDCARRY) &&
1025810258 N0.hasOneUse() && !N0.getNode()->hasAnyUseOfValue(1) &&
10259 (!LegalOperations || TLI.isOperationLegal(N0.getOpcode(), VT))) {
10259 // We only do for addcarry before legalize operation
10260 ((!LegalOperations && N0.getOpcode() == ISD::ADDCARRY) ||
10261 TLI.isOperationLegal(N0.getOpcode(), VT))) {
1026010262 SDLoc SL(N);
1026110263 auto X = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(0));
1026210264 auto Y = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(1));
1919 ; CHECK: # %bb.0:
2020 ; CHECK-DAG: addis [[REG1:[0-9]+]], [[REG2:[0-9]+]], [[VAR1:[a-z0-9A-Z_.]+]]@toc@ha
2121 ; CHECK-DAG: ld [[REG3:[0-9]+]], [[VAR1]]@toc@l([[REG1]])
22 ; CHECK-DAG: lbz [[REG4:[0-9]+]], 0([[REG3]])
22 ; CHECK-DAG: lwz [[REG4:[0-9]+]], 0([[REG3]])
2323 ; CHECK-DAG: addic [[REG5:[0-9]+]], [[REG3]], -1
24 ; CHECK-DAG: extsb [[REG6:[0-9]+]], [[REG4]]
25 ; CHECK-DAG: addze [[REG7:[0-9]+]], [[REG6]]
24 ; CHECK-DAG: addze [[REG7:[0-9]+]], [[REG4]]
2625 ; CHECK-DAG: addis [[REG8:[0-9]+]], [[REG2]], [[VAR2:[a-z0-9A-Z_.]+]]@toc@ha
2726 ; CHECK-DAG: andi. [[REG9:[0-9]+]], [[REG7]], 5
2827 ; CHECK-DAG: stb [[REG9]], [[VAR2]]@toc@l([[REG8]])
0 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu < %s | FileCheck %s
1
2 ; Test case adapted from PR40922.
3
4 @a.b = internal global i32 0, align 4
5
6 define i32 @a() {
7 entry:
8 %call = tail call i32 bitcast (i32 (...)* @d to i32 ()*)()
9 %0 = load i32, i32* @a.b, align 4
10 %conv = zext i32 %0 to i64
11 %add = add nuw nsw i64 %conv, 6
12 %and = and i64 %add, 8589934575
13 %cmp = icmp ult i64 %and, %conv
14 br i1 %cmp, label %if.then, label %if.end
15
16 if.then: ; preds = %entry
17 %call3 = tail call i32 bitcast (i32 (...)* @e to i32 ()*)()
18 br label %if.end
19
20 if.end: ; preds = %if.then, %entry
21 store i32 %call, i32* @a.b, align 4
22 ret i32 undef
23 }
24
25 ; CHECK-LABEL: @a
26 ; CHECK: li 5, 0
27 ; CHECK: mr 30, 3
28 ; CHECK: addic 6, 4, 6
29 ; CHECK: addze 5, 5
30 ; CHECK: rlwinm 6, 6, 0, 28, 26
31 ; CHECK: andi. 5, 5, 1
32
33 declare i32 @d(...)
34
35 declare i32 @e(...)