diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-08-18 20:28:54 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-08-18 20:28:54 +0000 |
| commit | 40e8ca46ad4a02c3cd2b29347ae340e7fd1be1aa (patch) | |
| tree | ca2a6cf976e810992395808c85a6360f5093a81a /llvm/lib | |
| parent | 5f4ce4e23db926c4c97b8477757c97634036db66 (diff) | |
| download | bcm5719-llvm-40e8ca46ad4a02c3cd2b29347ae340e7fd1be1aa.tar.gz bcm5719-llvm-40e8ca46ad4a02c3cd2b29347ae340e7fd1be1aa.zip | |
[InstCombine] use m_APInt to allow icmp (trunc X, Y), C folds for splat constant vectors
This is a sibling of:
https://reviews.llvm.org/rL278859
https://reviews.llvm.org/rL278935
https://reviews.llvm.org/rL278945
https://reviews.llvm.org/rL279066
https://reviews.llvm.org/rL279077
https://reviews.llvm.org/rL279101
llvm-svn: 279133
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 261c9eedf85..83064aacda8 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1538,14 +1538,9 @@ Instruction *InstCombiner::foldICmpCstShlConst(ICmpInst &I, Value *Op, Value *A, Instruction *InstCombiner::foldICmpTruncConstant(ICmpInst &Cmp, Instruction *Trunc, const APInt *C) { - // FIXME: This check restricts all folds under here to scalar types. - ConstantInt *RHS = dyn_cast<ConstantInt>(Cmp.getOperand(1)); - if (!RHS) - return nullptr; - ICmpInst::Predicate Pred = Cmp.getPredicate(); Value *X = Trunc->getOperand(0); - if (RHS->isOne() && C->getBitWidth() > 1) { + if (*C == 1 && C->getBitWidth() > 1) { // icmp slt trunc(signum(V)) 1 --> icmp slt V, 1 Value *V = nullptr; if (Pred == ICmpInst::ICMP_SLT && match(X, m_Signum(m_Value(V)))) @@ -1556,8 +1551,8 @@ Instruction *InstCombiner::foldICmpTruncConstant(ICmpInst &Cmp, if (Cmp.isEquality() && Trunc->hasOneUse()) { // Simplify icmp eq (trunc x to i8), 42 -> icmp eq x, 42|highbits if all // of the high bits truncated out of x are known. - unsigned DstBits = Trunc->getType()->getPrimitiveSizeInBits(), - SrcBits = X->getType()->getPrimitiveSizeInBits(); + unsigned DstBits = Trunc->getType()->getScalarSizeInBits(), + SrcBits = X->getType()->getScalarSizeInBits(); APInt KnownZero(SrcBits, 0), KnownOne(SrcBits, 0); computeKnownBits(X, KnownZero, KnownOne, 0, &Cmp); @@ -1566,7 +1561,7 @@ Instruction *InstCombiner::foldICmpTruncConstant(ICmpInst &Cmp, // Pull in the high bits from known-ones set. APInt NewRHS = C->zext(SrcBits); NewRHS |= KnownOne & APInt::getHighBitsSet(SrcBits, SrcBits - DstBits); - return new ICmpInst(Pred, X, Builder->getInt(NewRHS)); + return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), NewRHS)); } } |

