summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2020-01-14 11:51:09 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2020-01-14 11:51:41 +0000
commitc05a11108b9a9deb266c3c1758677462df61e05e (patch)
treea8e63f33c3d318e1758864d8a027180340fd4201 /llvm/lib/CodeGen
parentbad6032bc15fa8d16b67b86ef2b2fe48724e756e (diff)
downloadbcm5719-llvm-c05a11108b9a9deb266c3c1758677462df61e05e.tar.gz
bcm5719-llvm-c05a11108b9a9deb266c3c1758677462df61e05e.zip
[SelectionDAG] ComputeKnownBits - merge getValidMinimumShiftAmountConstant() and generic ISD::SHL handling.
As mentioned by @nikic on rGef5debac4302, we can merge the guaranteed bottom zero bits from the shifted value, and then, if a min shift amount is known, zero out the bottom bits as well.
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 64d439f5f78..313e07b5fdd 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2865,24 +2865,25 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
break;
}
case ISD::SHL:
+ Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
+
if (const APInt *ShAmt = getValidShiftAmountConstant(Op, DemandedElts)) {
- Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
unsigned Shift = ShAmt->getZExtValue();
Known.Zero <<= Shift;
Known.One <<= Shift;
// Low bits are known zero.
Known.Zero.setLowBits(Shift);
- } else if (const APInt *ShMinAmt =
- getValidMinimumShiftAmountConstant(Op, DemandedElts)) {
- // Minimum shift low bits are known zero.
- Known.Zero.setLowBits(ShMinAmt->getZExtValue());
- } else {
- // No matter the shift amount, the trailing zeros will stay zero.
- Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
- Known.Zero =
- APInt::getLowBitsSet(BitWidth, Known.countMinTrailingZeros());
- Known.One.clearAllBits();
+ break;
}
+
+ // No matter the shift amount, the trailing zeros will stay zero.
+ Known.Zero = APInt::getLowBitsSet(BitWidth, Known.countMinTrailingZeros());
+ Known.One.clearAllBits();
+
+ // Minimum shift low bits are known zero.
+ if (const APInt *ShMinAmt =
+ getValidMinimumShiftAmountConstant(Op, DemandedElts))
+ Known.Zero.setLowBits(ShMinAmt->getZExtValue());
break;
case ISD::SRL:
Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
OpenPOWER on IntegriCloud