OSDN Git Service

nir/loop_analyze: Properly handle swizzles in loop conditions
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 21 Jun 2019 14:18:16 +0000 (09:18 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Wed, 10 Jul 2019 00:20:59 +0000 (00:20 +0000)
commitff972c7a3a7e80a426b72f285902d35f6ca3b820
tree60bd72cf879cbc886c49b4488fa292846a4cddf6
parent0333649e638a38258957fd8b7e0367d73bbc7a80
nir/loop_analyze: Properly handle swizzles in loop conditions

This commit re-plumbs all of nir_loop_analyze to use nir_ssa_scalar for
all intermediate values so that we can properly handle swizzles.  Even
though if conditions are required to be scalars, they may still consume
swizzles so you could have ((a.yzw < b.zzx).xz && c.xx).y == 0 as your
loop termination condition.  The old code would just bail the moment it
saw its first non-zero swizzle but we can now properly chase the scalar
from the if condition to all the way to a, b, and c.

Shader-db results on Kaby Lake:

    total loops in shared programs: 4388 -> 4364 (-0.55%)
    loops in affected programs: 29 -> 5 (-82.76%)
    helped: 29
    HURT: 5

Shader-db results on Haswell:

    total loops in shared programs: 4370 -> 4373 (0.07%)
    loops in affected programs: 2 -> 5 (150.00%)
    helped: 2
    HURT: 5

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/nir/nir_loop_analyze.c