nir: get ffma support from NIR options for nir_lower_flrp
authorMarek Olšák <marek.olsak@amd.com>
Thu, 23 Jul 2020 02:13:16 +0000 (22:13 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 4 Sep 2020 17:06:22 +0000 (17:06 +0000)
This also fixes the inverted last parameter of nir_lower_flrp in most drivers.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6599>

14 files changed:
.gitlab-ci/traces-radeonsi.yml
src/amd/vulkan/radv_shader.c
src/broadcom/compiler/nir_to_vir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_flrp.c
src/freedreno/ir3/ir3_nir.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/radeonsi/si_shader_nir.c
src/gallium/drivers/vc4/vc4_program.c
src/gallium/frontends/vallium/val_pipeline.c
src/intel/compiler/brw_nir.c
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/midgard/midgard_compile.c

index f35e523385ed8ea865182d3b6008e2ec4b97dbe8..9e8d5dba8adcab33a5b458096971e4f487c59849 100644 (file)
@@ -173,7 +173,7 @@ traces:
   - path: godot/Material Testers.x86_64_2020.04.08_13.38_frame799.rdc
     expectations:
       - device: gl-radeonsi-stoney
-        checksum: 2ddcda6b1c136ce1448714a3ff8432eb
+        checksum: 5164e238381e7d77a64e3de771cc005f
   - path: gputest/gimark.trace
     expectations:
       - device: gl-radeonsi-stoney
index c76975c22526d09edf175127dbb209d171054899..bce321ac37501a2fa29bf880abd3e0228fbea377 100644 (file)
@@ -261,8 +261,7 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively,
                                  shader,
                                  nir_lower_flrp,
                                  lower_flrp,
-                                 false /* always_precise */,
-                                 shader->options->lower_ffma);
+                                 false /* always_precise */);
                         if (lower_flrp_progress) {
                                 NIR_PASS(progress, shader,
                                          nir_opt_constant_folding);
index e580e75ef3c14a88d681a9a308e61e1ed796ce27..1c6aeec56e5bbda7e36184a1a753c4d3e247f3db 100644 (file)
@@ -1451,8 +1451,7 @@ v3d_optimize_nir(struct nir_shader *s)
 
                         NIR_PASS(lower_flrp_progress, s, nir_lower_flrp,
                                  lower_flrp,
-                                 false /* always_precise */,
-                                 s->options->lower_ffma);
+                                 false /* always_precise */);
                         if (lower_flrp_progress) {
                                 NIR_PASS(progress, s, nir_opt_constant_folding);
                                 progress = true;
index 68576219e0672d1929554c6197cbd9d63912d6c9..bf054e8280273c8e9d5465d852aba33453633474 100644 (file)
@@ -4314,7 +4314,7 @@ void nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
 bool nir_lower_alu(nir_shader *shader);
 
 bool nir_lower_flrp(nir_shader *shader, unsigned lowering_mask,
-                    bool always_precise, bool have_ffma);
+                    bool always_precise);
 
 bool nir_lower_alu_to_scalar(nir_shader *shader, nir_instr_filter_cb cb, const void *data);
 bool nir_lower_bool_to_bitsize(nir_shader *shader);
index 38be18ecc6ba04fb42424f4253776ae3584cbb92..3b4d23bae11997cc49284dd7a36fe67bd755963a 100644 (file)
@@ -364,9 +364,10 @@ static void
 convert_flrp_instruction(nir_builder *bld,
                          struct u_vector *dead_flrp,
                          nir_alu_instr *alu,
-                         bool always_precise,
-                         bool have_ffma)
+                         bool always_precise)
 {
+   bool have_ffma = !bld->shader->options->lower_ffma;
+
    bld->cursor = nir_before_instr(&alu->instr);
 
    /* There are two methods to implement flrp(x, y, t).  The strictly correct
@@ -586,8 +587,7 @@ static void
 lower_flrp_impl(nir_function_impl *impl,
                 struct u_vector *dead_flrp,
                 unsigned lowering_mask,
-                bool always_precise,
-                bool have_ffma)
+                bool always_precise)
 {
    nir_builder b;
    nir_builder_init(&b, impl);
@@ -599,8 +599,7 @@ lower_flrp_impl(nir_function_impl *impl,
 
             if (alu->op == nir_op_flrp &&
                 (alu->dest.dest.ssa.bit_size & lowering_mask)) {
-               convert_flrp_instruction(&b, dead_flrp, alu, always_precise,
-                                        have_ffma);
+               convert_flrp_instruction(&b, dead_flrp, alu, always_precise);
             }
          }
       }
@@ -622,8 +621,7 @@ lower_flrp_impl(nir_function_impl *impl,
 bool
 nir_lower_flrp(nir_shader *shader,
                unsigned lowering_mask,
-               bool always_precise,
-               bool have_ffma)
+               bool always_precise)
 {
    struct u_vector dead_flrp;
 
@@ -633,7 +631,7 @@ nir_lower_flrp(nir_shader *shader,
    nir_foreach_function(function, shader) {
       if (function->impl) {
          lower_flrp_impl(function->impl, &dead_flrp, lowering_mask,
-                         always_precise, have_ffma);
+                         always_precise);
       }
    }
 
index bd73beefac9915c0ec6181c66024de9b00b6921c..46c1d1cf7ba90dfd63b0a4834853df7388da53a3 100644 (file)
@@ -185,8 +185,7 @@ ir3_optimize_loop(nir_shader *s)
                if (lower_flrp != 0) {
                        if (OPT(s, nir_lower_flrp,
                                        lower_flrp,
-                                       false /* always_precise */,
-                                       s->options->lower_ffma)) {
+                                       false /* always_precise */)) {
                                OPT(s, nir_opt_constant_folding);
                                progress = true;
                        }
