Bug 93027 - ICE: in match_reload, at lra-constraints.c:1060
Summary: ICE: in match_reload, at lra-constraints.c:1060
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Vladimir Makarov
Keywords: ice-on-valid-code, inline-asm, ra
Depends on:
Reported: 2019-12-20 13:00 UTC by 吳建興
Modified: 2021-12-03 03:36 UTC (History)
3 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2020-01-21 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description 吳建興 2019-12-20 13:00:50 UTC
g++ ./hi.c


int main() {
  int f= 0, w;

  asm volatile(
    : "+m&l"(f)
    : "0a"(&w)


during RTL pass: reload
./bug.cc: In function ‘int main()’:
./bug.cc:9:1: internal compiler error: in match_reload, at lra-constraints.c:1060
    9 | }
      | ^
0x2b55f43 match_reload
0x2b9c03f curr_insn_transform
0x2ba4656 lra_constraints(bool)
0x2b102b4 lra(_IO_FILE*)
0x28e6954 do_reload
0x28e6954 execute

It is probably the same bug in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84985
Comment 1 Vladimir Makarov 2020-01-08 21:35:33 UTC
Thank you for the report.  I've started working on it.  As changes in constraint processing needs a lot of testing, I think the patch will be read on Friday or on the next week.
Comment 2 Vladimir Makarov 2020-01-10 20:37:55 UTC
Sorry, I did a mistake in PR number and automatic commits reporting did not work.

Here are the patches fixing the PR:

Comment 3 Vladimir Makarov 2020-01-10 20:45:58 UTC
Author: vmakarov
Date: Fri Jan 10 20:45:19 2020
New Revision: 280138

URL: https://gcc.gnu.org/viewcvs?rev=280138&root=gcc&view=rev
2020-01-10  Vladimir Makarov  <vmakarov@redhat.com>

	PR inline-asm/93027
	* gcc.target/i386/pr93027.c: Use the right PR number in the test.

Comment 4 GCC Commits 2020-01-23 21:52:33 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:


commit r10-6190-g3a26c7b3a3569a5e1b6f0342e50aefe76ad0ec4d
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 23 22:50:40 2020 +0100

    testsuite: Require lp64 target rather x86_64-*-* in pr93027.c. [PR93027]
    I've noticed this test failed on x86_64-linux with -m32 or -mx32 testing,
    the triplet doesn't really say which actual multilib it is, and the test
    really works with lp64.
    2020-01-23  Jakub Jelinek  <jakub@redhat.com>
    	PR inline-asm/93027
    	* gcc.target/i386/pr93027.c: Require lp64 target rather x86_64-*-*.
Comment 5 Jakub Jelinek 2020-02-13 12:19:18 UTC
So fixed for trunk?  GCC 9 seems to ICE on this too in the same spot (but with -fchecking only or --enable-checking=yes), GCC 8 in extract_constraint_insn (but again with checking only).
Comment 6 Alexandre Oliva 2021-12-03 03:36:12 UTC
FWIW, with or without optimization, this testcase allocates inout f and in &w to the same register in the .reload dump.  If the asm code used %0, expecting it to be initially 0 as it should, it would fail:

int main (void) {
  int f = 0, w, z;

  asm volatile(
    "movl\t%0, %1"
    : "+m&l"(f), "=g" (z)
    : "0a"(&w)

  if (z)
    __builtin_abort ();

  return 0;