Skip to content

Commit 7907292

Browse files
authored
[DAG] Apply Disjoint flag. (#118045)
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 c3536b2 commit 7907292

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
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)) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=aarch64-none-eabi %s -o - | FileCheck %s
3+
4+
define i32 @test(i32 %a) {
5+
; CHECK-LABEL: test:
6+
; CHECK: // %bb.0: // %entry
7+
; CHECK-NEXT: add w0, w0, #193
8+
; CHECK-NEXT: ret
9+
entry:
10+
%add = add i32 %a, 1
11+
%or1 = or disjoint i32 %add, 64
12+
%or = or disjoint i32 %or1, 128
13+
ret i32 %or
14+
}

0 commit comments

Comments
 (0)