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/112773] [14 Regression] RISC-V ICE: in force_align_down_and_div, at poly-int.h:1828 on rv32gcv_zvl256b
Date: Fri, 01 Dec 2023 12:07:50 +0000	[thread overview]
Message-ID: <bug-112773-4-Kz7BoGOCDk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112773-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-12-01

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue might be we do not use vec_extract for memory arguments:

  /* Use vec_extract patterns for extracting parts of vectors whenever
     available.  If that fails, see whether the current modes and bitregion
     give a natural subreg.  */                  
  machine_mode outermode = GET_MODE (op0);
  if (VECTOR_MODE_P (outermode) && !MEM_P (op0))
    {   

and somehow the original reg operand got spilled inbetween.  That happens
here, after we could make vec_extract work for this.

  /* Make sure we are playing with integral modes.  Pun with subregs
     if we aren't.  */
  opt_scalar_int_mode op0_mode = int_mode_for_mode (GET_MODE (op0));
  scalar_int_mode imode;
  if (!op0_mode.exists (&imode) || imode != GET_MODE (op0))
    { 
...
      else
        {
          poly_int64 size = GET_MODE_SIZE (GET_MODE (op0));
          rtx mem = assign_stack_temp (GET_MODE (op0), size);
          emit_move_insn (mem, op0);
          op0 = adjust_bitfield_address_size (mem, BLKmode, 0, size);
        }

now, if we spilled we can elide the round-down I think (which is for
the fear of accessing invalid memory).  Thus like the following?

diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index b294eabb08d..e2b38b87bdf 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -1856,7 +1856,7 @@ extract_bit_field_1 (rtx str_rtx, poly_uint64 bitsize,
poly_uint64 bitnum,
   /* If we have a memory source and a non-constant bit offset, restrict
      the memory to the referenced bytes.  This is a worst-case fallback
      but is useful for things like vector booleans.  */
-  if (MEM_P (op0) && !bitnum.is_constant ())
+  if (MEM_P (str_rtx) && !bitnum.is_constant ())
     {
       bytenum = bits_to_bytes_round_down (bitnum);
       bitnum = num_trailing_bits (bitnum);

but that defers the ICE to

during RTL pass: expand
t.c: In function 'e':
t.c:4:6: internal compiler error: in to_constant, at poly-int.h:588
    4 | void e(unsigned f) {
      |      ^
0x10ea530 poly_int<2u, unsigned long>::to_constant() const
        /home/rguenther/src/trunk/gcc/poly-int.h:588
0x13cec67 extract_bit_field_1
        /home/rguenther/src/trunk/gcc/expmed.cc:1872

so I guess we really need to match the vec_extract pattern.

So you need to debug why that doesn't match here.

  parent reply	other threads:[~2023-12-01 12:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30  3:10 [Bug target/112773] New: " patrick at rivosinc dot com
2023-11-30  8:46 ` [Bug target/112773] " rguenth at gcc dot gnu.org
2023-11-30  9:06 ` juzhe.zhong at rivai dot ai
2023-11-30 17:10 ` patrick at rivosinc dot com
2023-12-01  1:57 ` juzhe.zhong at rivai dot ai
2023-12-01  2:01 ` juzhe.zhong at rivai dot ai
2023-12-01  2:02 ` juzhe.zhong at rivai dot ai
2023-12-01  2:05 ` patrick at rivosinc dot com
2023-12-01  2:05 ` juzhe.zhong at rivai dot ai
2023-12-01 10:27 ` rdapp at gcc dot gnu.org
2023-12-01 11:54 ` rdapp at gcc dot gnu.org
2023-12-01 12:07 ` rguenth at gcc dot gnu.org [this message]
2023-12-01 12:44 ` rdapp at gcc dot gnu.org
2023-12-01 13:20 ` rguenther at suse dot de
2023-12-01 21:16 ` rdapp at gcc dot gnu.org
2023-12-14 16:54 ` cvs-commit at gcc dot gnu.org
2023-12-14 19:51 ` patrick at rivosinc dot com
2023-12-14 20:13 ` rdapp at gcc dot gnu.org
2023-12-14 21:09 ` patrick at rivosinc 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-112773-4-Kz7BoGOCDk@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).