On Sat, May 13, 2017 at 2:47 PM, Markus Trippelsdorf <mar...@trippelsdorf.de> wrote: >> 2017-05-12 Uros Bizjak <ubiz...@gmail.com> >> >> * compare-elim.c (try_eliminate_compare): Canonicalize >> operation with embedded compare to >> [(set (reg:CCM) (compare:CCM (operation) (immediate))) >> (set (reg) (operation)]. >> >> * config/i386/i386.c (TARGET_FLAGS_REGNUM): New define. >> >> Re-bootstrapped and re-tested on x86_64-linux-gnu {,-m32}. >> >> Committed to mainline SVN. > > This causes gcc.dg/atomic/c11-atomic-exec-2.c to ICE with e.g. > -march=nehalem: > > markus@x4 gcc % gcc -std=c11 -pedantic-errors -march=nehalem -O2 > ./gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c > ./gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c: In function ‘test_minus’: > ./gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-2.c:120:1: internal compiler > error: in ix86_cc_mode, at config/i386/i386.c:22485 > } > ^ > 0xea7b37 ix86_cc_mode(rtx_code, rtx_def*, rtx_def*) > /home/markus/gcc/gcc/config/i386/i386.c:22485 > 0x1246e11 maybe_select_cc_mode > /home/markus/gcc/gcc/compare-elim.c:500 > 0x1246e11 try_eliminate_compare > /home/markus/gcc/gcc/compare-elim.c:665 > 0x1246e11 execute_compare_elim_after_reload > /home/markus/gcc/gcc/compare-elim.c:727 > 0x1246e11 execute > /home/markus/gcc/gcc/compare-elim.c:770
-mtune=intel is able to copy SFmode value through general registers, resulting in the following sequence: (insn 288 1008 1009 29 (parallel [ (set (reg:DI 4 si [687]) (lshiftrt:DI (reg:DI 4 si [687]) (const_int 32 [0x20]))) (clobber (reg:CC 17 flags)) ]) "ttt.c":41 546 {*lshrdi3_1} (nil)) (insn 1009 288 289 29 (set (reg:DI 2 cx [419]) (reg:DI 4 si [687])) "ttt.c":41 81 {*movdi_internal} (nil)) (insn 289 1009 291 29 (set (reg:SF 21 xmm0 [425]) (reg:SF 2 cx [419])) "ttt.c":41 127 {*movsf_internal} (nil)) (insn 291 289 292 29 (set (reg:CCFPU 17 flags) (compare:CCFPU (reg:SF 21 xmm0 [425]) (reg:SF 27 xmm6 [688]))) "ttt.c":41 51 {*cmpiusf} (expr_list:REG_EQUAL (compare:CCFPU (reg:SF 21 xmm0 [425]) (const_double:SF 0.0 [0x0.0p+0])) (nil))) Looking at compare-elim.c, equivalent_reg_at_start, the function traces the value in %xmm0 to %rsi. So, try_eliminate_compare tries to check if the target supports the compare of (lshiftrt:DI (reg:DI 4 si [687]) (const_int 32 [0x20]))) with (reg:SF 27 xmm6 [688]) which won't fly, since compare operands must have the same modes. I'm testing the following patch that ensures that the mode of register copy, found by equivalent_reg_at_start equals original mode. --cut here-- Index: compare-elim.c =================================================================== --- compare-elim.c (revision 247995) +++ compare-elim.c (working copy) @@ -526,6 +526,7 @@ maybe_select_cc_mode (struct comparison *cmp, rtx static rtx equivalent_reg_at_start (rtx reg, rtx_insn *end, rtx_insn *start) { + machine_mode orig_mode = GET_MODE (reg); rtx_insn *bb_head = BB_HEAD (BLOCK_FOR_INSN (end)); for (rtx_insn *insn = PREV_INSN (end); @@ -572,6 +573,9 @@ equivalent_reg_at_start (rtx reg, rtx_insn *end, r return NULL_RTX; } + if (GET_MODE (reg) != orig_mode) + return NULL_RTX; + return reg; } --cut here-- Uros.