[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Zhou Sheng
zhousheng00 at gmail.com
Wed Mar 14 02:07:50 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.660 -> 1.661
---
Log message:
ShiftAmt might equal to zero. Handle this situation.
---
Diffs of the changes: (+9 -7)
InstructionCombining.cpp | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.660 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.661
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.660 Tue Mar 13 22:21:24 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Mar 14 04:07:33 2007
@@ -1997,7 +1997,8 @@
RHSKnownZero <<= ShiftAmt;
RHSKnownOne <<= ShiftAmt;
// low bits known zero.
- RHSKnownZero |= APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth);
+ if (ShiftAmt)
+ RHSKnownZero |= APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth);
}
break;
case Instruction::LShr:
@@ -2013,14 +2014,16 @@
return true;
assert((RHSKnownZero & RHSKnownOne) == 0 &&
"Bits known to be one AND zero?");
- // Compute the new bits that are at the top now.
- APInt HighBits(APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth).shl(
- BitWidth - ShiftAmt));
RHSKnownZero &= TypeMask;
RHSKnownOne &= TypeMask;
RHSKnownZero = APIntOps::lshr(RHSKnownZero, ShiftAmt);
RHSKnownOne = APIntOps::lshr(RHSKnownOne, ShiftAmt);
- RHSKnownZero |= HighBits; // high bits known zero.
+ if (ShiftAmt) {
+ // Compute the new bits that are at the top now.
+ APInt HighBits(APInt::getAllOnesValue(BitWidth).shl(
+ BitWidth - ShiftAmt));
+ RHSKnownZero |= HighBits; // high bits known zero.
+ }
}
break;
case Instruction::AShr:
@@ -2048,8 +2051,7 @@
assert((RHSKnownZero & RHSKnownOne) == 0 &&
"Bits known to be one AND zero?");
// Compute the new bits that are at the top now.
- APInt HighBits(APInt::getAllOnesValue(ShiftAmt).zextOrCopy(BitWidth).shl(
- BitWidth - ShiftAmt));
+ APInt HighBits(APInt::getAllOnesValue(BitWidth).shl(BitWidth - ShiftAmt));
RHSKnownZero &= TypeMask;
RHSKnownOne &= TypeMask;
RHSKnownZero = APIntOps::lshr(RHSKnownZero, ShiftAmt);
More information about the llvm-commits
mailing list