[gvn] CSE gc.relocates based on meaning, not spelling (try 2)
authorPhilip Reames <listmail@philipreames.com>
Tue, 16 Mar 2021 17:52:01 +0000 (10:52 -0700)
committerPhilip Reames <listmail@philipreames.com>
Tue, 16 Mar 2021 17:59:31 +0000 (10:59 -0700)
commit6972e39d47eccc3e5fc3ded4a1e1b78f74d10af6
treed56c3af9336f32bfbcb61079dc1f3fdc8a4fdde2
parentf586de8459ce897faf532fdd49fd4aa81747589e
[gvn] CSE gc.relocates based on meaning, not spelling (try 2)

This was (partially) reverted in cfe8f8e0 because the conversion from readonly to readnone in Intrinsics.td exposed a couple of problems.  This change has been reworked to not need that change (via some explicit checks in client code).  This is being done to address the original optimization issue and simplify the testing of the readonly changes.  I'm working on that piece under 49607.

Original commit message follows:

The last two operands to a gc.relocate represent indices into the associated gc.statepoint's gc bundle list. (Effectively, gc.relocates are projections from the gc.statepoints multiple return values.)

We can use this to recognize when two gc.relocates are equivalent (and can be CSEd), even when the indices are non-equal. This is particular useful when considering a chain of multiple statepoints as it lets us eliminate all duplicate gc.relocates in a single pass.

Differential Revision: https://reviews.llvm.org/D97974
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/test/Transforms/EarlyCSE/gc_relocate.ll
llvm/test/Transforms/GVN/gc_relocate.ll