Commit graph

13 commits

Author SHA1 Message Date
Georg Lehmann
19fa9bd152 nir/tests: test algebraic patterns with maximum fp_math_ctrl
This means we don't run into undefined behavior when testing nan/inf inputs.
Also make sure that patterns using is_only_used_as_float are signed zero correct.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40291>
2026-03-13 07:13:10 +00:00
Rhys Perry
5e376e3ed2 nir: add nir_fp_analysis_state
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40190>
2026-03-05 11:26:25 +00:00
Emma Anholt
feb3e8f46e nir/opt_algebraic_tests: Initialize an obvious dummy value for all defs.
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
We were initializing to a nir_const_value of undefined (in practice on x86
builds, a pointer value), with .b set to 0.  Those values would get dumped
in the annotated shader disassembly at the end of a test where all inputs
where unexpectedly skipped, producing very surprising output.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:42 +00:00
Emma Anholt
6b6cf7b89f nir/opt_algebraic_tests: Fix annotating uint values.
In debugging the CI flakes, it was disconcerting to see:

1     %1 = fisnormal %0 (0.000000) // 0x55e7c4147c00

instead of:

1     %1 = fisnormal %0 (0.000000) // 0x0

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:42 +00:00
Emma Anholt
77cfb20d0a nir/opt_algebraic_tests: Fix leak of the variable conds ht.
We'd end the test with 500MB leaked.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:42 +00:00
Emma Anholt
e5a9eae2b5 nir/opt_algebraic_tests: Fix fuzzing levels for multi-component inputs.
We were enumerating enough for a single component, but not all the
combinations.  This helps show that our fdots fail pretty consistently.
And triggers more skipping from the fany_equal16s thanks to varied inputs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:41 +00:00
Emma Anholt
7fd0287a89 nir/opt_algebraic_tests: Test !nir_fp_preserve_signed_zero behavior.
Iterate over a set of sign-flips for 0.0s to see if we can find a set that
makes the search and replace sides match.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:41 +00:00
Emma Anholt
d9eb9a3eef nir/opt_algebraic_tests: Make sure we test the same inputs on BE as LE.
With the inexact signed zero support, we ended up with diverging inputs
producing diverging "all skipped" results for the matrix mul tests.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:40 +00:00
Emma Anholt
68f5bc4f12 nir/opt_algebraic_tests: Rename and use the enum result type more.
As I introduced another layer of iteration for signed zero testing, the
former logic got unwieldy.  In fact, it was already unwieldy enough that I
forgot to clear all_skipped when the assert failed, allowing a failing
test to be marked UNSUPPORTED instead of XFAIL.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:40 +00:00
Emma Anholt
7f1a64e7f5 nir/opt_algebraic_tests: Move more of the base class code to be methods.
Less passing the *test around separately.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:40 +00:00
Emma Anholt
845e2b3954 nir/opt_algebraic_tests: Remove unnecessary input_count.
Originally this was for sizing the array, but now we're doing std::vector.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:40 +00:00
Emma Anholt
c30c383d4d nir/opt_algebraic_tests: Allow testing of fdot*_replicated opcodes.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
2026-01-26 05:39:40 +00:00
Konstantin Seurer
363b2655b6 nir: Add a unit test base class for algebraic patterns
nir_algebraic_pattern_test can validate shaders with the following
structure:

%0 = @provide(base = 0)
...
%N = @provide(base = input_count)

// multiple equivalent expressions
a = ...
b = ...

valid = ieq(a, b)
@use(valid)

Expressions are evaluated by emulating the shader using
nir_eval_const_opcode.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39076>
2026-01-15 19:09:37 +00:00