[llvm-commits] [SignlessTypes] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Reid Spencer
reid at x10sys.com
Sat Oct 21 02:00:01 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.520.2.3 -> 1.520.2.4
---
Log message:
Implement backwards compatibility in bytecode reader for signless types.
Bump bytecode writer version number (to 6).
Fix bugs in DIV -> SDIV/UDIV changes.
---
Diffs of the changes: (+4 -4)
InstructionCombining.cpp | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.3 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.4
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.3 Thu Oct 19 23:27:17 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat Oct 21 03:59:42 2006
@@ -1977,7 +1977,7 @@
// 0 - (X sdiv C) -> (X sdiv -C)
if (Op1I->getOpcode() == Instruction::SDiv)
if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0))
- if (CSI->isNullValue())
+ if (CSI->isNullValue() && CSI->getType()->isSigned())
if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1)))
return BinaryOperator::createSDiv(Op1I->getOperand(0),
ConstantExpr::getNeg(DivRHS));
@@ -2173,14 +2173,14 @@
if (RHS->isAllOnesValue())
return BinaryOperator::createNeg(Op0);
+ // (X / C1) / C2 -> X / (C1*C2)
if (Instruction *LHS = dyn_cast<Instruction>(Op0))
if (LHS->getOpcode() == Instruction::SDiv ||
LHS->getOpcode()==Instruction::UDiv)
if (ConstantInt *LHSRHS = dyn_cast<ConstantInt>(LHS->getOperand(1))) {
- // (X / C1) / C2 -> X / (C1*C2)
return BinaryOperator::create(
Instruction::BinaryOps(LHS->getOpcode()), LHS->getOperand(0),
- ConstantExpr::getMul(RHS, LHSRHS),"");
+ ConstantExpr::getMul(RHS, LHSRHS),"");
}
// Check to see if this is an unsigned division with an exact power of 2,
@@ -3724,7 +3724,7 @@
static bool MulWithOverflow(ConstantInt *&Result, ConstantInt *In1,
ConstantInt *In2) {
Result = cast<ConstantInt>(ConstantExpr::getMul(In1, In2));
- return !In2->isNullValue() && ConstantExpr::getUDiv(Result, In2) != In1;
+ return !In2->isNullValue() && ConstantExpr::getSDiv(Result, In2) != In1;
}
static bool isPositive(ConstantInt *C) {
More information about the llvm-commits
mailing list