[clang] [llvm] [AArch64][SVE] Improve fixed-length addressing modes. (PR #129732)

Paul Walker via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 02:59:54 PST 2025


================
@@ -7380,17 +7380,31 @@ bool AArch64DAGToDAGISel::SelectAddrModeIndexedSVE(SDNode *Root, SDValue N,
     return false;
 
   SDValue VScale = N.getOperand(1);
-  if (VScale.getOpcode() != ISD::VSCALE)
+  std::optional<int64_t> MulImm;
+  if (VScale.getOpcode() == ISD::VSCALE) {
+    MulImm = cast<ConstantSDNode>(VScale.getOperand(0))->getSExtValue();
+  } else if (auto C = dyn_cast<ConstantSDNode>(VScale)) {
+    int64_t ByteOffset = C->getSExtValue();
+    constexpr auto SVEBitsPerBlock = AArch64::SVEBitsPerBlock;
+    auto MinVScale = Subtarget->getMinSVEVectorSizeInBits() / SVEBitsPerBlock;
+    auto MaxVScale = Subtarget->getMaxSVEVectorSizeInBits() / SVEBitsPerBlock;
+
+    if (!MaxVScale || MinVScale != MaxVScale || ByteOffset % MaxVScale != 0)
----------------
paulwalker-arm wrote:

This might start being a common idiom.  Do you mind adding a helper function to AArch64Subtarget along the lines of `optional<unsigned> getSVEVectorSizeInBits()`?


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


More information about the cfe-commits mailing list