[llvm] [AArch64] Extend efficient lowering of experimental.cttz.elts (PR #92114)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 04:27:48 PDT 2024


================
@@ -5838,9 +5840,21 @@ SDValue AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
     return SDValue();
   }
   case Intrinsic::experimental_cttz_elts: {
-    SDValue NewCttzElts =
-        DAG.getNode(AArch64ISD::CTTZ_ELTS, dl, MVT::i64, Op.getOperand(1));
+    SDValue CttzOp = Op.getOperand(1);
+    EVT VT = CttzOp.getValueType();
+
+    if (!VT.isScalableVector()) {
+      // Retrieve original fixed-width vector from ISD::TRUNCATE Node.
+      assert(CttzOp.getOpcode() == ISD::TRUNCATE && "Expected ISD::TRUNCATE!");
----------------
hazzlim wrote:

Thanks for pointing this out - I have updated so that we sign extend to the correct type before passing this (now valid) mask to `convertFixedMaskToScalableVector`.

We don't actually manage to optimise away the sign_extend, at present - I have updated the regression tests to reflect this as it seems to make sense to fix this in a separate, follow up patch?


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


More information about the llvm-commits mailing list