[all-commits] [llvm/llvm-project] 72a3cd: [MacroFusion] Early return when insts already clus...

Tomer Shafir via All-commits all-commits at lists.llvm.org
Wed Apr 15 22:51:19 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 72a3cd9e54f16d87f47bc984672999a9b67cd4f4
      https://github.com/llvm/llvm-project/commit/72a3cd9e54f16d87f47bc984672999a9b67cd4f4
  Author: Tomer Shafir <tomer.shafir8 at gmail.com>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M llvm/lib/CodeGen/MacroFusion.cpp
    A llvm/test/CodeGen/AArch64/macro-fusion-cluster-conflict.mir

  Log Message:
  -----------
  [MacroFusion] Early return when insts already clustered (#191710)

This patch adds an early return to `fuseInstructionPair()` when macro
fused instructions are already clustered, either by an earlier fusion or
another clustering like ld/st clustering, removing the assert.
    
The assert is generally wrong - there are edge cases where an earlier
ld/st clustering (before macro fusion) reached the assert because it
sets `ParentClusterIdx` and fails. For example, ADRP+LOAD/STORE on
AArch64, thought it seems to be a rare case because the addresses are
ususally unkown at compile time.
    
It doesn't effectively change how fusions are prioritized - early
fusions still win on fusion-fusion conflicts, like before. But it
changes how we resolve the edge case of ld/st-fusion conflicts:
    
Previously, fusions would effectively override ld/st clustering in this
case, given that we currently limits instruction membership to at most a
single cluster through `ParentClusterIdx`. Macro fusion runs after ld/st
clustering in the pipelines.
    
Here we inverse the priorities from MacroFusion's perspective and prefer
earlier ld/st clustering. I think they should be generally preferred
over fusions, because they not only save dispatch and execution slots,
but they also should decrease code size. Of course this heuristic can
fail in some cases. If a new clustering algorithm is added, it would
have to inspect ordering and be placed correctly.
    
I have inspected several internal workloads, and ld/st-fusion conflicts
very rarely appear.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list