public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
@ 2024-08-19  7:56 schwab@linux-m68k.org
  2024-08-19  8:01 ` [Bug target/116413] " schwab@linux-m68k.org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116413
           Summary: [LRA] [M68K] ICE: unrecognized insn in
                    lra_set_insn_recog_data, at lra.cc:1036
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, ra
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: schwab@linux-m68k.org
            Blocks: 113939
  Target Milestone: ---

With LRA enabled:

$ gcc/xgcc -B gcc/ -mcpu=5235 -Os
../gcc/gcc/testsuite/gcc.target/m68k/pr64461.c -S
during RTL pass: reload
../gcc/gcc/testsuite/gcc.target/m68k/pr64461.c: In function
‘rtems_rfs_block_map_indirect_alloc’:
../gcc/gcc/testsuite/gcc.target/m68k/pr64461.c:16:1: internal compiler error:
in lra_set_insn_recog_data, at lra.cc:1036
   16 | }
      | ^
0x1bf2c7e internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:491
0x6734a1 fancy_abort(char const*, int, char const*)
        ../../gcc/gcc/diagnostic.cc:1772
0xbfc0df lra_set_insn_recog_data(rtx_insn*)
        ../../gcc/gcc/lra.cc:1034
0xbfca56 lra_get_insn_recog_data(rtx_insn*)
        ../../gcc/gcc/lra-int.h:503
0xbfca56 setup_sp_offset
        ../../gcc/gcc/lra.cc:1877
0xbfe415 lra_process_new_insns(rtx_insn*, rtx_insn*, rtx_insn*, char const*)
        ../../gcc/gcc/lra.cc:1925
0xc15ca6 curr_insn_transform
        ../../gcc/gcc/lra-constraints.cc:4868
0xc17286 lra_constraints(bool)
        ../../gcc/gcc/lra-constraints.cc:5496
0xbff57a lra(_IO_FILE*, int)
        ../../gcc/gcc/lra.cc:2442
0xbad357 do_reload
        ../../gcc/gcc/ira.cc:5976
0xbad357 execute
        ../../gcc/gcc/ira.cc:6164


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113939
[Bug 113939] Switch m68k to LRA

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
@ 2024-08-19  8:01 ` schwab@linux-m68k.org
  2024-08-19  8:25 ` schwab@linux-m68k.org
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19  8:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
(insn 20 17 21 2 (set (reg:SI 43)
        (plus:SI (ashift:SI (reg/v:SI 40 [ b ])
                (const_int 2 [0x2]))
            (reg/v/f:SI 39 [ buffer ])))
"../../gcc/gcc/testsuite/gcc.target/m68k/pr64461.c":15:25 -1
     (nil))

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
  2024-08-19  8:01 ` [Bug target/116413] " schwab@linux-m68k.org
@ 2024-08-19  8:25 ` schwab@linux-m68k.org
  2024-08-19  9:42 ` schwab@linux-m68k.org
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19  8:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
This is generated without LRA:

(insn 22 17 9 2 (set (reg:SI 9 %a1)
        (plus:SI (plus:SI (mult:SI (reg/v:SI 0 %d0 [orig:40 b ] [40])
                    (const_int 4 [0x4]))
                (reg/v/f:SI 9 %a1 [orig:38 map ] [38]))
            (const_int 3 [0x3])))
"../../gcc/gcc/testsuite/gcc.target/m68k/pr64461.c":15:25 407 {*lea}
     (nil))
(insn 9 22 12 2 (set (mem:QI (plus:SI (plus:SI (mult:SI (reg/v:SI 0 %d0
[orig:40 b ] [40])
                        (const_int 4 [0x4]))
                    (reg/v/f:SI 8 %a0 [orig:39 buffer ] [39]))
                (const_int 3 [0x3])) [0 *_5+0 S1 A8])
        (mem:QI (reg:SI 9 %a1) [1 map_8(D)->blocks[b_9(D)]+3 S1 A8]))
"../../gcc/gcc/testsuite/gcc.target/m68k/pr64461.c":15:25 63 {*m68k.md:1137}
     (nil))

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
  2024-08-19  8:01 ` [Bug target/116413] " schwab@linux-m68k.org
  2024-08-19  8:25 ` schwab@linux-m68k.org
