diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 14880e40881..c6a79a2df5f 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -40114,11 +40114,10 @@ static SDValue combineInsertSubvector(SDNode *N, SelectionDAG &DAG, return Ld; } } - // If lower/upper loads are the same and the only users of the load, then - // lower to a VBROADCASTF128/VBROADCASTI128/etc. + // If lower/upper loads are the same and there's no other use of the lower + // load, then splat the loaded value with a broadcast. if (auto *Ld = dyn_cast(peekThroughOneUseBitcasts(SubVec2))) - if (SubVec2 == SubVec && ISD::isNormalLoad(Ld) && - SDNode::areOnlyUsersOf({N, Vec.getNode()}, SubVec2.getNode())) + if (SubVec2 == SubVec && ISD::isNormalLoad(Ld) && Vec.hasOneUse()) return DAG.getNode(X86ISD::SUBV_BROADCAST, dl, OpVT, SubVec); // If this is subv_broadcast insert into both halves, use a larger diff --git a/test/CodeGen/X86/avx-vbroadcastf128.ll b/test/CodeGen/X86/avx-vbroadcastf128.ll index e35919d4f32..9bd41796e58 100644 --- a/test/CodeGen/X86/avx-vbroadcastf128.ll +++ b/test/CodeGen/X86/avx-vbroadcastf128.ll @@ -106,16 +106,14 @@ define void @subv_reuse_is_ok(<4 x float>* %a, <8 x float>* %b) { ; X32: # %bb.0: ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax ; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx -; X32-NEXT: vmovups (%ecx), %xmm0 -; X32-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 +; X32-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1] ; X32-NEXT: vmovups %ymm0, (%eax) ; X32-NEXT: vzeroupper ; X32-NEXT: retl ; ; X64-LABEL: subv_reuse_is_ok: ; X64: # %bb.0: -; X64-NEXT: vmovups (%rdi), %xmm0 -; X64-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 +; X64-NEXT: vbroadcastf128 {{.*#+}} ymm0 = mem[0,1,0,1] ; X64-NEXT: vmovups %ymm0, (%rsi) ; X64-NEXT: vzeroupper ; X64-NEXT: retq