[llvm] r212498 - [x86] Fix assertion failure caused by a wrong combine of PSHUFD nodes with different types.

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Mon Jul 7 16:25:24 PDT 2014


Author: adibiagio
Date: Mon Jul  7 18:25:23 2014
New Revision: 212498

URL: http://llvm.org/viewvc/llvm-project?rev=212498&view=rev
Log:
[x86] Fix assertion failure caused by a wrong combine of PSHUFD nodes with different types.

When combining a sequence of two PSHUFD dag nodes into a single PSHUFD,
make sure that we assign the correct type to the resulting PSHUFD.
X86ISD::PSHUFD dag nodes can be either MVT::v4i32 or MVT::v4f32.

Before this change, an assertion failure was triggered in method
'DAGCombinerInfo::CombineTo' when trying to combine the shuffles from the test
below into a single PSHUFD.

define <4 x float> @test1(<4 x float> %V) {
  %1 = shufflevector <4 x float> %V, <4 x float> undef, <4 x i32> <i32 3, i32 0, i32 2, i32 1>
  %2 = shufflevector <4 x float> %1, <4 x float> undef, <4 x i32> <i32 3, i32 0, i32 2, i32 1>
  ret <4 x float> %2
}


Added:
    llvm/trunk/test/CodeGen/X86/pshufd-combine-crash.ll
Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=212498&r1=212497&r2=212498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Jul  7 18:25:23 2014
@@ -18510,7 +18510,7 @@ static bool combineRedundantDWordShuffle
   SmallVector<int, 4> VMask = getPSHUFShuffleMask(V);
   for (int &M : Mask)
     M = VMask[M];
-  V = DAG.getNode(X86ISD::PSHUFD, DL, MVT::v4i32, V.getOperand(0),
+  V = DAG.getNode(X86ISD::PSHUFD, DL, V.getValueType(), V.getOperand(0),
                   getV4X86ShuffleImm8ForMask(Mask, DAG));
 
   // It is possible that one of the combinable shuffles was completely absorbed

Added: llvm/trunk/test/CodeGen/X86/pshufd-combine-crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pshufd-combine-crash.ll?rev=212498&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pshufd-combine-crash.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pshufd-combine-crash.ll Mon Jul  7 18:25:23 2014
@@ -0,0 +1,14 @@
+; RUN: llc < %s -march=x86-64 -mcpu=corei7 -debug
+
+; REQUIRES: asserts
+
+; Test that the dag combiner doesn't assert if we try to replace a sequence of two
+; v4f32 X86ISD::PSHUFD nodes with a single PSHUFD.
+
+
+define <4 x float> @test(<4 x float> %V) {
+  %1 = shufflevector <4 x float> %V, <4 x float> undef, <4 x i32> <i32 3, i32 0, i32 2, i32 1>
+  %2 = shufflevector <4 x float> %1, <4 x float> undef, <4 x i32> <i32 3, i32 0, i32 2, i32 1>
+  ret <4 x float> %2
+}
+





More information about the llvm-commits mailing list