This is an archive of the discontinued LLVM Phabricator instance.

[Peephole] Allow folding loads into instructions w/multiple uses (such as test64rr)
ClosedPublic

Authored by reames on Jun 21 2019, 9:29 AM.

Details

Summary

Peephole opt has a one use limitation which appears to be accidental. The function being used was incorrectly documented as returning whether the def had one *user*, but instead returned true only when there was one *use*. Add a corresponding hasOneNonDbgUser helper, and adjust peephole-opt to use the appropriate one.

All of the actual folding code handles multiple uses within a single instruction. That codepath is well exercised through instruction selection.

The practical benefit of this is mostly restricted to atomics since our instruction selection is currently very conservative, but in theory, it can catch anything instruction selection might have missed or another pass inserted.

Diff Detail

Repository
rL LLVM

Event Timeline

reames created this revision.Jun 21 2019, 9:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2019, 9:29 AM
reames updated this revision to Diff 206025.Jun 21 2019, 9:38 AM

Further test updates. I updated the first patch while make check was still running because I'd expected the impact to be limited. I was surprised by how many places benefited outside of atomics.

skatkov accepted this revision.Jun 23 2019, 6:49 PM
skatkov added inline comments.
lib/CodeGen/PeepholeOptimizer.cpp
1309 ↗(On Diff #206025)

s/use/user/ ?

This revision is now accepted and ready to land.Jun 23 2019, 6:49 PM
This revision was automatically updated to reflect the committed changes.