[Mesa-dev] Mesa (master): glsl2: Add pass to remove redundant jumps

Luca Barbieri luca at luca-barbieri.com
Mon Sep 13 18:55:06 PDT 2010


ir_lower_jumps should already do the jump unification, and
could/should also remove the continue.
It's probably best to put all jump manipulations there to avoid
risking rerunning all passes a number of times linear in the program
size.

Regarding ifs, it would be nice to also remove empty else branches,
and possibly convert if(c) {} else {code()} to if(!c) {code()} or
perhaps do the reverse canonicalization instead.
And also things like "if(c) {if(c) {code()}}" to if(c) {code()}, as
well as "if(1) {code()}" to "code()", as well as ir_switch -> ir_if
and viceversa once ir_switch is added.

A "cfg simplification" pass might be more appropriate for this though,
unless it's necessary to add this to ir_lower_jumps to avoid the
"linear number of optimization runs" problems.


More information about the mesa-dev mailing list