This is an archive of the discontinued LLVM Phabricator instance.

[GC] Loosen ordering on statepoint reloads to allow CSE
ClosedPublic

Authored by reames on Mar 11 2020, 11:03 AM.

Details

Summary

We just removed a broken duplicate elimination algorithm in D75964, and after landed that it occurred to me that duplicate elimination is simply CSE. SelectionDAG has a build in CSE, so why wasn't that triggering? Well, it turns out we were overly conservative in the memory states for our reloads and CSE (rightly) considers the incoming memory state for a load part of the identity of the load.

By loosening the chain and allowing reordering, we also allow CSE. As shown in the test case, doing iterative CSE as we go is enough to eliminate duplicate stores in later statepoints as well. We key our (block local) slot map by SDValue, so commoning a previous pair of loads at construction time means we also common following stores.

Diff Detail

Event Timeline

reames created this revision.Mar 11 2020, 11:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2020, 11:03 AM
dantrushin accepted this revision.Mar 11 2020, 11:50 AM

Wow. That simple.
LGTM

llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
978

Typo? Should this read '...this lets ...' ?

This revision is now accepted and ready to land.Mar 11 2020, 11:50 AM
This revision was automatically updated to reflect the committed changes.