From 9c8840362525b89774c10378317fc18e5d222ba8 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 24 Jun 2014 10:38:10 +0000 Subject: InstCombine: Don't try to reorder shuffles where the mask is a ConstantExpr. We can't analyze the individual values of a vector expression. PR20114. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211581 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstructionCombining.cpp | 4 +++- test/Transforms/InstCombine/vec_shuffle.ll | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 88d7a0d59e..88d461e1b2 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1227,7 +1227,9 @@ Value *InstCombiner::SimplifyVectorOp(BinaryOperator &Inst) { if (isa(RHS)) Shuffle = cast(RHS); if (isa(LHS)) C1 = cast(LHS); if (isa(RHS)) C1 = cast(RHS); - if (Shuffle && C1 && isa(Shuffle->getOperand(1)) && + if (Shuffle && C1 && + (isa(C1) || isa(C1)) && + isa(Shuffle->getOperand(1)) && Shuffle->getType() == Shuffle->getOperand(0)->getType()) { SmallVector ShMask = Shuffle->getShuffleMask(); // Find constant C2 that has property: diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll index fc0f8bd0aa..eb4e9d6f8c 100644 --- a/test/Transforms/InstCombine/vec_shuffle.ll +++ b/test/Transforms/InstCombine/vec_shuffle.ll @@ -405,3 +405,12 @@ define i32 @pr19737(<4 x i32> %in0) { %rv = extractelement <4 x i32> %and.i, i32 0 ret i32 %rv } + +define <4 x i32> @pr20114(<4 x i32> %__mask) { +; CHECK-LABEL: @pr20114 +; CHECK: shufflevector +; CHECK: and + %mask01.i = shufflevector <4 x i32> %__mask, <4 x i32> undef, <4 x i32> + %masked_new.i.i.i = and <4 x i32> bitcast (<2 x i64> (<4 x i32>)* @pr20114 to i64), i64 ptrtoint (<4 x i32> (<4 x i32>)* @pr20114 to i64)> to <4 x i32>), %mask01.i + ret <4 x i32> %masked_new.i.i.i +} -- cgit v1.2.3