public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670
@ 2021-08-25  8:29 haoxintu at gmail dot com
  2021-08-25  8:57 ` [Bug target/102057] " ubizjak at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: haoxintu at gmail dot com @ 2021-08-25  8:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102057
           Summary: ICE at -O2 in extract_constrain_insn, at recog.c:2670
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi all.

This program makes GCC ICE. I think this program is syntactically valid and GCC
should not emit any error. I found there are many fixed PRs that crash at the
same point "recog.c:2670" and similar stack information. So, I am not sure if
this is a dup case, and please kindly close it if it is.

$cat small.c
#include <stdint.h>
extern n(int f);
a, b, c, d, e, f, g, i;
fn1(int64_t j, uint16_t k) {
  uint64_t *l = c;
  int8_t m;
  if (n(f))
    if (*l) {
      int8_t o;
      uint16_t *p = &k;
      if (i) {
        int64_t q = e;
        if (q)
          for (; *p <= 5; k += o)
            ;
      }
    }
  e = 8;
  while (e--) {
    a = 7;
    while (a) {
      a -= 5;
      if (i)
        if (5 << m)
          while (i)
            i += 4;
      for (; b;)
        ;
    }
  }
  int32_t r;
  g = (d ? k : m) >> (r = 2) ?: 3;
  for (; *l; l += f++) {
    int64_t *s;
    if (*s)
      for (; j;)
        if (0 / 0)
          for (;;)
            ;
  }
}

$gcc -O2 -w -fPIC small.c
small.c: In function ‘fn1’:
small.c:41:1: error: insn does not satisfy its constraints:
   41 | }
      | ^
(insn 429 394 430 22 (parallel [
            (set (reg:CCZ 17 flags)
                (compare:CCZ (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
                        (const_int 2 [0x2]))
                    (const_int 0 [0])))
            (set (reg:SI 41 r13 [orig:137 k ] [137])
                (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
                    (const_int 2 [0x2])))
        ]) "small.c":32:31 740 {*ashrsi3_cmp}
     (expr_list:REG_DEAD (reg:SI 0 ax [orig:90 _12 ] [90])
        (nil)))
during RTL pass: cprop_hardreg
small.c:41:1: internal compiler error: in extract_constrain_insn, at
recog.c:2670
0x681355 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        ../../gcc/rtl-error.c:108
0x68137b _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        ../../gcc/rtl-error.c:118
0x680484 extract_constrain_insn(rtx_insn*)
        ../../gcc/recog.c:2670
0xb738ce copyprop_hardreg_forward_1
        ../../gcc/regcprop.c:825
0xb7481d execute
        ../../gcc/regcprop.c:1390
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/haoxin/haoxin-data/compilers/gcc/build/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/home/haoxin/haoxin-data/compilers/gcc/build/ --enable-bootstrap
--enable-checking=release --enable-languages=c,c++ --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210825 (experimental) (GCC)

Reproduced in Godbol: https://godbolt.org/z/EfMa7zrcj

Thanks,
Haoxin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/102057] ICE at -O2 in extract_constrain_insn, at recog.c:2670
  2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
@ 2021-08-25  8:57 ` ubizjak at gmail dot com
  2021-08-25  9:03 ` [Bug target/102057] [12 Regression] " pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ubizjak at gmail dot com @ 2021-08-25  8:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
A recently added peephole is converting:

(insn 229 108 280 22 (parallel [
            (set (reg:CCZ 17 flags)
                (compare:CCZ (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
                        (const_int 2 [0x2]))
                    (const_int 0 [0])))
            (set (reg:SI 0 ax [orig:90 _12 ] [90])
                (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
                    (const_int 2 [0x2])))
        ]) "pr102057.c":32:31 740 {*ashrsi3_cmp}
     (nil))
(insn 280 229 231 22 (set (reg:SI 1 dx [141])
        (const_int 3 [0x3])) "pr102057.c":32:31 75 {*movsi_internal}
     (expr_list:REG_EQUIV (const_int 3 [0x3])
        (nil)))
(insn 231 280 114 22 (set (reg:SI 0 ax [orig:99 iftmp.13_29 ] [99])
        (if_then_else:SI (ne (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (reg:SI 0 ax [orig:99 iftmp.13_29 ] [99])
            (reg:SI 1 dx [141]))) "pr102057.c":32:31 1140 {*movsicc_noc}
     (expr_list:REG_DEAD (reg:CCZ 17 flags)
        (expr_list:REG_DEAD (reg:SI 1 dx [141])
            (nil))))

to:

(insn 429 228 430 22 (parallel [
            (set (reg:CCZ 17 flags)
                (compare:CCZ (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
                        (const_int 2 [0x2]))
                    (const_int 0 [0])))
            (set (reg:SI 41 r13 [orig:137 k ] [137])
                (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
                    (const_int 2 [0x2])))
        ]) "pr102057.c":32:31 -1
     (nil))
(insn 430 429 431 22 (set (reg:SI 0 ax [orig:90 _12 ] [90])
        (const_int 3 [0x3])) "pr102057.c":32:31 -1
     (nil))
(insn 431 430 114 22 (set (reg:SI 0 ax [orig:90 _12 ] [90])
        (if_then_else:SI (ne (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (reg:SI 41 r13 [orig:137 k ] [137])
            (reg:SI 0 ax [orig:90 _12 ] [90]))) "pr102057.c":32:31 -1
     (nil))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/102057] [12 Regression] ICE at -O2 in extract_constrain_insn, at recog.c:2670
  2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
  2021-08-25  8:57 ` [Bug target/102057] " ubizjak at gmail dot com
