diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-08-29 13:24:34 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-29 13:24:34 +0000 |
commit | 7a05641fa8ee27682514d5c40dd344f4a557b03c (patch) | |
tree | 9ef929061098cc5868b3d54018ea4f1f90f473cb | |
parent | f6db5bcd381e5f0e5970e74a9b15c6a1e804b80f (diff) | |
download | bcm5719-llvm-7a05641fa8ee27682514d5c40dd344f4a557b03c.tar.gz bcm5719-llvm-7a05641fa8ee27682514d5c40dd344f4a557b03c.zip |
[InstCombine] remove unnecessary shuffle undef folding
Add a test for constant folding to show that
(shuffle undef, undef, mask)
should already be handled via instsimplify.
llvm-svn: 340926
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 7 | ||||
-rw-r--r-- | llvm/test/Analysis/ConstantFolding/vector-undef-elts.ll | 8 |
2 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 1c2de6352fa..7be6dd02794 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -1379,13 +1379,6 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { // Canonicalize shuffle(x ,x,mask) -> shuffle(x, undef,mask') // Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask'). if (LHS == RHS || isa<UndefValue>(LHS)) { - if (isa<UndefValue>(LHS) && LHS == RHS) { - // shuffle(undef,undef,mask) -> undef. - Value *Result = (VWidth == LHSWidth) - ? LHS : UndefValue::get(SVI.getType()); - return replaceInstUsesWith(SVI, Result); - } - // Remap any references to RHS to use LHS. SmallVector<Constant*, 16> Elts; for (unsigned i = 0, e = LHSWidth; i != VWidth; ++i) { diff --git a/llvm/test/Analysis/ConstantFolding/vector-undef-elts.ll b/llvm/test/Analysis/ConstantFolding/vector-undef-elts.ll index f6969d83fce..ab1e8c1e436 100644 --- a/llvm/test/Analysis/ConstantFolding/vector-undef-elts.ll +++ b/llvm/test/Analysis/ConstantFolding/vector-undef-elts.ll @@ -59,3 +59,11 @@ define <3 x float> @fadd_commute() { ret <3 x float> %c } +define <4 x i32> @shuffle_of_undefs(<4 x i32> %v1, <4 x i32> %v2) { +; CHECK-LABEL: @shuffle_of_undefs( +; CHECK-NEXT: ret <4 x i32> undef +; + %r = shufflevector <4 x i32> undef, <4 x i32> undef, <4 x i32> <i32 5, i32 1, i32 2, i32 3> + ret <4 x i32> %r +} + |