Skip to content

Commit c677ac1

Browse files
alyssarosenzweigMarge Bot
authored and
Marge Bot
committed
agx: fix ctz of zero with address calcs
../src/asahi/compiler/agx_nir_lower_address.c:82:30: runtime error: passing zero to ctz(), which is not a valid argument #0 0x56175dca5684 in pass ../src/asahi/compiler/agx_nir_lower_address.c:82 waydroid#1 0x56175dca2eda in nir_function_intrinsics_pass ../src/compiler/nir/nir_builder.h:164 waydroid#2 0x56175dca308c in nir_shader_intrinsics_pass ../src/compiler/nir/nir_builder.h:191 waydroid#3 0x56175dca68ae in agx_nir_lower_address ../src/asahi/compiler/agx_nir_lower_address.c:167 waydroid#4 0x56175dc885c0 in agx_optimize_nir ../src/asahi/compiler/agx_compile.c:3063 waydroid#5 0x56175dc9650d in agx_compile_shader_nir ../src/asahi/compiler/agx_compile.c:3827 waydroid#6 0x56175dc52148 in main ../src/asahi/clc/asahi_clc.c:359 waydroid#7 0x7fdf1c343249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 waydroid#8 0x7fdf1c343304 in __libc_start_main_impl ../csu/libc-start.c:360 waydroid#9 0x56175dc44760 in _start (/builds/mesa/mesa/_build/src/asahi/clc/asahi_clc+0xbd0760) Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33685>
1 parent dfae262 commit c677ac1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/asahi/compiler/agx_nir_algebraic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ def isubshl(x, y, s):
215215
# neither multiplication overflows.
216216
(('amul', ('ishl', ('u2u64', 'a@32'), '#b(is_ult_32)'), '#c'),
217217
('amul', ('u2u64', a), ('ishl', c, b))),
218+
219+
# We depending on simplifying this.
220+
(('iadd', a, 0), a),
218221
]
219222

220223
fuse_lea = []

src/asahi/compiler/agx_nir_lower_address.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ pass(struct nir_builder *b, nir_intrinsic_instr *intr, void *data)
7979
* shift.
8080
*/
8181
int64_t raw_scalar = nir_scalar_as_uint(const_scalar);
82+
assert(raw_scalar != 0 && "must have been optimized out");
83+
8284
uint32_t shift = MIN2(__builtin_ctz(raw_scalar), max_shift);
8385
int64_t k = raw_scalar >> shift;
8486

0 commit comments

Comments
 (0)