From fb09d25df50dad9aa580032e66dd076b7c31c6c9 Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Thu, 23 Jul 2015 08:25:23 +0000 Subject: [PATCH] X86: Fixed assertion failure in 32-bit mode The DAG Node "SCALAR_TO_VECTOR" may be created if the type of the scalar element is legal. Added a check for the scalar type before creating this node. Added a test that fails with assertion on the current version. Differential Revision: http://reviews.llvm.org/D11413 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242994 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 5 +++-- test/CodeGen/X86/avx-shuffle-x86_32.ll | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index dc73cb2392f..4c09eaf12c8 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -7380,8 +7380,9 @@ static SDValue lowerVectorShuffleAsElementInsertion( // all the smarts here sunk into that routine. However, the current // lowering of BUILD_VECTOR makes that nearly impossible until the old // vector shuffle lowering is dead. - if (SDValue V2S = getScalarValueForVectorElement( - V2, Mask[V2Index] - Mask.size(), DAG)) { + SDValue V2S = getScalarValueForVectorElement(V2, Mask[V2Index] - Mask.size(), + DAG); + if (V2S && DAG.getTargetLoweringInfo().isTypeLegal(V2S.getValueType())) { // We need to zext the scalar if it is smaller than an i32. V2S = DAG.getBitcast(EltVT, V2S); if (EltVT == MVT::i8 || EltVT == MVT::i16) { diff --git a/test/CodeGen/X86/avx-shuffle-x86_32.ll b/test/CodeGen/X86/avx-shuffle-x86_32.ll index 78b4888cfa1..4bdba37c711 100644 --- a/test/CodeGen/X86/avx-shuffle-x86_32.ll +++ b/test/CodeGen/X86/avx-shuffle-x86_32.ll @@ -6,3 +6,14 @@ define <4 x i64> @test1(<4 x i64> %a) nounwind { ; CHECK-LABEL: test1: ; CHECK-NOT: vinsertf128 } + +define <8 x i16> @test2(<4 x i16>* %v) nounwind { +; CHECK-LABEL: test2 +; CHECK: vmovsd +; CHECK: vmovq + %v9 = load <4 x i16>, <4 x i16> * %v, align 8 + %v10 = shufflevector <4 x i16> %v9, <4 x i16> undef, <8 x i32> + %v11 = shufflevector <8 x i16> , <8 x i16> %v10, <8 x i32> + ret <8 x i16> %v11 +} + -- 2.11.0