@ 2024-08-19  9:42 ` schwab@linux-m68k.org
  2024-08-19 12:59 ` schwab@linux-m68k.org
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
The issue is that LRA canonicalizes MULT to ASHIFT (outside of MEM), but
m68k_decompose_index only recognizes MULT, so that *lea fails to match.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (2 preceding siblings ...)
  2024-08-19  9:42 ` schwab@linux-m68k.org
@ 2024-08-19 12:59 ` schwab@linux-m68k.org
  2024-08-19 13:02 ` schwab@linux-m68k.org
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> ---
Created attachment 58956
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58956&action=edit
Accept ASHIFT like MULT

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (3 preceding siblings ...)
  2024-08-19 12:59 ` schwab@linux-m68k.org
@ 2024-08-19 13:02 ` schwab@linux-m68k.org
  2024-08-19 13:16 ` schwab@linux-m68k.org
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19 13:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
With that patch, *lea is used in more places and LRA fails to remove the inner
SUBREG.

../../../gcc/libgcc/libgcov-profiler.c: In function ‘__gcov_interval_profiler’:
../../../gcc/libgcc/libgcov-profiler.c:46:1: error: insn does not satisfy its
constraints:
   46 | }
      | ^
(insn 41 65 66 6 (set (reg/f:SI 8 %a0 [orig:44 _14 ] [44])
        (plus:SI (ashift:SI (subreg:SI (reg/v:DI 0 %d0 [orig:47 delta ] [47])
4)
                (const_int 3 [0x3]))
            (reg:SI 9 %a1))) "../../../gcc/libgcc/libgcov-profiler.c":45:13 407
{*lea}
     (nil))
during RTL pass: postreload

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (4 preceding siblings ...)
  2024-08-19 13:02 ` schwab@linux-m68k.org
@ 2024-08-19 13:16 ` schwab@linux-m68k.org
  2024-08-19 13:31 ` schwab@linux-m68k.org
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andreas Schwab <schwab@linux-m68k.org> ---
Created attachment 58957
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58957&action=edit
_gcov_interval_profiler.i

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (5 preceding siblings ...)
  2024-08-19 13:16 ` schwab@linux-m68k.org
@ 2024-08-19 13:31 ` schwab@linux-m68k.org
  2024-08-19 13:36 ` matz at gcc dot gnu.org
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-19 13:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andreas Schwab <schwab@linux-m68k.org> ---
Comment #5 was built _without_ LRA.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (6 preceding siblings ...)
  2024-08-19 13:31 ` schwab@linux-m68k.org
@ 2024-08-19 13:36 ` matz at gcc dot gnu.org
  2024-08-20  9:00 ` rsandifo at gcc dot gnu.org
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: matz at gcc dot gnu.org @ 2024-08-19 13:36 UTC (permalink / raw)
  To: gcc-bugs

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

Michael Matz <matz at gcc dot gnu.org> changed:

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

--- Comment #8 from Michael Matz <matz at gcc dot gnu.org> ---
Yeah, reload doesn't expect ASHIFTs within operands here.  The below would fix
that:

diff --git a/gcc/final.cc b/gcc/final.cc
index eb9e065d9f0..5d911586de5 100644
--- a/gcc/final.cc
+++ b/gcc/final.cc
@@ -3146,6 +3146,7 @@ walk_alter_subreg (rtx *xp, bool *changed)
     case PLUS:
     case MULT:
     case AND:
+    case ASHIFT:
       XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);
       XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1), changed);
       break;

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (7 preceding siblings ...)
  2024-08-19 13:36 ` matz at gcc dot gnu.org
@ 2024-08-20  9:00 ` rsandifo at gcc dot gnu.org
  2024-08-21  8:34 ` schwab@linux-m68k.org
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-08-20  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

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

--- Comment #9 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
(In reply to Michael Matz from comment #8)
> Yeah, reload doesn't expect ASHIFTs within operands here.  The below would
> fix
> that:
> 
> diff --git a/gcc/final.cc b/gcc/final.cc
> index eb9e065d9f0..5d911586de5 100644
> --- a/gcc/final.cc
> +++ b/gcc/final.cc
> @@ -3146,6 +3146,7 @@ walk_alter_subreg (rtx *xp, bool *changed)
>      case PLUS:
>      case MULT:
>      case AND:
> +    case ASHIFT:
>        XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);
>        XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1), changed);
>        break;
LGTM FWIW.

