[llvm] r185960 - WidenVecRes_BUILD_VECTOR must use the first operand's type

Hal Finkel hfinkel at anl.gov
Tue Jul 9 11:55:11 PDT 2013


Author: hfinkel
Date: Tue Jul  9 13:55:10 2013
New Revision: 185960

URL: http://llvm.org/viewvc/llvm-project?rev=185960&view=rev
Log:
WidenVecRes_BUILD_VECTOR must use the first operand's type

Because integer BUILD_VECTOR operands may have a larger type than the result's
vector element type, and all operands must have the same type, when widening a
BUILD_VECTOR node by adding UNDEFs, we cannot use the vector element type, but
rather must use the type of the existing operands.

Another bug found by llvm-stress.

Added:
    llvm/trunk/test/CodeGen/PowerPC/bv-widen-undef.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=185960&r1=185959&r2=185960&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Tue Jul  9 13:55:10 2013
@@ -1872,7 +1872,10 @@ SDValue DAGTypeLegalizer::WidenVecRes_BU
   SDLoc dl(N);
   // Build a vector with undefined for the new nodes.
   EVT VT = N->getValueType(0);
-  EVT EltVT = VT.getVectorElementType();
+
+  // Integer BUILD_VECTOR operands may be larger than the node's vector element
+  // type. The UNDEFs need to have the same type as the existing operands.
+  EVT EltVT = N->getOperand(0).getValueType();
   unsigned NumElts = VT.getVectorNumElements();
 
   EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);

Added: llvm/trunk/test/CodeGen/PowerPC/bv-widen-undef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/bv-widen-undef.ll?rev=185960&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/bv-widen-undef.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/bv-widen-undef.ll Tue Jul  9 13:55:10 2013
@@ -0,0 +1,23 @@
+; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 < %s
+target triple = "powerpc64-unknown-linux-gnu"
+
+define void @autogen_SD4357(i8) {
+BB:
+  br label %CF
+
+CF:                                               ; preds = %CF, %BB
+  br i1 undef, label %CF, label %CF77
+
+CF77:                                             ; preds = %CF81, %CF77, %CF
+  %Shuff12 = shufflevector <2 x i8> <i8 -1, i8 -1>, <2 x i8> <i8 -1, i8 -1>, <2 x i32> <i32 0, i32 undef>
+  br i1 undef, label %CF77, label %CF80
+
+CF80:                                             ; preds = %CF80, %CF77
+  %B21 = mul <2 x i8> %Shuff12, <i8 -1, i8 -1>
+  %Cmp24 = fcmp une ppc_fp128 0xM00000000000000000000000000000000, 0xM00000000000000000000000000000000
+  br i1 %Cmp24, label %CF80, label %CF81
+
+CF81:                                             ; preds = %CF80
+  %I36 = insertelement <2 x i8> %B21, i8 %0, i32 0
+  br label %CF77
+}





More information about the llvm-commits mailing list