aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/ExprTypeConvert.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-08 06:47:33 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-08 06:47:33 +0000
commit3822ff5c71478c7c90a50ca57045fb676fcb5005 (patch)
tree44d109d0052024ecdbcfceb248446b56a7bfce0f /lib/Transforms/ExprTypeConvert.cpp
parent73fb07566b24d43bb116c2ade0297d90ec72490d (diff)
For PR950:
This patch converts the old SHR instruction into two instructions, AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not dependent on the sign of their operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/ExprTypeConvert.cpp')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 91450218c0..e0aaf7b668 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -76,10 +76,12 @@ bool llvm::ExpressionConvertibleToType(Value *V, const Type *Ty,
!ExpressionConvertibleToType(I->getOperand(1), Ty, CTMap, TD))
return false;
break;
- case Instruction::Shr:
+ case Instruction::LShr:
+ case Instruction::AShr:
if (!Ty->isInteger()) return false;
- if (Ty->isSigned() != V->getType()->isSigned()) return false;
- // FALL THROUGH
+ if (!ExpressionConvertibleToType(I->getOperand(0), Ty, CTMap, TD))
+ return false;
+ break;
case Instruction::Shl:
if (!Ty->isInteger()) return false;
if (!ExpressionConvertibleToType(I->getOperand(0), Ty, CTMap, TD))
@@ -243,7 +245,8 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty,
break;
case Instruction::Shl:
- case Instruction::Shr:
+ case Instruction::LShr:
+ case Instruction::AShr:
Res = new ShiftInst(cast<ShiftInst>(I)->getOpcode(), Dummy,
I->getOperand(1), Name);
VMC.ExprMap[I] = Res;
@@ -476,7 +479,8 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
Value *OtherOp = I->getOperand((V == I->getOperand(0)) ? 1 : 0);
return ExpressionConvertibleToType(OtherOp, Ty, CTMap, TD);
}
- case Instruction::Shr:
+ case Instruction::LShr:
+ case Instruction::AShr:
if (Ty->isSigned() != V->getType()->isSigned()) return false;
// FALL THROUGH
case Instruction::Shl:
@@ -746,7 +750,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
break;
}
case Instruction::Shl:
- case Instruction::Shr:
+ case Instruction::LShr:
+ case Instruction::AShr:
assert(I->getOperand(0) == OldVal);
Res = new ShiftInst(cast<ShiftInst>(I)->getOpcode(), NewVal,
I->getOperand(1), Name);