public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/104446] [9/10/11/12 Regression] ICE in trunc_int_for_mode, at explow.cc:59 since r9-6999
Date: Fri, 11 Feb 2022 12:52:07 +0000	[thread overview]
Message-ID: <bug-104446-4-AUks87IzM4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104446-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:fb76c0ad35f96505ecd9213849ebc3df6163a0f7

commit r12-7196-gfb76c0ad35f96505ecd9213849ebc3df6163a0f7
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 11 11:34:46 2022 +0100

    combine: Fix ICE with substitution of CONST_INT into PRE_DEC argument
[PR104446]

    The following testcase ICEs, because combine substitutes
    (insn 10 9 11 2 (set (reg/v:SI 7 sp [ a ])
            (const_int 0 [0])) "pr104446.c":9:5 81 {*movsi_internal}
         (nil))
    (insn 13 11 14 2 (set (mem/f:SI (pre_dec:SI (reg/f:SI 7 sp)) [0  S4 A32])
            (reg:SI 85)) "pr104446.c":10:3 56 {*pushsi2}
         (expr_list:REG_DEAD (reg:SI 85)
            (expr_list:REG_ARGS_SIZE (const_int 16 [0x10])
                (nil))))
    forming
    (insn 13 11 14 2 (set (mem/f:SI (pre_dec:SI (const_int 0 [0])) [0  S4 A32])
            (reg:SI 85)) "pr104446.c":10:3 56 {*pushsi2}
         (expr_list:REG_DEAD (reg:SI 85)
            (expr_list:REG_ARGS_SIZE (const_int 16 [0x10])
                (nil))))
    which is invalid RTL (pre_dec's argument must be a REG).
    I know substitution creates various forms of invalid RTL and hopes that
    invalid RTL just won't recog.
    But unfortunately in this case we ICE before we get to recog, as
    try_combine does:
      if (n_auto_inc)
        {
          int new_n_auto_inc = 0;
          for_each_inc_dec (newpat, count_auto_inc, &new_n_auto_inc);

          if (n_auto_inc != new_n_auto_inc)
            {
              if (dump_file && (dump_flags & TDF_DETAILS))
                fprintf (dump_file, "Number of auto_inc expressions
changed\n");
              undo_all ();
              return 0;
            }
        }
    and for_each_inc_dec under the hood will do e.g. for the PRE_DEC case:
        case PRE_DEC:
        case POST_DEC:
          {
            poly_int64 size = GET_MODE_SIZE (GET_MODE (mem));
            rtx r1 = XEXP (x, 0);
            rtx c = gen_int_mode (-size, GET_MODE (r1));
            return fn (mem, x, r1, r1, c, data);
          }
    and that code rightfully expects that the PRE_DEC operand has non-VOIDmode
    (as it needs to be a REG) - gen_int_mode for VOIDmode results in ICE.
    I think it is better not to emit the clearly invalid RTL during
substitution
    like we do for other cases, than to adding workarounds for invalid IL
    created by combine to rtlanal.cc and perhaps elsewhere.
    As for the testcase, of course it is UB at runtime to modify sp that way,
    but if such code is never reached, we must compile it, not to ICE on it.
    And I don't see why on other targets which use the autoinc rtxes much more
    it couldn't happen with other registers.

    2022-02-11  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/104446
            * combine.cc (subst): Don't substitute CONST_INTs into RTX_AUTOINC
            operands.

            * gcc.target/i386/pr104446.c: New test.

  parent reply	other threads:[~2022-02-11 12:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 19:40 [Bug c/104446] New: [9/10/11/12 Regression] ICE in trunc_int_for_mode, at explow.cc:59 gscfq@t-online.de
2022-02-08 21:37 ` [Bug middle-end/104446] " pinskia at gcc dot gnu.org
2022-02-09  7:32 ` rguenth at gcc dot gnu.org
2022-02-09  9:04 ` [Bug middle-end/104446] [9/10/11/12 Regression] ICE in trunc_int_for_mode, at explow.cc:59 since r9-6999 jakub at gcc dot gnu.org
2022-02-09 11:13 ` jakub at gcc dot gnu.org
2022-02-09 11:32 ` jakub at gcc dot gnu.org
2022-02-10  7:47 ` segher at gcc dot gnu.org
2022-02-11 12:52 ` cvs-commit at gcc dot gnu.org [this message]
2022-02-11 12:53 ` [Bug middle-end/104446] [9/10/11 " jakub at gcc dot gnu.org
2022-02-19  8:02 ` cvs-commit at gcc dot gnu.org
2022-02-19  8:08 ` [Bug middle-end/104446] [9/10 " jakub at gcc dot gnu.org
2022-05-10  8:23 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:24 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub 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-104446-4-AUks87IzM4@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).