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 | cc846016bfa5bba6dad85cf48fc58ab16e56a9e7 (patch) | |
tree | 8a2ec8fd179ec0ba4056707e53c44a60ec08517d /llvm/lib/IR/ConstantFold.cpp | |
parent | 7d4720e5cd0982f32be87bb9a4a199d01645aa61 (diff) | |
download | llvm-cc846016bfa5bba6dad85cf48fc58ab16e56a9e7.zip llvm-cc846016bfa5bba6dad85cf48fc58ab16e56a9e7.tar.gz llvm-cc846016bfa5bba6dad85cf48fc58ab16e56a9e7.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.
llvm-svn: 185284
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index bf93d4f..da9762f 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/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); - } } } } |