public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/111720] RISC-V: Ugly codegen in RVV
Date: Thu, 19 Oct 2023 06:37:55 +0000	[thread overview]
Message-ID: <bug-111720-4-M34uhOUzdI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111720-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111720

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that we cannot CSE a VLA typed "load" (whatever that is) to a
constnant.

    char arr[] = {1, 2, 7, 1, 3, 4, 5, 3, 1
    , 0, 1, 2, 4, 4, 9, 9, 1, 2, 7, 1, 3, 4, 5, 3, 
    1, 0, 1, 2, 4, 4, 9, 9};
    char m = 1;

    svint8_t varr = *(svint8_t*)arr;

we don't know what portion of 'arr' this accesses.  The relevant bit in
vn_reference_lookup_3 would be

  /* 3) Assignment from a constant.  We can use folds native encode/interpret
     routines to extract the assigned bits.  */
  else if (known_eq (ref->size, maxsize)
           && is_gimple_reg_type (vr->type)
           && !reverse_storage_order_for_component_p (vr->operands)
           && !contains_storage_order_barrier_p (vr->operands)
           && gimple_assign_single_p (def_stmt)
           && CHAR_BIT == 8
           && BITS_PER_UNIT == 8
           && BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN
           /* native_encode and native_decode operate on arrays of bytes
              and so fundamentally need a compile-time size and offset.  */
           && maxsize.is_constant (&maxsizei)
           && offset.is_constant (&offseti)
           && (is_gimple_min_invariant (gimple_assign_rhs1 (def_stmt))
               || (TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME
                   && is_gimple_min_invariant (SSA_VAL (gimple_assign_rhs1
(def_

and we fail at maxsize.is_constant (&maxsizei), that's the actual size of
the load.  Maybe there's constraints that are target specific and not
encoded in poly-int that could be used here, but I don't really know.

So yes, pieces of the compiler are defensive about VLA accesses and
they probably have to be.

In particular this part of VN doesn't try to use undefinedness (the access
exceeds the size of 'arr') to limit things - but in the end we'd still
need to construct a VLA typed constant and I have no idea how to do that.

Maybe Richard has an idea.

Note this has nothing to do about whether we have a CLOBBER or not.  You
can "disable" those with -fstack-reuse=none and that doesn't make a
difference.

  parent reply	other threads:[~2023-10-19  6:37 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-07 22:28 [Bug c/111720] New: " juzhe.zhong at rivai dot ai
2023-10-07 22:34 ` [Bug target/111720] " juzhe.zhong at rivai dot ai
2023-10-07 22:36 ` pinskia at gcc dot gnu.org
2023-10-07 22:38 ` juzhe.zhong at rivai dot ai
2023-10-07 22:41 ` juzhe.zhong at rivai dot ai
2023-10-07 22:43 ` juzhe.zhong at rivai dot ai
2023-10-07 22:44 ` pinskia at gcc dot gnu.org
2023-10-07 22:44 ` pinskia at gcc dot gnu.org
2023-10-07 22:47 ` juzhe.zhong at rivai dot ai
2023-10-07 22:49 ` juzhe.zhong at rivai dot ai
2023-10-07 22:51 ` pinskia at gcc dot gnu.org
2023-10-07 22:55 ` juzhe.zhong at rivai dot ai
2023-10-07 23:09 ` juzhe.zhong at rivai dot ai
2023-10-17  8:26 ` juzhe.zhong at rivai dot ai
2023-10-18  3:29 ` pan2.li at intel dot com
2023-10-19  2:07 ` juzhe.zhong at rivai dot ai
2023-10-19  6:37 ` rguenth at gcc dot gnu.org [this message]
2023-10-19  7:45 ` juzhe.zhong at rivai dot ai
2023-10-19 11:16 ` rguenth at gcc dot gnu.org
2023-10-19 11:30 ` juzhe.zhong at rivai dot ai
2023-10-19 11:34 ` rguenther at suse dot de
2023-10-19 11:58 ` juzhe.zhong at rivai dot ai
2023-10-19 12:02 ` rguenther at suse dot de
2023-10-19 12:08 ` juzhe.zhong at rivai dot ai
2023-10-19 12:20 ` rguenther at suse dot de
2023-10-19 12:38 ` juzhe.zhong at rivai dot ai
2023-10-19 13:30 ` rguenther at suse dot de
2023-11-01  7:33 ` pan2.li at intel dot com
2023-11-06 10:27 ` rguenth at gcc dot gnu.org
2023-11-06 10:44 ` juzhe.zhong at rivai dot ai
2023-11-23  1:20 ` cvs-commit at gcc dot gnu.org
2023-11-23  1:29 ` pan2.li at intel dot com

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-111720-4-M34uhOUzdI@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).