freedreno/ir3: Do not propagate away a widening move

A narrowing move from const is just emulated CONSTANT_DEMOTION_ENABLE so
we can permit it.  But not the inverse.

Cc: mesa-stable
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30835>
(cherry picked from commit 63a5803433)
This commit is contained in:
Rob Clark 2024-10-22 09:27:11 -07:00 committed by Eric Engestrom
parent f0cb1eb414
commit 742e2ddb4b
2 changed files with 11 additions and 1 deletions

View file

@ -174,7 +174,7 @@
"description": "freedreno/ir3: Do not propagate away a widening move",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1031,6 +1031,16 @@ is_const_mov(struct ir3_instruction *instr)
type_t src_type = instr->cat1.src_type;
type_t dst_type = instr->cat1.dst_type;
/* Allow a narrowing move, but not a widening one. A narrowing
* move from full c1.x can be folded into a hc1.x use in an ALU
* instruction because it is doing the same thing as constant-
* demotion. If CONSTANT_DEMOTION_ENABLE wasn't set, we'd need
* return false in all cases.
*/
if ((type_size(dst_type) > type_size(src_type)) ||
(type_size(dst_type) == 8))
return false;
return (type_float(src_type) && type_float(dst_type)) ||
(type_uint(src_type) && type_uint(dst_type)) ||
(type_sint(src_type) && type_sint(dst_type));