[llvm-commits] [llvm] r60366 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Bill Wendling
isanbard at gmail.com
Mon Dec 1 11:46:27 PST 2008
Author: void
Date: Mon Dec 1 13:46:27 2008
New Revision: 60366
URL: http://llvm.org/viewvc/llvm-project?rev=60366&view=rev
Log:
Use a simple comparison. Overflow on integer negation can only occur when the
integer is "minint".
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=60366&r1=60365&r2=60366&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Dec 1 13:46:27 2008
@@ -2934,20 +2934,9 @@
if (Value *LHSNeg = dyn_castNegVal(Op0)) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(LHSNeg)) {
ConstantInt *RHSNeg = cast<ConstantInt>(ConstantExpr::getNeg(RHS));
- APInt RHSNegAPI(RHSNeg->getValue());
-
- APInt NegOne = -APInt(RHSNeg->getBitWidth(), 1, true);
- APInt TwoToExp(RHSNeg->getBitWidth(), 1 << (RHSNeg->getBitWidth() - 1));
-
- if ((RHS->getValue().isNegative() &&
- RHSNegAPI.slt(TwoToExp - 1)) ||
- (RHS->getValue().isNonNegative() &&
- RHSNegAPI.sgt(TwoToExp * NegOne))) {
+ if (RHS != RHSNeg) {
ConstantInt *CINeg = cast<ConstantInt>(ConstantExpr::getNeg(CI));
- APInt CINegAPI(CINeg->getValue());
-
- if ((CI->getValue().isNegative() && CINegAPI.slt(TwoToExp - 1)) ||
- (CI->getValue().isNonNegative() && CINegAPI.sgt(TwoToExp*NegOne)))
+ if (CI != CINeg)
return BinaryOperator::CreateSDiv(LHSNeg,
ConstantExpr::getNeg(RHS));
}
More information about the llvm-commits
mailing list