https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106457
--- Comment #7 from qinzhao at gcc dot gnu.org --- another testing case failed with the current "array_at_struct_end_p": gcc/testsuite/gcc.target/aarch64/vadd_reduc-2.c 1 /* { dg-do compile } */ 2 /* { dg-additional-options "-O3 -std=c99" } */ 3 /* { dg-final { check-function-bodies "**" "" "" } } */ 4 5 #include <stdint.h> 6 7 #pragma GCC target "+nosve" 8 9 /* 10 **test: 11 ** ... 12 ** addv s0, v0.4s 13 ** fmov w0, s0 14 ** and w1, w0, 65535 15 ** add w0, w1, w0, lsr 16 16 ** lsr w0, w0, 1 17 ** ret 18 */ 19 int test (uint8_t *p, uint32_t t[1][1], int n) { 20 21 int sum = 0; 22 uint32_t a0; 23 for (int i = 0; i < 4; i++, p++) 24 t[i][0] = p[0]; 25 26 for (int i = 0; i < 4; i++) { 27 { 28 int t0 = t[0][i] + t[0][i]; 29 a0 = t0; 30 }; 31 sum += a0; 32 } 33 return (((uint16_t)sum) + ((uint32_t)sum >> 16)) >> 1; 34 } in the above, at line 24, the array_ref t[i][0] was identified as "true" by the current array_at_struct_end_p: Breakpoint 1, array_at_struct_end_p (ref=0xfffff57a2990) at ../../latest_gcc/gcc/tree.cc:12690 12690 if (TREE_CODE (ref) == ARRAY_REF (gdb) call debug_tree(ref) <array_ref 0xfffff57a2990 type <integer_type 0xfffff599e310 uint32_t sizes-gimplified public unsigned SI size <integer_cst 0xfffff56c1050 constant 32> unit-size <integer_cst 0xfffff56c1068 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0xfffff57d0690 precision:32 min <integer_cst 0xfffff56c1080 0> max <integer_cst 0xfffff56c1038 4294967295> context <translation_unit_decl 0xfffff5a00ca8 t.c>> arg:0 <mem_ref 0xfffff59f8390 type <array_type 0xfffff5a70dc8 type <integer_type 0xfffff599e310 uint32_t> SI size <integer_cst 0xfffff56c1050 32> unit-size <integer_cst 0xfffff56c1068 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0xfffff5a70e70 domain <integer_type 0xfffff5a70d20> pointer_to_this <pointer_type 0xfffff5a71110>> arg:0 <ssa_name 0xfffff5761908 type <pointer_type 0xfffff5a71110> visited def_stmt _4 = t_27(D) + _3; version:4 ptr-info 0xfffff56c84c0> arg:1 <integer_cst 0xfffff56c8328 constant 0> t.c:24:6 start: t.c:24:5 finish: t.c:24:8> arg:1 <integer_cst 0xfffff56c11a0 type <integer_type 0xfffff57d05e8 int> constant 0> t.c:24:9 start: t.c:24:5 finish: t.c:24:11> ...(gdb) n 12774 if (ref (gdb) n 12806 return true; (gdb) Looks like that the current array_at_struct_end_p cannot handle multi-dimension array reference correctly.