summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-06-06 16:56:57 +0000
committerSanjay Patel <spatel@rotateright.com>2016-06-06 16:56:57 +0000
commit6a333c3ed9006e9140e7b29dfb36b4fe37825eaf (patch)
tree6141e786bcad44a1f7d8495f1cc03a9b5588c4eb /llvm/lib/Transforms
parent83ccd1a994b21c8f98fe4b44d56dcba7cea4b5c6 (diff)
downloadbcm5719-llvm-6a333c3ed9006e9140e7b29dfb36b4fe37825eaf.tar.gz
bcm5719-llvm-6a333c3ed9006e9140e7b29dfb36b4fe37825eaf.zip
[InstCombine] limit icmp transform to ConstantInt (PR28011)
In r271810 ( http://reviews.llvm.org/rL271810 ), I loosened the check above this to work for any Constant rather than ConstantInt. AFAICT, that part makes sense if we can determine that the shrunken/extended constant remained equal. But it doesn't make sense for this later transform where we assume that the constant DID change. This could assert for a ConstantExpr: https://llvm.org/bugs/show_bug.cgi?id=28011 And it could be wrong for a vector as shown in the added regression test. llvm-svn: 271908
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index cb9c7e5b893..b3727e4bbe5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2459,12 +2459,14 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICmp) {
return new ICmpInst(ICmp.getUnsignedPredicate(), LHSCIOp, Res1);
}
- // The re-extended constant changed so the constant cannot be represented
- // in the shorter type. Consequently, we cannot emit a simple comparison.
+ // The re-extended constant changed, partly changed (in the case of a vector),
+ // or could not be determined to be equal (in the case of a constant
+ // expression), so the constant cannot be represented in the shorter type.
+ // Consequently, we cannot emit a simple comparison.
// All the cases that fold to true or false will have already been handled
// by SimplifyICmpInst, so only deal with the tricky case.
- if (isSignedCmp || !isSignedExt)
+ if (isSignedCmp || !isSignedExt || !isa<ConstantInt>(C))
return nullptr;
// Evaluate the comparison for LT (we invert for GT below). LE and GE cases
OpenPOWER on IntegriCloud