diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 5c954ab63aab..d960a7427176 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -20550,8 +20550,8 @@ static SDValue scalarizeBinOpOfSplats(SDNode *N, SelectionDAG &DAG) { SDLoc DL(N); SDValue IndexC = DAG.getVectorIdxConstant(Index0, DL); - SDValue X = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, N0, IndexC); - SDValue Y = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, N1, IndexC); + SDValue X = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, Src0, IndexC); + SDValue Y = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, EltVT, Src1, IndexC); SDValue ScalarBO = DAG.getNode(Opcode, DL, EltVT, X, Y, N->getFlags()); // If all lanes but 1 are undefined, no need to splat the scalar result. diff --git a/llvm/test/CodeGen/X86/pr46189.ll b/llvm/test/CodeGen/X86/pr46189.ll index aea4a92cef4b..558483754c68 100644 --- a/llvm/test/CodeGen/X86/pr46189.ll +++ b/llvm/test/CodeGen/X86/pr46189.ll @@ -12,12 +12,13 @@ define { i64, i64 } @PR46189(double %0, double %1, double %2, double %3, double ; SSE-NEXT: unpcklpd {{.*#+}} xmm3 = xmm3[0,0] ; SSE-NEXT: divpd %xmm3, %xmm5 ; SSE-NEXT: cvttpd2dq %xmm5, %xmm0 -; SSE-NEXT: subsd %xmm2, %xmm1 -; SSE-NEXT: addsd %xmm2, %xmm2 -; SSE-NEXT: unpcklpd {{.*#+}} xmm1 = xmm1[0],xmm2[0] +; SSE-NEXT: movapd %xmm1, %xmm3 +; SSE-NEXT: subsd %xmm2, %xmm3 +; SSE-NEXT: addsd %xmm2, %xmm1 +; SSE-NEXT: unpcklpd {{.*#+}} xmm3 = xmm3[0],xmm1[0] ; SSE-NEXT: unpcklpd {{.*#+}} xmm4 = xmm4[0,0] -; SSE-NEXT: divpd %xmm4, %xmm1 -; SSE-NEXT: cvttpd2dq %xmm1, %xmm1 +; SSE-NEXT: divpd %xmm4, %xmm3 +; SSE-NEXT: cvttpd2dq %xmm3, %xmm1 ; SSE-NEXT: unpcklps {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1] ; SSE-NEXT: movq %xmm0, %rax ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1] @@ -32,9 +33,9 @@ define { i64, i64 } @PR46189(double %0, double %1, double %2, double %3, double ; AVX-NEXT: vmovddup {{.*#+}} xmm3 = xmm3[0,0] ; AVX-NEXT: vdivpd %xmm3, %xmm0, %xmm0 ; AVX-NEXT: vcvttpd2dq %xmm0, %xmm0 -; AVX-NEXT: vsubsd %xmm2, %xmm1, %xmm1 -; AVX-NEXT: vaddsd %xmm2, %xmm0, %xmm2 -; AVX-NEXT: vunpcklpd {{.*#+}} xmm1 = xmm1[0],xmm2[0] +; AVX-NEXT: vsubsd %xmm2, %xmm1, %xmm3 +; AVX-NEXT: vaddsd %xmm2, %xmm1, %xmm1 +; AVX-NEXT: vunpcklpd {{.*#+}} xmm1 = xmm3[0],xmm1[0] ; AVX-NEXT: vmovddup {{.*#+}} xmm2 = xmm4[0,0] ; AVX-NEXT: vdivpd %xmm2, %xmm1, %xmm1 ; AVX-NEXT: vcvttpd2dq %xmm1, %xmm1