http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59049
Bug ID: 59049 Summary: Two VOIDmode constant in comparison passed to cstoresi4 Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: amylaar at gcc dot gnu.org For gcc.c-torture/execute/builtins/strlen-2.c compilation, -O1, with target arc-elf, I see an ICE in config/arc/arc.c:gen_compare_reg, as it has been passed a comparison for two VOIDmode constants: (ne:SI (const_int 3 [0x3]) (const_int 3 [0x3])) We should not generate such comparisons. [amylaar@rowan gcc]$ ./cc1 -fpreprocessed strlen-2.i -quiet -dumpbase strlen-2.c -auxbase strlen-2 -O1 -w -version -fno-diagnostics-show-caret -fdiagnostics-color=never -fno-tree-loop-distribute-patterns -o strlen-2.s GNU C (GCC) version 4.9.0 20131024 (experimental) (arc-elf) compiled by GNU C version 4.8.1 20130603 (Red Hat 4.8.1-1), GMP version 5.1.1, MPFR version 3.1.1, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C (GCC) version 4.9.0 20131024 (experimental) (arc-elf) compiled by GNU C version 4.8.1 20130603 (Red Hat 4.8.1-1), GMP version 5.1.1, MPFR version 3.1.1, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: a28c59382a8f5b3c721a450c1591fc5d /home/amylaar/synopsys/synopsys-gcc-mainline/unisrc-4.8/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2.c: In function ‘main_test’: /home/amylaar/synopsys/synopsys-gcc-mainline/unisrc-4.8/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2.c:25:1: internal compiler error: in gen_compare_reg, at config/arc/arc.c:1430 0x899316f gen_compare_reg(rtx_def*, machine_mode) ../../gcc/gcc/config/arc/arc.c:1430 0x89cfa80 gen_cstoresi4(rtx_def*, rtx_def*, rtx_def*, rtx_def*) ../../gcc/gcc/config/arc/arc.md:3208 0x85c8a6d insn_gen_fn::operator()(rtx_def*, rtx_def*, rtx_def*, rtx_def*) const ../../gcc/gcc/recog.h:286 0x85c83b9 maybe_gen_insn(insn_code, unsigned int, expand_operand*) ../../gcc/gcc/optabs.c:8217 0x85c8604 maybe_expand_insn(insn_code, unsigned int, expand_operand*) ../../gcc/gcc/optabs.c:8243 0x83942ef emit_cstore ../../gcc/gcc/expmed.c:5121 0x8394a85 emit_store_flag_1 ../../gcc/gcc/expmed.c:5362 0x8394b7c emit_store_flag(rtx_def*, rtx_code, rtx_def*, rtx_def*, machine_mode, int, int) ../../gcc/gcc/expmed.c:5405 0x83959ec emit_store_flag_force(rtx_def*, rtx_code, rtx_def*, rtx_def*, machine_mode, int, int) ../../gcc/gcc/expmed.c:5727 0x83ba5dd do_store_flag ../../gcc/gcc/expr.c:10832 0x83b1fb5 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/gcc/expr.c:8787 0x83b9191 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**) ../../gcc/gcc/expr.c:10444 0x83ad831 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**) ../../gcc/gcc/expr.c:7796 0x83b3ab6 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**) ../../gcc/gcc/expr.c:9253 0x83ad831 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**) ../../gcc/gcc/expr.c:7796 0x831e807 expand_normal ../../gcc/gcc/expr.h:450 0x8320856 do_jump(tree_node*, rtx_def*, rtx_def*, int) ../../gcc/gcc/dojump.c:608 0x831fa22 do_jump_1(tree_code, tree_node*, tree_node*, rtx_def*, rtx_def*, int) ../../gcc/gcc/dojump.c:364 0x831e918 jumpifnot_1(tree_code, tree_node*, tree_node*, rtx_def*, int) ../../gcc/gcc/dojump.c:114 0x82af4bd expand_gimple_cond ../../gcc/gcc/cfgexpand.c:2030 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. emit_cstore has generated this comparison. I propose to use copy_to_mode_reg in this case to preserve the information about the mode. I see that for the testcase, the unnecessary instructions are removed in the ce1 pass.