Skip to content

Commit 7b3f0d1

Browse files
committed
[DAG] Apply Disjoint flag.
or disjoint (or disjoint (x, c0), c1) --> or disjont x, or (c0, c1) Alive2: https://alive2.llvm.org/ce/z/3wPth5 Signed-off-by: feng.feng <[email protected]>
1 parent 6f794b3 commit 7b3f0d1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,11 @@ SDValue DAGCombiner::reassociateOpsCommutative(unsigned Opc, const SDLoc &DL,
12201220

12211221
if (DAG.isConstantIntBuildVectorOrConstantInt(N1)) {
12221222
// Reassociate: (op (op x, c1), c2) -> (op x, (op c1, c2))
1223-
if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, DL, VT, {N01, N1}))
1223+
if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, DL, VT, {N01, N1})) {
1224+
NewFlags.setDisjoint(Flags.hasDisjoint() &&
1225+
N0->getFlags().hasDisjoint());
12241226
return DAG.getNode(Opc, DL, VT, N00, OpNode, NewFlags);
1227+
}
12251228
return SDValue();
12261229
}
12271230
if (TLI.isReassocProfitable(DAG, N0, N1)) {

llvm/test/CodeGen/AArch64/apply-disjoint-flag-in-dagcombine.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
define i32 @test(i32 %a) {
55
; CHECK-LABEL: test:
66
; CHECK: // %bb.0: // %entry
7-
; CHECK-NEXT: add w8, w0, #1
8-
; CHECK-NEXT: orr w0, w8, #0xc0
7+
; CHECK-NEXT: add w0, w0, #193
98
; CHECK-NEXT: ret
109
entry:
1110
%add = add i32 %a, 1

0 commit comments

Comments
 (0)