diff options
author | Friedrich Vock <friedrich.vock@gmx.de> | 2022-12-08 21:26:28 +0100 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2022-12-14 20:47:01 +0000 |
commit | 57827e69036ae963272c6880729ac990b9ed22af (patch) | |
tree | b776ee3aa8e7e6de2cb4082cc3230b9efd7af9d3 | |
parent | 68fece9af5a9ffb2ff0ec2f925c314d660f6d412 (diff) | |
download | mesa-57827e69036ae963272c6880729ac990b9ed22af.tar.gz |
nir: Do not consider phis with incompatible dests equal
CSE tries to collapse equal instructions, and collapsing two phis with incompatible dests is illegal.
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Fixes: 6bdce55c ("nir: Add a basic CSE pass")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19960>
(cherry picked from commit a54c2c828941ef1325fc1a3b49eba32f3c964f0d)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_instr_set.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/.pick_status.json b/.pick_status.json index 1bc68430bf4..46418079807 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1228,7 +1228,7 @@ "description": "nir: Do not consider phis with incompatible dests equal", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "6bdce55c44a45fc8ec8426996572c18ecf88bd64" }, diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c index 032fcbcb918..985db65c0a1 100644 --- a/src/compiler/nir/nir_instr_set.c +++ b/src/compiler/nir/nir_instr_set.c @@ -707,6 +707,14 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2) if (phi1->instr.block != phi2->instr.block) return false; + /* In case of phis with no sources, the dest needs to be checked + * to ensure that phis with incompatible dests won't get merged + * during CSE. */ + if (phi1->dest.ssa.num_components != phi2->dest.ssa.num_components) + return false; + if (phi1->dest.ssa.bit_size != phi2->dest.ssa.bit_size) + return false; + nir_foreach_phi_src(src1, phi1) { nir_foreach_phi_src(src2, phi2) { if (src1->pred == src2->pred) { |