nir/lower_idiv: Be less creative about signs
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 1 Aug 2022 22:56:01 +0000 (18:56 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 3 Aug 2022 14:24:38 +0000 (14:24 +0000)
commita4a15f500ce43b18b2ee99b740b7f2575abcfa4e
treea2009190a8a1e1753f858e623557e0508e9b0ee6
parente13c9d2168dfb216a4920e84d89dbcc08de3dfe0
nir/lower_idiv: Be less creative about signs

I'm sorry to whoever wrote this, but

   (x - (int) (x < 0)) ^ -((int) (x < 0))

is not an acceptable way to write iabs.

Shader-db results on Intel Tiger Lake with lower_idiv enabled:

    total instructions in shared programs: 21122548 -> 21122570 (<.01%)
    instructions in affected programs: 2369 -> 2391 (0.93%)
    helped: 2
    HURT: 8

    total cycles in shared programs: 791609360 -> 791608062 (<.01%)
    cycles in affected programs: 114106 -> 112808 (-1.14%)
    helped: 9
    HURT: 1

If we make the Intel back-end less stupid, we get to 9/1 helped/HURT for
instructions as well but that's for a different MR.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17845>
src/compiler/nir/nir_lower_idiv.c