diff options
author | Jesse Natalie <jenatali@microsoft.com> | 2021-04-11 19:15:35 -0700 |
---|---|---|
committer | Dylan Baker <dylan.c.baker@intel.com> | 2021-04-21 09:53:37 -0700 |
commit | 1e4bcfea0c535031798c3fdbbf12658fef2ab943 (patch) | |
tree | 49c5ef23cc5d3aaf00df64acb13864fe0887d201 | |
parent | c30215de7ecf4df5d7115154f390aaf7976c4789 (diff) |
nir_opt_deref: ptr_as_array(deref_cast<T*>(x))[0] isn't the same as x[0] if the cast has alignment
This breaks CLOn12's handling of CL CTS test_basic vector_creation for char3 (at least).
Removing this cast causes us to try to load from a deref with no alignment info.
Fixes: 99bb2a4d ("nir/opt_deref: Don't remove casts with alignment information")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10165>
(cherry picked from commit 4b69ae8e1eaaf6591f8e76ec64bf0bc2dcfeb019)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_deref.c | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json index 424e606009b..8ed1efd2b8b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -625,7 +625,7 @@ "description": "nir_opt_deref: ptr_as_array(deref_cast<T*>(x))[0] isn't the same as x[0] if the cast has alignment", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "99bb2a4de66fa662fb4bcb29df8e2749972ee986" }, diff --git a/src/compiler/nir/nir_deref.c b/src/compiler/nir/nir_deref.c index 4735175b786..cc869101990 100644 --- a/src/compiler/nir/nir_deref.c +++ b/src/compiler/nir/nir_deref.c @@ -1111,7 +1111,8 @@ opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref) if (nir_src_is_const(deref->arr.index) && nir_src_as_int(deref->arr.index) == 0) { /* If it's a ptr_as_array deref with an index of 0, it does nothing - * and we can just replace its uses with its parent. + * and we can just replace its uses with its parent, unless it has + * alignment information. * * The source of a ptr_as_array deref always has a deref_type of * nir_deref_type_array or nir_deref_type_cast. If it's a cast, it @@ -1120,6 +1121,7 @@ opt_deref_ptr_as_array(nir_builder *b, nir_deref_instr *deref) * opt_deref_cast() above. */ if (parent->deref_type == nir_deref_type_cast && + parent->cast.align_mul == 0 && is_trivial_deref_cast(parent)) parent = nir_deref_instr_parent(parent); nir_ssa_def_rewrite_uses(&deref->dest.ssa, |