summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-08-26 19:11:49 +0000
committerPhilip Reames <listmail@philipreames.com>2019-08-26 19:11:49 +0000
commitb92c971099f4ce4938223c48bd282b48af5006ea (patch)
tree9f1ec5632bbef8aa68dfbf755b9c5b8ca5d48a43 /llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
parent7e3d043459ea503a0c987208c627ae794682ab22 (diff)
downloadbcm5719-llvm-b92c971099f4ce4938223c48bd282b48af5006ea.tar.gz
bcm5719-llvm-b92c971099f4ce4938223c48bd282b48af5006ea.zip
[InstCombine] icmp eq/ne (gep inbounds P, Idx..), null -> icmp eq/ne P, null for vectors
Extend the transform introduced in https://reviews.llvm.org/D66608 to work for vector geps as well. Differential Revision: https://reviews.llvm.org/D66671 llvm-svn: 369949
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index b80e9ade75d..c4491178018 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -895,7 +895,6 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
return new ICmpInst(ICmpInst::getSignedPredicate(Cond), Offset,
Constant::getNullValue(Offset->getType()));
} else if (GEPLHS->isInBounds() && ICmpInst::isEquality(Cond) &&
- GEPLHS->getType()->isPointerTy() && // TODO: extend to vector geps
isa<Constant>(RHS) && cast<Constant>(RHS)->isNullValue() &&
!NullPointerIsDefined(I.getFunction(),
RHS->getType()->getPointerAddressSpace())) {
@@ -914,7 +913,13 @@ Instruction *InstCombiner::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
// In general, we're allowed to make values less poison (i.e. remove
// sources of full UB), so in this case, we just select between the two
// non-poison cases (1 and 4 above).
+ //
+ // For vectors, we apply the same reasoning on a per-lane basis.
auto *Base = GEPLHS->getPointerOperand();
+ if (GEPLHS->getType()->isVectorTy() && Base->getType()->isPointerTy()) {
+ int NumElts = GEPLHS->getType()->getVectorNumElements();
+ Base = Builder.CreateVectorSplat(NumElts, Base);
+ }
return new ICmpInst(Cond, Base,
ConstantExpr::getBitCast(cast<Constant>(RHS),
Base->getType()));
OpenPOWER on IntegriCloud