mesa/src/intel
Yevhenii Kolesnikov 32b7ba66b0 intel/compiler: fix cmod propagation optimisations
Knowing following:
 - CMP writes to flag register the result of
   applying cmod to the `src0 - src1`.
   After that it stores the same value to dst.
   Other instructions first store their result to
   dst, and then store cmod(dst) to the flag
   register.
 - inst is either CMP or MOV
 - inst->dst is null
 - inst->src[0] overlaps with scan_inst->dst
 - inst->src[1] is zero
 - scan_inst wrote to a flag register

There can be three possible paths:

 - scan_inst is CMP:

   Considering that src0 is either 0x0 (false),
   or 0xffffffff (true), and src1 is 0x0:

   - If inst's cmod is NZ, we can always remove
     scan_inst: NZ is invariant for false and true. This
     holds even if src0 is NaN: .nz is the only cmod,
     that returns true for NaN.

   - .g is invariant if src0 has a UD type

   - .l is invariant if src0 has a D type

 - scan_inst and inst have the same cmod:

   If scan_inst is anything than CMP, it already
   wrote the appropriate value to the flag register.

 - else:

   We can change cmod of scan_inst to that of inst,
   and remove inst. It is valid as long as we make
   sure that no instruction uses the flag register
   between scan_inst and inst.

Nine new cmod_propagation unit tests:
 - cmp_cmpnz
 - cmp_cmpg
 - plnnz_cmpnz
 - plnnz_cmpz (*)
 - plnnz_sel_cmpz
 - cmp_cmpg_D
 - cmp_cmpg_UD (*)
 - cmp_cmpl_D (*)
 - cmp_cmpl_UD

(*) this would fail without changes to brw_fs_cmod_propagation.

This fixes optimisation that used to be illegal (see issue #2154)

= Before =
 0: linterp.z.f0.0(8) vgrf0:F, g2:F, attr0<0>:F
 1: cmp.nz.f0.0(8) null:F, vgrf0:F, 0f
= After =
 0: linterp.z.f0.0(8) vgrf0:F, g2:F, attr0<0>:F

Now it is optimised as such (note change of cmod in line 0):

= Before =
 0: linterp.z.f0.0(8) vgrf0:F, g2:F, attr0<0>:F
 1: cmp.nz.f0.0(8) null:F, vgrf0:F, 0f
= After =
 0: linterp.nz.f0.0(8) vgrf0:F, g2:F, attr0<0>:F

No shaderdb changes

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2154

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3348>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3348>
2020-03-11 21:21:25 +00:00
..
blorp blorp: Write to depth/stencil images as depth/stencil when possible 2020-03-05 18:56:45 +00:00
common intel/isl: Move get_format_encoding function to isl 2020-02-13 18:44:50 +00:00
compiler intel/compiler: fix cmod propagation optimisations 2020-03-11 21:21:25 +00:00
dev intel/device: bdw_gt1 actually has 6 eus per subslice 2020-03-03 00:36:10 +00:00
genxml intel/gen12+: Disable mid thread preemption. 2020-03-03 19:52:06 +00:00
isl isl: Set 3DSTATE_DEPTH_BUFFER::Depth correctly for 3D surfaces 2020-03-05 18:56:45 +00:00
perf util/hash_table: added hash functions for integer types 2020-01-23 17:06:57 +00:00
tools intel/tools: Fix compilation with UBSan 2020-03-10 15:20:26 +00:00
vulkan anv: stop storing prog param data into shader blobs 2020-03-07 05:51:45 +00:00
Android.blorp.mk intel: android: remove libdrm_intel requirement 2017-03-30 19:07:23 +01:00
Android.common.mk android: static link with libexpat with Android O+ 2019-03-25 10:11:57 +02:00
Android.compiler.mk android: fix build issues with brw_nir_trig_workarounds.c 2017-10-04 07:39:05 +03:00
Android.dev.mk drm-uapi: use local files, not system libdrm 2019-02-14 11:20:00 +00:00
Android.genxml.mk intel/genxml: generate pack files for gen12 on android builds 2019-08-28 13:38:33 -07:00
Android.isl.mk isl: Fix the android build. 2020-02-05 21:31:40 -08:00
Android.mk i965: extract performance query metrics 2019-04-17 14:10:42 +01:00
Android.perf.mk i965: extract performance query metrics 2019-04-17 14:10:42 +01:00
Android.vulkan.mk anv/android: setup gralloc1 usage from gralloc0 usage manually 2020-01-28 14:46:25 +02:00
Makefile.perf.am i965: extract performance query metrics 2019-04-17 14:10:42 +01:00
Makefile.sources intel/isl: Add isl_aux_info.c to Makefile.sources 2020-02-25 00:41:15 +00:00
meson.build meson: only build imgui when needed 2019-11-25 07:51:56 +00:00