[Mesa-dev] [PATCH 2/3] nir/gcm: Add value numbering support

Jason Ekstrand jason at jlekstrand.net
Tue Sep 6 21:19:56 UTC 2016


On Sep 6, 2016 1:50 PM, "Eric Anholt" <eric at anholt.net> wrote:
>
> Jason Ekstrand <jason at jlekstrand.net> writes:
>
> > ---
>
> This seems fine, but the commit message needs some expansion.  Questions
> I had:
>
> Does this help compared to an implementation with nir CSE already?

Yes, value numbering is capable of detecting common values even if one does
not dominate the other.  For instance, in you have

if (...) {
   ssa_1 = ssa_0 + 7;
   /* use ssa_1 */
} else {
   ssa_2 = ssa_0 + 7;
   /* use ssa_2 */
}

Global value numbering doesn't care about dominance relationships so it
figures out that ssa_1 and ssa_2 are the same and converts this to

if (...) {
   ssa_1 = ssa_0 + 7;
   /* use ssa_1 */
} else {
   /* use ssa_2 */
}

Obviously, we just broke SSA form which is bad.  Global code motion,
however, will repair this for us by turning this into

ssa_1 = ssa_0 + 7;
if (...) {
   /* use ssa_1 */
} else {
   /* use ssa_2 */
}

> Does nir CSE still get us anything that this doesn't?

It's still useful primarily because it's less of a scorched-earth approach
and doesn't require GCM.  This makes it q bit more appropriate for use as a
clean-up in a late optimization run.

I can add since of that to the commit message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160906/a228b672/attachment.html>


More information about the mesa-dev mailing list