i965: Emit MOVs for neg/abs.
authorMatt Turner <mattst88@gmail.com>
Thu, 8 Aug 2013 20:50:01 +0000 (13:50 -0700)
committerMatt Turner <mattst88@gmail.com>
Fri, 16 Aug 2013 20:11:07 +0000 (13:11 -0700)
Necessary to avoid combining a bitcast and a modifier into a single
operation. Otherwise if safe, the MOV should be removed by
copy-propagation or register coalescing.

With this and the next patch, there are only four changes in shader-db:
all a single extra instruction. The code does something like
   mov a.w, -b.x
and copy propagation doesn't work because it only handles no-op
swizzles. Seems acceptable, given the known limitation of our copy
propagation.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereoytpe441@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 984b08a6b60aecc3ee6db7bac8d615eb07731898..964ad4074a6f27207bf90df9d2697983c0293096 100644 (file)
@@ -361,12 +361,12 @@ fs_visitor::visit(ir_expression *ir)
       break;
    case ir_unop_neg:
       op[0].negate = !op[0].negate;
-      this->result = op[0];
+      emit(MOV(this->result, op[0]));
       break;
    case ir_unop_abs:
       op[0].abs = true;
       op[0].negate = false;
-      this->result = op[0];
+      emit(MOV(this->result, op[0]));
       break;
    case ir_unop_sign:
       temp = fs_reg(this, ir->type);
index 454ec38feead12103a6ef7ab14b44d603455d862..455d9dcb12c83267e5d3c864001b4ca5bca36984 100644 (file)
@@ -1365,12 +1365,12 @@ vec4_visitor::visit(ir_expression *ir)
       break;
    case ir_unop_neg:
       op[0].negate = !op[0].negate;
-      this->result = op[0];
+      emit(MOV(result_dst, op[0]));
       break;
    case ir_unop_abs:
       op[0].abs = true;
       op[0].negate = false;
-      this->result = op[0];
+      emit(MOV(result_dst, op[0]));
       break;
 
    case ir_unop_sign: