[PATCH] D145113: [DAGCombiner][AArch64] Constant fold ISD::VSCALE if VScaleMin==VScaleMax.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 00:31:45 PST 2023


sdesmalen added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14846
+  // Constant fold vscale if the min and max value are known.
+  auto Attr = DAG.getMachineFunction().getFunction().getFnAttribute(Attribute::VScaleRange);
+  if (!Attr.isValid())
----------------
Please use clang-format


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14850-14857
+  unsigned VScaleMin = Attr.getVScaleRangeMin();
+  std::optional<unsigned> VScaleMax = Attr.getVScaleRangeMax();
+  if (!VScaleMax || VScaleMin != VScaleMax)
+    return SDValue();
+
+  APInt C = N->getConstantOperandAPInt(0);
+  C *= VScaleMin;
----------------
Seems easier to write:

  unsigned VScaleMin = Attr.getVScaleRangeMin();
  if (std::optional<unsigned> VScaleMax = Attr.getVScaleRangeMax())
    if (*VScaleMax == VScaleMin)
      return DAG.getConstant(VScaleMin * N->getConstantOperandAPInt(0), SDLoc(N),
                             N->getValueType(0));
  return SDValue();

?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145113/new/

https://reviews.llvm.org/D145113



More information about the llvm-commits mailing list