[llvm] [NewPM] Adds a port for AArch64PostLegalizerLowering (PR #190718)

Anshul Nigham via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 23:55:36 PDT 2026


================
@@ -1258,11 +1260,33 @@ AArch64PostLegalizerLoweringImpl::AArch64PostLegalizerLoweringImpl(
 {
 }
 
-class AArch64PostLegalizerLowering : public MachineFunctionPass {
+bool runPostLegalizerLowering(
+    MachineFunction &MF,
+    const AArch64PostLegalizerLoweringImplRuleConfig &RuleConfig) {
+  if (MF.getProperties().hasFailedISel())
+    return false;
+  assert(MF.getProperties().hasLegalized() && "Expected a legalized function?");
+  const Function &F = MF.getFunction();
+
+  const AArch64Subtarget &ST = MF.getSubtarget<AArch64Subtarget>();
+  CombinerInfo CInfo(/*AllowIllegalOps=*/true, /*ShouldLegalizeIllegal=*/false,
+                     /*LegalizerInfo=*/nullptr, /*OptEnabled=*/true,
----------------
nigham wrote:

It's all over the place (used Gemini to generate the answer below but manually verified):

   1. Hardcoded to false: In AArch64O0PreLegalizerCombiner.cpp, it is explicitly set to false (/*EnableOpt=*/false), consistent with a non-optimizing O0 pass.
   2. Hardcoded to true: In AArch64PostLegalizerLowering.cpp, it is explicitly set to true (/*OptEnabled=*/true). This indicates that the transformations in this pass are considered essential lowerings that
      should always be performed.
   3. Dynamically determined: In both AArch64PreLegalizerCombiner.cpp and AArch64PostLegalizerCombiner.cpp, the value is determined at runtime based on the global optimization level:

Since this PR is a pure port, I wanted to keep existing functionality.

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


More information about the llvm-commits mailing list