From 2ab1b8c1ec452fb743f6cc5051e75a01039cabfe Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 30 Oct 2019 13:22:13 -0700 Subject: [WebAssembly] Handle multiple loads of splatted loads Summary: Fixes an ISel failure when a splatted load is used more than once. The failure was due to the hacks we were doing in ISel lowering to preserve the original load as the operand of a LOAD_SPLAT node. The fix is to properly lower the splatted use of the load to a separate LOAD_SPLAT node. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69640 --- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index 2f698711a74..5cb796e389f 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -466,11 +466,14 @@ const char * WebAssemblyTargetLowering::getTargetNodeName(unsigned Opcode) const { switch (static_cast(Opcode)) { case WebAssemblyISD::FIRST_NUMBER: + case WebAssemblyISD::FIRST_MEM_OPCODE: break; #define HANDLE_NODETYPE(NODE) \ case WebAssemblyISD::NODE: \ return "WebAssemblyISD::" #NODE; +#define HANDLE_MEM_NODETYPE(NODE) HANDLE_NODETYPE(NODE) #include "WebAssemblyISD.def" +#undef HANDLE_MEM_NODETYPE #undef HANDLE_NODETYPE } return nullptr; @@ -1432,7 +1435,11 @@ SDValue WebAssemblyTargetLowering::LowerBUILD_VECTOR(SDValue Op, if (Subtarget->hasUnimplementedSIMD128() && (SplattedLoad = dyn_cast(SplatValue)) && SplattedLoad->getMemoryVT() == VecT.getVectorElementType()) { - Result = DAG.getNode(WebAssemblyISD::LOAD_SPLAT, DL, VecT, SplatValue); + Result = DAG.getMemIntrinsicNode( + WebAssemblyISD::LOAD_SPLAT, DL, DAG.getVTList({VecT}), + {SplattedLoad->getChain(), SplattedLoad->getBasePtr(), + SplattedLoad->getOffset()}, + SplattedLoad->getMemoryVT(), SplattedLoad->getMemOperand()); } else { Result = DAG.getSplatBuildVector(VecT, DL, SplatValue); } -- cgit v1.2.3