From 4d1156a69ca7ad0e52499f3421fe4a965453a57d Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Wed, 25 Jul 2018 17:08:13 +0000 Subject: [PATCH] Fix corruption of result number in LegalizeVectorOps.cpp When VectorLegalizer::LegalizeOp creates a new SDValue after iterating over its arguments, we need to refer to the same result number of the new node that the original value used. Reviewed by: cameron.mcinally Differential Revision: https://reviews.llvm.org/D49805 llvm-svn: 337939 --- .../SelectionDAG/LegalizeVectorOps.cpp | 3 +- .../X86/vector-constrained-fp-intrinsics.ll | 28 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp index ee2906f9e82..67928d4bdbd 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -223,7 +223,8 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { for (const SDValue &Op : Node->op_values()) Ops.push_back(LegalizeOp(Op)); - SDValue Result = SDValue(DAG.UpdateNodeOperands(Op.getNode(), Ops), 0); + SDValue Result = SDValue(DAG.UpdateNodeOperands(Op.getNode(), Ops), + Op.getResNo()); bool HasVectorValue = false; if (Op.getOpcode() == ISD::LOAD) { diff --git a/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll b/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll index c78cbbf6d5b..a1e29a356c2 100644 --- a/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll +++ b/test/CodeGen/X86/vector-constrained-fp-intrinsics.ll @@ -27,10 +27,10 @@ define <4 x double> @constrained_vector_fdiv_v4f64() { ; NO-FMA-LABEL: constrained_vector_fdiv_v4f64: ; NO-FMA: # %bb.0: ; NO-FMA-NEXT: movapd {{.*#+}} xmm2 = [1.000000e+01,1.000000e+01] -; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [3.000000e+00,4.000000e+00] -; NO-FMA-NEXT: divpd %xmm2, %xmm1 ; NO-FMA-NEXT: movapd {{.*#+}} xmm0 = [1.000000e+00,2.000000e+00] ; NO-FMA-NEXT: divpd %xmm2, %xmm0 +; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [3.000000e+00,4.000000e+00] +; NO-FMA-NEXT: divpd %xmm2, %xmm1 ; NO-FMA-NEXT: retq ; ; HAS-FMA-LABEL: constrained_vector_fdiv_v4f64: @@ -72,10 +72,10 @@ entry: define <4 x double> @constrained_vector_fmul_v4f64() { ; NO-FMA-LABEL: constrained_vector_fmul_v4f64: ; NO-FMA: # %bb.0: # %entry -; NO-FMA-NEXT: movapd {{.*#+}} xmm0 = [1.797693e+308,1.797693e+308] -; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [4.000000e+00,5.000000e+00] -; NO-FMA-NEXT: mulpd %xmm0, %xmm1 -; NO-FMA-NEXT: mulpd {{.*}}(%rip), %xmm0 +; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [1.797693e+308,1.797693e+308] +; NO-FMA-NEXT: movapd {{.*#+}} xmm0 = [2.000000e+00,3.000000e+00] +; NO-FMA-NEXT: mulpd %xmm1, %xmm0 +; NO-FMA-NEXT: mulpd {{.*}}(%rip), %xmm1 ; NO-FMA-NEXT: retq ; ; HAS-FMA-LABEL: constrained_vector_fmul_v4f64: @@ -119,10 +119,10 @@ entry: define <4 x double> @constrained_vector_fadd_v4f64() { ; NO-FMA-LABEL: constrained_vector_fadd_v4f64: ; NO-FMA: # %bb.0: # %entry -; NO-FMA-NEXT: movapd {{.*#+}} xmm0 = [1.797693e+308,1.797693e+308] -; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [2.000000e+00,2.000000e-01] -; NO-FMA-NEXT: addpd %xmm0, %xmm1 -; NO-FMA-NEXT: addpd {{.*}}(%rip), %xmm0 +; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [1.797693e+308,1.797693e+308] +; NO-FMA-NEXT: movapd {{.*#+}} xmm0 = [1.000000e+00,1.000000e-01] +; NO-FMA-NEXT: addpd %xmm1, %xmm0 +; NO-FMA-NEXT: addpd {{.*}}(%rip), %xmm1 ; NO-FMA-NEXT: retq ; ; HAS-FMA-LABEL: constrained_vector_fadd_v4f64: @@ -165,10 +165,10 @@ entry: define <4 x double> @constrained_vector_fsub_v4f64() { ; NO-FMA-LABEL: constrained_vector_fsub_v4f64: ; NO-FMA: # %bb.0: # %entry -; NO-FMA-NEXT: movapd {{.*#+}} xmm0 = [-1.797693e+308,-1.797693e+308] -; NO-FMA-NEXT: movapd %xmm0, %xmm1 -; NO-FMA-NEXT: subpd {{.*}}(%rip), %xmm1 +; NO-FMA-NEXT: movapd {{.*#+}} xmm1 = [-1.797693e+308,-1.797693e+308] +; NO-FMA-NEXT: movapd %xmm1, %xmm0 ; NO-FMA-NEXT: subpd {{.*}}(%rip), %xmm0 +; NO-FMA-NEXT: subpd {{.*}}(%rip), %xmm1 ; NO-FMA-NEXT: retq ; ; HAS-FMA-LABEL: constrained_vector_fsub_v4f64: @@ -425,8 +425,8 @@ entry: define <4 x double> @constrained_vector_sqrt_v4f64() { ; NO-FMA-LABEL: constrained_vector_sqrt_v4f64: ; NO-FMA: # %bb.0: # %entry -; NO-FMA-NEXT: sqrtpd {{.*}}(%rip), %xmm1 ; NO-FMA-NEXT: sqrtpd {{.*}}(%rip), %xmm0 +; NO-FMA-NEXT: sqrtpd {{.*}}(%rip), %xmm1 ; NO-FMA-NEXT: retq ; ; HAS-FMA-LABEL: constrained_vector_sqrt_v4f64: