i965/vec4: Combine generate_math[12]_gen6 methods.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 7 Jun 2014 09:32:40 +0000 (02:32 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 10 Jun 2014 23:38:26 +0000 (16:38 -0700)
These are trivial to combine: we should just avoid checking the second
operand if it's brw_null_reg.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp

index d8fa20bdd5b0137014608e59475976b9a8b93d15..614ff0b7faa6391facd798e92c2237e6c1628217 100644 (file)
@@ -654,17 +654,14 @@ private:
    void generate_math1_gen4(vec4_instruction *inst,
                            struct brw_reg dst,
                            struct brw_reg src);
-   void generate_math1_gen6(vec4_instruction *inst,
-                           struct brw_reg dst,
-                           struct brw_reg src);
    void generate_math2_gen4(vec4_instruction *inst,
                            struct brw_reg dst,
                            struct brw_reg src0,
                            struct brw_reg src1);
-   void generate_math2_gen6(vec4_instruction *inst,
-                           struct brw_reg dst,
-                           struct brw_reg src0,
-                           struct brw_reg src1);
+   void generate_math_gen6(vec4_instruction *inst,
+                           struct brw_reg dst,
+                           struct brw_reg src0,
+                           struct brw_reg src1);
 
    void generate_tex(vec4_instruction *inst,
                     struct brw_reg dst,
index 86dfbd56e70b1c97bf191dc828ae24da4620778b..119bcaecf7a32233e518b06e59d36cf46b075f26 100644 (file)
@@ -177,30 +177,17 @@ check_gen6_math_src_arg(struct brw_reg src)
 }
 
 void
-vec4_generator::generate_math1_gen6(vec4_instruction *inst,
-                                    struct brw_reg dst,
-                                    struct brw_reg src)
-{
-   /* Can't do writemask because math can't be align16. */
-   assert(dst.dw1.bits.writemask == WRITEMASK_XYZW);
-   check_gen6_math_src_arg(src);
-
-   brw_set_default_access_mode(p, BRW_ALIGN_1);
-   gen6_math(p, dst, brw_math_function(inst->opcode), src, brw_null_reg());
-   brw_set_default_access_mode(p, BRW_ALIGN_16);
-}
-
-void
-vec4_generator::generate_math2_gen6(vec4_instruction *inst,
-                                    struct brw_reg dst,
-                                    struct brw_reg src0,
-                                    struct brw_reg src1)
+vec4_generator::generate_math_gen6(vec4_instruction *inst,
+                                   struct brw_reg dst,
+                                   struct brw_reg src0,
+                                   struct brw_reg src1)
 {
    /* Can't do writemask because math can't be align16. */
    assert(dst.dw1.bits.writemask == WRITEMASK_XYZW);
    /* Source swizzles are ignored. */
    check_gen6_math_src_arg(src0);
-   check_gen6_math_src_arg(src1);
+   if (src1.file == BRW_GENERAL_REGISTER_FILE)
+      check_gen6_math_src_arg(src1);
 
    brw_set_default_access_mode(p, BRW_ALIGN_1);
    gen6_math(p, dst, brw_math_function(inst->opcode), src0, src1);
@@ -1129,7 +1116,7 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
          gen6_math(p, dst, brw_math_function(inst->opcode), src[0],
                    brw_null_reg());
       } else if (brw->gen == 6) {
-        generate_math1_gen6(inst, dst, src[0]);
+        generate_math_gen6(inst, dst, src[0], brw_null_reg());
       } else {
         generate_math1_gen4(inst, dst, src[0]);
       }
@@ -1141,7 +1128,7 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
       if (brw->gen >= 7) {
          gen6_math(p, dst, brw_math_function(inst->opcode), src[0], src[1]);
       } else if (brw->gen == 6) {
-        generate_math2_gen6(inst, dst, src[0], src[1]);
+        generate_math_gen6(inst, dst, src[0], src[1]);
       } else {
         generate_math2_gen4(inst, dst, src[0], src[1]);
       }