i965: Emit 0.0:F sources with type VF instead.
authorMatt Turner <mattst88@gmail.com>
Fri, 2 May 2014 21:47:55 +0000 (14:47 -0700)
committerMatt Turner <mattst88@gmail.com>
Sun, 25 May 2014 06:03:24 +0000 (23:03 -0700)
Number of compacted instructions: 817752 -> 827404 (1.18%)

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_eu_emit.c

index d8efa017386be8570fd19c81f44dcb0db198e576..1810233c143b989067b7f8419421c6c0e83963ab 100644 (file)
@@ -357,6 +357,22 @@ brw_set_src0(struct brw_compile *p, struct brw_instruction *insn,
       } else {
          insn->bits1.da1.src1_reg_type = BRW_HW_REG_TYPE_UD;
       }
+
+      /* Compacted instructions only have 12-bits (plus 1 for the other 20)
+       * for immediate values. Presumably the hardware engineers realized
+       * that the only useful floating-point value that could be represented
+       * in this format is 0.0, which can also be represented as a VF-typed
+       * immediate, so they gave us the previously mentioned mapping on IVB+.
+       *
+       * Strangely, we do have a mapping for imm:f in src1, so we don't need
+       * to do this there.
+       *
+       * If we see a 0.0:F, change the type to VF so that it can be compacted.
+       */
+      if (insn->bits3.ud == 0x0 &&
+          insn->bits1.da1.src0_reg_type == BRW_HW_REG_TYPE_F) {
+         insn->bits1.da1.src0_reg_type = BRW_HW_REG_IMM_TYPE_VF;
+      }
    }
    else
    {