This is an archive of the discontinued LLVM Phabricator instance.

[EarlyCSE] Teach about CSE'ing over invariant.start intrinsics
ClosedPublic

Authored by anna on Aug 8 2016, 8:41 AM.

Details

Summary

Teach EarlyCSE about invariant.start intrinsic. Specifically, we can perform
store-load, load-load forwarding over this call. Also, keep in mind that we
cannot perform DSE over the call since it reads memory.

Diff Detail

Repository
rL LLVM

Event Timeline

anna updated this revision to Diff 67177.Aug 8 2016, 8:41 AM
anna retitled this revision from to [EarlyCSE] Teach about CSE'ing over invariant.start intrinsics.
anna updated this object.
anna added reviewers: sanjoy, majnemer, reames, dberlin.
anna added a subscriber: llvm-commits.
sanjoy requested changes to this revision.Aug 9 2016, 11:13 AM
sanjoy edited edge metadata.
sanjoy added inline comments.
test/Transforms/EarlyCSE/invariant.start.ll
50 ↗(On Diff #67177)

Why do you need to prevent DSE here? As written, the program is undefined (since we're changing an invariant location).

The only problematic optimization around invariant_(start|end) that I can come up with is stores floating into the invariant region. DSE seems fine, even in case like:

*ptr = 100
k = invariant_start(ptr)
;; BODY
invariant_end(k, ptr)
*ptr = 500

If BODY contains a read from ptr then we won't DSE the first store, but if not, it looks like it is fine to DSE it.

This revision now requires changes to proceed.Aug 9 2016, 11:13 AM
anna added inline comments.Aug 9 2016, 11:32 AM
test/Transforms/EarlyCSE/invariant.start.ll
50 ↗(On Diff #67177)

So, DSE can take place since anyway the program would be undefined with stores following invariant.start. Also, with invariant_start/end in place, DSE will not take place since invariant_end is still read-write.

I think with the CSE optimization, stores cannot float *into* the invariant region. So, I'll remove the lastStore to nullptr and keep the DSE tests.

sanjoy added inline comments.Aug 9 2016, 12:09 PM
test/Transforms/EarlyCSE/invariant.start.ll
9 ↗(On Diff #67177)

Btw, I think you need a space after the :.

anna updated this revision to Diff 67396.Aug 9 2016, 12:37 PM
anna edited edge metadata.
anna marked 2 inline comments as done.

DSE can be done in presence of invariant.start. Add testcases

sanjoy accepted this revision.Aug 9 2016, 12:43 PM
sanjoy edited edge metadata.

lgtm

This revision is now accepted and ready to land.Aug 9 2016, 12:43 PM
This revision was automatically updated to reflect the committed changes.