summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-05-06 02:39:09 +0000
committerNadav Rotem <nrotem@apple.com>2013-05-06 02:39:09 +0000
commit4ee312bac138a18c39353d4736eb5921532f9624 (patch)
tree8bca6791c6b31accb25362ae9e75acc09e29245e
parent8b9dc21d6f12a0251cdb6116c2297c13d77073d5 (diff)
downloadllvm-4ee312bac138a18c39353d4736eb5921532f9624.tar.gz
llvm-4ee312bac138a18c39353d4736eb5921532f9624.tar.bz2
llvm-4ee312bac138a18c39353d4736eb5921532f9624.tar.xz
Revert r164763 because it introduces new shuffles.
Thanks Nick Lewycky for pointing this out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181177 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/InstCombine/InstCombineSelect.cpp20
-rw-r--r--test/Transforms/InstCombine/vec_demanded_elts.ll2
-rw-r--r--test/Transforms/InstCombine/vec_shuffle.ll70
3 files changed, 2 insertions, 90 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 2defe631ae..59502fb988 100644
--- a/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -974,7 +974,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
return &SI;
}
- if (VectorType *VecTy = dyn_cast<VectorType>(SI.getType())) {
+ if (VectorType* VecTy = dyn_cast<VectorType>(SI.getType())) {
unsigned VWidth = VecTy->getNumElements();
APInt UndefElts(VWidth, 0);
APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
@@ -984,24 +984,6 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
return &SI;
}
- if (ConstantVector *CV = dyn_cast<ConstantVector>(CondVal)) {
- // Form a shufflevector instruction.
- SmallVector<Constant *, 8> Mask(VWidth);
- Type *Int32Ty = Type::getInt32Ty(CV->getContext());
- for (unsigned i = 0; i != VWidth; ++i) {
- Constant *Elem = cast<Constant>(CV->getOperand(i));
- if (ConstantInt *E = dyn_cast<ConstantInt>(Elem))
- Mask[i] = ConstantInt::get(Int32Ty, i + (E->isZero() ? VWidth : 0));
- else if (isa<UndefValue>(Elem))
- Mask[i] = UndefValue::get(Int32Ty);
- else
- return 0;
- }
- Constant *MaskVal = ConstantVector::get(Mask);
- Value *V = Builder->CreateShuffleVector(TrueVal, FalseVal, MaskVal);
- return ReplaceInstUsesWith(SI, V);
- }
-
if (isa<ConstantAggregateZero>(CondVal)) {
return ReplaceInstUsesWith(SI, FalseVal);
}
diff --git a/test/Transforms/InstCombine/vec_demanded_elts.ll b/test/Transforms/InstCombine/vec_demanded_elts.ll
index 2d90750a2f..0019a57627 100644
--- a/test/Transforms/InstCombine/vec_demanded_elts.ll
+++ b/test/Transforms/InstCombine/vec_demanded_elts.ll
@@ -196,7 +196,7 @@ define <4 x float> @test_select(float %f, float %g) {
; CHECK-NOT: insertelement
; CHECK: %a3 = insertelement <4 x float> %a0, float 3.000000e+00, i32 3
; CHECK-NOT: insertelement
-; CHECK: shufflevector <4 x float> %a3, <4 x float> <float undef, float 4.000000e+00, float 5.000000e+00, float undef>, <4 x i32> <i32 0, i32 5, i32 6, i32 3>
+; CHECK: %ret = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x float> %a3, <4 x float> <float undef, float 4.000000e+00, float 5.000000e+00, float undef>
%a0 = insertelement <4 x float> undef, float %f, i32 0
%a1 = insertelement <4 x float> %a0, float 1.000000e+00, i32 1
%a2 = insertelement <4 x float> %a1, float 2.000000e+00, i32 2
diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll
index 37d4d56e91..8f78c2e6bd 100644
--- a/test/Transforms/InstCombine/vec_shuffle.ll
+++ b/test/Transforms/InstCombine/vec_shuffle.ll
@@ -153,73 +153,3 @@ define <8 x i8> @test12a(<8 x i8> %tmp6, <8 x i8> %tmp2) nounwind {
ret <8 x i8> %tmp3
}
-; We should form a shuffle out of a select with constant condition.
-define <4 x i16> @test13a(<4 x i16> %lhs, <4 x i16> %rhs) {
-; CHECK: @test13a
-; CHECK-NEXT: shufflevector <4 x i16> %lhs, <4 x i16> %rhs, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
-; CHECK-NEXT: ret
- %A = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>,
- <4 x i16> %lhs, <4 x i16> %rhs
- ret <4 x i16> %A
-}
-
-define <4 x i16> @test13b(<4 x i16> %lhs, <4 x i16> %rhs) {
-; CHECK: @test13b
-; CHECK-NEXT: ret <4 x i16> %lhs
- %A = select <4 x i1> <i1 true, i1 undef, i1 true, i1 true>,
- <4 x i16> %lhs, <4 x i16> %rhs
- ret <4 x i16> %A
-}
-
-define <4 x i16> @test13c(<4 x i16> %lhs, <4 x i16> %rhs) {
-; CHECK: @test13c
-; CHECK-NEXT: shufflevector <4 x i16> %lhs, <4 x i16> %rhs, <4 x i32> <i32 0, i32 undef, i32 2, i32 7>
-; CHECK-NEXT: ret
- %A = select <4 x i1> <i1 true, i1 undef, i1 true, i1 false>,
- <4 x i16> %lhs, <4 x i16> %rhs
- ret <4 x i16> %A
-}
-
-define <4 x i16> @test13d(<4 x i16> %lhs, <4 x i16> %rhs) {
-; CHECK: @test13d
-; CHECK: select
-; CHECK-NEXT: ret
- %A = select <4 x i1> <i1 true, i1 icmp ugt (<4 x i16>(<4 x i16>, <4 x i16>)* @test13a, <4 x i16>(<4 x i16>, <4 x i16>)* @test13b), i1 true, i1 false>,
- <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
-}
-
-; Check that sequences of insert/extract element are
-; collapsed into shuffle instruction with correct shuffle indexes.
-
-define <4 x float> @test14a(<4 x float> %LHS, <4 x float> %RHS) {
-; CHECK: @test14a
-; CHECK-NEXT: shufflevector <4 x float> %LHS, <4 x float> %RHS, <4 x i32> <i32 4, i32 0, i32 6, i32 6>
-; CHECK-NEXT: ret <4 x float> %tmp4
- %tmp1 = extractelement <4 x float> %LHS, i32 0
- %tmp2 = insertelement <4 x float> %RHS, float %tmp1, i32 1
- %tmp3 = extractelement <4 x float> %RHS, i32 2
- %tmp4 = insertelement <4 x float> %tmp2, float %tmp3, i32 3
- ret <4 x float> %tmp4
-}
-
-define <4 x float> @test14b(<4 x float> %LHS, <4 x float> %RHS) {
-; CHECK: @test14b
-; CHECK-NEXT: shufflevector <4 x float> %LHS, <4 x float> %RHS, <4 x i32> <i32 4, i32 3, i32 6, i32 6>
-; CHECK-NEXT: ret <4 x float> %tmp5
- %tmp0 = extractelement <4 x float> %LHS, i32 3
- %tmp1 = insertelement <4 x float> %RHS, float %tmp0, i32 0
- %tmp2 = extractelement <4 x float> %tmp1, i32 0
- %tmp3 = insertelement <4 x float> %RHS, float %tmp2, i32 1
- %tmp4 = extractelement <4 x float> %RHS, i32 2
- %tmp5 = insertelement <4 x float> %tmp3, float %tmp4, i32 3
- ret <4 x float> %tmp5
-}