From: Bruno Cardoso Lopes Date: Thu, 1 Sep 2011 18:15:06 +0000 (+0000) Subject: Fix vbroadcast matching logic to early unmatch if the node doesn't have X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a39ccdb9d4829548756efaaac0d19ebae8b7ff5d;p=oota-llvm.git Fix vbroadcast matching logic to early unmatch if the node doesn't have only one use. Fix PR10825. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138951 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 0d454149301..706b1a2f80c 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -6409,12 +6409,16 @@ static bool isVectorBroadcast(SDValue &Op) { if (Is256) V = V.getOperand(1); - if (V.hasOneUse() && V.getOpcode() != ISD::SCALAR_TO_VECTOR) + + if (!V.hasOneUse()) return false; // Check the source scalar_to_vector type. 256-bit broadcasts are // supported for 32/64-bit sizes, while 128-bit ones are only supported // for 32-bit scalars. + if (V.getOpcode() != ISD::SCALAR_TO_VECTOR) + return false; + unsigned ScalarSize = V.getOperand(0).getValueType().getSizeInBits(); if (ScalarSize != 32 && ScalarSize != 64) return false; diff --git a/test/CodeGen/X86/avx-vbroadcast.ll b/test/CodeGen/X86/avx-vbroadcast.ll index ffa9710677c..89b41884401 100644 --- a/test/CodeGen/X86/avx-vbroadcast.ll +++ b/test/CodeGen/X86/avx-vbroadcast.ll @@ -75,6 +75,7 @@ entry: ; CHECK: _G ; CHECK-NOT: vbroadcastsd (% +; CHECK: ret define <2 x i64> @G(i64* %ptr) nounwind uwtable readnone ssp { entry: %q = load i64* %ptr, align 8 @@ -82,3 +83,12 @@ entry: %vecinit2.i = insertelement <2 x i64> %vecinit.i, i64 %q, i32 1 ret <2 x i64> %vecinit2.i } + +; CHECK: _H +; CHECK-NOT: vbroadcastss +; CHECK: ret +define <4 x i32> @H(<4 x i32> %a) { + %x = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> + ret <4 x i32> %x +} +