[llvm] [AArch64] Match constants in SelectSMETileSlice (PR #151494)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 02:00:56 PDT 2025


================
@@ -7617,16 +7617,29 @@ bool AArch64DAGToDAGISel::SelectAnyPredicate(SDValue N) {
 bool AArch64DAGToDAGISel::SelectSMETileSlice(SDValue N, unsigned MaxSize,
                                              SDValue &Base, SDValue &Offset,
                                              unsigned Scale) {
-  // Try to untangle an ADD node into a 'reg + offset'
-  if (CurDAG->isBaseWithConstantOffset(N))
-    if (auto C = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
+  auto MatchConstantOffset = [&](SDValue CN) -> SDValue {
+    if (auto *C = dyn_cast<ConstantSDNode>(CN)) {
       int64_t ImmOff = C->getSExtValue();
-      if ((ImmOff > 0 && ImmOff <= MaxSize && (ImmOff % Scale == 0))) {
-        Base = N.getOperand(0);
-        Offset = CurDAG->getTargetConstant(ImmOff / Scale, SDLoc(N), MVT::i64);
-        return true;
-      }
+      if ((ImmOff > 0 && ImmOff <= MaxSize && (ImmOff % Scale == 0)))
+        return CurDAG->getTargetConstant(ImmOff / Scale, SDLoc(N), MVT::i64);
     }
+    return SDValue();
+  };
----------------
gbossu wrote:

Super-nit (Nothing to do): That PR would have been even quicker to look at if it was split in a first completely NFC commit that introduces `MatchConstantOffset` and uses it to match `reg + offset`, followed by another commit (not NFC) using that same lambda to match plain constants.

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


More information about the llvm-commits mailing list