This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Add flag reduction pass
ClosedPublic

Authored by arsenm on Oct 21 2022, 11:21 AM.

Details

Summary

Try to remove each flag from instructions. It may make more
sense to introduce these flags instead.

Diff Detail

Event Timeline

arsenm created this revision.Oct 21 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 11:21 AM
arsenm requested review of this revision.Oct 21 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 11:21 AM
Herald added a subscriber: wdng. · View Herald Transcript
regehr accepted this revision.Oct 21 2022, 11:27 AM

LGTM.

there's a simple test that we can apply to determine whether we add or remove any given flag: we should do whatever reduces the amount of undefined behavior. so, for example, nsw is one that we definitely to eliminate because this makes code more defined and hence (in general) easier to understand.

This revision is now accepted and ready to land.Oct 21 2022, 11:27 AM

LGTM.

we should do whatever reduces the amount of undefined behavior. so, for example, nsw is one that we definitely to eliminate because this makes code more defined and hence (in general) easier to understand.

My idea of simpler to understand is codegens to fewer instructions. Things that introduce undefined behavior are more likely to enable optimizations and different lowerings that reduce instructions emitted

My idea of simpler to understand is codegens to fewer instructions. Things that introduce undefined behavior are more likely to enable optimizations and different lowerings that reduce instructions emitted

right, adding UB enables more optimizations -- making the compiler execution harder to understand. I'll absolutely die on this hill but if you feel strongly enough in the other direction we should just add flags controlling this sort of thing. but my way is a better default.

aeubanks accepted this revision.Oct 21 2022, 1:15 PM

I'm still of the opinion that llvm-reduce should reduce textual IR as much as possible to provide as reduced of a test case as possible by default, but flags to control less text vs less codegen vs less UB of course would be good