Surprisingly, we missed a trivial case here. Fix that!
authorNick Lewycky <nicholas@mxc.ca>
Fri, 28 Sep 2012 09:33:53 +0000 (09:33 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Fri, 28 Sep 2012 09:33:53 +0000 (09:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164814 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/vec_shuffle.ll

index 70483ceb0625de25786db5f5b9315d57d4244864..0ba7340e64237c9093b20a839f656acdcabcbd2b 100644 (file)
@@ -930,6 +930,10 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
       Value *V = Builder->CreateShuffleVector(TrueVal, FalseVal, MaskVal);
       return ReplaceInstUsesWith(SI, V);
     }
+
+    if (isa<ConstantAggregateZero>(CondVal)) {
+      return ReplaceInstUsesWith(SI, FalseVal);
+    }
   }
 
   return 0;
index a7f9fcfbe0f8fd5a257136857b9d3d532a0a8451..14f532195d7c3b82e09b4702ece85da2cbd3bcc8 100644 (file)
@@ -188,3 +188,11 @@ define <4 x i16> @test13d(<4 x i16> %lhs, <4 x i16> %rhs) {
            <4 x i16> %lhs, <4 x i16> %rhs
   ret <4 x i16> %A
 }
+
+define <4 x i16> @test13e(<4 x i16> %lhs, <4 x i16> %rhs) {
+; CHECK: @test13e
+; CHECK-NEXT: ret <4 x i16> %rhs
+  %A = select <4 x i1> <i1 false, i1 false, i1 false, i1 false>,
+           <4 x i16> %lhs, <4 x i16> %rhs
+  ret <4 x i16> %A
+}