From: Ayman Musa Date: Sun, 3 Sep 2017 09:09:16 +0000 (+0000) Subject: [X86] Fix crash on assert of non-simple type after type-legalization X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9cee299c04c70bf2373bd73c1b7624970540d5a;p=llvm [X86] Fix crash on assert of non-simple type after type-legalization The function combineShuffleToVectorExtend in DAGCombine might generate an illegal typed node after "legalize types" phase, causing assertion on non-simple type to fail afterwards. Adding a type check in case the combine is running after the type legalize pass. Differential Revision: https://reviews.llvm.org/D37330 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312438 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 6dbfced44d1..ae923e8ac07 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -15492,7 +15492,8 @@ static SDValue combineShuffleOfScalars(ShuffleVectorSDNode *SVN, static SDValue combineShuffleToVectorExtend(ShuffleVectorSDNode *SVN, SelectionDAG &DAG, const TargetLowering &TLI, - bool LegalOperations) { + bool LegalOperations, + bool LegalTypes) { EVT VT = SVN->getValueType(0); bool IsBigEndian = DAG.getDataLayout().isBigEndian(); @@ -15525,9 +15526,10 @@ static SDValue combineShuffleToVectorExtend(ShuffleVectorSDNode *SVN, EVT OutSVT = EVT::getIntegerVT(*DAG.getContext(), EltSizeInBits * Scale); EVT OutVT = EVT::getVectorVT(*DAG.getContext(), OutSVT, NumElts / Scale); - if (!LegalOperations || - TLI.isOperationLegalOrCustom(ISD::ANY_EXTEND_VECTOR_INREG, OutVT)) - return DAG.getBitcast(VT, + if (!LegalTypes || TLI.isTypeLegal(OutVT)) + if (!LegalOperations || + TLI.isOperationLegalOrCustom(ISD::ANY_EXTEND_VECTOR_INREG, OutVT)) + return DAG.getBitcast(VT, DAG.getAnyExtendVectorInReg(N0, SDLoc(SVN), OutVT)); } @@ -15758,7 +15760,7 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { return S; // Match shuffles that can be converted to any_vector_extend_in_reg. - if (SDValue V = combineShuffleToVectorExtend(SVN, DAG, TLI, LegalOperations)) + if (SDValue V = combineShuffleToVectorExtend(SVN, DAG, TLI, LegalOperations, LegalTypes)) return V; // Combine "truncate_vector_in_reg" style shuffles. diff --git a/test/CodeGen/X86/pr34397.ll b/test/CodeGen/X86/pr34397.ll new file mode 100644 index 00000000000..778968f6d0c --- /dev/null +++ b/test/CodeGen/X86/pr34397.ll @@ -0,0 +1,22 @@ +target triple = "x86_64-unknown-linux-gnu" + +define internal fastcc <32 x i64> @test(<32 x i64> %s.0.6, <32 x i64> %s.0.7) { +entry: + %s.1.6 = shufflevector <32 x i64> %s.0.6, <32 x i64> %s.0.7, <32 x i32> + %s.2.5 = shufflevector <32 x i64> undef, <32 x i64> %s.1.6, <32 x i32> + %s.3.4 = shufflevector <32 x i64> undef, <32 x i64> %s.2.5, <32 x i32> + %s.4.4 = shufflevector <32 x i64> %s.3.4, <32 x i64> undef, <32 x i32> + %s.5.4 = shufflevector <32 x i64> %s.4.4, <32 x i64> undef, <32 x i32> + %s.6.3 = shufflevector <32 x i64> undef, <32 x i64> %s.5.4, <32 x i32> + %s.7.2 = shufflevector <32 x i64> undef, <32 x i64> %s.6.3, <32 x i32> + %s.8.2 = shufflevector <32 x i64> %s.7.2, <32 x i64> zeroinitializer, <32 x i32> + %s.9.2 = shufflevector <32 x i64> %s.8.2, <32 x i64> undef, <32 x i32> + %s.10.1 = shufflevector <32 x i64> undef, <32 x i64> %s.9.2, <32 x i32> + %s.11.1 = shufflevector <32 x i64> %s.10.1, <32 x i64> undef, <32 x i32> + %s.12.1 = shufflevector <32 x i64> %s.11.1, <32 x i64> undef, <32 x i32> + %s.13.1 = shufflevector <32 x i64> %s.12.1, <32 x i64> undef, <32 x i32> + %s.14.0 = shufflevector <32 x i64> undef, <32 x i64> %s.13.1, <32 x i32> + %s.15.0 = shufflevector <32 x i64> %s.14.0, <32 x i64> undef, <32 x i32> + %s.16.0 = shufflevector <32 x i64> %s.15.0, <32 x i64> undef, <32 x i32> + ret <32 x i64> %s.16.0 +}