Fix a regression in 403.gcc and 186.crafty introduced in 47383. To test
that a value is >= 32, check that all of the high bits are zero, not
just one or more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47467 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 91e52a6..203a508 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -5147,8 +5147,8 @@
APInt KnownZero, KnownOne;
DAG.ComputeMaskedBits(Amt, Mask, KnownZero, KnownOne);
- // If we know that the high bit of the shift amount is one, then we can do
- // this as a couple of simple shifts.
+ // If we know that if any of the high bits of the shift amount are one, then
+ // we can do this as a couple of simple shifts.
if (KnownOne.intersects(Mask)) {
// Mask out the high bit, which we know is set.
Amt = DAG.getNode(ISD::AND, Amt.getValueType(), Amt,
@@ -5174,9 +5174,9 @@
}
}
- // If we know that the high bit of the shift amount is zero, then we can do
- // this as a couple of simple shifts.
- if (KnownZero.intersects(Mask)) {
+ // If we know that the high bits of the shift amount are all zero, then we can
+ // do this as a couple of simple shifts.
+ if ((KnownZero & Mask) == Mask) {
// Compute 32-amt.
SDOperand Amt2 = DAG.getNode(ISD::SUB, Amt.getValueType(),
DAG.getConstant(NVTBits, Amt.getValueType()),