This is an archive of the discontinued LLVM Phabricator instance.

[NewGVN] Replace predicate info leftovers
ClosedPublic

Authored by davide on May 15 2017, 7:16 PM.

Details

Summary

For those watching, we were leaving some ssa.copy around and those arrived to the backend where we failed to lower.
The comment in the code contains the whole story, for those interested :)

Diff Detail

Repository
rL LLVM

Event Timeline

davide created this revision.May 15 2017, 7:16 PM
davide added inline comments.May 15 2017, 7:21 PM
lib/Transforms/Scalar/NewGVN.cpp
2798–2800 ↗(On Diff #99093)

I think I could probably just forcefully cast to CallInst as we're always guaranteed that PredicateInfo will insert calls in the map, FWIW.

dberlin edited edge metadata.May 15 2017, 8:08 PM

(You forgot the testcase :P)

lib/Transforms/Scalar/NewGVN.cpp
2784 ↗(On Diff #99093)

This isn't quite right.
Let me try to rewrite what i wrote in the bug report better here:

In most cases, we are able to eliminate the ssa.copy intrinsics in eliminateInstructions.
The two cases we are able to eliminate them are:

  1. We don't use the predicate info (in which case, we will value number the ssa.copy to its argument)
  2. We use the predicate info to find an equivalent, and something in the congruence class we come up with dominates the predicateinfo.

This is the vast majority of cases.
However, we are not guaranteed that any of the equivalents we come up with if we use the predicateinfo dominates it.
This is particularly true when the used predicateinfo is an and/or of two conditions.

In these cases, we will end up with some ssa.copy left after and need to eliminate them.

2795 ↗(On Diff #99093)

I realized there's an easier way to accomplish this.
In eliminateInstructions,
where we have:

// Don't replace our existing users with ourselves.
if (U->get() == DominatingLeader)
  continue;

right before this, add

if (DominatingLeader is a  PredicateInfo copy)
  DominatingLeader = copy argument

Sorry, I didn't do git add of the testcase, I'll do in my next upload.

lib/Transforms/Scalar/NewGVN.cpp
2784 ↗(On Diff #99093)

I think the comment can be committed separately (your redacted version). I'll go ahead and do it.

2795 ↗(On Diff #99093)

Yes, I like this better too (more surgical)

davide updated this revision to Diff 99098.May 15 2017, 9:05 PM

updated, now with testcase.

dberlin accepted this revision.May 15 2017, 10:00 PM

LGTM, thanks!

This revision is now accepted and ready to land.May 15 2017, 10:00 PM
This revision was automatically updated to reflect the committed changes.