From 48cd5a5632dfebdb12536f7189bd705251f1d515 Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 10 Feb 2023 14:29:16 -0800 Subject: [PATCH 1/2] Transform IntCon(0) to VecCon(0) for WithElement case --- src/coreclr/jit/lclmorph.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/lclmorph.cpp b/src/coreclr/jit/lclmorph.cpp index e3e9cccb7d51d1..bbc823f12c8836 100644 --- a/src/coreclr/jit/lclmorph.cpp +++ b/src/coreclr/jit/lclmorph.cpp @@ -1209,13 +1209,21 @@ class LocalAddressVisitor final : public GenTreeVisitor assert(elementType == TYP_SIMD12); assert(varDsc->TypeGet() == TYP_SIMD16); + // If we are not doing struct promotion and we have zero-initialization, + // then we need to produce a VecCon(0). + if (elementNode->IsIntegralConst(0)) + { + DEBUG_DESTROY_NODE(elementNode); + elementNode = m_compiler->gtNewZeroConNode(TYP_SIMD12); + } + // We inverse the operands here and take elementNode as the main value and simdLclNode[3] as the // new value. This gives us a new TYP_SIMD16 with all elements in the right spots GenTree* indexNode = m_compiler->gtNewIconNode(3, TYP_INT); - hwiNode = - m_compiler->gtNewSimdWithElementNode(TYP_SIMD16, elementNode, indexNode, simdLclNode, - CORINFO_TYPE_FLOAT, 16, /* isSimdAsHWIntrinsic */ true); + hwiNode = m_compiler->gtNewSimdWithElementNode(TYP_SIMD16, elementNode, indexNode, simdLclNode, + CORINFO_TYPE_FLOAT, 16, + /* isSimdAsHWIntrinsic */ true); } user->AsOp()->gtOp2 = hwiNode; From 63bcc9f1f8da6d0b70bf4f147d655e8b8e3f4081 Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 10 Feb 2023 14:34:57 -0800 Subject: [PATCH 2/2] Formatting --- src/coreclr/jit/lclmorph.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/lclmorph.cpp b/src/coreclr/jit/lclmorph.cpp index bbc823f12c8836..38431916e065fd 100644 --- a/src/coreclr/jit/lclmorph.cpp +++ b/src/coreclr/jit/lclmorph.cpp @@ -1221,9 +1221,9 @@ class LocalAddressVisitor final : public GenTreeVisitor // new value. This gives us a new TYP_SIMD16 with all elements in the right spots GenTree* indexNode = m_compiler->gtNewIconNode(3, TYP_INT); - hwiNode = m_compiler->gtNewSimdWithElementNode(TYP_SIMD16, elementNode, indexNode, simdLclNode, - CORINFO_TYPE_FLOAT, 16, - /* isSimdAsHWIntrinsic */ true); + hwiNode = + m_compiler->gtNewSimdWithElementNode(TYP_SIMD16, elementNode, indexNode, simdLclNode, + CORINFO_TYPE_FLOAT, 16, /* isSimdAsHWIntrinsic */ true); } user->AsOp()->gtOp2 = hwiNode;