radv: don't lower indirects until after opts have run
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 8 Mar 2018 05:20:48 +0000 (16:20 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 20 Mar 2018 04:01:44 +0000 (15:01 +1100)
Noticed while passing by. Not sure if it impacts anything, but
likely to impact GFX9 more than anything else since we lower
inputs, outputs and locals there.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_shader.c

index ac577c36e9f1415edb1c8918028be925a9763ff5..c6935805c79ddb3f1dc9f48ac76e820ccedd17d1 100644 (file)
@@ -275,7 +275,6 @@ radv_shader_compile_to_nir(struct radv_device *device,
        nir_lower_var_copies(nir);
        nir_lower_global_vars_to_local(nir);
        nir_remove_dead_variables(nir, nir_var_local);
-       ac_lower_indirect_derefs(nir, device->physical_device->rad_info.chip_class);
        nir_lower_subgroups(nir, &(struct nir_lower_subgroups_options) {
                        .subgroup_size = 64,
                        .ballot_bit_size = 64,
@@ -287,6 +286,14 @@ radv_shader_compile_to_nir(struct radv_device *device,
 
        radv_optimize_nir(nir);
 
+       /* Indirect lowering must be called after the radv_optimize_nir() loop
+        * has been called at least once. Otherwise indirect lowering can
+        * bloat the instruction count of the loop and cause it to be
+        * considered too large for unrolling.
+        */
+       ac_lower_indirect_derefs(nir, device->physical_device->rad_info.chip_class);
+       radv_optimize_nir(nir);
+
        return nir;
 }