This is an archive of the discontinued LLVM Phabricator instance.

Let EarlyCSE fold equivalent freeze instructions
ClosedPublic

Authored by aqjune on Feb 28 2020, 1:51 AM.

Details

Summary

This patch makes EarlyCSE fold equivalent freeze instructions.

Another optimization that I think will be useful is to remove freeze if its operand is used as a branch condition or at llvm.assume:

  %c = ...
  br i1 %c, label %A, ..
A:
  %d = freeze %c ; %d can be optimized to %c because %c cannot be poison or undef (or 'br %c' would be UB otherwise)

If it make sense for EarlyCSE to support this as well, I will make a patch for this.

Diff Detail

Event Timeline

aqjune created this revision.Feb 28 2020, 1:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2020, 1:51 AM
aqjune edited the summary of this revision. (Show Details)Feb 28 2020, 1:53 AM
aqjune added reviewers: spatel, reames.
lebedev.ri accepted this revision.Feb 28 2020, 2:16 AM
lebedev.ri added a subscriber: lebedev.ri.

This LG.

This revision is now accepted and ready to land.Feb 28 2020, 2:16 AM
This revision was automatically updated to reflect the committed changes.

Another optimization that I think will be useful is to remove freeze if its operand is used as a branch condition or at llvm.assume:

That doesn't sound like a CSE optimization. Maybe InstSimplify?