Following ICEs: $ arm-linux-gnueabi-gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c -Og -mflip-thumb -c /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c: In function ‘do_noret_di’: /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c:85:3: note: ‘__sync_fetch_and_nand’ changed semantics in GCC 4.4 __sync_fetch_and_nand (AL+15, 0xa00000007ll); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c:98:3: note: ‘__sync_nand_and_fetch’ changed semantics in GCC 4.4 __sync_nand_and_fetch (AL+23, 0xa00000007ll); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ during RTL pass: expand /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c: In function ‘do_ret_di’: /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c:107:7: internal compiler error: in int_mode_for_mode, at stor-layout.c:403 if (__sync_bool_compare_and_swap (AL+1, 0x200000003ll, 0x1234567890ll) != ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0xb46b8a int_mode_for_mode(machine_mode) .././../gcc/stor-layout.c:403 0x80ae2e emit_move_via_integer .././../gcc/expr.c:3313 0x817d35 emit_move_insn_1(rtx_def*, rtx_def*) .././../gcc/expr.c:3693 0x81803e emit_move_insn(rtx_def*, rtx_def*) .././../gcc/expr.c:3761 0x7fa283 force_reg(machine_mode, rtx_def*) .././../gcc/explow.c:642 0xa57741 prepare_cmp_insn .././../gcc/optabs.c:3777 0xa57d21 emit_cmp_and_jump_insns(rtx_def*, rtx_def*, rtx_code, rtx_def*, machine_mode, int, rtx_def*, profile_probability) .././../gcc/optabs.c:4054 0x77f41f do_compare_rtx_and_jump(rtx_def*, rtx_def*, rtx_code, int, machine_mode, rtx_def*, rtx_code_label*, rtx_code_label*, profile_probability) .././../gcc/dojump.c:1151 0x806d95 emit_store_flag_force(rtx_def*, rtx_code, rtx_def*, rtx_def*, machine_mode, int, int) .././../gcc/expmed.c:6050 0xa59e16 expand_atomic_compare_and_swap(rtx_def**, rtx_def**, rtx_def*, rtx_def*, rtx_def*, bool, memmodel, memmodel) .././../gcc/optabs.c:6270 0x6cfa33 expand_builtin_compare_and_swap .././../gcc/builtins.c:5618 0x6dc791 expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int) .././../gcc/builtins.c:7203 0x8144cc expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) .././../gcc/expr.c:10874 0x81f8f7 expand_expr .././../gcc/expr.h:276 0x81f8f7 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*) .././../gcc/expr.c:5483 0x820d07 expand_assignment(tree_node*, tree_node*, bool) .././../gcc/expr.c:5343 0x6ffe7f expand_call_stmt .././../gcc/cfgexpand.c:2664 0x6ffe7f expand_gimple_stmt_1 .././../gcc/cfgexpand.c:3585 0x6ffe7f expand_gimple_stmt .././../gcc/cfgexpand.c:3751 0x701897 expand_gimple_basic_block .././../gcc/cfgexpand.c:5750
I can't reproduce this on GCC 8.
I can with: commit 23298f15ba71145bae317e9c07f7078663dbd923 (HEAD, parent/trunk, parent/master) Author: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon Dec 18 08:35:23 2017 +0000 2017-12-18 Richard Biener <rguenther@suse.de> PR tree-optimization/81877 * tree-ssa-loop-im.c (ref_indep_loop_p): Remove safelen parameters. (outermost_indep_loop): Adjust. (ref_indep_loop_p_1): Likewise. Remove safelen handling again. (can_sm_ref_p): Adjust. * g++.dg/torture/pr81877.C: New testcase. * g++.dg/vect/pr70729.cc: XFAIL. * g++.dg/vect/pr70729-nest.cc: XFAIL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255776 138bc75d-0d04-0410-961f-82ee72b054a4 $ ./xgcc -v Using built-in specs. COLLECT_GCC=./xgcc Target: arm-unknown-linux-gnueabi Configured with: ../configure --enable-languages=c,c++ --disable-multilib --disable-bootstrap --target=arm-unknown-linux-gnueabi Thread model: posix gcc version 8.0.0 20171218 (experimental) (GCC) $ ./cc1 -fpreprocessed di-longlong64-sync-1.i -mflip-thumb -mcpu=arm10tdmi -mtls-dialect=gnu -marm -march=armv5t -Og
(In reply to Martin Liška from comment #2) > I can with: > > commit 23298f15ba71145bae317e9c07f7078663dbd923 (HEAD, parent/trunk, > parent/master) > Author: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> > Date: Mon Dec 18 08:35:23 2017 +0000 > > 2017-12-18 Richard Biener <rguenther@suse.de> > > PR tree-optimization/81877 > * tree-ssa-loop-im.c (ref_indep_loop_p): Remove safelen > parameters. > (outermost_indep_loop): Adjust. > (ref_indep_loop_p_1): Likewise. Remove safelen handling again. > (can_sm_ref_p): Adjust. > > * g++.dg/torture/pr81877.C: New testcase. > * g++.dg/vect/pr70729.cc: XFAIL. > * g++.dg/vect/pr70729-nest.cc: XFAIL. > > > git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255776 > 138bc75d-0d04-0410-961f-82ee72b054a4 > > $ ./xgcc -v > Using built-in specs. > COLLECT_GCC=./xgcc > Target: arm-unknown-linux-gnueabi > Configured with: ../configure --enable-languages=c,c++ --disable-multilib > --disable-bootstrap --target=arm-unknown-linux-gnueabi > Thread model: posix > gcc version 8.0.0 20171218 (experimental) (GCC) > > $ ./cc1 -fpreprocessed di-longlong64-sync-1.i -mflip-thumb -mcpu=arm10tdmi > -mtls-dialect=gnu -marm -march=armv5t -Og I can reproduce it with this.
I can see this failing with: $./arm-none-linux-gnueabi-gcc ./src/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c -mthumb -march=armv5t -O[g,1,2,3] and $./arm-none-linux-gnueabi-gcc ./src/gcc/gcc/testsuite/gcc.dg/di-longlong64-sync-1.c -mthumb -march=armv6 -O[g,1,2,3]
As far as I can see, the function expand_atomic_compare_and_swap() calls emit_store_flag_force() with a explicit VOIDmode and because of this, do_compare_rtx_and_jump() fails to split the instruction using any do_jump_by_parts_* (which needs an int_mode). This then moves deep and causes the forced move instructions with a VOIDmode and causes the ICE. The attached patch fixes this but I am not sure why the explicit VOIDmode was used on the first place or if the proposed patch is the right approach here? Anyone got any ideas? Sudi diff --git a/gcc/optabs.c b/gcc/optabs.c index 3354e40..efc95f7 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -6312,7 +6312,7 @@ expand_atomic_compare_and_swap (rtx *ptarget_bool, rtx *ptarget_oval, success_bool_from_val: target_bool = emit_store_flag_force (target_bool, EQ, target_oval, - expected, VOIDmode, 1, 1); + expected, mode, 1, 1); success: /* Make sure that the oval output winds up where the caller asked. */ if (ptarget_oval)
Patch submitted https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00219.html
Author: sudi Date: Thu Jan 11 10:46:59 2018 New Revision: 256526 URL: https://gcc.gnu.org/viewcvs?rev=256526&root=gcc&view=rev Log: [PR82096] Fix ICE in int_mode_for_mode with arm-linux-gnueabi The bug reported a particular test di-longlong64-sync-1.c failing when run on arm-linux-gnueabi with options -mthumb -march=armv5t -O[g,1,2,3] and -mthumb -march=armv6 -O[g,1,2,3]. The crash was caused because of the explicit VOIDmode argument that is sent to emit_store_flag_force () and that the emit_store_flag_force () was not handling the VOIDmode adequately. This patch fixes that. ChangeLog entries: *** gcc/ChangeLog *** 2017-01-11 Sudakshina Das <sudi.das@arm.com> PR target/82096 * expmed.c (emit_store_flag_force): Swap if const op0 and change VOIDmode to mode of op0. *** gcc/testsuite/ChangeLog *** 2017-01-11 Sudakshina Das <sudi.das@arm.com> PR target/82096 * gcc.c-torture/compile/pr82096.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr82096.c Modified: trunk/gcc/ChangeLog trunk/gcc/expmed.c trunk/gcc/testsuite/ChangeLog
Does this ICE reproduce with older compilers? We may need to backport the fix if so
Yes I at least 6 and 7 need backports. Haven't gone beyond that yet.
Adjusting regression markers. GCC 6 is the oldest release we maintain for now, so we only need backports for 6 and 7
Author: sudi Date: Fri Feb 16 15:37:35 2018 New Revision: 257741 URL: https://gcc.gnu.org/viewcvs?rev=257741&root=gcc&view=rev Log: Fix emit_store_flag_force () function to fix ICE in int_mode_for_mode, at stor-layout.c:403 with arm-linux-gnueabi. *** gcc/ChangeLog *** 2018-02-16 Sudakshina Das <sudi.das@arm.com> Backport from trunk 2018-01-10 Sudakshina Das <sudi.das@arm.com> PR target/82096 * expmed.c (emit_store_flag_force): Swap if const op0 and change VOIDmode to mode of op0. *** gcc/testsuite/ChangeLog *** 2018-02-16 Sudakshina Das <sudi.das@arm.com> Backport from trunk 2018-01-12 Sudakshina Das <sudi.das@arm.com> * gcc.c-torture/compile/pr82096.c: Add dg-skip-if directive. Backport from trunk 2018-01-10 Sudakshina Das <sudi.das@arm.com> PR target/82096 * gcc.c-torture/compile/pr82096.c: New test. Added: branches/gcc-7-branch/gcc/testsuite/gcc.c-torture/compile/pr82096.c Modified: branches/gcc-7-branch/gcc/ChangeLog branches/gcc-7-branch/gcc/expmed.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
Fixed on GCC 7 branch too. Sudi, do you plan on backporting to GCC 6 as well?
Author: sudi Date: Wed Feb 21 12:50:31 2018 New Revision: 257871 URL: https://gcc.gnu.org/viewcvs?rev=257871&root=gcc&view=rev Log: Fix emit_store_flag_force () function to fix ICE in int_mode_for_mode, at stor-layout.c:403 with arm-linux-gnueabi. *** gcc/ChangeLog *** 2018-02-21 Sudakshina Das <sudi.das@arm.com> Backport from trunk 2018-01-10 Sudakshina Das <sudi.das@arm.com> PR target/82096 * expmed.c (emit_store_flag_force): Swap if const op0 and change VOIDmode to mode of op0. *** gcc/testsuite/ChangeLog *** 2018-02-21 Sudakshina Das <sudi.das@arm.com> Backport from trunk 2018-01-12 Sudakshina Das <sudi.das@arm.com> * gcc.c-torture/compile/pr82096.c: Add dg-skip-if directive. Backport from trunk 2018-01-10 Sudakshina Das <sudi.das@arm.com> PR target/82096 * gcc.c-torture/compile/pr82096.c: New test. Added: branches/gcc-6-branch/gcc/testsuite/gcc.c-torture/compile/pr82096.c Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/expmed.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Backported to gcc-6