Created attachment 36501 [details] Preprocessed source file Since https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=210824 GCC fails with ICE when generating ARM Thumb1 code: /tmp/test.i: In function 'ubidi_writeReordered_55': /tmp/test.i:4748:1: internal compiler error: in patch_jump_insn, at cfgrtl.c:1303 } ^ 0x63700e patch_jump_insn ../../gcc/gcc/cfgrtl.c:1303 0x63715b redirect_branch_edge ../../gcc/gcc/cfgrtl.c:1329 0x6376e2 rtl_redirect_edge_and_branch ../../gcc/gcc/cfgrtl.c:1462 0x629889 redirect_edge_and_branch(edge_def*, basic_block_def*) ../../gcc/gcc/cfghooks.c:376 0xd0be1d try_forward_edges ../../gcc/gcc/cfgcleanup.c:621 0xd0be1d try_optimize_cfg ../../gcc/gcc/cfgcleanup.c:2835 0xd0be1d cleanup_cfg(int) ../../gcc/gcc/cfgcleanup.c:3049 0xd0d318 execute ../../gcc/gcc/cfgcleanup.c:3178 The following commands fail: * gcc -march=armv4t -mthumb /tmp/test.i -S -o /tmp/test.o -O1 -fcrossjumping * gcc -march=armv5te -mthumb /tmp/test.i -S -o /tmp/test.o -O1 -fcrossjumping * gcc -march=armv6 -mthumb /tmp/test.i -S -o /tmp/test.o -O1 -fcrossjumping The following work: * gcc -march=armv6t2 -mthumb /tmp/test.i -S -o /tmp/test.o -O1 -fcrossjumping * gcc -march=armv5te -marm /tmp/test.i -S -o /tmp/test.o -O1 -fcrossjumping * gcc -march=armv5te -mthumb /tmp/test.i -S -o /tmp/test.o -O1 The log was produced using clear gcc from gcc-5_1_0-release tag. The following configure options were passed to gcc: ../gcc/configure --build=x86_64-linux --host=x86_64-linux --target=arm-linux-gnueabi --enable-languages=c --enable-checking=all --disable-nls
Please try a more recent snapshot from the GCC 5 branch.
trunk and 5.2.1 20151108 fails with the command line options -march=armv4t -mthumb -mfloat-abi=soft -O2 and the testcase. reducing.
Created attachment 36771 [details] reduced testcase reduced testcase
Sounds like a RA issue to me. In *.ira we have: (jump_insn 175 174 176 26 (parallel [ (set (pc) (if_then_else (lt (plus:SI (reg/v:SI 134 [ runCount ]) (const_int -1 [0xffffffffffffffff])) (const_int 0 [0])) (label_ref 105) (pc))) (set (reg/v:SI 152 [ runCount ]) (plus:SI (reg/v:SI 134 [ runCount ]) (const_int -1 [0xffffffffffffffff]))) (clobber (scratch:SI)) ]) pr67954.i:89 759 {*addsi3_cbranch} (expr_list:REG_DEAD (reg/v:SI 134 [ runCount ]) (int_list:REG_BR_PROB 900 (nil))) -> 105) and then in *.reload we have: Choosing alt 4 in insn 175: (0) *?m (1) &l (2) 1 (3) lIJ {*addsi3_cbranch} ... Choosing alt 1 in insn 175: (0) l (1) X (2) l (3) lL {*addsi3_cbranch} ... Choosing alt 1 in insn 175: (0) l (1) X (2) l (3) lL {*addsi3_cbranch} ... Choosing alt 1 in insn 175: (0) l (1) X (2) l (3) lL {*addsi3_cbranch} ... (jump_insn 175 548 176 26 (parallel [ (set (pc) (if_then_else (lt (plus:SI (reg:SI 3 r3 [374]) (const_int -1 [0xffffffffffffffff])) (const_int 0 [0])) (label_ref 105) (pc))) (set (reg/v:SI 2 r2 [orig:152 runCount ] [152]) (plus:SI (reg:SI 3 r3 [374]) (const_int -1 [0xffffffffffffffff]))) (clobber (mem/c:SI (reg:SI 2 r2 [437]) [6 %sfp+-32 S4 A32])) ]) pr67954.i:89 759 {*addsi3_cbranch} (int_list:REG_BR_PROB 900 (nil)) -> 105) The pattern has (clobber (match_scratch:SI 1 "=X,X,l,l,&l,&l"))] If LRA really chooses the alt 1, then the match_scratch has =X constraint, but I would expect that it would not leave in complete garbage like the memory dereference that doesn't pass scratch_operand. Vlad? Note I could only reproduce this on the 5 branch.
Author: vmakarov Date: Wed Nov 25 17:57:15 2015 New Revision: 230893 URL: https://gcc.gnu.org/viewcvs?rev=230893&root=gcc&view=rev Log: 2015-11-25 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/67954 * lra-constraints.c (curr_insn_transform): Add check on scratch pseudo when change class to NO_REGS. Add an assert. Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/lra-constraints.c
Author: vmakarov Date: Wed Nov 25 17:58:35 2015 New Revision: 230894 URL: https://gcc.gnu.org/viewcvs?rev=230894&root=gcc&view=rev Log: 2015-11-25 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/67954 * lra-constraints.c (curr_insn_transform): Add check on scratch pseudo when change class to NO_REGS. Add an assert. Modified: trunk/gcc/ChangeLog trunk/gcc/lra-constraints.c
The problem occurred in rare cases when a pseudo created from a scratch was reloaded and assigned to reg and memory back again. The new reload pseudo loses "created from clobber" mark and occurs more once in insns.
Assuming fixed for 5.3+.
This also needs to be applied to the 4.9 branch -- it also contains an offending commit.
Author: vmakarov Date: Thu Nov 26 22:13:36 2015 New Revision: 230986 URL: https://gcc.gnu.org/viewcvs?rev=230986&root=gcc&view=rev Log: 2015-11-25 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/67954 * lra-constraints.c (curr_insn_transform): Add check on scratch pseudo when change class to NO_REGS. Add an assert. Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/lra-constraints.c
(In reply to Dmitry Eremin-Solenikov from comment #9) > This also needs to be applied to the 4.9 branch -- it also contains an > offending commit. Thanks for the remainder. I've just committed the patch into gcc-4.9 branch too.