diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2018-07-05 14:46:58 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2018-07-26 15:11:13 -0700 |
commit | 254f716ac1c2b4758324908c857c88674e2f7106 (patch) | |
tree | 2411052ff5c99d1e62e751ba2fd5fb15bc0cc7d7 | |
parent | 5934e6b584ceed3c5d1cd7ec839d693cf41d6066 (diff) |
i965/fs: Invert if-condition for nir_op_inotexperiments
-rw-r--r-- | src/intel/compiler/brw_fs_nir.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index a41dc2a47b8..113678ba0ff 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -390,13 +390,36 @@ fs_visitor::nir_emit_cf_list(exec_list *list) void fs_visitor::nir_emit_if(nir_if *if_stmt) { + fs_inst *inst = NULL; + bool invert = false; + /* first, put the condition into f0 */ - fs_inst *inst = bld.MOV(bld.null_reg_d(), - retype(get_nir_src(if_stmt->condition), - BRW_REGISTER_TYPE_D)); + if (if_stmt->condition.is_ssa && + if_stmt->condition.ssa->parent_instr->type == nir_instr_type_alu) { + nir_alu_instr *const cond = + nir_instr_as_alu(if_stmt->condition.ssa->parent_instr); + + /* FINISHME: Care about swizzle here? */ + if (cond->op == nir_op_inot && + !cond->src[0].negate && + !cond->src[0].abs) { + inst = bld.MOV(bld.null_reg_d(), + retype(get_nir_src(cond->src[0].src), + BRW_REGISTER_TYPE_D)); + + invert = true; + } + } + + if (inst == NULL) { + inst = bld.MOV(bld.null_reg_d(), + retype(get_nir_src(if_stmt->condition), + BRW_REGISTER_TYPE_D)); + } + inst->conditional_mod = BRW_CONDITIONAL_NZ; - bld.IF(BRW_PREDICATE_NORMAL); + bld.IF(BRW_PREDICATE_NORMAL)->predicate_inverse = invert; nir_emit_cf_list(&if_stmt->then_list); |