This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Try to turn calls into something else
ClosedPublic

Authored by arsenm on Oct 23 2022, 11:53 AM.

Details

Summary

Try to turn calls that look like operators into known
intrinsics. Also try to turn calls that look like a load or
a store into a load or store.

Diff Detail

Event Timeline

arsenm created this revision.Oct 23 2022, 11:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2022, 11:53 AM
arsenm requested review of this revision.Oct 23 2022, 11:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2022, 11:53 AM
Herald added a subscriber: wdng. · View Herald Transcript
dblaikie added inline comments.Oct 24 2022, 11:39 AM
llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
98–101

Could invert this to reduce indentation?

if (!IsStore || DataArg)
  return false;
DataArg = Arg;

(or even split out the two conditions and have separate returns - keep each one simpler)

183

This amounts to an else-after-return, since the above switch is exhaustive - maybe skip the else? (& tag the end of the previous if with llvm_unreachable - same thing with this following if.

arsenm updated this revision to Diff 470274.Oct 24 2022, 1:24 PM
arsenm marked 2 inline comments as done.

Address comments

aeubanks added inline comments.Oct 28 2022, 4:00 PM
llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
139

why volatile?

194

IMO a call to an intrinsic is less reduced than a call to some arbitrary external function.
Perhaps it's finally time to create a flag for reducing IR optimizing for codegen?

arsenm added inline comments.Oct 28 2022, 4:03 PM
llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
139

volatile acts more like a call with a pointer. It's treated as a pointer capture, has stricter scheduling. Plus we may be emitting a load/store from null in the default address space, so this makes that defined. If the volatile doesn't matter, the volatile reduction can remove it later

194

An intrinsic has known behavior, an arbitrary external call doesn't. From a semantics perspective, that's more understandable

aeubanks accepted this revision.Nov 7 2022, 1:30 PM
aeubanks added inline comments.
llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
194

from a "I want to submit this IR reproducer as a test case" standpoint, calling an intrinsic as opposed to an arbitrary call is weirder. there's very little code that deals specifically with fshl at least in the middle-end, but a lot that deals with generic calls. so picking some random intrinsic is weird

but sure, we can go with this and see if people (I) get annoyed or not

This revision is now accepted and ready to land.Nov 7 2022, 1:30 PM