Filip Gawin
9083e9a483
nir: fix shadowed variable in nir_lower_bit_size.c
...
Fixes: 6d79298992 ("nir/lower_bit_size: fix lowering of {imul,umul}_high")
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12527 >
2021-08-26 18:04:22 +00:00
Ian Romanick
7d8bf7c167
nir/lower_bit_size: Support add_sat and sub_sat
...
Without this, lowered saturating ALU instructions would only clamp to
the range of the new type instead of the range of the old type.
v2: Use nir_iclamp. Suggested by Jason. Use new
u_{int,uint}N_{min,max}() helpers.
Fixes: 090e282407 ("nir: Add a saturated unsigned integer add opcode")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12142 >
2021-08-24 19:58:57 +00:00
Emma Anholt
673cc9323a
nir: Move phi src setup to a helper.
...
Cleans up the ralloc/list push code all over the tree.
Reviewed-by: Matt Turner <mattst88@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11772 >
2021-08-13 16:11:57 +00:00
Jason Ekstrand
e20e85f01e
nir: Make nir_ssa_def_rewrite_uses_after take an SSA value
...
This replaces the new_src parameter of nir_ssa_def_rewrite_uses_after()
with an SSA def, and rewrites all the users as needed.
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com >
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383 >
2021-03-08 16:59:55 +00:00
Jason Ekstrand
117668b811
nir: Make nir_ssa_def_rewrite_uses take an SSA value
...
This commit replaces the new_src parameter of nir_ssa_def_rewrite_uses()
with an SSA def, removes nir_ssa_def_rewrite_uses_ssa(), and rewrites
all the users as needed.
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com >
Acked-by: Alyssa Rosenzweig <alyssa@collabora.com >
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9383 >
2021-03-08 16:59:55 +00:00
Jason Ekstrand
d41ac6e2ca
nir/lower_bit_size: Support phi instructions
...
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8872 >
2021-02-16 16:36:31 +00:00
Jason Ekstrand
f95665cfeb
nir/lower_bit_size: Add support for lowering subgroup ops
...
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7482 >
2020-11-09 18:58:51 +00:00
Jason Ekstrand
2c4b47184d
nir/lower_bit_size: Pass a nir_instr to the callback
...
This way we can start supporting more than just ALU ops.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7482 >
2020-11-09 18:58:51 +00:00
Jason Ekstrand
15c6e05a72
nir/lower_bit_size: Don't cast comparison results
...
Some ALU ops (comparisons being the primary example) have a fixed
bit-size destination and, in that case, we don't want to insert a
conversion on the destination.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7482 >
2020-11-09 18:58:51 +00:00
Rhys Perry
475077c790
nir/lower_bit_size: optimize upcast of b2i8/b2i16
...
This also seems to be done by nir_opt_algebraic, but RADV will be moving
nir_lower_bit_size() to after that (so it doesn't create unsupported
8/16-bit instructions) and it doesn't seem worth creating a new pass just
for this simple optimization.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4791 >
2020-11-04 11:50:37 +00:00
Jesse Natalie
ea715741b5
nir_lower_bit_size: Support lowering ops with differing source/dest sizes
...
Specifically the bit-finding routines always return int32. Don't complain
about the dest already being 32 bits when lowering to 32 bits, and
don't bother casting the dest if it's already right.
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6313 >
2020-08-27 16:57:42 +00:00
Jesse Natalie
43d22c8f20
nir: Add a lowering pass to split 64bit phis
...
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6313 >
2020-08-27 16:57:41 +00:00
Eric Anholt
d84a16e481
nir: Add nir_[iu]shr_imm and nir_udiv_imm helpers and use them.
...
I was doing math manually in a lowering pass for converting a division to
a ushr, and this will let the pass be expressed more naturally.
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6378 >
2020-08-24 09:53:17 -07:00
Jesse Natalie
aa581fcc69
nir: Support vec8/vec16 in nir_lower_bit_size
...
Reviewed-by: Gert Wollny <gert.wollny@collabora.com >
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6030 >
2020-07-23 18:23:07 -07:00
Jason Ekstrand
5e1c42d85f
nir: Call nir_metadata_preserve on !progress
...
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5171 >
2020-06-11 05:08:12 +00:00
Rob Clark
866618c5c8
nir: extract out convert_to_bitsize() helper
...
Signed-off-by: Rob Clark <robdclark@chromium.org >
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com >
Reviewed-by: Eric Anholt <eric@anholt.net >
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5318 >
2020-06-03 21:24:13 +00:00
Rhys Perry
6d79298992
nir/lower_bit_size: fix lowering of {imul,umul}_high
...
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4387 >
2020-04-23 10:57:38 +00:00
Rhys Perry
715ef95700
nir/lower_bit_size: fix lowering of shifts
...
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com >
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4387 >
2020-04-23 10:57:38 +00:00
Iago Toral Quiroga
b9a3d8c23e
compiler/nir: add a lowering pass to convert the bit size of ALU operations
...
Not all bit-sizes may be supported natively in hardware for all operations.
This pass allows drivers to lower such operations to a bit-size that is
actually supported and then converts the result back to the original
bit-size.
Compiler backends control which operations and wich bit-sizes require
the lowering through a callback function.
v2: generalize this pass and make it available in NIR core (Rob, Jason)
v3: remove some temporaries and reduce nesting in instruction loop using
a continue statement (Jason)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net >
2018-05-03 11:40:25 +02:00