[llvm] [AMDGPU][GIsel][NPM] Port AMDGPUPostLegalizerCombiner to NPM (PR #216274)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 02:40:37 PDT 2026


================
@@ -442,11 +444,33 @@ bool AMDGPUPostLegalizerCombinerImpl::matchCombine_s_mul_u64(
 // Pass boilerplate
 // ================
 
-class AMDGPUPostLegalizerCombiner : public MachineFunctionPass {
+static bool
+runCombiner(MachineFunction &MF, GISelValueTracking *VT,
+            MachineDominatorTree *MDT,
+            const AMDGPUPostLegalizerCombinerImplRuleConfig &RuleConfig,
+            bool EnableOpt) {
+  const Function &F = MF.getFunction();
+  const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
+  const AMDGPULegalizerInfo *LI =
+      static_cast<const AMDGPULegalizerInfo *>(ST.getLegalizerInfo());
+
+  CombinerInfo CInfo(/*AllowIllegalOps*/ false, /*ShouldLegalizeIllegal*/ true,
+                     LI, EnableOpt, F.hasOptSize(), F.hasMinSize());
+  // Disable fixed-point iteration to reduce compile-time
+  CInfo.MaxIterations = 1;
+  CInfo.ObserverLvl = CombinerInfo::ObserverLevel::SinglePass;
+  // Legalizer performs DCE, so a full DCE pass is unnecessary.
+  CInfo.EnableFullDCE = false;
+  AMDGPUPostLegalizerCombinerImpl Impl(MF, CInfo, *VT, /*CSEInfo*/ nullptr,
----------------
arsenm wrote:

CSEInfo should be populated. If it's not already in old pm, should fix that first 

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


More information about the llvm-commits mailing list