[llvm] [SLP][AArch64]Support masked div/rem on non-pow-2 vectors (PR #210623)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 13:54:39 PDT 2026


================
@@ -421,6 +421,48 @@ getFloorFullVectorNumberOfElements(const TargetTransformInfo &TTI, Type *Ty,
   return (Sz / RegVF) * RegVF;
 }
 
+/// For a non-power-of-2 \p NumElts-wide integer div/rem \p Opcode, returns the
+/// padded full-register vector type if padding is structurally possible, or
+/// nullptr if the vector already fills a register or the opcode is not
+/// div/rem. Does not check profitability; see getMaskedDivRemCost for that.
+static FixedVectorType *getMaskedDivRemType(const TargetTransformInfo &TTI,
+                                            unsigned Opcode, Type *ScalarTy,
+                                            unsigned NumElts) {
+  if (!Instruction::isIntDivRem(Opcode) || has_single_bit(NumElts))
+    return nullptr;
+  unsigned PaddedNumElts =
+      getFullVectorNumberOfElements(TTI, ScalarTy, NumElts);
+  if (PaddedNumElts == NumElts)
+    return nullptr;
----------------
alexey-bataev wrote:

We still can have non-power-of-2 number of elements, like 6, so it cannot be assertion

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


More information about the llvm-commits mailing list