The different canonicalisation rules around ASHIFT/MULT in memories vs outside
memories is an unfortunate wart, but what LRA is doing for lea is the correct
behaviour.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (8 preceding siblings ...)
  2024-08-20  9:00 ` rsandifo at gcc dot gnu.org
@ 2024-08-21  8:34 ` schwab@linux-m68k.org
  2024-08-21  8:56 ` rsandifo at gcc dot gnu.org
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-21  8:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Andreas Schwab <schwab@linux-m68k.org> ---
$ ./xgcc -B . ../../gcc/gcc/testsuite/gcc.c-torture/compile/opout.c -O
-std=gnu89 -mlra -S
during RTL pass: reload
../../gcc/gcc/testsuite/gcc.c-torture/compile/opout.c: In function ‘z’:
../../gcc/gcc/testsuite/gcc.c-torture/compile/opout.c:12:1: internal compiler
error: in decompose_normal_address, at rtlanal.cc:6699
   12 | }
      | ^

(plus:SI (plus:SI (ashift:SI (plus:SI (reg/f:SI 24 %argptr)
                (const_int -4 [0xfffffffffffffffc]))
            (const_int 1 [0x1]))
        (reg/f:SI 41 [ _6 ]))
    (const_int 20 [0x14]))

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (9 preceding siblings ...)
  2024-08-21  8:34 ` schwab@linux-m68k.org
@ 2024-08-21  8:56 ` rsandifo at gcc dot gnu.org
  2024-08-21  9:13 ` schwab@linux-m68k.org
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-08-21  8:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
I can't reproduce this with m68k-elf.  Do you have any local changes beyond
making TARGET_LRA_P return true?

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (10 preceding siblings ...)
  2024-08-21  8:56 ` rsandifo at gcc dot gnu.org
@ 2024-08-21  9:13 ` schwab@linux-m68k.org
  2024-08-21  9:18 ` schwab@linux-m68k.org
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-21  9:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Andreas Schwab <schwab@linux-m68k.org> ---
Which cpu are you targeting?  m68k-linux defaults to 68020.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (11 preceding siblings ...)
  2024-08-21  9:13 ` schwab@linux-m68k.org
@ 2024-08-21  9:18 ` schwab@linux-m68k.org
  2024-08-21 11:16 ` rsandifo at gcc dot gnu.org
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-21  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Andreas Schwab <schwab@linux-m68k.org> ---
And of course this is with #c4 applied.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (12 preceding siblings ...)
  2024-08-21  9:18 ` schwab@linux-m68k.org
@ 2024-08-21 11:16 ` rsandifo at gcc dot gnu.org
  2024-08-21 12:16 ` schwab@linux-m68k.org
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-08-21 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Created attachment 58967
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58967&action=edit
Patch for the decompse_mem_address ICE

Thanks.  Can you try the attached patch?

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (13 preceding siblings ...)
  2024-08-21 11:16 ` rsandifo at gcc dot gnu.org
@ 2024-08-21 12:16 ` schwab@linux-m68k.org
  2024-08-21 12:36 ` schwab@linux-m68k.org
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-21 12:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Andreas Schwab <schwab@linux-m68k.org> ---
That fixes the ICE from #10 and no further regression in gcc.c-torture.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (14 preceding siblings ...)
  2024-08-21 12:16 ` schwab@linux-m68k.org
@ 2024-08-21 12:36 ` schwab@linux-m68k.org
  2024-08-21 12:44 ` rsandifo at gcc dot gnu.org
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-21 12:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from Andreas Schwab <schwab@linux-m68k.org> ---
$ gcc/xgcc -B gcc/ -fpic ../gcc/gcc/testsuite/gcc.dg/pr52139.c -S -mlra -O 
-fno-tree-dominator-opts -fno-tree-fre
../gcc/gcc/testsuite/gcc.dg/pr52139.c: In function ‘foo’:
../gcc/gcc/testsuite/gcc.dg/pr52139.c:50:1: error: unrecognizable insn:
   50 | }
      | ^
(insn 9 49 50 4 (set (reg:HI 33)
        (mem/u/c:HI (plus:SI (ashift:SI (reg/v:SI 32 [ a ])
                    (const_int 1 [0x1]))
                (label_ref:SI 11)) [0  S2 A8]))
"../gcc/gcc/testsuite/gcc.dg/pr52139.c":12:3 -1
     (insn_list:REG_LABEL_OPERAND 11 (nil)))
during RTL pass: vregs

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (15 preceding siblings ...)
  2024-08-21 12:36 ` schwab@linux-m68k.org
