mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 22:20:09 +01:00
glsl: Drop no-op shifts involving 0.
I noticed this in a shader in Unigine Heaven that was spilling. While it
doesn't really reduce register pressure, it shaves a few instructions
anyway (7955 -> 7882).
v2: Fix turning "0 >> x" into "x" instead of "0" (caught by Erik
Faye-Lund).
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
3a0fdf2ab6
commit
08bf52712e
1 changed files with 10 additions and 0 deletions
|
|
@ -346,6 +346,16 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
|
|||
}
|
||||
break;
|
||||
|
||||
case ir_binop_rshift:
|
||||
case ir_binop_lshift:
|
||||
/* 0 >> x == 0 */
|
||||
if (is_vec_zero(op_const[0]))
|
||||
return ir->operands[0];
|
||||
/* x >> 0 == x */
|
||||
if (is_vec_zero(op_const[1]))
|
||||
return ir->operands[0];
|
||||
break;
|
||||
|
||||
case ir_binop_logic_and:
|
||||
/* FINISHME: Also simplify (a && a) to (a). */
|
||||
if (is_vec_one(op_const[0])) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue