[llvm] [AArch64][SME] Enable dynamic shuffle for fixed length types. (PR #72490)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 01:11:39 PST 2024


================
@@ -26171,13 +26196,39 @@ static SDValue GenerateFixedLengthSVETBL(SDValue Op, SDValue Op1, SDValue Op2,
         DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, ContainerVT,
                     DAG.getConstant(Intrinsic::aarch64_sve_tbl, DL, MVT::i32),
                     Op1, SVEMask);
-  else if (Subtarget.hasSVE2())
-    Shuffle =
-        DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, ContainerVT,
-                    DAG.getConstant(Intrinsic::aarch64_sve_tbl2, DL, MVT::i32),
-                    Op1, Op2, SVEMask);
-  else
-    llvm_unreachable("Cannot lower shuffle without SVE2 TBL");
+  else if (Subtarget.hasSVE2()) {
+    if (!MinMaxEqual) {
+      SDValue VScale = (BitsPerElt == 64)
+                           ? DAG.getVScale(DL, MVT::i64, APInt(64, 1))
+                           : DAG.getVScale(DL, MVT::i32, APInt(32, 1));
+      SDValue Mul =
+          DAG.getNode(ISD::MUL, DL, (BitsPerElt == 64) ? MVT::i64 : MVT::i32,
+                      DAG.getConstant(128 / BitsPerElt, DL,
----------------
sdesmalen-arm wrote:

You can pass `128 / BitsPerElt` to DAG.getVScale to get the same effect, reducing the need for the `Mul` variable.

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


More information about the llvm-commits mailing list