[Mesa-dev] [PATCH 48/50] glsl: add lowering for mod64()
Dave Airlie
airlied at gmail.com
Tue Mar 13 04:25:13 UTC 2018
From: Elie Tournier <elie.tournier at collabora.com>
This lowers to floor using the same code as the float lowering,
it also fixes things to avoid creating more instructions that
need lowering.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/compiler/glsl/ir_optimization.h | 1 +
src/compiler/glsl/lower_instructions.cpp | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 38e35e3..5e6c82a 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -58,6 +58,7 @@
#define DOPS_TO_DTRUNC 0x800000
#define DRSQ_TO_DRCP 0x1000000
#define DFMA_TO_DMULADD 0x2000000
+#define DMOD_TO_FLOOR 0x4000000
/* Opertaions for lower_64bit_integer_instructions() */
#define MUL64 (1U << 0)
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp
index b8f7224..d2a838c 100644
--- a/src/compiler/glsl/lower_instructions.cpp
+++ b/src/compiler/glsl/lower_instructions.cpp
@@ -359,6 +359,8 @@ lower_instructions_visitor::mod_to_floor(ir_expression *ir)
if (lowering(DOPS_TO_DFRAC) && ir->type->is_double())
dfloor_to_dfrac(floor_expr);
+ else if (lowering(DOPS_TO_DTRUNC) && ir->type->is_double())
+ dfloor_to_dtrunc(floor_expr);
ir_expression *const mul_expr =
new(ir) ir_expression(ir_binop_mul,
@@ -369,6 +371,8 @@ lower_instructions_visitor::mod_to_floor(ir_expression *ir)
ir->init_num_operands();
ir->operands[0] = new(ir) ir_dereference_variable(x);
ir->operands[1] = mul_expr;
+ if (ir->type->is_double())
+ sub_to_add_neg(ir);
this->progress = true;
}
@@ -1855,8 +1859,9 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
break;
case ir_binop_mod:
- if (lowering(MOD_TO_FLOOR) && (ir->type->is_float() || ir->type->is_double()))
- mod_to_floor(ir);
+ if ((lowering(MOD_TO_FLOOR) && ir->type->is_float()) ||
+ (lowering(DMOD_TO_FLOOR) && ir->type->is_double()))
+ mod_to_floor(ir);
break;
case ir_binop_pow:
--
2.9.5
More information about the mesa-dev
mailing list