diff options
author | Elie Tournier <tournier.elie@gmail.com> | 2017-08-16 03:00:41 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2018-01-18 14:16:27 +1000 |
commit | 594a21a0ae75fe65fa65a4f3e5466711c0a019a5 (patch) | |
tree | 9f88046d99c5197371e2493ab66ddedc3f76e2bf | |
parent | 07c9e8d93d967a52cfc06393459b2231c5e17bd0 (diff) |
glsl: Add a lowering pass for 64-bit float max()
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
-rw-r--r-- | src/compiler/glsl/lower_instructions.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index 65107ed0905..774efb208b3 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -177,6 +177,7 @@ private: void imul_high_to_mul(ir_expression *ir); void sqrt_to_abs_sqrt(ir_expression *ir); void min_to_less(ir_expression *ir); + void max_to_less(ir_expression *ir); ir_expression *_carry(operand a, operand b); }; @@ -1688,6 +1689,20 @@ lower_instructions_visitor::min_to_less(ir_expression *ir) this->progress = true; } +void +lower_instructions_visitor::max_to_less(ir_expression *ir) +{ + ir_rvalue *x_clone = ir->operands[0]->clone(ir, NULL); + ir_rvalue *y_clone = ir->operands[1]->clone(ir, NULL); + ir->operation = ir_triop_csel; + ir->init_num_operands(); + ir->operands[0] = less(ir->operands[0], ir->operands[1]); + ir->operands[1] = y_clone; + ir->operands[2] = x_clone; + + this->progress = true; +} + ir_visitor_status lower_instructions_visitor::visit_leave(ir_expression *ir) { @@ -1837,6 +1852,12 @@ lower_instructions_visitor::visit_leave(ir_expression *ir) min_to_less(ir); break; + case ir_binop_max: + if (lowering(MIN_MAX_TO_LESS) && + ir->type->is_double() && ir->type->is_scalar()) + max_to_less(ir); + break; + default: return visit_continue; } |