[PATCH] D150769: [SelectionDAG][computeKnownBits]: Move ISD::ADD/ISD::SUB into their own cases
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 03:25:51 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b3912e9b8cb: Reapply [SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits() (authored by 0xdc03, committed by nikic).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150769/new/
https://reviews.llvm.org/D150769
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/Thumb2/mve-blockplacement.ll
Index: llvm/test/CodeGen/Thumb2/mve-blockplacement.ll
===================================================================
--- llvm/test/CodeGen/Thumb2/mve-blockplacement.ll
+++ llvm/test/CodeGen/Thumb2/mve-blockplacement.ll
@@ -366,18 +366,16 @@
; CHECK-NEXT: str r0, [sp, #12] @ 4-byte Spill
; CHECK-NEXT: movs r1, #4
; CHECK-NEXT: strd r2, r12, [sp, #4] @ 8-byte Folded Spill
-; CHECK-NEXT: add.w r3, r3, r4, lsr #1
; CHECK-NEXT: add.w r1, r1, r4, lsr #1
-; CHECK-NEXT: movw r4, #65532
-; CHECK-NEXT: vdup.32 q6, r3
-; CHECK-NEXT: movt r4, #32767
-; CHECK-NEXT: and.w r7, r1, r4
+; CHECK-NEXT: add.w r3, r3, r4, lsr #1
+; CHECK-NEXT: bic r7, r1, #3
; CHECK-NEXT: adr r1, .LCPI1_0
-; CHECK-NEXT: vdup.32 q7, r3
; CHECK-NEXT: vldrw.u32 q0, [r1]
; CHECK-NEXT: adr r1, .LCPI1_1
; CHECK-NEXT: vldrw.u32 q5, [r1]
+; CHECK-NEXT: vdup.32 q6, r3
; CHECK-NEXT: vadd.i32 q4, q0, lr
+; CHECK-NEXT: vdup.32 q7, r3
; CHECK-NEXT: b .LBB1_4
; CHECK-NEXT: .LBB1_2: @ %for.body6.preheader
; CHECK-NEXT: @ in Loop: Header=BB1_4 Depth=1
Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2694,11 +2694,9 @@
if (Op.getOpcode() == ISD::MUL) {
Known = KnownBits::mul(KnownOp0, KnownOp1);
} else { // Op.getOpcode() is either ISD::ADD or ISD::SUB.
- // TODO: Update `computeForAddCarry` to handle the NSW flag as well so
- // that `Flags.hasNoSignedWrap()` can be passed through here
- // instead of false.
- Known = KnownBits::computeForAddSub(Op.getOpcode() == ISD::ADD, false,
- KnownOp0, KnownOp1);
+ Known = KnownBits::computeForAddSub(Op.getOpcode() == ISD::ADD,
+ Flags.hasNoSignedWrap(), KnownOp0,
+ KnownOp1);
}
break;
}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3646,6 +3646,15 @@
// All bits are zero except the low bit.
Known.Zero.setBitsFrom(1);
break;
+ case ISD::ADD:
+ case ISD::SUB: {
+ SDNodeFlags Flags = Op.getNode()->getFlags();
+ Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
+ Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
+ Known = KnownBits::computeForAddSub(Op.getOpcode() == ISD::ADD,
+ Flags.hasNoSignedWrap(), Known, Known2);
+ break;
+ }
case ISD::USUBO:
case ISD::SSUBO:
case ISD::USUBO_CARRY:
@@ -3659,7 +3668,6 @@
break;
}
[[fallthrough]];
- case ISD::SUB:
case ISD::SUBC: {
assert(Op.getResNo() == 0 &&
"We only compute knownbits for the difference here.");
@@ -3687,7 +3695,6 @@
break;
}
[[fallthrough]];
- case ISD::ADD:
case ISD::ADDC:
case ISD::ADDE: {
assert(Op.getResNo() == 0 && "We only compute knownbits for the sum here.");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150769.526986.patch
Type: text/x-patch
Size: 3276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230531/2555991a/attachment.bin>
More information about the llvm-commits
mailing list