mesa/src
Ian Romanick 73580de2e8 nir/loop_analyze: Fix get_iteration for nir_op_fneu
Consider the loop:

    float i = 0.0;
    while (true) {
       if (i != 0.0)
          break;

       i = i + 1.0;
    }

This loop clearly executes exactly one time.

Some trickery is necessary to handle cases where the initial loop value
is very large and the increment is, by comparison, very small.  From the
fenu_once test case,

    float i = -604462909807314587353088.0;
    while (true) {
       if (i != -604462909807314587353088.0)
          break;

       i = i + 36028797018963968.0;
    }

This loop should also execute exactly once, but this is much more
challenging to calculate due to precision issues.

Going towards smaller magnitude (i.e., adding a small positive value to
a large negative value) requires a smaller delta to make a difference
than going towards a larger magnitude. For this reason,
-604462909807314587353088.0 + 36028797018963968.0 !=
-604462909807314587353088.0, but -604462909807314587353088.0 +
-36028797018963968.0 == -604462909807314587353088.0. Math class is
tough.

No changes in shader-db or fossil-db.

v2: Fix major bug in checking result of the eval_const_binop(nir_op_feq,
...) discovered while developing fneu_once_easy unit test. Fix a typo in
the comment just above that. Add fneu_once_easy test.

v3: Skip the iteration count adjustment tests for nir_op_fenu and
nir_op_ine. Since the iteration count is either 1 or unknown, all this
function can do is add numerical error. Add fenu_once tests.

v4: Change the initial value in the fneu_once test from large positive
to large negative. Change check in get_iteration from nir_op_fsub to
nir_op_fadd. Both changes from discussion with M Henning. Also add some
more explanation in fneu_once.

v5: Rename test cases.

Fixes: 6772a17acc ("nir: Add a loop analysis pass")
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19732>
(cherry picked from commit f75c83c4aa)
2022-11-23 19:11:59 +00:00
..
amd aco: ensure MRT0 is written with dual source blending 2022-11-23 19:11:59 +00:00
android_stub
asahi asahi: Identify counts for compute kernels 2022-10-29 19:23:51 +00:00
broadcom v3d(v): account for debug flags when using the cache 2022-11-23 19:11:59 +00:00
c11 c11: Getting the macro guard of HAVE_PTHREAD in c11/threads.h to be consistence with util/u_uthread.h 2022-10-20 03:04:56 +00:00
compiler nir/loop_analyze: Fix get_iteration for nir_op_fneu 2022-11-23 19:11:59 +00:00
drm-shim drm-shim: drop gnu99 override 2022-09-16 02:06:38 +00:00
egl Revert "egl/glx: add fallback for zink loading" 2022-11-17 14:05:05 +00:00
etnaviv util/mesa/wide: Rename _SIMPLE_MTX_INITIALIZER_NP to SIMPLE_MTX_INITIALIZER 2022-10-14 03:27:41 +00:00
freedreno freedreno/ci: Skip civilization-v/CivilizationV-trim trace 2022-11-17 14:05:04 +00:00
gallium rusticl/device: put space at the end of CL_DEVICE_VERSION 2022-11-23 19:11:59 +00:00
gbm utils: Merge util/debug.* into util/u_debug.* and remove util/debug.* 2022-11-02 07:25:39 +00:00
getopt
glx Revert "egl/glx: add fallback for zink loading" 2022-11-17 14:05:05 +00:00
gtest
hgl
imagination nir: Drop infer_non_readable option for nir_opt_access() 2022-11-02 03:42:04 +00:00
imgui
intel intel/fs: put scratch surface in the surface state heap 2022-11-23 19:11:59 +00:00
loader loader/dri3: Add DRI performance option to wait for next buffer on swap 2022-10-25 08:30:35 +00:00
mapi meson: Refactoring shared gen_vs_module_defs_normal_command out 2022-11-17 14:05:02 +00:00
mesa mesa/st: Query driver for interop data 2022-11-02 18:11:41 +00:00
microsoft utils: Merge util/debug.* into util/u_debug.* and remove util/debug.* 2022-11-02 07:25:39 +00:00
nouveau nv50/ir/nir: ignore sampler for TXF/TXQ ops. 2022-11-02 12:29:34 +00:00
panfrost CI: convert to use the new S3 server instead of the legacy minio 2022-11-17 14:05:04 +00:00
tool pps: enable track_event in intel.cfg 2022-10-09 22:39:53 +03:00
util util: include sys/time.h for timespec functions 2022-11-17 14:05:05 +00:00
virtio venus: handle VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT 2022-11-17 14:05:03 +00:00
vulkan vulkan/wsi/wayland: Set num_modifier_lists = 0 if num_drm_modifiers == 0 2022-11-23 19:11:58 +00:00
meson.build meson: Remove usage of use_elf_tls 2022-07-29 23:59:11 +00:00