summaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-03-28 09:19:01 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-03-28 09:19:01 +0000
commite82fca09bffc73310499bdcfbdea87a095420e09 (patch)
tree68fe4e86e13d894e98938df4ae4bb20e6138b4fe /lib/Transforms
parent197d19d11c949743c29d3996e391ba0caeae040d (diff)
downloadexternal_llvm-e82fca09bffc73310499bdcfbdea87a095420e09.zip
external_llvm-e82fca09bffc73310499bdcfbdea87a095420e09.tar.gz
external_llvm-e82fca09bffc73310499bdcfbdea87a095420e09.tar.bz2
1. Make more use of getLowBitsSet/getHighBitsSet.
2. Make the APInt value do the zext/trunc stuff instead of using ConstantExpr::getZExt(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 1c39f05..29640e4 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -6304,8 +6304,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
case Instruction::ZExt: {
// We need to emit an AND to clear the high bits.
assert(SrcBitSize < DestBitSize && "Not a zext?");
- Constant *C = ConstantInt::get(APInt::getAllOnesValue(SrcBitSize));
- C = ConstantExpr::getZExt(C, DestTy);
+ Constant *C = ConstantInt::get(APInt::getLowBitsSet(DestBitSize, SrcBitSize));
return BinaryOperator::createAnd(Res, C);
}
case Instruction::SExt:
@@ -6487,8 +6486,7 @@ Instruction *InstCombiner::visitTrunc(CastInst &CI) {
unsigned ShAmt = ShAmtV->getZExtValue();
// Get a mask for the bits shifting in.
- APInt Mask(APInt::getAllOnesValue(SrcBitWidth).lshr(
- SrcBitWidth-ShAmt).shl(DestBitWidth));
+ APInt Mask(APInt::getLowBitsSet(SrcBitWidth, ShAmt).shl(DestBitWidth));
Value* SrcIOp0 = SrcI->getOperand(0);
if (SrcI->hasOneUse() && MaskedValueIsZero(SrcIOp0, Mask)) {
if (ShAmt >= DestBitWidth) // All zeros.
@@ -6547,7 +6545,7 @@ Instruction *InstCombiner::visitZExt(CastInst &CI) {
// If we're actually extending zero bits and the trunc is a no-op
if (MidSize < DstSize && SrcSize == DstSize) {
// Replace both of the casts with an And of the type mask.
- APInt AndValue(APInt::getAllOnesValue(MidSize).zext(SrcSize));
+ APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize));
Constant *AndConst = ConstantInt::get(AndValue);
Instruction *And =
BinaryOperator::createAnd(CSrc->getOperand(0), AndConst);