diff options
author | Thomas Raoux <thomasraoux@google.com> | 2020-03-30 10:36:21 -0700 |
---|---|---|
committer | Thomas Raoux <thomasraoux@google.com> | 2020-03-30 11:27:09 -0700 |
commit | 3ea0774b13a538759aa1a68f30130d18ddb0d3f2 (patch) | |
tree | f19bd3ecf25f6fd958a60bc909e185b98b4eea2f /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 8242509a49e019c0279305d152c7ab2b9cdc2d0d (diff) | |
download | llvm-3ea0774b13a538759aa1a68f30130d18ddb0d3f2.zip llvm-3ea0774b13a538759aa1a68f30130d18ddb0d3f2.tar.gz llvm-3ea0774b13a538759aa1a68f30130d18ddb0d3f2.tar.bz2 |
[ConstantFold][NFC] Compile time optimization for large vectors
Optimize the common case of splat vector constant. For large vector
going through all elements is expensive. For splatr/broadcast cases we
can skip going through all elements.
Differential Revision: https://reviews.llvm.org/D76664
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index ab6afa1..0075130 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -174,7 +174,13 @@ static bool getShuffleDemandedElts(const ShuffleVectorInst *Shuf, int NumElts = Shuf->getOperand(0)->getType()->getVectorNumElements(); int NumMaskElts = Shuf->getMask()->getType()->getVectorNumElements(); DemandedLHS = DemandedRHS = APInt::getNullValue(NumElts); - + if (DemandedElts.isNullValue()) + return true; + // Simple case of a shuffle with zeroinitializer. + if (isa<ConstantAggregateZero>(Shuf->getMask())) { + DemandedLHS.setBit(0); + return true; + } for (int i = 0; i != NumMaskElts; ++i) { if (!DemandedElts[i]) continue; |