[Mesa-dev] [PATCH 03/23] i965/fs: Use MOV.nz instead of AND.nz to generate flag on GEN6+
Ian Romanick
idr at freedesktop.org
Fri Mar 20 13:58:03 PDT 2015
From: Ian Romanick <ian.d.romanick at intel.com>
On SNB+, the Boolean result is always 0 or ~0, so MOV.nz produces the
same effect as AND.nz. However, later cmod propagation passes can
handle the MOV.nz, but they cannot handle the AND.nz because the source
is not generated by a CMP.
It's worth noting that this commit was a lot more effective before
commit bb22aa0 (i965/fs: Ignore type in cmod prop if scan_inst is CMP.).
Without that commit, this commit improved ~2,500 shaders on each
affected platform, including Sandy Bridge.
Ivy Bridge (0x0166):
total instructions in shared programs: 6291794 -> 6291668 (-0.00%)
instructions in affected programs: 41207 -> 41081 (-0.31%)
helped: 154
HURT: 28
Haswell (0x0426):
total instructions in shared programs: 5779180 -> 5779054 (-0.00%)
instructions in affected programs: 37210 -> 37084 (-0.34%)
helped: 154
HURT: 28
Broadwell (0x162E):
total instructions in shared programs: 6823014 -> 6822848 (-0.00%)
instructions in affected programs: 40195 -> 40029 (-0.41%)
helped: 164
HURT: 28
No change on GM45, Iron Lake, Sandy Bridge, Ivy Bridge with NIR, or
Haswell with NIR.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 2f1d49c..e39dab3 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2591,7 +2591,14 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir)
if (!expr || expr->operation == ir_binop_ubo_load) {
ir->accept(this);
- fs_inst *inst = emit(AND(reg_null_d, this->result, fs_reg(1)));
+ fs_inst *inst;
+
+ if (brw->gen <= 5) {
+ inst = emit(AND(reg_null_d, this->result, fs_reg(1)));
+ } else {
+ inst = emit(MOV(reg_null_d, this->result));
+ }
+
inst->conditional_mod = BRW_CONDITIONAL_NZ;
return;
}
@@ -2618,7 +2625,11 @@ fs_visitor::emit_bool_to_cond_code_of_reg(ir_expression *expr, fs_reg op[3])
switch (expr->operation) {
case ir_unop_logic_not:
- inst = emit(AND(reg_null_d, op[0], fs_reg(1)));
+ if (brw->gen <= 5) {
+ inst = emit(AND(reg_null_d, op[0], fs_reg(1)));
+ } else {
+ inst = emit(MOV(reg_null_d, op[0]));
+ }
inst->conditional_mod = BRW_CONDITIONAL_Z;
break;
--
2.1.0
More information about the mesa-dev
mailing list