summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_search.c
Commit message (Collapse)AuthorAgeFilesLines
* nir: Remove the mem_ctx parameter from ssa_def_rewrite_usesJason Ekstrand2015-09-111-1/+1
| | | | Reviewed-by: Thomas Helland <[email protected]>
* glsl: Resolve GCC sign-compare warning.Rhys Kidd2015-09-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mesa/src/glsl/nir/nir_lower_tex_projector.c: In function 'nir_lower_tex_projector_block': mesa/src/glsl/nir/nir_lower_tex_projector.c:63:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < tex->num_srcs; i++) { ^ mesa/src/glsl/nir/nir_lower_tex_projector.c: In function 'nir_lower_tex_projector_block': mesa/src/glsl/nir/nir_lower_tex_projector.c:114:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = proj_index + 1; i < tex->num_srcs; i++) { ^ mesa/src/glsl/nir/nir_lower_tex_projector.c: In function 'nir_lower_tex_projector_block': mesa/src/glsl/nir/nir_lower_tex_projector.c:53:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (proj_index = 0; proj_index < tex->num_srcs; proj_index++) { ^ mesa/src/glsl/nir/nir_lower_tex_projector.c:57:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (proj_index == tex->num_srcs) ^ mesa/src/glsl/nir/nir_search.c: In function 'match_value': mesa/src/glsl/nir/nir_search.c:84:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < num_components; ++i) ^ mesa/src/glsl/nir/nir_search.c: In function 'match_value': mesa/src/glsl/nir/nir_search.c:110:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < num_components; ++i) { ^ mesa/src/glsl/nir/nir_search.c: In function 'match_value': mesa/src/glsl/nir/nir_search.c:139:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (i < num_components) ^ mesa/src/glsl/nir/nir_opt_peephole_ffma.c: In function 'get_mul_for_src': mesa/src/glsl/nir/nir_opt_peephole_ffma.c:130:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (unsigned i = 0; i < num_components; i++) ^ Signed-off-by: Rhys Kidd <[email protected]> Reviewed-by: Thomas Helland <[email protected]> Reviewed-by: Jan Vesely <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* nir: cleanup open-coded instruction castsRob Clark2015-06-301-1/+1
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/search: Save/restore the variables_seen bitmask when matchingJason Ekstrand2015-05-081-0/+12
| | | | | | | | | | | | | Shader-db results on Broadwell: total instructions in shared programs: 7152330 -> 7137006 (-0.21%) instructions in affected programs: 1330548 -> 1315224 (-1.15%) helped: 5797 HURT: 76 GAINED: 0 LOST: 8 Reviewed-by: Connor Abbott <[email protected]>
* nir/search: Assert that variable id's are in rangeJason Ekstrand2015-05-081-0/+1
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/search: handle explicitly sized sources in match_valueJason Ekstrand2015-05-081-8/+8
| | | | | | | | | | Previously, this case was being handled in match_expression prior to calling match_value. However, there is really no good reason for this given that match_value has all of the information it needs. Also, they weren't being handled properly in the commutative case and putting it in match_value gives us that for free. Reviewed-by: Connor Abbott <[email protected]>
* nir: Add and use initializer #defines for nir_src and nir_destJason Ekstrand2015-05-081-1/+1
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Convert the if-test for num_inputs == 2 to an assertionIan Romanick2015-04-161-2/+2
| | | | | | | | | Suggested by Jason on a different patch after some comments / questions by Ilia. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: Allow nir_opt_algebraic to see booleanness through &&, ||, ^, !.Eric Anholt2015-02-211-1/+29
| | | | | | | | | | | | | | | | | We have some useful optimizations to drop things like 'ine a, 0' on a boolean argument, but if 'a' came from logical operations on bools, it couldn't tell. These kinds of constructs appear as a result of TGSI->NIR quite frequently (at least with if flattening), so being a little more aggressive in detecting booleans can pay off. v2: Add ixor as a booleanness-preserving op (Suggestion by Connor). vc4 results: total instructions in shared programs: 40207 -> 39881 (-0.81%) instructions in affected programs: 6677 -> 6351 (-4.88%) Reviewed-by: Matt Turner <[email protected]> (v1) Reviewed-by: Connor Abbott <[email protected]>
* nir/search: Allow for matching variables based on typesJason Ekstrand2015-01-291-0/+11
| | | | | | | | | | | This allows you to match on an unknown value but only if it is of a given type. 90% of the uses of this are for matching only booleans, but adding the generality of arbitrary types is no more complex. nir_algebraic.py doesn't handle this yet but that's ok because the C language will ensure that the default type on all variables is void. Reviewed-by: Kenneth Graunke <[email protected]>
* nir/search: Add support for matching unknown constantsJason Ekstrand2015-01-291-0/+6
| | | | | | | | | | | | | There are some algebraic transformations that we want to do but only if certain things are constants. For instance, we may want to replace a * (b + c) with (a * b) + (a * c) as long as a and either b or c is constant. While this generates more instructions, some of it will get constant folded. nir_algebraic.py doesn't handle this yet, but that's ok because the C language will make sure that false is the default for now. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Use pointers for nir_src_copy and nir_dest_copyJason Ekstrand2015-01-261-2/+2
| | | | | | | | This avoids the overhead of copying structures and better matches the newly added nir_alu_src_copy and nir_alu_dest_copy. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: Make an easier helper for setting up SSA defs.Eric Anholt2015-01-221-5/+3
| | | | | | | | Almost all instructions we nir_ssa_def_init() for are nir_dests, and you have to keep from forgetting to set is_ssa when you do. Just provide the simpler helper, instead. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Stop using designated initializersJason Ekstrand2015-01-211-20/+12
| | | | | | | | | Designated initializers with anonymous unions don't work in MSVC or GCC < 4.6. With a couple of constructor methods, we don't need them any more and the code is actually cleaner. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88467 Reviewed-by: Connor Abbot <[email protected]>
* nir/search: Use nir_op_infos to determine if an operation is commutativeJason Ekstrand2015-01-151-33/+2
| | | | | | | Prior to this commit, we had a big switch statement for this. Now it's baked into the opcode metadata so we can just use that. Reviewed-by: Connor Abbott <[email protected]>
* nir: Make load_const SSA-onlyJason Ekstrand2015-01-151-6/+4
| | | | | | | | As it was, we weren't ever using load_const in a non-SSA way. This allows us to substantially simplify the load_const instruction. If we ever need a non-SSA constant load, we can do a load_const and an imov. Reviewed-by: Connor Abbott <[email protected]>
* nir: Add an expression matching frameworkJason Ekstrand2015-01-151-0/+364
This framework provides a simple way to do simple search-and-replace operations on NIR code. The nir_search.h header provides four simple data structures for representing expressions: nir_value and four subtypes: nir_variable, nir_constant, and nir_expression. An expression tree can then be represented by nesting these data structures as needed. The nir_replace_instr function takes an instruction, an expression, and a value; if the instruction matches the expression, it is replaced with a new chain of instructions to generate the given replacement value. The framework keeps track of swizzles on sources and automatically generates the currect swizzles for the replacement value. Reviewed-by: Connor Abbott <[email protected]>