aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-19 17:59:02 +0000
committerChris Lattner <sabre@nondot.org>2010-12-19 17:59:02 +0000
commit368397bb7de8318a4663fec846bda714ae78dd7a (patch)
tree61fdd21578b0689f8c7ab07eccaf3a61c26d4cd6 /lib
parentf0f568b49e111da1258902b73a7b9266222e1842 (diff)
fix a bug (possibly 8816) in the sadd forming xform: it isn't
profitable (or safe) to promote code when the add-with-constant has other uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122175 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 80497e9391..376a38edda 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1588,6 +1588,16 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
static Instruction *ProcessUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B,
ConstantInt *CI2, ConstantInt *CI1,
InstCombiner::BuilderTy *Builder) {
+ // The transformation we're trying to do here is to transform this into an
+ // llvm.sadd.with.overflow. To do this, we have to replace the original add
+ // with a narrower add, and discard the add-with-constant that is part of the
+ // range check (if we can't eliminate it, this isn't profitable).
+
+ // In order to eliminate the add-with-constant, the compare can be its only
+ // use.
+ Value *AddWithCst = I.getOperand(0);
+ if (!AddWithCst->hasOneUse()) return 0;
+
const IntegerType *WideType = cast<IntegerType>(CI1->getType());
unsigned WideWidth = WideType->getBitWidth();
unsigned NarrowWidth = WideWidth / 2;