From 7e0e166d1783671e555eff26b9932012fadea691 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 28 Sep 2012 09:33:53 +0000 Subject: [PATCH] Surprisingly, we missed a trivial case here. Fix that! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164814 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineSelect.cpp | 4 ++++ test/Transforms/InstCombine/vec_shuffle.ll | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index 70483ceb062..0ba7340e642 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -930,6 +930,10 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { Value *V = Builder->CreateShuffleVector(TrueVal, FalseVal, MaskVal); return ReplaceInstUsesWith(SI, V); } + + if (isa(CondVal)) { + return ReplaceInstUsesWith(SI, FalseVal); + } } return 0; diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll index a7f9fcfbe0f..14f532195d7 100644 --- a/test/Transforms/InstCombine/vec_shuffle.ll +++ b/test/Transforms/InstCombine/vec_shuffle.ll @@ -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> , + <4 x i16> %lhs, <4 x i16> %rhs + ret <4 x i16> %A +}