diff options
author | Paul Berry <stereotype441@gmail.com> | 2013-11-27 17:57:19 -0800 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2013-12-09 10:54:26 -0800 |
commit | 2c17f97fe6a40e4a963fb4eec0ea0555f562b1be (patch) | |
tree | 2211956818d4250465da8176f800654016802188 /src/glsl/ir_optimization.h | |
parent | 97d8b770549584a2cd6b14956f15beeef0d83cad (diff) | |
download | external_mesa3d-2c17f97fe6a40e4a963fb4eec0ea0555f562b1be.zip external_mesa3d-2c17f97fe6a40e4a963fb4eec0ea0555f562b1be.tar.gz external_mesa3d-2c17f97fe6a40e4a963fb4eec0ea0555f562b1be.tar.bz2 |
glsl/loops: consolidate bounded loop handling into a lowering pass.
Previously, all of the back-ends (ir_to_mesa, st_glsl_to_tgsi, and the
i965 fs and vec4 visitors) had nearly identical logic for handling
bounded loops. This replaces the duplicate logic with an equivalent
lowering pass that is used by all the back-ends.
Note: on i965, there is a slight increase in instruction count. For
example, a loop like this:
for (int i = 0; i < 100; i++) {
total += i;
}
would previously compile down to this (vec4) native code:
mov(8) g4<1>.xD 0D
mov(8) g8<1>.xD 0D
loop:
cmp.ge.f0(8) null g8<4;4,1>.xD 100D
(+f0) break(8)
add(8) g5<1>.xD g5<4;4,1>.xD g4<4;4,1>.xD
add(8) g8<1>.xD g8<4;4,1>.xD 1D
add(8) g4<1>.xD g4<4;4,1>.xD 1D
while(8) loop
After this patch, the "(+f0) break(8)" turns into:
(+f0) if(8)
break(8)
endif(8)
because the back-end isn't smart enough to recognize that "if
(condition) break;" can be done using a conditional break instruction.
However, it should be relatively easy for a future peephole
optimization to properly optimize this.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/ir_optimization.h')
-rw-r--r-- | src/glsl/ir_optimization.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index 3ca9f57..87c2c82 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -101,6 +101,7 @@ bool do_swizzle_swizzle(exec_list *instructions); bool do_tree_grafting(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); bool do_vec_index_to_swizzle(exec_list *instructions); +bool lower_bounded_loops(exec_list *instructions); bool lower_discard(exec_list *instructions); void lower_discard_flow(exec_list *instructions); bool lower_instructions(exec_list *instructions, unsigned what_to_lower); |