[llvm] [WebAssembly] Recognise EXTEND_HIGH (PR #123325)

Thomas Lively via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 14:58:35 PST 2025


================
@@ -2143,6 +2143,32 @@ WebAssemblyTargetLowering::LowerSIGN_EXTEND_INREG(SDValue Op,
                      Op.getOperand(1));
 }
 
+static SDValue GetExtendHigh(SDValue Op, unsigned UserOpc, EVT VT,
+                             SelectionDAG &DAG) {
+  if (Op.getOpcode() != ISD::VECTOR_SHUFFLE)
+    return SDValue();
+
+  assert((UserOpc == WebAssemblyISD::EXTEND_LOW_U ||
+          UserOpc == WebAssemblyISD::EXTEND_LOW_S) &&
+         "expected extend_low");
+  auto *Shuffle = cast<ShuffleVectorSDNode>(Op.getNode());
+  ArrayRef<int> Mask = Shuffle->getMask();
+
+  // Look for a shuffle which moves from the high half to the low half.
+  size_t FirstIdx = Mask.size() / 2;
+  for (size_t i = 0; i < Mask.size() / 2; ++i) {
----------------
tlively wrote:

Do we have to check that the top half of the mask has expected values as well?

https://github.com/llvm/llvm-project/pull/123325


More information about the llvm-commits mailing list