summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-03-27 17:49:27 +0000
committerReid Kleckner <reid@kleckner.net>2014-03-27 17:49:27 +0000
commit3bdf9bc48b9e2b678882ade29ee1fb4db69f134c (patch)
tree1e35dcaee0866c875c48c4de716e7e8df5789f04 /llvm/lib/Transforms
parent3a571019c8b17e6f5896c5b2a80e3a854011eb32 (diff)
downloadbcm5719-llvm-3bdf9bc48b9e2b678882ade29ee1fb4db69f134c.tar.gz
bcm5719-llvm-3bdf9bc48b9e2b678882ade29ee1fb4db69f134c.zip
InstCombine: Don't combine constants on unsigned icmps
Fixes a miscompile introduced in r204912. It would miscompile code like (unsigned)(a + -49) <= 5U. The transform would turn this into (unsigned)a < 55U, which would return true for values in [0, 49], when it should not. llvm-svn: 204948
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 9bf38189542..fea0d0245c8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3010,7 +3010,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
return FoldICmpAddOpCst(I, X, Cst, I.getSwappedPredicate());
ConstantInt *Cst2;
- if (match(Op1, m_ConstantInt(Cst)) &&
+ if (I.isSigned() &&
+ match(Op1, m_ConstantInt(Cst)) &&
match(Op0, m_Add(m_Value(X), m_ConstantInt(Cst2))) &&
cast<BinaryOperator>(Op0)->hasNoSignedWrap()) {
// icmp X+Cst2, Cst --> icmp X, Cst-Cst2
OpenPOWER on IntegriCloud