[llvm-commits] [llvm] r122183 - in /llvm/trunk/lib/Transforms/InstCombine: InstCombineCalls.cpp InstructionCombining.cpp
Chris Lattner
sabre at nondot.org
Sun Dec 19 11:43:52 PST 2010
Author: lattner
Date: Sun Dec 19 13:43:52 2010
New Revision: 122183
URL: http://llvm.org/viewvc/llvm-project?rev=122183&view=rev
Log:
move a transformation to a more logical place, simplifying it.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=122183&r1=122182&r2=122183&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Sun Dec 19 13:43:52 2010
@@ -523,21 +523,6 @@
return InsertValueInst::Create(Struct, Add, 0);
}
}
-
- // If the normal result of the add is dead, and the RHS is a constant, we
- // can transform this into a range comparison.
- // overflow = uadd a, -4 --> overflow = icmp ugt a, 3
- if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
- if (ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(II->use_back()))
- if (II->hasOneUse() && EVI->getNumIndices() == 1 && !EVI->use_empty() &&
- *EVI->idx_begin() == 1) { // Extract of overflow result.
- Builder->SetInsertPoint(EVI);
- Value *R = Builder->CreateICmpUGT(LHS, ConstantExpr::getNot(CI));
- R->takeName(EVI);
- ReplaceInstUsesWith(*EVI, R);
- return II;
- }
-
}
// FALL THROUGH uadd into sadd
case Intrinsic::sadd_with_overflow:
@@ -565,7 +550,6 @@
return InsertValueInst::Create(Struct, II->getArgOperand(0), 0);
}
}
-
break;
case Intrinsic::usub_with_overflow:
case Intrinsic::ssub_with_overflow:
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=122183&r1=122182&r2=122183&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sun Dec 19 13:43:52 2010
@@ -1147,6 +1147,13 @@
EraseInstFromFunction(*II);
return BinaryOperator::CreateAdd(LHS, RHS);
}
+
+ // If the normal result of the add is dead, and the RHS is a constant,
+ // we can transform this into a range comparison.
+ // overflow = uadd a, -4 --> overflow = icmp ugt a, 3
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(II->getArgOperand(1)))
+ return new ICmpInst(ICmpInst::ICMP_UGT, II->getArgOperand(0),
+ ConstantExpr::getNot(CI));
break;
case Intrinsic::usub_with_overflow:
case Intrinsic::ssub_with_overflow:
More information about the llvm-commits
mailing list