[PATCH] D150110: [TargetLowering]: Fix unnecessary call to `computeKnownBits`
Dhruv Chawla via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 8 07:06:09 PDT 2023
0xdc03 updated this revision to Diff 520363.
0xdc03 added a comment.
- Fix formatting
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150110/new/
https://reviews.llvm.org/D150110
Files:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2592,9 +2592,10 @@
SDNodeFlags Flags = Op.getNode()->getFlags();
unsigned DemandedBitsLZ = DemandedBits.countl_zero();
APInt LoMask = APInt::getLowBitsSet(BitWidth, BitWidth - DemandedBitsLZ);
- if (SimplifyDemandedBits(Op0, LoMask, DemandedElts, Known2, TLO,
+ KnownBits KnownOp0, KnownOp1;
+ if (SimplifyDemandedBits(Op0, LoMask, DemandedElts, KnownOp0, TLO,
Depth + 1) ||
- SimplifyDemandedBits(Op1, LoMask, DemandedElts, Known2, TLO,
+ SimplifyDemandedBits(Op1, LoMask, DemandedElts, KnownOp1, TLO,
Depth + 1) ||
// See if the operation should be performed at a smaller bit width.
ShrinkDemandedOp(Op, BitWidth, DemandedBits, TLO)) {
@@ -2691,7 +2692,16 @@
}
}
- [[fallthrough]];
+ 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);
+ }
+ break;
}
default:
// We also ask the target about intrinsics (which could be specific to it).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150110.520363.patch
Type: text/x-patch
Size: 1650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230508/0df806d2/attachment.bin>
More information about the llvm-commits
mailing list