Make demanded-elt simplification for shufflevector slightly stronger. Spotted by...
authorEli Friedman <eli.friedman@gmail.com>
Thu, 15 Sep 2011 01:14:29 +0000 (01:14 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 15 Sep 2011 01:14:29 +0000 (01:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139768 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
test/Transforms/InstCombine/vec_demanded_elts.ll

index 66f39be17b3c38baa8e3460737df24c08048613e..81929bc623035c7c75af6725f8dfcc59e2b0e6b1 100644 (file)
@@ -962,6 +962,9 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
       unsigned MaskVal = Shuffle->getMaskValue(i);
       if (MaskVal == -1u) {
         UndefElts.setBit(i);
+      } else if (!DemandedElts[i]) {
+        NewUndefElts = true;
+        UndefElts.setBit(i);
       } else if (MaskVal < LHSVWidth) {
         if (UndefElts4[MaskVal]) {
           NewUndefElts = true;
index e0188fe91aeb270e415133bda8fa4071d7d238e2..cc63371eded671103dfa9154e16ece7a193d136e 100644 (file)
@@ -152,3 +152,14 @@ entry:
        ret <4 x i32> %0
 }
 declare <4 x i32> @llvm.x86.sse41.pmovzxwd(<8 x i16>) nounwind readnone
+
+define <4 x float> @dead_shuffle_elt(<4 x float> %x, <2 x float> %y) nounwind {
+entry:
+; CHECK: define <4 x float> @dead_shuffle_elt
+; CHECK: shufflevector <2 x float> %y, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
+  %shuffle.i = shufflevector <2 x float> %y, <2 x float> %y, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
+  %shuffle9.i = shufflevector <4 x float> %x, <4 x float> %shuffle.i, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
+  ret <4 x float> %shuffle9.i
+}
+
+