This is an archive of the discontinued LLVM Phabricator instance.

[CGP] In optimizeMemoryInst handle select similarly to phi
ClosedPublic

Authored by john.brawn on Sep 25 2017, 10:11 AM.

Details

Summary

This lets us optimize away selects that perform the same address computation in two different ways and is also the first step towards being able to handle selects between two different, but compatible, address computations.

Diff Detail

Repository
rL LLVM

Event Timeline

davide added a subscriber: davide.Sep 25 2017, 12:24 PM

shouldn't GVN handle this case?

skatkov added inline comments.Sep 25 2017, 10:14 PM
lib/CodeGen/CodeGenPrepare.cpp
4462 ↗(On Diff #116568)

Please update at least this comment. Now the variable PhiSeen means not only Phi but also Select.

john.brawn edited the summary of this revision. (Show Details)

Rename PhiSeen to PhiOrSelectSeen and adjust a comment.

john.brawn marked an inline comment as done.Sep 26 2017, 6:17 AM

shouldn't GVN handle this case?

It's quite possible that we never actually see this kind of input, but this patch is just part of D38133 that's been split out to simplify things.

skatkov accepted this revision.Sep 27 2017, 2:02 AM

LGTM

This revision is now accepted and ready to land.Sep 27 2017, 2:02 AM
skatkov added inline comments.Sep 27 2017, 8:54 AM
lib/CodeGen/CodeGenPrepare.cpp
4396 ↗(On Diff #116659)

Please consider separation PhiSeen and SelectSeen, we probably will need it in future.
From other side we can do it later if we really need it.
So it is up to you.

This revision was automatically updated to reflect the committed changes.