[llvm] [MacroFusion] Support multiple predicators (PR #72219)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 22:05:00 PST 2023


topperc wrote:

> > If we're already going to have a bitset of enabled macrofusions, why can't we have a single tblgenerated function that checks each bit and calls the function for a particular macrofusion if that bit is enabled. Why do we need to translate the bitset into a vector of function pointers?
> 
> I think this is a kind of optimization. Suppose that we have a bitset of enabled macrofusions and a single tblgenerated function, it will be like:
> 
> ```c++
> static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
>                                    const TargetSubtargetInfo &TSI,
>                                    const MachineInstr *FirstMI,
>                                    const MachineInstr &SecondMI) {
>   if (ST.hasFusion(Fusion0) && isFusion0(FirstMI, SecondMI))
>     return true;
>   if (ST.hasFusion(Fusion1) && isFusion1(FirstMI, SecondMI))
>     return true;
>   // ...
>   if (ST.hasFusion(FusionX) && isFusionX(FirstMI, SecondMI))
>     return true;
>   return false;
> }
> ```
> 
> For most branches, they are evalated to `false` (a subtarget may not support all the macro fusions). Then we are wasting some time to test if we support the macro fusion, this can be huge cost (remember that `shouldScheduleAdjacent` will be called for each SDep). If we translate the bitset into a vector of function pointers (those functions that the subtarget really supports), then we are move the bits checking to the time when we create the MacroFusionMutation (this is only done once). We can save some compile time by doing this I think.

Do you plan to add a lot of macrofusions after this patch series? Is this a near term performance concern?

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


More information about the llvm-commits mailing list