From 3a42e92a4f2fd60bdbb19b4111c20d969934c62c Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Mon, 28 Mar 2022 15:54:31 -0700 Subject: [PATCH] glsl: Drop the dead MOD_TO_FLOOR path. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's now called lower_fmod in NIR. Reviewed-by: Marek Olšák Reviewed-by: Timothy Arceri Part-of: --- src/compiler/glsl/ir_optimization.h | 1 - src/compiler/glsl/lower_instructions.cpp | 61 ------------------------ src/intel/compiler/brw_vec4_nir.cpp | 2 +- 3 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h index c86caff8a39..1d5816d4952 100644 --- a/src/compiler/glsl/ir_optimization.h +++ b/src/compiler/glsl/ir_optimization.h @@ -38,7 +38,6 @@ struct gl_shader_program; #define FDIV_TO_MUL_RCP 0x02 #define EXP_TO_EXP2 0x04 #define LOG_TO_LOG2 0x10 -#define MOD_TO_FLOOR 0x20 #define INT_DIV_TO_MUL_RCP 0x40 #define LDEXP_TO_ARITH 0x80 #define CARRY_TO_ARITH 0x100 diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index 92068686025..8e6ed3c368c 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -35,7 +35,6 @@ * - INT_DIV_TO_MUL_RCP * - EXP_TO_EXP2 * - LOG_TO_LOG2 - * - MOD_TO_FLOOR * - LDEXP_TO_ARITH * - CARRY_TO_ARITH * - BORROW_TO_ARITH @@ -74,10 +73,6 @@ * do have base 2 versions, so this pass converts exp and log to exp2 * and log2 operations. * - * MOD_TO_FLOOR: - * ------------- - * Breaks an ir_binop_mod expression down to (op0 - op1 * floor(op0 / op1)) - * * Many GPUs don't have a MOD instruction (945 and 965 included), and * if we have to break it down like this anyway, it gives an * opportunity to do things like constant fold the (1.0 / op1) easily. @@ -138,7 +133,6 @@ private: void sub_to_add_neg(ir_expression *); void div_to_mul_rcp(ir_expression *); void int_div_to_mul_rcp(ir_expression *); - void mod_to_floor(ir_expression *); void exp_to_exp2(ir_expression *); void log_to_log2(ir_expression *); void ldexp_to_arith(ir_expression *); @@ -292,56 +286,6 @@ lower_instructions_visitor::log_to_log2(ir_expression *ir) this->progress = true; } -void -lower_instructions_visitor::mod_to_floor(ir_expression *ir) -{ - ir_variable *x = new(ir) ir_variable(ir->operands[0]->type, "mod_x", - ir_var_temporary); - ir_variable *y = new(ir) ir_variable(ir->operands[1]->type, "mod_y", - ir_var_temporary); - this->base_ir->insert_before(x); - this->base_ir->insert_before(y); - - ir_assignment *const assign_x = - new(ir) ir_assignment(new(ir) ir_dereference_variable(x), - ir->operands[0]); - ir_assignment *const assign_y = - new(ir) ir_assignment(new(ir) ir_dereference_variable(y), - ir->operands[1]); - - this->base_ir->insert_before(assign_x); - this->base_ir->insert_before(assign_y); - - ir_expression *const div_expr = - new(ir) ir_expression(ir_binop_div, x->type, - new(ir) ir_dereference_variable(x), - new(ir) ir_dereference_variable(y)); - - /* Don't generate new IR that would need to be lowered in an additional - * pass. - */ - if ((lowering(FDIV_TO_MUL_RCP) && ir->type->is_float_16_32()) || - (lowering(DDIV_TO_MUL_RCP) && ir->type->is_double())) - div_to_mul_rcp(div_expr); - - ir_expression *const floor_expr = - new(ir) ir_expression(ir_unop_floor, x->type, div_expr); - - if (lowering(DOPS_TO_DFRAC) && ir->type->is_double()) - dfloor_to_dfrac(floor_expr); - - ir_expression *const mul_expr = - new(ir) ir_expression(ir_binop_mul, - new(ir) ir_dereference_variable(y), - floor_expr); - - ir->operation = ir_binop_sub; - ir->init_num_operands(); - ir->operands[0] = new(ir) ir_dereference_variable(x); - ir->operands[1] = mul_expr; - this->progress = true; -} - void lower_instructions_visitor::ldexp_to_arith(ir_expression *ir) { @@ -1766,11 +1710,6 @@ lower_instructions_visitor::visit_leave(ir_expression *ir) log_to_log2(ir); break; - case ir_binop_mod: - if (lowering(MOD_TO_FLOOR) && ir->type->is_float_16_32_64()) - mod_to_floor(ir); - break; - case ir_binop_ldexp: if (lowering(LDEXP_TO_ARITH) && ir->type->is_float()) ldexp_to_arith(ir); diff --git a/src/intel/compiler/brw_vec4_nir.cpp b/src/intel/compiler/brw_vec4_nir.cpp index 347c3d3bbe3..a93453f837a 100644 --- a/src/intel/compiler/brw_vec4_nir.cpp +++ b/src/intel/compiler/brw_vec4_nir.cpp @@ -1900,7 +1900,7 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr) unreachable("not reached: should be lowered by DIV_TO_MUL_RCP in the compiler"); case nir_op_fmod: - unreachable("not reached: should be lowered by MOD_TO_FLOOR in the compiler"); + unreachable("not reached: should be lowered by lower_fmod in the compiler"); case nir_op_fsub: case nir_op_isub: