nir/load_store_vectorize: assume CAN_REORDER ops don't alias with stores
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 21 Oct 2020 15:43:16 +0000 (16:43 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 21 Apr 2021 20:26:58 +0000 (20:26 +0000)
fossil-db (GFX10.3):
Totals from 20 (0.01% of 139391) affected shaders:
SGPRs: 688 -> 712 (+3.49%); split: -1.16%, +4.65%
CodeSize: 35488 -> 34424 (-3.00%); split: -3.04%, +0.05%
Instrs: 6405 -> 6259 (-2.28%); split: -2.44%, +0.16%
Cycles: 51768 -> 51268 (-0.97%); split: -1.21%, +0.24%

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10384>

src/compiler/nir/nir_opt_load_store_vectorize.c

index aae6609..279b126 100644 (file)
@@ -593,6 +593,9 @@ create_entry(struct vectorize_ctx *ctx,
    else if (entry->key->var)
       entry->access = entry->key->var->data.access;
 
+   if (nir_intrinsic_can_reorder(intrin))
+      entry->access |= ACCESS_CAN_REORDER;
+
    uint32_t restrict_modes = nir_var_shader_in | nir_var_shader_out;
    restrict_modes |= nir_var_shader_temp | nir_var_function_temp;
    restrict_modes |= nir_var_uniform | nir_var_mem_push_const;
@@ -920,6 +923,9 @@ may_alias(struct entry *a, struct entry *b)
    assert(mode_to_index(get_variable_mode(a)) ==
           mode_to_index(get_variable_mode(b)));
 
+   if ((a->access | b->access) & ACCESS_CAN_REORDER)
+      return false;
+
    /* if the resources/variables are definitively different and both have
     * ACCESS_RESTRICT, we can assume they do not alias. */
    bool res_different = a->key->var != b->key->var ||