i965/vec4: Fix saturation errors when coalescing registers
authorAntia Puentes <apuentes@igalia.com>
Wed, 5 Aug 2015 13:57:33 +0000 (15:57 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 14 Sep 2015 10:11:46 +0000 (12:11 +0200)
commit79f1a7ae28c37f77e08e550cd077959a2a1f8341
tree86072dd6470add3f1b1787c02ce30e363df01382
parentd1bce52e13bbade24b9fb700ee83e98a8af248c8
i965/vec4: Fix saturation errors when coalescing registers

If the register types do not match and the instruction
that contains the final destination is saturated, register
coalescing generated non-equivalent code.

This did not happen when using IR because types usually
matched, but it is visible in nir-vec4.

For example,
   mov      vgrf7:D vgrf2:D
   mov.sat  m4:F vgrf7:F

is coalesced to:
   mov.sat  m4:D vgrf2:D

The patch prevents coalescing in such scenario, unless the
instruction we want to coalesce into is a MOV (without type
conversion implied). In that case, the patch sets the register
types to the type of the final destination.

Shader-db results in HSW (only vec4 instructions shown):

total instructions in shared programs: 1754415 -> 1754416 (0.00%)
instructions in affected programs:     74 -> 75 (1.35%)
helped:                                0
HURT:                                  1
GAINED:                                0
LOST:                                  0

Only one extra instruction in one of the shaders, that comes from
eliminating a saturation error by preventing register coalesce.

Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/drivers/dri/i965/brw_vec4.cpp