diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h index ea4ee7748f6..591d01386fe 100644 --- a/src/intel/compiler/brw_eu.h +++ b/src/intel/compiler/brw_eu.h @@ -199,9 +199,6 @@ brw_inst *brw_##OP(struct brw_codegen *p, \ struct brw_reg src1, \ struct brw_reg src2); -#define ROUND(OP) \ -void brw_##OP(struct brw_codegen *p, struct brw_reg dest, struct brw_reg src0); - ALU1(MOV) ALU2(SEL) ALU1(NOT) @@ -222,6 +219,8 @@ ALU2(AVG) ALU2(MUL) ALU1(FRC) ALU1(RNDD) +ALU1(RNDE) +ALU1(RNDZ) ALU2(MAC) ALU2(MACH) ALU1(LZD) @@ -244,13 +243,9 @@ ALU2(ADDC) ALU2(SUBB) ALU2(MAC) -ROUND(RNDZ) -ROUND(RNDE) - #undef ALU1 #undef ALU2 #undef ALU3 -#undef ROUND /* Helpers for SEND instruction: diff --git a/src/intel/compiler/brw_eu_emit.c b/src/intel/compiler/brw_eu_emit.c index 44577de62e8..427b01e789b 100644 --- a/src/intel/compiler/brw_eu_emit.c +++ b/src/intel/compiler/brw_eu_emit.c @@ -1020,33 +1020,6 @@ brw_inst *brw_##OP(struct brw_codegen *p, \ return brw_alu3(p, BRW_OPCODE_##OP, dest, src0, src1, src2); \ } -/* Rounding operations (other than RNDD) require two instructions - the first - * stores a rounded value (possibly the wrong way) in the dest register, but - * also sets a per-channel "increment bit" in the flag register. A predicated - * add of 1.0 fixes dest to contain the desired result. - * - * Sandybridge and later appear to round correctly without an ADD. - */ -#define ROUND(OP) \ -void brw_##OP(struct brw_codegen *p, \ - struct brw_reg dest, \ - struct brw_reg src) \ -{ \ - const struct gen_device_info *devinfo = p->devinfo; \ - brw_inst *rnd, *add; \ - rnd = next_insn(p, BRW_OPCODE_##OP); \ - brw_set_dest(p, rnd, dest); \ - brw_set_src0(p, rnd, src); \ - \ - if (devinfo->gen < 6) { \ - /* turn on round-increments */ \ - brw_inst_set_cond_modifier(devinfo, rnd, BRW_CONDITIONAL_R); \ - add = brw_ADD(p, dest, dest, brw_imm_f(1.0f)); \ - brw_inst_set_pred_control(devinfo, add, BRW_PREDICATE_NORMAL); \ - } \ -} - - ALU2(SEL) ALU1(NOT) ALU2(AND) @@ -1061,6 +1034,8 @@ ALU2(ROR) ALU3(CSEL) ALU1(FRC) ALU1(RNDD) +ALU1(RNDE) +ALU1(RNDZ) ALU2(MAC) ALU2(MACH) ALU1(LZD) @@ -1080,9 +1055,6 @@ ALU1(CBIT) ALU2(ADDC) ALU2(SUBB) -ROUND(RNDZ) -ROUND(RNDE) - brw_inst * brw_MOV(struct brw_codegen *p, struct brw_reg dest, struct brw_reg src0) { diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index a861a1d938d..4cfac360874 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -1593,6 +1593,12 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr, case nir_op_ftrunc: inst = bld.RNDZ(result, op[0]); + if (devinfo->gen < 6) { + set_condmod(BRW_CONDITIONAL_R, inst); + set_predicate(BRW_PREDICATE_NORMAL, + bld.ADD(result, result, brw_imm_f(1.0f))); + inst = bld.MOV(result, result); /* for potential saturation */ + } inst->saturate = instr->dest.saturate; break; @@ -1615,6 +1621,12 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr, break; case nir_op_fround_even: inst = bld.RNDE(result, op[0]); + if (devinfo->gen < 6) { + set_condmod(BRW_CONDITIONAL_R, inst); + set_predicate(BRW_PREDICATE_NORMAL, + bld.ADD(result, result, brw_imm_f(1.0f))); + inst = bld.MOV(result, result); /* for potential saturation */ + } inst->saturate = instr->dest.saturate; break; diff --git a/src/intel/compiler/brw_vec4_nir.cpp b/src/intel/compiler/brw_vec4_nir.cpp index 03fda5e9aaa..d32f65a9dbe 100644 --- a/src/intel/compiler/brw_vec4_nir.cpp +++ b/src/intel/compiler/brw_vec4_nir.cpp @@ -1379,6 +1379,12 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr) case nir_op_ftrunc: inst = emit(RNDZ(dst, op[0])); + if (devinfo->gen < 6) { + inst->conditional_mod = BRW_CONDITIONAL_R; + inst = emit(ADD(dst, src_reg(dst), brw_imm_f(1.0f))); + inst->predicate = BRW_PREDICATE_NORMAL; + inst = emit(MOV(dst, src_reg(dst))); /* for potential saturation */ + } inst->saturate = instr->dest.saturate; break; @@ -1409,6 +1415,12 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr) case nir_op_fround_even: inst = emit(RNDE(dst, op[0])); + if (devinfo->gen < 6) { + inst->conditional_mod = BRW_CONDITIONAL_R; + inst = emit(ADD(dst, src_reg(dst), brw_imm_f(1.0f))); + inst->predicate = BRW_PREDICATE_NORMAL; + inst = emit(MOV(dst, src_reg(dst))); /* for potential saturation */ + } inst->saturate = instr->dest.saturate; break;