diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-06-30 13:47:43 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-06-30 13:47:43 +0000 |
commit | 80c070493d657a4bcc6eca5627c28d659d3330d8 (patch) | |
tree | b4ddcd619465d15211d9f7645a16997b13088fd6 /lib | |
parent | 58b6dc032a668e637a9a9e63290652f32d372a5f (diff) | |
download | external_llvm-80c070493d657a4bcc6eca5627c28d659d3330d8.zip external_llvm-80c070493d657a4bcc6eca5627c28d659d3330d8.tar.gz external_llvm-80c070493d657a4bcc6eca5627c28d659d3330d8.tar.bz2 |
ConstantFold: Check that truncating the other side is safe under a sext when trying to remove a sext from a compare.
Fixes PR16462.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/ConstantFold.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/IR/ConstantFold.cpp b/lib/IR/ConstantFold.cpp index bf93d4f..da9762f 100644 --- a/lib/IR/ConstantFold.cpp +++ b/lib/IR/ConstantFold.cpp @@ -1857,9 +1857,9 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, if (CE1Inverse == CE1Op0) { // Check whether we can safely truncate the right hand side. Constant *C2Inverse = ConstantExpr::getTrunc(C2, CE1Op0->getType()); - if (ConstantExpr::getZExt(C2Inverse, C2->getType()) == C2) { + if (ConstantExpr::getCast(CE1->getOpcode(), C2Inverse, + C2->getType()) == C2) return ConstantExpr::getICmp(pred, CE1Inverse, C2Inverse); - } } } } |