index 9ac0efad7e466532d60a7c6fa824586a2e2e200e..f58f8ccbe8bcdb40e8e0bc4cf9fd95e7c4c17523 100644 (file)
@@ -203,7 +203,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
                                NIR_PASS_V(sel->nir, nir_lower_int64);
                                NIR_PASS_V(sel->nir, nir_opt_vectorize, NULL, NULL);
                        }
-                       NIR_PASS_V(sel->nir, nir_lower_flrp, ~0, false, false);
+                       NIR_PASS_V(sel->nir, nir_lower_flrp, ~0, false);
                }
                nir_tgsi_scan_shader(sel->nir, &sel->info, true);
 
index a2f3af831ad8e2596c758d9de4643de8ea9f4471..02fd6dfd48b89677d0ca36c56c6695adc002b64f 100644 (file)
@@ -644,8 +644,7 @@ static void si_nir_opts(struct nir_shader *nir, bool first)
          assert(lower_flrp);
          bool lower_flrp_progress = false;
 
-         NIR_PASS(lower_flrp_progress, nir, nir_lower_flrp, lower_flrp, false /* always_precise */,
-                  nir->options->lower_ffma);
+         NIR_PASS(lower_flrp_progress, nir, nir_lower_flrp, lower_flrp, false /* always_precise */);
          if (lower_flrp_progress) {
             NIR_PASS(progress, nir, nir_opt_constant_folding);
             progress = true;
index 0d448fa2754f76d0a6e49cf7ce48f73d89e7231b..4f2956bb735a871f471dda1c383ccef730d72a66 100644 (file)
@@ -1546,8 +1546,7 @@ vc4_optimize_nir(struct nir_shader *s)
 
                         NIR_PASS(lower_flrp_progress, s, nir_lower_flrp,
                                  lower_flrp,
-                                 false /* always_precise */,
-                                 s->options->lower_ffma);
+                                 false /* always_precise */);
                         if (lower_flrp_progress) {
                                 NIR_PASS(progress, s, nir_opt_constant_folding);
                                 progress = true;
index fb0a88a051d49f38c70bb4a91a84407510acb31f..a1d83902c56d0e375bd06d2f12c15287da5f130f 100644 (file)
@@ -590,7 +590,7 @@ val_shader_compile_to_ir(struct val_pipeline *pipeline,
    do {
       progress = false;
 
-      progress |= OPT(nir_lower_flrp, 32|64, true, false);
+      progress |= OPT(nir_lower_flrp, 32|64, true);
       progress |= OPT(nir_split_array_vars, nir_var_function_temp);
       progress |= OPT(nir_shrink_vec_array_vars, nir_var_function_temp);
       progress |= OPT(nir_opt_deref);
index 8cf2131ef72de709cf739a4a0e04525803482ad7..d7b7551d7399bdc62cda5ae0ff884c35f2c85351 100644 (file)
@@ -597,8 +597,7 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler,
       if (lower_flrp != 0) {
          if (OPT(nir_lower_flrp,
                  lower_flrp,
-                 false /* always_precise */,
-                 compiler->devinfo->gen >= 6)) {
+                 false /* always_precise */)) {
             OPT(nir_opt_constant_folding);
          }
 
index 6e5df53ea1f151294a29b229f5db1f330db39641..089a134cf1e1005a01d48a48ea2ece8be0ae0735 100644 (file)
@@ -305,8 +305,7 @@ st_nir_opts(nir_shader *nir)
 
             NIR_PASS(lower_flrp_progress, nir, nir_lower_flrp,
                      lower_flrp,
-                     false /* always_precise */,
-                     nir->options->lower_ffma);
+                     false /* always_precise */);
             if (lower_flrp_progress) {
                NIR_PASS(progress, nir,
                         nir_opt_constant_folding);
index 39f9b6580407cea65c2f1b0ee470cdd2b9df4422..413c8d3f2c84764db524f3b37aca493f789fdb1d 100644 (file)
@@ -1272,8 +1272,7 @@ bi_optimize_nir(nir_shader *nir)
                                  nir,
                                  nir_lower_flrp,
                                  lower_flrp,
-                                 false /* always_precise */,
-                                 nir->options->lower_ffma);
+                                 false /* always_precise */);
                         if (lower_flrp_progress) {
                                 NIR_PASS(progress, nir,
                                          nir_opt_constant_folding);
index bd13efd0ecad2618a94323fe0736f6e902dfa1c9..415000b9825bdafbe5454fe3431225f54a9e75b4 100644 (file)
@@ -536,8 +536,7 @@ optimise_nir(nir_shader *nir, unsigned quirks, bool is_blend)
                                  nir,
                                  nir_lower_flrp,
                                  lower_flrp,
-                                 false /* always_precise */,
-                                 nir->options->lower_ffma);
+                                 false /* always_precise */);
                         if (lower_flrp_progress) {
                                 NIR_PASS(progress, nir,
                                          nir_opt_constant_folding);