<div dir="ltr">On 2 December 2013 13:46, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
total instructions in shared programs: 1519751 -> 1519442 (-0.02%)<br>
instructions in affected programs:     10154 -> 9845 (-3.04%)<br>
---<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 23 +++++++++++++++--------<br>
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 23 ++++++++++++++++-------<br>
 2 files changed, 31 insertions(+), 15 deletions(-)<br></blockquote><div><br></div><div>Clever.  I like it.<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index 9eb9a9d..a0e803b 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -382,18 +382,25 @@ fs_visitor::visit(ir_expression *ir)<br>
       emit(MOV(this->result, op[0]));<br>
       break;<br>
    case ir_unop_sign:<br>
-      temp = fs_reg(this, ir->type);<br>
+      if (ir->type->is_float()) {<br>
+         emit(CMP(reg_null_f, op[0], fs_reg(0.0f), BRW_CONDITIONAL_NZ));<br>
<br>
-      emit(MOV(this->result, fs_reg(0.0f)));<br>
+         op[0].type = BRW_REGISTER_TYPE_UD;<br>
+         this->result.type = BRW_REGISTER_TYPE_UD;<br>
+         emit(AND(this->result, op[0], fs_reg(0x80000000u)));<br>
<br>
-      emit(CMP(reg_null_f, op[0], fs_reg(0.0f), BRW_CONDITIONAL_G));<br>
-      inst = emit(MOV(this->result, fs_reg(1.0f)));<br>
-      inst->predicate = BRW_PREDICATE_NORMAL;<br>
+         inst = emit(OR(this->result, this->result, fs_reg(0x3f800000u)));<br>
+         inst->predicate = BRW_PREDICATE_NORMAL;<br>
<br>
-      emit(CMP(reg_null_f, op[0], fs_reg(0.0f), BRW_CONDITIONAL_L));<br>
-      inst = emit(MOV(this->result, fs_reg(-1.0f)));<br>
-      inst->predicate = BRW_PREDICATE_NORMAL;<br>
+         this->result.type = BRW_REGISTER_TYPE_F;<br>
+      } else {<br>
+         emit(CMP(reg_null_d, op[0], fs_reg(0), BRW_CONDITIONAL_G));<br>
<br>
+         emit(ASR(this->result, op[0], fs_reg(31)));<br>
+<br>
+         inst = emit(OR(this->result, this->result, fs_reg(1)));<br>
+         inst->predicate = BRW_PREDICATE_NORMAL;<br>
+      }<br>
       break;<br>
    case ir_unop_rcp:<br>
       emit_math(SHADER_OPCODE_RCP, this->result, op[0]);<br>
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
index a13eafb..986663b 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
@@ -1259,16 +1259,25 @@ vec4_visitor::visit(ir_expression *ir)<br>
       break;<br>
<br>
    case ir_unop_sign:<br>
-      emit(MOV(result_dst, src_reg(0.0f)));<br>
+      if (ir->type->is_float()) {<br>
+         emit(CMP(dst_null_f(), op[0], src_reg(0.0f), BRW_CONDITIONAL_NZ));<br>
<br>
-      emit(CMP(dst_null_d(), op[0], src_reg(0.0f), BRW_CONDITIONAL_G));<br>
-      inst = emit(MOV(result_dst, src_reg(1.0f)));<br>
-      inst->predicate = BRW_PREDICATE_NORMAL;<br>
+         op[0].type = BRW_REGISTER_TYPE_UD;<br>
+         result_dst.type = BRW_REGISTER_TYPE_UD;<br>
+         emit(AND(result_dst, op[0], src_reg(0x80000000u)));<br>
<br>
-      emit(CMP(dst_null_d(), op[0], src_reg(0.0f), BRW_CONDITIONAL_L));<br>
-      inst = emit(MOV(result_dst, src_reg(-1.0f)));<br>
-      inst->predicate = BRW_PREDICATE_NORMAL;<br>
+         inst = emit(OR(result_dst, src_reg(result_dst), src_reg(0x3f800000u)));<br>
+         inst->predicate = BRW_PREDICATE_NORMAL;<br>
+<br>
+         this->result.type = BRW_REGISTER_TYPE_F;<br>
+      } else {<br>
+         emit(CMP(dst_null_d(), op[0], src_reg(0), BRW_CONDITIONAL_G));<br>
+<br>
+         emit(ASR(result_dst, op[0], src_reg(31)));<br>
<br>
+         inst = emit(OR(result_dst, src_reg(result_dst), src_reg(1)));<br>
+         inst->predicate = BRW_PREDICATE_NORMAL;<br>
+      }<br>
       break;<br>
<br>
    case ir_unop_rcp:<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>