diff options
author | Jason Ekstrand <[email protected]> | 2016-08-10 14:34:49 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-09-08 20:53:01 -0700 |
commit | 88a2a2e05302179c59e257533ed77d2d0a6a5021 (patch) | |
tree | 7b552b25b277a2ee80e2aafdbd34477946610b96 /src/compiler/nir/nir.h | |
parent | 99ff4b3eb21ccc5df670e4dc62073cee96d07f23 (diff) |
nir/gcm: Add global value numbering support
Unlike the current CSE pass, global 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_1 */
}
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_1 */
}
This intended to eventually mostly replace CSE. However, conventional CSE
may still be useful because it's less of a scorched-earth approach and
doesn't require GCM. This makes it a bit more appropriate for use as a
clean-up in a late optimization run.
Signed-off-by: Jason Ekstrand <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir.h')
-rw-r--r-- | src/compiler/nir/nir.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index c1cf94001f6..ff7c422a6ea 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2587,7 +2587,7 @@ bool nir_opt_dce(nir_shader *shader); bool nir_opt_dead_cf(nir_shader *shader); -void nir_opt_gcm(nir_shader *shader); +bool nir_opt_gcm(nir_shader *shader, bool value_number); bool nir_opt_peephole_select(nir_shader *shader); |