When compiling Python 3.5.4 or 3.6.3 with -mfpmath=sse on x86 Linux using gcc 7.2.0, I get an ICE/segfault in lra_eliminate_reg_if_possible while compiling cmathmodule.c: building 'cmath' extension gcc -pthread -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -O2 -march=native -pipe -fomit-frame-pointer -mfpmath=sse -O2 -march=native -pipe -fomit-frame-pointer -mfpmath=sse -Werror=declaration-after-statement -I./Include -I. -I/home/aidan/src/Python-3.5.4/Include -I/home/aidan/src/Python-3.5.4 -c /home/aidan/src/Python-3.5.4/Modules/cmathmodule.c -o build/temp.linux-i686-3.5/home/aidan/src/Python-3.5.4/Modules/cmathmodule.o In file included from /home/aidan/src/Python-3.5.4/Modules/cmathmodule.c:11:0: /home/aidan/src/Python-3.5.4/Modules/clinic/cmathmodule.c.h: In function ‘cmath_acos’: /home/aidan/src/Python-3.5.4/Modules/clinic/cmathmodule.c.h:44:1: internal compiler error: Segmentation fault } ^ Please submit a full bug report, with preprocessed source if appropriate. C-Reduce produced the following reduced test case which triggers the same ICE/segfault: typedef struct { double a } b; b c; d, e; f() { _setjmp(); b g; if (d) g.a = copysign(e, d); c = g; } A suitable set of compile options to reproduce this using the above test case is: gcc -fPIC -O1 -march=prescott -mfpmath=sse -c cmathmodule-reduced.i The ICE does not appear to occur with gcc 6.4.0, nor does it occur if either of -mfpmath=sse or -fPIC are disabled. It is, however, still present in the gcc 7 branch as of at least r255440. Backtrace is as follows: Program received signal SIGSEGV, Segmentation fault. 0x084cb7f4 in lra_eliminate_reg_if_possible (loc=0xb772ad38) at ../.././gcc/lra-eliminations.c:1385 1385 || ! TEST_HARD_REG_BIT (lra_no_alloc_regs, regno)) (gdb) bt #0 0x084cb7f4 in lra_eliminate_reg_if_possible (loc=0xb772ad38) at ../.././gcc/lra-eliminations.c:1385 #1 0x084bc1f0 in (anonymous namespace)::address_eliminator::address_eliminator (this=0xbfffdb90, ad=<optimized out>) at ../.././gcc/lra-constraints.c:362 #2 0x084bc320 in satisfies_memory_constraint_p (op=op@entry=0xb772ad40, constraint=CONSTRAINT_m) at ../.././gcc/lra-constraints.c:401 #3 0x084c2b3a in process_alt_operands (only_alternative=<optimized out>) at ../.././gcc/lra-constraints.c:2252 #4 curr_insn_transform (check_only_p=check_only_p@entry=false) at ../.././gcc/lra-constraints.c:3848 #5 0x084c5880 in lra_constraints (first_p=false) at ../.././gcc/lra-constraints.c:4863 #6 0x084b620e in lra (f=0x0) at ../.././gcc/lra.c:2392 #7 0x08477648 in do_reload () at ../.././gcc/ira.c:5478 #8 (anonymous namespace)::pass_reload::execute (this=0x96ec4d0) at ../.././gcc/ira.c:5662 #9 0x0853a145 in execute_one_pass (pass=0x96ec4d0) at ../.././gcc/passes.c:2465 #10 0x0853a94f in execute_pass_list_1 (pass=0x96ec4d0) at ../.././gcc/passes.c:2554 #11 0x0853a962 in execute_pass_list_1 (pass=0x96eb950, pass@entry=0x96e9280) at ../.././gcc/passes.c:2555 #12 0x0853a9a9 in execute_pass_list (fn=0xb7720000, pass=0x96e9280) at ../.././gcc/passes.c:2565 #13 0x082c18cc in cgraph_node::expand (this=0xb7726000) at ../.././gcc/cgraphunit.c:2042 #14 0x082c2c08 in expand_all_functions () at ../.././gcc/cgraphunit.c:2178 #15 symbol_table::compile (this=this@entry=0xb76680c4) at ../.././gcc/cgraphunit.c:2535 #16 0x082c48e9 in symbol_table::compile (this=0xb76680c4) at ../.././gcc/cgraphunit.c:2595 #17 symbol_table::finalize_compilation_unit (this=0xb76680c4) at ../.././gcc/cgraphunit.c:2625 #18 0x085f417a in compile_file () at ../.././gcc/toplev.c:492 #19 0x081a14e3 in do_compile () at ../.././gcc/toplev.c:2003 #20 toplev::main (this=0xbfffe8fe, argc=<optimized out>, argv=<optimized out>) at ../.././gcc/toplev.c:2138 #21 0x081a3741 in main (argc=10, argv=0xbfffe9c4) at ../.././gcc/main.c:39
Cleaned up testcase: /* PR rtl-optimization/83317 */ /* { dg-do compile } */ /* { dg-options "-O1" } */ /* { dg-additional-options "-fPIC" { target fpic } } */ /* { dg-additional-options "-march=prescott -mfpmath=sse" { target ia32 } } */ struct S { double a; }; struct S c; int d, e; void *buf[64]; extern int setjmp (void **); void foo () { setjmp (buf); struct S g; if (d) g.a = __builtin_copysign (e, d); c = g; } Started with r243632, even latest trunk ICEs.
Instead of -march=prescott we can use -msse2.
Investigating.
Eric, I think the patch caused the problem was intended for asm insns but it actually works on any insn. I guess constraining the original patch to asms could be a solution. I can make a patch and after testing will commit it if it is ok with you. Something like Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 255470) +++ lra-constraints.c (working copy) @@ -3222,7 +3222,8 @@ /* Do not attempt to decompose arbitrary addresses generated by combine for asm operands with loose constraints, e.g 'X'. */ else if (MEM_P (op) - && !(get_constraint_type (cn) == CT_FIXED_FORM + && !(INSN_CODE (curr_insn) < 0 + && get_constraint_type (cn) == CT_FIXED_FORM && constraint_satisfied_p (op, cn))) decompose_mem_address (&ad, op); else if (GET_CODE (op) == SUBREG
> I guess constraining the original patch to asms could be a solution. I can > make a patch and after testing will commit it if it is ok with you. > > Something like > > Index: lra-constraints.c > =================================================================== > --- lra-constraints.c (revision 255470) > +++ lra-constraints.c (working copy) > @@ -3222,7 +3222,8 @@ > /* Do not attempt to decompose arbitrary addresses generated by combine > for asm operands with loose constraints, e.g 'X'. */ > else if (MEM_P (op) > - && !(get_constraint_type (cn) == CT_FIXED_FORM > + && !(INSN_CODE (curr_insn) < 0 > + && get_constraint_type (cn) == CT_FIXED_FORM > && constraint_satisfied_p (op, cn))) > decompose_mem_address (&ad, op); > else if (GET_CODE (op) == SUBREG It's OK with me, but both the original patch and this one are only kludges. The problem is that they consider only the first alternative, i.e. they work fine if there is only one "X" in the constraint but badly fail for e.g. "X,m". I can simply revert the original patch and XFAIL the test, no big deal.
Author: vmakarov Date: Fri Dec 8 23:47:44 2017 New Revision: 255517 URL: https://gcc.gnu.org/viewcvs?rev=255517&root=gcc&view=rev Log: 2017-12-08 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/83317 * lra-constraints.c (process_address_1): Add insn code check. 2017-12-08 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/83317 * gcc.target/i386/pr83317.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr83317.c Modified: trunk/gcc/ChangeLog trunk/gcc/lra-constraints.c trunk/gcc/testsuite/ChangeLog
GCC 7.3 is being released, adjusting target milestone.
Fixed in GCC 8.