Commit graph

11 commits

Author SHA1 Message Date
Kenneth Graunke
32aaf89823 glsl: Rename various ir_* files to lower_* and opt_*.
This helps distinguish between lowering passes, optimization passes, and
other compiler code.
2010-11-15 16:34:20 -08:00
Luca Barbieri
4dfb89904c glsl: introduce ir_binop_all_equal and ir_binop_any_equal, allow vector cmps
Currently GLSL IR forbids any vector comparisons, and defines "ir_binop_equal"
and "ir_binop_nequal" to compare all elements and give a single bool.

This is highly unintuitive and prevents generation of optimal Mesa IR.

Hence, first rename "ir_binop_equal" to "ir_binop_all_equal" and
"ir_binop_nequal" to "ir_binop_any_nequal".

Second, readd "ir_binop_equal" and "ir_binop_nequal" with the same semantics
as less, lequal, etc.

Third, allow all comparisons to acts on vectors.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2010-09-13 17:53:04 -07:00
Ian Romanick
a35faa6a41 glsl2: Perform algebraic simplifications on logical binary operators
Reduces glsl-vs-all-01 from 42 Mesa IR instructions (including the
END) to 17.
2010-09-01 10:25:11 -07:00
Eric Anholt
0e6066df63 glsl: When doing algebraic simplification, make sure the type still matches.
When simplifying (vec4(1.0) / (float(x))) to rcp(float(x)), we forgot
to produce a vec4, angering ir_validate when starting alien-arena.

Fixes:
glsl-algebraic-add-zero-2
glsl-algebraic-div-one-2
glsl-algebraic-mul-one-2
glsl-algebraic-sub-zero-3
glsl-algebraic-rcp-sqrt-2
2010-08-17 13:50:45 -07:00
Eric Anholt
f166d94fac glsl: Make ir_algebraic new expressions allocate out of the parent.
This could reduce the amount of memory used by a shader tree after
optimization, and increases consistency with other passes.
2010-08-17 13:47:15 -07:00
Eric Anholt
b3b0cf6a4c glsl2: Add a generic visitor class to call back with pointers to each rvalue.
I keep copy and pasting this code all over, so consolidate it in one
place.
2010-08-13 17:54:46 -07:00
Eric Anholt
0ff3b2b344 glsl2: Make ir_algebraic reassociate add/mul operands for constant folding.
It's rather easy to produce two constant multiplies separated by other
multiplies while writing a BRDF shader, and non-obvious enough in the
resulting codegen that I didn't catch it in my demo code until just
recently.  Cuts 3 965 instructions from my demo (<1%), and 20 from
glsl-fs-raytrace (1.3%).
2010-08-09 21:42:17 -07:00
Ian Romanick
c88e60a27b ir_algebraic: Support other comparisons in ir_unop_logic_not 2010-08-09 10:46:38 -07:00
Ian Romanick
fe277089c7 ir_algebraic: Convert ir_unop_logic_not handler to use a switch statement
Currently only ir_binop_equal and ir_binop_nequal are supported, but
soon all of the relational operators will be added.  Making this
change now will simplify those commits.
2010-08-09 10:19:39 -07:00
Kenneth Graunke
f7b94f32a2 ir_algebraic: Use ir_constant::zero. 2010-07-28 15:46:26 -07:00
Eric Anholt
832aad989e glsl2: Add optimization pass for algebraic simplifications.
This cleans up the assembly output of almost all the non-logic tests
glsl-algebraic-*.  glsl-algebraic-pow-two needs love (basically,
flattening to a temporary and squaring it).
2010-07-27 09:43:52 -07:00