@ 2021-08-25  9:03 ` pinskia at gcc dot gnu.org
  2021-08-25  9:14 ` ubizjak at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-25  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |12.0
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-08-25
            Summary|ICE at -O2 in               |[12 Regression] ICE at -O2
                   |extract_constrain_insn, at  |in extract_constrain_insn,
                   |recog.c:2670                |at recog.c:2670

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/102057] [12 Regression] ICE at -O2 in extract_constrain_insn, at recog.c:2670
  2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
  2021-08-25  8:57 ` [Bug target/102057] " ubizjak at gmail dot com
  2021-08-25  9:03 ` [Bug target/102057] [12 Regression] " pinskia at gcc dot gnu.org
@ 2021-08-25  9:14 ` ubizjak at gmail dot com
  2021-08-25  9:45 ` ubizjak at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ubizjak at gmail dot com @ 2021-08-25  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sayle at gcc dot gnu.org

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
Regressed by r12-2640

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/102057] [12 Regression] ICE at -O2 in extract_constrain_insn, at recog.c:2670
  2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-25  9:14 ` ubizjak at gmail dot com
@ 2021-08-25  9:45 ` ubizjak at gmail dot com
  2021-08-26 15:27 ` cvs-commit at gcc dot gnu.org
  2021-08-26 15:30 ` ubizjak at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: ubizjak at gmail dot com @ 2021-08-25  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
Oooh, default argument!

--cut here--
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 41d85623ad6..528116dfe2d 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -19475,8 +19472,8 @@
                                          (match_dup 0)))]
 {
   operands[7] = SET_DEST (XVECEXP (PATTERN (peep2_next_insn (1)), 0, 0));
-  operands[8] = replace_rtx (operands[5], operands[0], operands[1]);
-  operands[9] = replace_rtx (operands[6], operands[0], operands[1]);
+  operands[8] = replace_rtx (operands[5], operands[0], operands[1], true);
+  operands[9] = replace_rtx (operands[6], operands[0], operands[1], true);
 })

 ;; Eliminate a reg-reg mov by inverting the condition of a cmov (#2).
@@ -19507,8 +19504,8 @@
                                          (match_dup 0)))]
 {
   operands[7] = SET_DEST (XVECEXP (PATTERN (peep2_next_insn (2)), 0, 0));
-  operands[8] = replace_rtx (operands[5], operands[0], operands[1]);
-  operands[9] = replace_rtx (operands[6], operands[0], operands[1]);
+  operands[8] = replace_rtx (operands[5], operands[0], operands[1], true);
+  operands[9] = replace_rtx (operands[6], operands[0], operands[1], true);
 })

 (define_expand "mov<mode>cc"
--cut here--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/102057] [12 Regression] ICE at -O2 in extract_constrain_insn, at recog.c:2670
  2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2021-08-25  9:45 ` ubizjak at gmail dot com
@ 2021-08-26 15:27 ` cvs-commit at gcc dot gnu.org
  2021-08-26 15:30 ` ubizjak at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-26 15:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:226eb7ff5d73669184a4a56cd348fa6c46b3ec52

commit r12-3162-g226eb7ff5d73669184a4a56cd348fa6c46b3ec52
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Thu Aug 26 17:26:06 2021 +0200

    [i386] Set all_regs to true in the call to replace_rtx [PR102057]

    We want to replace all REGs equal to FROM.

    2021-08-26  Uroš Bizjak  <ubizjak@gmail.com>

    gcc/
            PR target/102057
            * config/i386/i386.md (cmove reg-reg move elimination peephole2s):
            Set all_regs to true in the call to replace_rtx.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/102057] [12 Regression] ICE at -O2 in extract_constrain_insn, at recog.c:2670
  2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
                   ` (4 preceding siblings ...)
  2021-08-26 15:27 ` cvs-commit at gcc dot gnu.org
@ 2021-08-26 15:30 ` ubizjak at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: ubizjak at gmail dot com @ 2021-08-26 15:30 UTC (permalink / raw)
  To: gcc-bugs

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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |ubizjak at gmail dot com
             Target|                            |x86_64

--- Comment #6 from Uroš Bizjak <ubizjak at gmail dot com> ---
Fixed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-26 15:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25  8:29 [Bug target/102057] New: ICE at -O2 in extract_constrain_insn, at recog.c:2670 haoxintu at gmail dot com
2021-08-25  8:57 ` [Bug target/102057] " ubizjak at gmail dot com
2021-08-25  9:03 ` [Bug target/102057] [12 Regression] " pinskia at gcc dot gnu.org
2021-08-25  9:14 ` ubizjak at gmail dot com
2021-08-25  9:45 ` ubizjak at gmail dot com
2021-08-26 15:27 ` cvs-commit at gcc dot gnu.org
2021-08-26 15:30 ` ubizjak at gmail dot com

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).