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: Tue, 09 Aug 2022 14:11:53 +0000	[thread overview]
Message-ID: <bug-106457-4-THLWK6t9bw@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 #8 from qinzhao at gcc dot gnu.org ---
another testing case failed with the current array_at_struct_end_p is:
gcc/testsuite/gcc.dg/torture/pr50067-1.c:
  1 /* { dg-do run } */
  2 
  3 /* Make sure data-dependence analysis does not compute a bogus
  4    distance vector for the different sized accesses.  */
  5 
  6 extern int memcmp(const void *, const void *, __SIZE_TYPE__);
  7 extern void abort (void);
  8 short a[32] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21    , 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
  9 short b[32] = { 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, };
 10 int main()
 11 {
 12 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 13   int i;
 14   if (sizeof (short) == 2)
 15     {
 16       for (i = 0; i < 32; ++i)
 17         (*((unsigned short(*)[32])&a[0]))[i] =
(*((char(*)[32])&a[0]))[i+8];
 18       if (memcmp (&a, &b, sizeof (a)) != 0)
 19         abort ();
 20     }
 21 #endif
 22   return 0;
 23 }

In the above, the array ref at line 17: (*((char(*)[32])&a[0]))[i+8] was
identified as TRUE by the current array_at_struct_end_p:
12690     if (TREE_CODE (ref) == ARRAY_REF
(gdb) call debug_tree(ref)
 <array_ref 0xfffff57a2b50
    type <integer_type 0xfffff57d03f0 char public unsigned QI
        size <integer_cst 0xfffff56c0f00 constant 8>
        unit-size <integer_cst 0xfffff56c0f18 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0xfffff57d03f0 precision:8 min <integer_cst 0xfffff56c0f60 0> max <integer_cst
0xfffff56c0f48 255>
        pointer_to_this <pointer_type 0xfffff57d40f8>>

    arg:0 <mem_ref 0xfffff59fe3d0
        type <array_type 0xfffff5994d70 type <integer_type 0xfffff57d03f0 char>
            BLK
            size <integer_cst 0xfffff56c1170 constant 256>
            unit-size <integer_cst 0xfffff56c1260 constant 32>
            align:8 warn_if_not_align:0 symtab:0 alias-set 0 canonical-type
0xfffff5994d70 domain <integer_type 0xfffff5994b78>
            pointer_to_this <pointer_type 0xfffff5994e18>>

        arg:0 <addr_expr 0xfffff56dbbe0 type <pointer_type 0xfffff5994ec0>
            constant arg:0 <var_decl 0xfffff5770ea0 a>>
        arg:1 <integer_cst 0xfffff56c7c08 constant 0>
       
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-1.c:17:42
start:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-1.c:17:41
finish:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-1.c:17:63>
    arg:1 <ssa_name 0xfffff57612d8
        type <integer_type 0xfffff57d05e8 int sizes-gimplified public 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
0xfffff57d05e8 precision:32 min <integer_cst 0xfffff56c1008 -2147483648> max
<integer_cst 0xfffff56c1020 2147483647>
            pointer_to_this <pointer_type 0xfffff57d1a40>>
        visited
        def_stmt _1 = i_13 + 8;
        version:1
        ptr-info 0xfffff59fee20>
   
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-1.c:17:64
start:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-1.c:17:41
finish:
/home/opc/Work/GCC/latest_gcc/gcc/testsuite/gcc.dg/torture/pr50067-1.c:17:68>
....(gdb) n
12801           return true;
(gdb)

  parent reply	other threads:[~2022-08-09 14:11 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
2022-08-09 14:11 ` qinzhao at gcc dot gnu.org [this message]
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-THLWK6t9bw@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).