summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-02-05 22:58:45 +0000
committerSanjay Patel <spatel@rotateright.com>2019-02-05 22:58:45 +0000
commitcddb1e54697d0eed7329f4bee8878802b388ab29 (patch)
treed3f16fedd30c8ccf6cccf18b5f099d84f78e120a /llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
parent1b8df427121e3d7edf5cfaf0f3e3550ed2091d62 (diff)
downloadbcm5719-llvm-cddb1e54697d0eed7329f4bee8878802b388ab29.tar.gz
bcm5719-llvm-cddb1e54697d0eed7329f4bee8878802b388ab29.zip
[InstCombine] limit extracting shuffle transform based on uses
As discussed in D53037, this can lead to worse codegen, and we don't generally expect the backend to be able to optimize arbitrary shuffles. If there's only one use of the 1st shuffle, that means it's getting removed, so that should always be safe. llvm-svn: 353235
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index abc2297f346..6889cd9189c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -1498,6 +1498,11 @@ static Instruction *foldIdentityExtractShuffle(ShuffleVectorInst &Shuf) {
if (!match(Op0, m_ShuffleVector(m_Value(X), m_Value(Y), m_Constant(Mask))))
return nullptr;
+ // Be conservative with shuffle transforms. If we can't kill the 1st shuffle,
+ // then combining may result in worse codegen.
+ if (!Op0->hasOneUse())
+ return nullptr;
+
// We are extracting a subvector from a shuffle. Remove excess elements from
// the 1st shuffle mask to eliminate the extract.
//
OpenPOWER on IntegriCloud