i965/vs: Use the embedded-comparison SEL on gen6+, like the FS does.
authorEric Anholt <eric@anholt.net>
Wed, 18 Jan 2012 20:58:45 +0000 (12:58 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 23 Jan 2012 20:50:54 +0000 (12:50 -0800)
Shaves a few instructions off of the VS in Lightsmark, but no
statistically significant performance difference on gen7 (n=5).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 06bde92c8d8e7452ecb1f981e3ebca1d4fb54e71..2436bc9336a89537e50427f9ba395b37b6291c76 100644 (file)
@@ -1285,16 +1285,26 @@ vec4_visitor::visit(ir_expression *ir)
       break;
 
    case ir_binop_min:
-      emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_L));
+      if (intel->gen >= 6) {
+        inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]);
+        inst->conditional_mod = BRW_CONDITIONAL_L;
+      } else {
+        emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_L));
 
-      inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]);
-      inst->predicate = BRW_PREDICATE_NORMAL;
+        inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]);
+        inst->predicate = BRW_PREDICATE_NORMAL;
+      }
       break;
    case ir_binop_max:
-      emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_G));
+      if (intel->gen >= 6) {
+        inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]);
+        inst->conditional_mod = BRW_CONDITIONAL_G;
+      } else {
+        emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_G));
 
-      inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]);
-      inst->predicate = BRW_PREDICATE_NORMAL;
+        inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]);
+        inst->predicate = BRW_PREDICATE_NORMAL;
+      }
       break;
 
    case ir_binop_pow: