public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548
@ 2020-08-31 10:30 asolokha at gmx dot com
  2024-04-17  8:46 ` [Bug rtl-optimization/96865] " jeevitha at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: asolokha at gmx dot com @ 2020-08-31 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96865
           Summary: ICE in hash_rtx_cb, at cse.c:2548
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---
            Target: powerpc-*-linux-gnu

gcc-11.0.0-alpha20200830 snapshot (g:6ccadc4c0486ff011a32c74de1a31148acb3cbe2)
ICEs when compiling the following testcase, reduced from
gcc/testsuite/gcc.target/sparc/tls-ld-uint16.c, w/ -m32 -O2 -fPIC
-fselective-scheduling:

__thread int ky __attribute__ ((tls_model ("local-dynamic")));

void
y9 (int cw)
{
  ky = cw;
}

% powerpc-e300c3-linux-gnu-gcc-11.0.0 -m32 -O2 -fPIC -fselective-scheduling -c
ggkraci7.c
during RTL pass: sched1
ggkraci7.c: In function 'y9':
ggkraci7.c:7:1: internal compiler error: in hash_rtx_cb, at cse.c:2548
    7 | }
      | ^
0x75e4f1 hash_rtx_cb(rtx_def const*, machine_mode, int*, int*, bool, int
(*)(rtx_def const*, machine_mode, rtx_def**, machine_mode*))
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/cse.c:2548
0x159e1fc hash_rtx_cb(rtx_def const*, machine_mode, int*, int*, bool, int
(*)(rtx_def const*, machine_mode, rtx_def**, machine_mode*))
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/cse.c:2526
0xd3eff8 vinsn_init
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched-ir.c:1199
0xd4243f vinsn_create
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched-ir.c:1231
0xd4243f init_global_and_expr_for_insn
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched-ir.c:3028
0xd352db sched_scan
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched-ir.c:2818
0xd3804a sel_init_global_and_expr(vec<basic_block_def*, va_heap, vl_ptr>)
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched-ir.c:3050
0xd52743 sel_region_init
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched.c:6901
0xd52743 sel_sched_region(int)
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched.c:7624
0xd53c59 run_selective_scheduling()
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sel-sched.c:7720
0xd33904 rest_of_handle_sched
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sched-rgn.c:3724
0xd33904 execute
       
/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-11.0.0_alpha20200830/work/gcc-11-20200830/gcc/sched-rgn.c:3834

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

* [Bug rtl-optimization/96865] ICE in hash_rtx_cb, at cse.c:2548
  2020-08-31 10:30 [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548 asolokha at gmx dot com
@ 2024-04-17  8:46 ` jeevitha at gcc dot gnu.org
  2024-04-17 14:37 ` bergner at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jeevitha at gcc dot gnu.org @ 2024-04-17  8:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jeevitha <jeevitha at gcc dot gnu.org> changed:

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

--- Comment #1 from Jeevitha <jeevitha at gcc dot gnu.org> ---
The issue was in the following RTL,
(insn 6 2 21 2 (parallel [
            (set (reg:SI 96 lr)
                (unspec:SI [
                        (symbol_ref:SI ("_GLOBAL_OFFSET_TABLE_") [flags 0x42])
                        (label_ref 0)
                    ] UNSPEC_TOCPTR))
            (code_label 0 0 0 2 (nil) [2 uses])
        ]) "test.c":6:6 798 {load_toc_v4_PIC_1b_normal}

The above RTL will generate the following assembly:

        bcl 20,31,$+8

There is no need for 'label_ref 0' and 'code_label' in the RTL instruction, as
the assembly does not require them. Is my understanding correct?

Currently, we are encountering an ICE due to the following reason: In the
'hash_rtx' function [cse.cc], handling for 'LABEL_REF' is present but not for
'code_label', causing it to not return a hash directly. Instead, it searches
for the format corresponding to '(code_label 0 0 0 4 (nil))', which is
"uuB00is". In the provided code snippet below, 'B' and 'u' do not have case
handling, leading to a 'gcc_unreachable'. This is the reason for the ICE
currently.


fmt = GET_RTX_FORMAT (code);  //code -> code_label
  for (; i >= 0; i--)
    {
      switch (fmt[i])
        {
        case 'e':
          /* If we are about to do the last recursive call
             needed at this level, change it into iteration.
             This function  is called enough to be worth it.  */
          if (i == 0)
            {
              x = XEXP (x, i);
              goto repeat;
            }

          hash += hash_rtx (XEXP (x, i), VOIDmode, do_not_record_p,
                            hash_arg_in_memory_p,
                            have_reg_qty, cb);
          break;

        case 'E':
          for (j = 0; j < XVECLEN (x, i); j++)
            hash += hash_rtx (XVECEXP (x, i, j), VOIDmode, do_not_record_p,
                              hash_arg_in_memory_p,
                              have_reg_qty, cb);
          break;

        case 's':
          hash += hash_rtx_string (XSTR (x, i));
          break;

        case 'i':
          hash += (unsigned int) XINT (x, i);
          break;

        case 'p':
          hash += constant_lower_bound (SUBREG_BYTE (x));
          break;

        case '0': case 't':
          /* Unused.  */
          break;

        default:
          gcc_unreachable ();
        }
    }

To address this, I've removed 'operand1' and adjusted the respective
'match_dup' to 'operand0' in the below pattern.

(define_insn "load_toc_v4_PIC_1b_normal"
  [(set (reg:SI LR_REGNO)
        (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
                    (label_ref (match_operand 1 "" ""))]
                UNSPEC_TOCPTR))
   (match_dup 1)]

After implementing the mentioned change, there were no ICEs or regressions. Is
this approach correct?

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

* [Bug rtl-optimization/96865] ICE in hash_rtx_cb, at cse.c:2548
  2020-08-31 10:30 [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548 asolokha at gmx dot com
  2024-04-17  8:46 ` [Bug rtl-optimization/96865] " jeevitha at gcc dot gnu.org
@ 2024-04-17 14:37 ` bergner at gcc dot gnu.org
  2024-04-17 14:41 ` bergner at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bergner at gcc dot gnu.org @ 2024-04-17 14:37 UTC (permalink / raw)
  To: gcc-bugs

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

Peter Bergner <bergner at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

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

* [Bug rtl-optimization/96865] ICE in hash_rtx_cb, at cse.c:2548
  2020-08-31 10:30 [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548 asolokha at gmx dot com
  2024-04-17  8:46 ` [Bug rtl-optimization/96865] " jeevitha at gcc dot gnu.org
  2024-04-17 14:37 ` bergner at gcc dot gnu.org
@ 2024-04-17 14:41 ` bergner at gcc dot gnu.org
  2024-04-17 15:06 ` segher at gcc dot gnu.org
  2024-04-17 15:11 ` segher at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: bergner at gcc dot gnu.org @ 2024-04-17 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

Peter Bergner <bergner at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |12.0, 13.0, 14.0

--- Comment #2 from Peter Bergner <bergner at gcc dot gnu.org> ---
Fails on trunk and basically all earlier versions.

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

* [Bug rtl-optimization/96865] ICE in hash_rtx_cb, at cse.c:2548
  2020-08-31 10:30 [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2024-04-17 14:41 ` bergner at gcc dot gnu.org
@ 2024-04-17 15:06 ` segher at gcc dot gnu.org
  2024-04-17 15:11 ` segher at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: segher at gcc dot gnu.org @ 2024-04-17 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |abel at ispras dot ru

--- Comment #3 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Yup.  I thought there would be missing options needed for this to fail (-mcpu=
for example), but it fails with plain trunk.

Something with sel-sched.  It works fine without that.

Putting the maintainers of selective scheduling on Cc:.

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

* [Bug rtl-optimization/96865] ICE in hash_rtx_cb, at cse.c:2548
  2020-08-31 10:30 [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2024-04-17 15:06 ` segher at gcc dot gnu.org
@ 2024-04-17 15:11 ` segher at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: segher at gcc dot gnu.org @ 2024-04-17 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Well, I wanted to add Alex as well, but BZ does not allow that?  Says he does
not exist?

Is there some other mail address than that mentioned in MAINTAINERS, the one he
usually uses, that works, maybe @gcc.gnu.org?

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

end of thread, other threads:[~2024-04-17 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 10:30 [Bug rtl-optimization/96865] New: ICE in hash_rtx_cb, at cse.c:2548 asolokha at gmx dot com
2024-04-17  8:46 ` [Bug rtl-optimization/96865] " jeevitha at gcc dot gnu.org
2024-04-17 14:37 ` bergner at gcc dot gnu.org
2024-04-17 14:41 ` bergner at gcc dot gnu.org
2024-04-17 15:06 ` segher at gcc dot gnu.org
2024-04-17 15:11 ` segher at gcc dot gnu.org

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