diff options
author | Ian Romanick <[email protected]> | 2015-05-08 12:55:00 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2017-10-30 09:27:09 -0700 |
commit | 6403efbe7458d05cf117adb41c8a152ed6e28bdd (patch) | |
tree | 74c392361a08b0f04895ca667d828ac7083ad304 /src/compiler/glsl/loop_analysis.cpp | |
parent | 34f7e761bc61d3086c1e4e42285c31678b256107 (diff) |
glsl: Remove ir_binop_greater and ir_binop_lequal expressions
NIR does not have these instructions. TGSI and Mesa IR both implement
them using < and >=, repsectively. Removing them deletes a bunch of
code and means I don't have to add code to the SPIR-V generator for
them.
v2: Rebase on 2+ years of change... and fix a major bug added in the
rebase.
text data bss dec hex filename
8255291 268856 294072 8818219 868e2b 32-bit i965_dri.so before
8254235 268856 294072 8817163 868a0b 32-bit i965_dri.so after
7815339 345592 420592 8581523 82f193 64-bit i965_dri.so before
7813995 345560 420592 8580147 82ec33 64-bit i965_dri.so after
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler/glsl/loop_analysis.cpp')
-rw-r--r-- | src/compiler/glsl/loop_analysis.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/compiler/glsl/loop_analysis.cpp b/src/compiler/glsl/loop_analysis.cpp index 2979e09433f..0fb6e9feb74 100644 --- a/src/compiler/glsl/loop_analysis.cpp +++ b/src/compiler/glsl/loop_analysis.cpp @@ -87,7 +87,8 @@ find_initial_value(ir_loop *loop, ir_variable *var) static int calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, - enum ir_expression_operation op, bool continue_from_then) + enum ir_expression_operation op, bool continue_from_then, + bool swap_compare_operands) { if (from == NULL || to == NULL || increment == NULL) return -1; @@ -154,8 +155,9 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, ir_expression *const add = new(mem_ctx) ir_expression(ir_binop_add, mul->type, mul, from); - ir_expression *cmp = - new(mem_ctx) ir_expression(op, glsl_type::bool_type, add, to); + ir_expression *cmp = swap_compare_operands + ? new(mem_ctx) ir_expression(op, glsl_type::bool_type, to, add) + : new(mem_ctx) ir_expression(op, glsl_type::bool_type, add, to); if (continue_from_then) cmp = new(mem_ctx) ir_expression(ir_unop_logic_not, cmp); @@ -582,8 +584,6 @@ loop_analysis::visit_leave(ir_loop *ir) switch (cond->operation) { case ir_binop_less: - case ir_binop_greater: - case ir_binop_lequal: case ir_binop_gequal: { /* The expressions that we care about will either be of the form * 'counter < limit' or 'limit < counter'. Figure out which is @@ -592,18 +592,12 @@ loop_analysis::visit_leave(ir_loop *ir) ir_rvalue *counter = cond->operands[0]->as_dereference_variable(); ir_constant *limit = cond->operands[1]->as_constant(); enum ir_expression_operation cmp = cond->operation; + bool swap_compare_operands = false; if (limit == NULL) { counter = cond->operands[1]->as_dereference_variable(); limit = cond->operands[0]->as_constant(); - - switch (cmp) { - case ir_binop_less: cmp = ir_binop_greater; break; - case ir_binop_greater: cmp = ir_binop_less; break; - case ir_binop_lequal: cmp = ir_binop_gequal; break; - case ir_binop_gequal: cmp = ir_binop_lequal; break; - default: assert(!"Should not get here."); - } + swap_compare_operands = true; } if ((counter == NULL) || (limit == NULL)) @@ -616,7 +610,8 @@ loop_analysis::visit_leave(ir_loop *ir) loop_variable *lv = ls->get(var); if (lv != NULL && lv->is_induction_var()) { t->iterations = calculate_iterations(init, limit, lv->increment, - cmp, t->continue_from_then); + cmp, t->continue_from_then, + swap_compare_operands); if (incremented_before_terminator(ir, var, t->ir)) { t->iterations--; |