diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-24 00:40:59 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-24 00:40:59 +0000 |
commit | 0f9d82c5c4c8149c86d13e2d3adab10f8ba9f948 (patch) | |
tree | 03717b8413bf2ce437bb29539396b78e47b9e81d | |
parent | b3307b232ad02dbb5b7f873473a83a1712db71d0 (diff) |
For PR1066:
Fix this by ensuring that a bitcast is inserted to do sign switching. This
is only temporarily needed as the merging of signed and unsigned is next
on the SignlessTypes plate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32757 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index d0e74c1fa0..592e61d040 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2002,8 +2002,14 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (CU->getZExtValue() == SI->getType()->getPrimitiveSizeInBits()-1) { // Ok, the transformation is safe. Insert AShr. - return new ShiftInst(Instruction::AShr, SI->getOperand(0), - CU, SI->getName()); + // FIXME: Once integer types are signless, this cast should be + // removed. + Value *ShiftOp = SI->getOperand(0); + if (ShiftOp->getType() != I.getType()) + ShiftOp = InsertCastBefore(Instruction::BitCast, ShiftOp, + I.getType(), I); + return new ShiftInst(Instruction::AShr, ShiftOp, CU, + SI->getName()); } } } |