This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Introduce new scoring mechanism for MIR reductions
ClosedPublic

Authored by arsenm on Apr 19 2022, 3:42 PM.

Details

Summary

Many MIR reductions benefit from or require increasing the instruction
count. For example, unlike in the IR, you may need to insert a new
instruction to represent an undef. The current instruction reduction
pass works around this by sticking implicit defs on whatever
instruction happens to be first in the entry block block.

Other strategies I've applied manually include breaking instructions
with multiple defs into separate instructions, or breaking large register defs
into multiple subregister defs.

Make up a simple scoring system based on what I generally try to get
rid of first when manually reducing. Counts implicit defs as free
since reduction passes will be introducing them, although they
probably should count for something. It also might make more sense to
have a comparison the two functions, rather than having to compute a
contextless number. This isn't particularly well tested since overall
the MIR support isn't in a place where it is useful on the kinds of testcases
I want to throw at it

Diff Detail

Event Timeline

arsenm created this revision.Apr 19 2022, 3:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 3:42 PM
arsenm requested review of this revision.Apr 19 2022, 3:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 3:42 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm updated this revision to Diff 423925.Apr 20 2022, 8:48 AM

Fix missing squash

Right, so with MIR reductions we totally forgot about this an relied on the IR serialization size which is obviously wrong. This looks like an improvement to me. Of course the details of the metric can always be discussed but this should be better than nothing. Especially if we start inserting IMPLICIT_DEF instructions during reduction.

markus accepted this revision.Apr 27 2022, 11:57 PM
This revision is now accepted and ready to land.Apr 27 2022, 11:57 PM