[llvm] 7907292 - [DAG] Apply Disjoint flag. (#118045)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 17:21:07 PST 2024
Author: fengfeng
Date: 2024-12-03T09:21:03+08:00
New Revision: 7907292daa781aaba2be531a8599998f5fd3f645
URL: https://github.com/llvm/llvm-project/commit/7907292daa781aaba2be531a8599998f5fd3f645
DIFF: https://github.com/llvm/llvm-project/commit/7907292daa781aaba2be531a8599998f5fd3f645.diff
LOG: [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 <feng.feng at iluvatar.com>
Added:
llvm/test/CodeGen/AArch64/apply-disjoint-flag-in-dagcombine.ll
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6c8e9969784c92..6435a2119077f5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1220,8 +1220,11 @@ SDValue DAGCombiner::reassociateOpsCommutative(unsigned Opc, const SDLoc &DL,
if (DAG.isConstantIntBuildVectorOrConstantInt(N1)) {
// Reassociate: (op (op x, c1), c2) -> (op x, (op c1, c2))
- if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, DL, VT, {N01, N1}))
+ if (SDValue OpNode = DAG.FoldConstantArithmetic(Opc, DL, VT, {N01, N1})) {
+ NewFlags.setDisjoint(Flags.hasDisjoint() &&
+ N0->getFlags().hasDisjoint());
return DAG.getNode(Opc, DL, VT, N00, OpNode, NewFlags);
+ }
return SDValue();
}
if (TLI.isReassocProfitable(DAG, N0, N1)) {
diff --git a/llvm/test/CodeGen/AArch64/apply-disjoint-flag-in-dagcombine.ll b/llvm/test/CodeGen/AArch64/apply-disjoint-flag-in-dagcombine.ll
new file mode 100644
index 00000000000000..5622f2ae20efde
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/apply-disjoint-flag-in-dagcombine.ll
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-none-eabi %s -o - | FileCheck %s
+
+define i32 @test(i32 %a) {
+; CHECK-LABEL: test:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: add w0, w0, #193
+; CHECK-NEXT: ret
+entry:
+ %add = add i32 %a, 1
+ %or1 = or disjoint i32 %add, 64
+ %or = or disjoint i32 %or1, 128
+ ret i32 %or
+}
More information about the llvm-commits
mailing list