public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikpelinux at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/80786] m68k: internal compiler error: in change_address_1
Date: Mon, 01 Jan 2024 15:30:22 +0000	[thread overview]
Message-ID: <bug-80786-4-B64NkomR9p@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-80786-4@http.gcc.gnu.org/bugzilla/>

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

Mikael Pettersson <mikpelinux at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpelinux at gmail dot com

--- Comment #4 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Reduced test case:

> cat /tmp/pr80786.c
extern long G[];

void dir_op(short op, short *dirs)
{
    if (!op)
        *dirs = G[1];
}
> gcc/xgcc -Bgcc -O2 -mpcrel -S /tmp/pr80786.c
during RTL pass: final
/tmp/pr80786.c: In function 'dir_op':
/tmp/pr80786.c:7:1: internal compiler error: in change_address_1, at
emit-rtl.cc:2299
    7 | }
      | ^
0x40dc15 change_address_1
        /mnt/scratch/other/mikpe-gcc.git/gcc/emit-rtl.cc:2299
0x668fc9 adjust_address_1(rtx_def*, machine_mode, poly_int<1u, long>, int, int,
int, poly_int<1u, long>)
        /mnt/scratch/other/mikpe-gcc.git/gcc/emit-rtl.cc:2433
0x10c2ea2 output_80
        /mnt/scratch/other/mikpe-gcc.git/gcc/config/m68k/m68k.md:1678
...

This is gcc-14 from 2023-12-30, and output_80 is m68k.md's truncsihi2 insn.

The source operand is

(mem:SI (const:SI (plus:SI (symbol_ref:SI ("G") [flags 0x40] <var_decl
0x7f3eb88f1000 G>)
            (const_int 4 [0x4]))) [1 G[1]+0 S4 A16])

which truncsihi2 wants to adjust by adding 2 to the offset, but

(const:SI (plus:SI (symbol_ref:SI ("G") [flags 0x40] <var_decl 0x7f3eb88f1000
G>)
        (const_int 6 [0x6])))

is rejected by m68k_legitimate_constant_address_p, causing
m68k_decompose_address to fail, and the assert in change_address_1 to fire.

Disabling this insn for TARGET_PCREL seems to work, but I don't know what
negative side-effects that might have.

gcc-4.9 and older were ok, gcc-5 and above ICE, starting with

aea3d681ec784b1a44ee3b37b0df2b71bdfadfc3 is the first new commit
commit aea3d681ec784b1a44ee3b37b0df2b71bdfadfc3
Author: DJ Delorie <dj@redhat.com>
Date:   Fri Aug 29 19:19:42 2014 -0400

    expr.c (convert_move): If the target has an explicit converter, use it.

      parent reply	other threads:[~2024-01-01 15:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-80786-4@http.gcc.gnu.org/bugzilla/>
2021-07-18 15:35 ` mikpelinux at gmail dot com
2023-08-06 21:06 ` giulio.benetti at benettiengineering dot com
2024-01-01 15:30 ` mikpelinux at gmail dot com [this message]

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-80786-4-B64NkomR9p@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).