summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-12-01 19:46:27 +0000
committerBill Wendling <isanbard@gmail.com>2008-12-01 19:46:27 +0000
commite6c87a49528322404524662cf17733224ef5514e (patch)
tree68edc6e10eb2337f527dcbc95ea3cdc4542a0f59 /llvm/lib/Transforms
parente74e210a3f82fffde390bfa9234a0184a2241333 (diff)
downloadbcm5719-llvm-e6c87a49528322404524662cf17733224ef5514e.tar.gz
bcm5719-llvm-e6c87a49528322404524662cf17733224ef5514e.zip
Use a simple comparison. Overflow on integer negation can only occur when the
integer is "minint". llvm-svn: 60366
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 9c6ff8acc57..e4ddecf7563 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2934,20 +2934,9 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
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));
}
OpenPOWER on IntegriCloud