@ 2024-08-21 12:44 ` rsandifo at gcc dot gnu.org
  2024-08-21 13:47 ` matz at gcc dot gnu.org
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2024-08-21 12:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
Hmm, but if the ICE is coming from vregs then it doesn't sound like it's
related to LRA.  vregs is the first RTL pass to run.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (16 preceding siblings ...)
  2024-08-21 12:44 ` rsandifo at gcc dot gnu.org
@ 2024-08-21 13:47 ` matz at gcc dot gnu.org
  2024-08-27  8:48 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: matz at gcc dot gnu.org @ 2024-08-21 13:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Michael Matz <matz at gcc dot gnu.org> ---
This last problem is a pre-existing one in the backend.  It accepts bare
label_ref plus operands, but it does so also in flag_pic mode.  There it
isn't correct (because it implies another memory reference).  This problem
was masked earlier because expand generates the address reference to the
jump table with a ASHIFT, which wasn't accepted formerly by the backend.
That non-acceptance lead to expand decomposing everything in the address
to registers, including the bare label_ref, which then ultimately went the
correct ways.

The LRA patches now _do_ accept the ASHIFT parts (and that's okay), but this
leads to an overall acceptance of '(plus (ashift (reg) (1)) (label_ref))'
and that's not acceptable (ahem).  Solution: don't accept a bare label_ref
as plus operand if flag_pic.  See below:

@@ -2247,6 +2275,7 @@ m68k_decompose_address (machine_mode mode, rtx x,
      references.  It seems unlikely that we would ever generate indexed
      accesses to unplaced labels in other cases.  */
   if (GET_CODE (x) == PLUS
+      && !flag_pic
       && m68k_jump_table_ref_p (XEXP (x, 1))
       && m68k_decompose_index (XEXP (x, 0), strict_p, address))
     {

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (17 preceding siblings ...)
  2024-08-21 13:47 ` matz at gcc dot gnu.org
@ 2024-08-27  8:48 ` cvs-commit at gcc dot gnu.org
  2024-08-27 13:35 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-27  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #19 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsandifo@gcc.gnu.org>:

https://gcc.gnu.org/g:708ee71808ea61758e73d0e36274b4194b28576a

commit r15-3213-g708ee71808ea61758e73d0e36274b4194b28576a
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Tue Aug 27 09:48:28 2024 +0100

    Handle arithmetic on eliminated address indices [PR116413]

    This patch fixes gcc.c-torture/compile/opout.c for m68k with LRA
    enabled.  The test has:

    ...
    z (a, b)
    {
      return (int) &a + (int) &b + (int) x + (int) z;
    }

    so it adds the address of two incoming arguments.  This ends up
    being treated as an LEA in which the "index" is the incoming
    argument pointer, which the LEA multiplies by 2.  The incoming
    argument pointer is then eliminated, leading to:

    (plus:SI (plus:SI (ashift:SI (plus:SI (reg/f:SI 24 %argptr)
                    (const_int -4 [0xfffffffffffffffc]))
                (const_int 1 [0x1]))
            (reg/f:SI 41 [ _6 ]))
        (const_int 20 [0x14]))

    In the address_info scheme, the innermost plus has to be treated
    as the index "term", since that's the thing that's subject to
    index_reg_class.

    gcc/
            PR middle-end/116413
            * rtl.h (address_info): Update commentary.
            * rtlanal.cc (valid_base_or_index_term_p): New function, split
            out from...
            (get_base_term, get_index_term): ...here.  Handle elimination
PLUSes.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (18 preceding siblings ...)
  2024-08-27  8:48 ` cvs-commit at gcc dot gnu.org
@ 2024-08-27 13:35 ` cvs-commit at gcc dot gnu.org
  2024-08-27 20:22 ` cvs-commit at gcc dot gnu.org
  2024-08-27 20:23 ` schwab@linux-m68k.org
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-27 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #20 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Michael Matz <matz@gcc.gnu.org>:

https://gcc.gnu.org/g:359209bdc7245f8768b5044acded8509545e4990

commit r15-3219-g359209bdc7245f8768b5044acded8509545e4990
Author: Michael Matz <matz@suse.de>
Date:   Thu Aug 22 17:03:56 2024 +0200

    final: go down ASHIFT in walk_alter_subreg

    when experimenting with m68k plus LRA one of the
    changes in the backend is to accept ASHIFTs (not only
    MULT) as scale code for address indices.  When then not
    turning on LRA but using reload those addresses are
    presented to it which chokes on them.  While reload is
    going away the change to make them work doesn't really hurt
    (and generally seems useful, as MULT and ASHIFT really are
    no different).  So just add it.

            PR target/116413
            * final.cc (walk_alter_subreg): Recurse on AHIFT.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (19 preceding siblings ...)
  2024-08-27 13:35 ` cvs-commit at gcc dot gnu.org
@ 2024-08-27 20:22 ` cvs-commit at gcc dot gnu.org
  2024-08-27 20:23 ` schwab@linux-m68k.org
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-27 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #21 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andreas Schwab <schwab@gcc.gnu.org>:

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

commit r15-3233-ga83e519ab2d4e7df2756411cd9d21c6f1b583429
Author: Andreas Schwab <schwab@linux-m68k.org>
Date:   Tue Aug 27 21:01:00 2024 +0200

    m68k: Accept ASHIFT like MULT in address operand

    When LRA pulls an address operand out of a MEM it caninoicalizes a
    containing MULT into ASHIFT.  Adjust the address decomposer to recognize
    this form.

            PR target/116413
            * config/m68k/m68k.cc (m68k_decompose_index): Accept ASHIFT like
            MULT.
            (m68k_rtx_costs) [PLUS]: Likewise.
            (m68k_legitimize_address): Likewise.

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

* [Bug target/116413] [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036
  2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
                   ` (20 preceding siblings ...)
  2024-08-27 20:22 ` cvs-commit at gcc dot gnu.org
@ 2024-08-27 20:23 ` schwab@linux-m68k.org
  21 siblings, 0 replies; 23+ messages in thread
From: schwab@linux-m68k.org @ 2024-08-27 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #22 from Andreas Schwab <schwab@linux-m68k.org> ---
Fixed for gcc 15.

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

end of thread, other threads:[~2024-08-27 20:23 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-19  7:56 [Bug target/116413] New: [LRA] [M68K] ICE: unrecognized insn in lra_set_insn_recog_data, at lra.cc:1036 schwab@linux-m68k.org
2024-08-19  8:01 ` [Bug target/116413] " schwab@linux-m68k.org
2024-08-19  8:25 ` schwab@linux-m68k.org
2024-08-19  9:42 ` schwab@linux-m68k.org
2024-08-19 12:59 ` schwab@linux-m68k.org
2024-08-19 13:02 ` schwab@linux-m68k.org
2024-08-19 13:16 ` schwab@linux-m68k.org
2024-08-19 13:31 ` schwab@linux-m68k.org
2024-08-19 13:36 ` matz at gcc dot gnu.org
2024-08-20  9:00 ` rsandifo at gcc dot gnu.org
2024-08-21  8:34 ` schwab@linux-m68k.org
2024-08-21  8:56 ` rsandifo at gcc dot gnu.org
2024-08-21  9:13 ` schwab@linux-m68k.org
2024-08-21  9:18 ` schwab@linux-m68k.org
2024-08-21 11:16 ` rsandifo at gcc dot gnu.org
2024-08-21 12:16 ` schwab@linux-m68k.org
2024-08-21 12:36 ` schwab@linux-m68k.org
2024-08-21 12:44 ` rsandifo at gcc dot gnu.org
2024-08-21 13:47 ` matz at gcc dot gnu.org
2024-08-27  8:48 ` cvs-commit at gcc dot gnu.org
2024-08-27 13:35 ` cvs-commit at gcc dot gnu.org
2024-08-27 20:22 ` cvs-commit at gcc dot gnu.org
2024-08-27 20:23 ` schwab@linux-m68k.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).