This is an archive of the discontinued LLVM Phabricator instance.

[MachineCSE] Add an option to do machine cse at all time regardless of profitable checking
ClosedPublic

Authored by jaykang10 on Aug 3 2023, 7:21 AM.

Details

Summary

MachineCSE pass has heuristics to check that common subexpression would increase register pressure. For example,

%1 = mov 0
%2 = add %1, ...
...
%5 = mov 0
%6 = copy %5 --> it is copy for access subreg.
...

We can see a common sub expression mov 0 on above example and we can imagine the %5 can be removed. However, MachineCSE pass does not remove it because it could increase register pressure.
I agree with evan's commit message. If the MI does not use vreg, it just creates a live range and does not close any other vreg's live range. However, I feel it could be too conservative... I am not sure how we can improve the heuristics without performance regression so I would like to suggest to add an option which does CSE at all time.

Diff Detail

Event Timeline

jaykang10 created this revision.Aug 3 2023, 7:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 7:21 AM
jaykang10 requested review of this revision.Aug 3 2023, 7:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 7:21 AM
jaykang10 retitled this revision from [AArch64] Add an option to do machine cse at all time regardless of profitable checking to [MachineCSE] Add an option to do machine cse at all time regardless of profitable checking.Aug 3 2023, 7:22 AM
dmgreen accepted this revision.Aug 7 2023, 12:59 AM

Having a debug options is always useful. LGTM but I have some suggestions of the name.

llvm/lib/CodeGen/MachineCSE.cpp
68

Maybe name this AggressiveMachineCSE or something like it, to try and show that it overrides the profitability but not correctness.

70

Maybe "Override the profitability heuristics for Machine CSE"?

This revision is now accepted and ready to land.Aug 7 2023, 12:59 AM

Thanks.
Let me update the name.

llvm/lib/CodeGen/MachineCSE.cpp
68

Let me update the name with AggressiveMachineCSE .

70

Let me update it.

jaykang10 updated this revision to Diff 547673.Aug 7 2023, 1:43 AM

Following @dmgreen's comment, updated name.

jaykang10 updated this revision to Diff 547676.Aug 7 2023, 2:01 AM
This revision was landed with ongoing or failed builds.Aug 7 2023, 2:07 AM
This revision was automatically updated to reflect the committed changes.