[Bug target/101177] sh3: internal compiler error: Illegal instruction

2021-07-05 Thread gcc_bugzilla at foobar dot franken.de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101177

--- Comment #3 from Harold Gutch  ---
With my patch, the NetBSD/dreamcast build successfully reaches multiuser.

Also, note that the rest of the commit looks very much like what the commit
message described, but I don't see anything that might explain the inversion in
the comparison, leading me to believe that this was a typo that managed to
sneak in by accident.

[Bug target/101177] sh3: internal compiler error: Illegal instruction

2021-07-01 Thread gcc_bugzilla at foobar dot franken.de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101177

--- Comment #2 from Harold Gutch  ---
Created attachment 51098
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51098=edit
revert the change of condition

[Bug target/101177] sh3: internal compiler error: Illegal instruction

2021-07-01 Thread gcc_bugzilla at foobar dot franken.de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101177

Harold Gutch  changed:

   What|Removed |Added

 CC||gcc_bugzilla at foobar dot 
franken
   ||.de

--- Comment #1 from Harold Gutch  ---
(In reply to Roland Illig from comment #0)
> $ cat lex.c
> int
> lex_input(void);
> 
> int
> lex_character_constant(void);
> 
> int
> lex_character_constant(void)
> {
> int c = lex_input();
> if (c == 7)
> return c;
> c &= 255;
> return c == 0 ? -1 : c;
> }
> 
> $ /home/rillig/builds/sh3-tools/bin/sh--netbsdelf-gcc --version
> sh--netbsdelf-gcc (NetBSD nb1 20200907) 9.3.0
> Copyright (C) 2019 Free Software Foundation, Inc.
> 
> $ /home/rillig/builds/sh3-tools/bin/sh--netbsdelf-gcc lex.c -O1
> sh--netbsdelf-gcc: internal compiler error: Illegal instruction signal
> terminated program cc1

This is not specific to the NetBSD cross toolchain, this also happens with a
vanilla GCC built on Linux, verified with both 9.3.0 and git head.

I bisected this to commit 91f66e78cc141da77ff9e0e3c8519e1af3f26c07 ,
https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/config/sh/sh.md;h=e19e977087db4d5231f2276af53a42ee82bd50de;hp=2645fca47383c96571f4750033f893ad869e;hb=91f66e78cc141da77ff9e0e3c8519e1af3f26c07;hpb=8faa81184f856447084a9ee41a63fc4be6bca572

I cannot claim to understand the details of this patch, but note that in the
second part of the diff the condition gets inverted.  Take for this the simple
case of SUBREG_P(reg) being false, then this changed from

  if (find_regno_note (curr_insn, REG_DEAD, REGNO (operands[0])) == NULL_RTX)

to

  if (find_regno_note (curr_insn, REG_DEAD, REGNO (operands[0])) != NULL_RTX)

After changing this back to "==", the test case passes for me again, and I can
run a full build of NetBSD/Dreamcast (SH3).  I have not verified however if the
built system works correctly.