Bug 112332 - [14 regression] ICE: internal compiler error: in extract_constrain_insn, at recog.cc:2705
Summary: [14 regression] ICE: internal compiler error: in extract_constrain_insn, at r...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: 14.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2023-11-01 10:50 UTC by Sergei Trofimovich
Modified: 2023-11-01 17:24 UTC (History)
1 user (show)

See Also:
Host:
Target: x86
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2023-11-01 10:50:11 UTC
Noticed ICE today when attempted to build python-3.11.6 with gcc-master r14-5055-g7480dbb6e7891f.

Extracted reproducer:

// $ cat dtoa.c.c
typedef union {
  double d;
  int L[2];
} U;
void d2b();
char _Py_dg_dtoa(double dd) {
  int be;
  U u;
  u.d = dd;
  if ((&u)->L[1])
    d2b(&be);
  goto failed_malloc;
  goto fast_failed;
  goto one_digit;
  goto no_digits;
  goto ret1;
  goto bump_up;
fast_failed:
bump_up:
no_digits:
one_digit:
ret1:
failed_malloc:
  return 0;
}

Crashing:

./gcc/xgcc -Bgcc -O2 -fstack-protector-strong dtoa.c.c -o a.o
dtoa.c.c: In function ‘_Py_dg_dtoa’:
dtoa.c.c:25:1: error: insn does not satisfy its constraints:
   25 | }
      | ^
(insn 51 3 9 2 (parallel [
            (set (mem/v/f/c:DI (plus:DI (reg/f:DI 7 sp)
                        (const_int 8 [0x8])) [4 D.2786+0 S8 A64])
                (unspec:DI [
                        (mem/v/f:DI (const_int 40 [0x28]) [5 MEM[(<address-space-1> long unsigned int *)40B]+0 S8 A64 AS1])
                    ] UNSPEC_SP_SET))
            (set (reg:DI 0 ax [orig:103 dd ] [103])
                (reg:DI 20 xmm0 [109]))
        ]) "dtoa.c.c":10:6 1461 {*stack_protect_set_2_di_di}
     (expr_list:REG_DEAD (reg:DI 20 xmm0 [109])
        (nil)))
during RTL pass: cprop_hardreg
dtoa.c.c:25:1: internal compiler error: in extract_constrain_insn, at recog.cc:2705
0x7ef71b _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        /home/slyfox/dev/git/gcc/gcc/rtl-error.cc:108
0x7ef741 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        /home/slyfox/dev/git/gcc/gcc/rtl-error.cc:118
0x7eddcb extract_constrain_insn(rtx_insn*)
        /home/slyfox/dev/git/gcc/gcc/recog.cc:2705
0xf60c47 copyprop_hardreg_forward_1
        /home/slyfox/dev/git/gcc/gcc/regcprop.cc:836
0xf61d44 execute
        /home/slyfox/dev/git/gcc/gcc/regcprop.cc:1423

Compiler:

$ ./gcc/xgcc -Bgcc -v
Reading specs from gcc/specs
COLLECT_GCC=./gcc/xgcc
COLLECT_LTO_WRAPPER=gcc/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/slyfox/dev/git/gcc/configure --disable-bootstrap --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231101 (experimental) (GCC)
Comment 1 Sergei Trofimovich 2023-11-01 10:55:00 UTC
Slightly shorter example:

typedef union {
  double d;
  int L[2];
} U;
void d2b(int*);
void _Py_dg_dtoa(double dd) {
  int be;
  U u;
  u.d = dd;
  if ((&u)->L[1])
    d2b(&be);
}
Comment 2 Uroš Bizjak 2023-11-01 10:57:54 UTC
(In reply to Sergei Trofimovich from comment #1)
> Slightly shorter example:
> 
> typedef union {
>   double d;
>   int L[2];
> } U;
> void d2b(int*);
> void _Py_dg_dtoa(double dd) {
>   int be;
>   U u;
>   u.d = dd;
>   if ((&u)->L[1])
>     d2b(&be);
> }

Let's put back those extran constraints...
Comment 3 Uroš Bizjak 2023-11-01 11:01:17 UTC
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 35d073c9a21..75c75f610c2 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -25748,7 +25748,7 @@ (define_peephole2
              (set (match_operand:W 2 "general_reg_operand") (const_int 0))
              (clobber (reg:CC FLAGS_REG))])
    (set (match_operand:SWI48 3 "general_reg_operand")
-       (match_operand:SWI48 4 "general_operand"))]
+       (match_operand:SWI48 4 "general_gr_operand"))]
   "peep2_reg_dead_p (0, operands[3])
    && peep2_reg_dead_p (1, operands[2])"
   [(parallel [(set (match_dup 0)
Comment 4 GCC Commits 2023-11-01 11:14:26 UTC
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:64f3a1937a2b87ebe5f3c1bf2ceec48bfbcd4ccf

commit r14-5056-g64f3a1937a2b87ebe5f3c1bf2ceec48bfbcd4ccf
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed Nov 1 12:06:36 2023 +0100

    i386: Fix stack protector peephole2 operand predicate [PR112332]
    
            PR target/112332
    
    gcc/ChangeLog:
    
            * config/i386/i386.md (stack_protexct_set_2 peephole2):
            Use general_gr_operand as operand 4 predicate.
Comment 5 Uroš Bizjak 2023-11-01 11:15:07 UTC
Fixed.
Comment 6 Sergei Trofimovich 2023-11-01 12:44:30 UTC
I confirm that the fix also fixes original python-3.11.6 build failure. Thank you!