diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-02-05 22:58:45 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-02-05 22:58:45 +0000 |
commit | cddb1e54697d0eed7329f4bee8878802b388ab29 (patch) | |
tree | d3f16fedd30c8ccf6cccf18b5f099d84f78e120a /llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | |
parent | 1b8df427121e3d7edf5cfaf0f3e3550ed2091d62 (diff) | |
download | bcm5719-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.cpp | 5 |
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. // |