Bug 88188 - ICE in print_operand, at config/rs6000/rs6000.c
Summary: ICE in print_operand, at config/rs6000/rs6000.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-11-25 05:58 UTC by Arseny Solokha
Modified: 2019-01-04 20:44 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc-*-linux-gnu, powerpcspe-*-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-11-26 00:00:00


Attachments
gcc9-pr88188.patch (964 bytes, patch)
2018-11-26 10:06 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2018-11-25 05:58:16 UTC
rs6000 and powerpcspe backends ICE processing some kinds of invalid assembly. Namely, they hit gcc_unreachable() or gcc_assert() compiling gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c, gcc/testsuite/gcc.target/cris/20011127-1.c, and gcc/testsuite/gcc.target/msp430/msp_abi_div_funcs.c:

% powerpc-e300c3-linux-gnu-gcc-9.0.0-alpha20181118 -c gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c
during RTL pass: final
gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c: In function 'foo':
gcc/testsuite/gcc.target/i386/indirect-thunk-register-4.c:10:1: internal compiler error: in print_operand, at config/rs6000/rs6000.c:20992
   10 | }
      | ^
0x6da7e3 print_operand(_IO_FILE*, rtx_def*, int)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/config/rs6000/rs6000.c:20992
0x9eb84f output_operand(rtx_def*, int)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:4042
0x9ec4d6 output_asm_insn(char const*, rtx_def**)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:3935
0x9ee6a6 final_scan_insn_1
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:2712
0x9ee998 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:3149
0x9eecae final_1
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:2019
0x9ef838 rest_of_handle_final
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:4649
0x9ef838 execute
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181118/work/gcc-9-20181118/gcc/final.c:4723

(for cris test it ICEs on line 21062 and for msp430 on line 20647 instead).
Comment 1 Jakub Jelinek 2018-11-26 10:06:47 UTC
Created attachment 45090 [details]
gcc9-pr88188.patch

Untested fix (ignoring powerpcspe, because it really should be removed as unmaintained).
Comment 2 Jakub Jelinek 2018-11-27 15:41:29 UTC
Author: jakub
Date: Tue Nov 27 15:40:57 2018
New Revision: 266515

URL: https://gcc.gnu.org/viewcvs?rev=266515&root=gcc&view=rev
Log:
	PR target/88188
	* config/rs6000/rs6000.c (print_operand) <case 'D'>: Use
	output_operand_lossage instead of gcc_assert.
	<case 't'>: Likewise.
	<case 'z'>: Likewise.
	<case 'V'>: Use output_operand_lossage instead of gcc_unreachable.

	* gcc.target/powerpc/pr88188.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr88188.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c
Comment 3 Christophe Lyon 2018-11-28 10:15:24 UTC
(In reply to Jakub Jelinek from comment #2)
>     trunk/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c

Is this part of the commit intended?

It's not mentioned in the ChangeLog, and I see a regression:
FAIL: gcc.dg/tree-ssa/phi-opt-11.c scan-tree-dump-times optimized "if" 0
(used to have PASS: gcc.dg/tree-ssa/phi-opt-11.c scan-tree-dump-times optimized "if" 2)

on arm-none-eabi --with-mode thumb --with-cpu cortex-m3
Comment 4 Jakub Jelinek 2018-11-28 11:13:53 UTC
(In reply to Christophe Lyon from comment #3)
> (In reply to Jakub Jelinek from comment #2)
> >     trunk/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-11.c
> 
> Is this part of the commit intended?
> 
> It's not mentioned in the ChangeLog, and I see a regression:
> FAIL: gcc.dg/tree-ssa/phi-opt-11.c scan-tree-dump-times optimized "if" 0
> (used to have PASS: gcc.dg/tree-ssa/phi-opt-11.c scan-tree-dump-times
> optimized "if" 2)
> 
> on arm-none-eabi --with-mode thumb --with-cpu cortex-m3

It was intended, but not as part of this commit, sorry for the screw-up.
It was meant as the PR85368 fix.
I've tested it on x86_64 as example of !logical_op_short_circuit && branch_cost target, Jeff/Andreas on s390x as example of logical_op_short_circuit && branch_cost target and I've tested on powerpc64{,le} as example of logical_op_short_circuit && !branch_cost target.
arm is a branch_cost target and cortex-m3 is logical_op_short_circuit, why doesn't the -mbranch-cost=2 option override the cortex-m3 defaults?
Anyway, can you follow-up in PR85368 instead of here, in order not to clutter this PR?
Comment 5 Jakub Jelinek 2018-12-04 19:42:24 UTC
Author: jakub
Date: Tue Dec  4 19:41:52 2018
New Revision: 266794

URL: https://gcc.gnu.org/viewcvs?rev=266794&root=gcc&view=rev
Log:
	PR target/88188
	* config/rs6000/rs6000.c (ccr_bit): Return -1 instead of assertion
	failures.
	(print_operand): Use REG_P instead of GET_CODE == REG.
	<case 'D'>: Also check CR_REGNO_P (REGNO (x)).
	<case 't'>: Likewise.  Remove GET_MODE check.
	* config/rs6000/rs6000.md (scc patterns): Assert ccr_bit didn't
	return -1.

	* gcc.target/powerpc/pr88188-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr88188-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.c
    trunk/gcc/config/rs6000/rs6000.md
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2019-01-04 20:44:50 UTC
Not worth backporting IMHO.