public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "qinzhao at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106457] array_at_struct_end_p returns TRUE for a two-dimension array which is not inside any structure
Date: Mon, 08 Aug 2022 15:13:58 +0000	[thread overview]
Message-ID: <bug-106457-4-gCBmcp3IGH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106457-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2022-08-08 15:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 18:43 [Bug tree-optimization/106457] New: " qinzhao at gcc dot gnu.org
2022-07-28  8:07 ` [Bug tree-optimization/106457] " rguenth at gcc dot gnu.org
2022-07-28 12:35 ` cvs-commit at gcc dot gnu.org
2022-07-28 12:36 ` rguenth at gcc dot gnu.org
2022-08-01 21:11 ` qinzhao at gcc dot gnu.org
2022-08-01 21:13 ` qinzhao at gcc dot gnu.org
2022-08-04 17:59 ` qinzhao at gcc dot gnu.org
2022-08-08 15:13 ` qinzhao at gcc dot gnu.org [this message]
2022-08-09 14:11 ` qinzhao at gcc dot gnu.org
2022-08-09 14:16 ` qinzhao at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106457-4-gCBmcp3IGH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).