summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-10-25 20:11:47 +0000
committerSanjay Patel <spatel@rotateright.com>2016-10-25 20:11:47 +0000
commitf3dda13bd2fd08252ff5aaf84974a28d7c721f57 (patch)
tree51f884312fdd1ed50354eea29fb08560436805b8 /llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
parentf6c4ab901b18b42cf26ad4984466ff9f51c48b42 (diff)
downloadbcm5719-llvm-f3dda13bd2fd08252ff5aaf84974a28d7c721f57.tar.gz
bcm5719-llvm-f3dda13bd2fd08252ff5aaf84974a28d7c721f57.zip
[InstCombine] Ensure that truncated int types are legal.
Fixes the FIXMEs in D25952 and rL285075. Patch by bryant! Differential Revision: https://reviews.llvm.org/D25955 llvm-svn: 285108
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 9a31de4f8aa..652d2c7bef4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1950,9 +1950,6 @@ Instruction *InstCombiner::foldICmpShlConstant(ICmpInst &Cmp,
And, Constant::getNullValue(And->getType()));
}
- // FIXME: This transform can create illegal types. Use the DataLayout to
- // decide when to try this?
-
// Transform (icmp pred iM (shl iM %v, N), C)
// -> (icmp pred i(M-N) (trunc %v iM to i(M-N)), (trunc (C>>N))
// Transform the shl to a trunc if (trunc (C>>N)) has no loss and M-N.
@@ -1960,7 +1957,8 @@ Instruction *InstCombiner::foldICmpShlConstant(ICmpInst &Cmp,
// free on the target. It has the additional benefit of comparing to a
// smaller constant, which will be target friendly.
unsigned Amt = ShiftAmt->getLimitedValue(TypeBits - 1);
- if (Shl->hasOneUse() && Amt != 0 && C->countTrailingZeros() >= Amt) {
+ if (Shl->hasOneUse() && Amt != 0 && C->countTrailingZeros() >= Amt &&
+ DL.isLegalInteger(TypeBits - Amt)) {
Type *TruncTy = IntegerType::get(Cmp.getContext(), TypeBits - Amt);
if (X->getType()->isVectorTy())
TruncTy = VectorType::get(TruncTy, X->getType()->getVectorNumElements());
OpenPOWER on IntegriCloud