summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-10-27 17:30:50 +0000
committerSanjay Patel <spatel@rotateright.com>2016-10-27 17:30:50 +0000
commit611f9f92fcb1a0bdcfd481dbf7ee67be04dd54e0 (patch)
treed80eeb45d822f6ffa7d560f7491cb58fa94627d5 /llvm/lib/Transforms/InstCombine/InstCombineInternal.h
parentd598c8103a66823ed076b52320e1389a561c82b1 (diff)
downloadbcm5719-llvm-611f9f92fcb1a0bdcfd481dbf7ee67be04dd54e0.tar.gz
bcm5719-llvm-611f9f92fcb1a0bdcfd481dbf7ee67be04dd54e0.zip
[InstCombine] handle simple vector integer constants in IsFreeToInvert
llvm-svn: 285318
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineInternal.h')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineInternal.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index e85b3a58af5..176b7a07556 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -84,6 +84,24 @@ static inline bool IsFreeToInvert(Value *V, bool WillInvertAllUses) {
if (isa<ConstantInt>(V))
return true;
+ // A vector of constant integers can be inverted easily.
+ Constant *CV;
+ if (V->getType()->isVectorTy() && match(V, PatternMatch::m_Constant(CV))) {
+ unsigned NumElts = V->getType()->getVectorNumElements();
+ for (unsigned i = 0; i != NumElts; ++i) {
+ Constant *Elt = CV->getAggregateElement(i);
+ if (!Elt)
+ return false;
+
+ if (isa<UndefValue>(Elt))
+ continue;
+
+ if (!isa<ConstantInt>(Elt))
+ return false;
+ }
+ return true;
+ }
+
// Compares can be inverted if all of their uses are being modified to use the
// ~V.
if (isa<CmpInst>(V))
OpenPOWER on IntegriCloud