When I feed the following program "ice.c" typedef double v2df __attribute__ ((mode(V2DF))); int main() { volatile v2df xd; v2df yd = { 1.0, 4.0 }; xd = __builtin_ia32_cvtps2pd(__builtin_ia32_rsqrtps(__builtin_ia32_cvtpd2ps(yd))); return 0; } to GCC 3.4.3 with gcc -march=pentium4 -mcpu=pentium4 -msse2 -funroll-loops ice.c -o ice I get the following: ice.c: In function `main': ice.c:11: internal compiler error: in simplify_binary_operation, at simplify-rtx.c:1202 If I omit "-funroll-loops", everything seems to work. Best regards, Steffen 8-)
Confirmed : Search converges between 2003-03-31-trunk (#217) and 2003-04-01-trunk (#218).
Works OK with gcc version 4.0.0 20041123 (experimental). Following ASM is produced with 'gcc -march=pentium4 -mcpu=pentium4 -msse2 -funroll-loops': .LC0: .long 0 .long 1072693248 .long 0 .long 1074790400 .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $40, %esp andl $-16, %esp movl $0, %eax | addl $15, %eax | addl $15, %eax | shrl $4, %eax |<--- WHY? sall $4, %eax | subl %eax, %esp movapd .LC0, %xmm0 movapd %xmm0, -24(%ebp) cvtpd2ps -24(%ebp), %xmm0 rsqrtps %xmm0, %xmm0 cvtps2pd %xmm0, %xmm0 movapd %xmm0, -40(%ebp) movl $0, %eax leave ret I don't know what is the purpouse of marked operations on %eax...
Oops... gcc 4.0 crashes with "-msse2 -O2", with or without -funroll-loops: pr18614.c: In function âmainâ: pr18614.c:12: internal compiler error: in simplify_binary_operation, at simplify-rtx.c:1202
Gcc crashes with this insn: (insn 25 24 26 0 (set (reg:V4SF 60 [ D.1457 ]) (subreg:V4SF (vec_concat:V4SI (subreg:V2SI (float_truncate:V2SF (reg:V2DF 73)) 0) (const_vector:V2SI [ (const_int 0 [0x0]) (const_int 0 [0x0]) ])) 0)) -1 (nil) (nil)) n_elts is calculated as 4, but op0_n_elts and op1_n_elts are 2 (which is kind of obvious for vec_concat). Because a constant is loaded to (reg 73), the whole insn simplifies to vec_concat of two constant 2-element vectors. This triggers the asserts: gcc_assert (op0_n_elts == n_elts); gcc_assert (op1_n_elts == n_elts); The fix would be to prevent an entry of vec_concat into simplify_binary_operation().
Patch here: http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01867.html Resulting ASM with '-O2 -msse2' is much better. Optimization did its job quite well :) .LC1: .long 1065353216 .long 1082130432 .long 0 .long 0 .text .p2align 4,,15 .globl main .type main, @function main: pushl %ebp xorl %eax, %eax movl %esp, %ebp subl $24, %esp rsqrtps .LC1, %xmm0 andl $-16, %esp subl $16, %esp cvtps2pd %xmm0, %xmm0 movapd %xmm0, -24(%ebp) leave ret
Fixed on mainline: CVSROOT: /cvs/gcc Module name: gcc Changes by: uros@gcc.gnu.org 2004-11-23 16:20:51 Modified files: gcc : ChangeLog simplify-rtx.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr18614-1.c Log message: rtl-optimization/18614 * simplify-rtx.c (simplify_binary_operation): Do not simplify inner elements of constant arguments of VEC_CONCAT insn. testsuite: * gcc.dg/pr18614-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6487&r2=2.6488 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/simplify-rtx.c.diff?cvsroot=gcc&r1=1.208&r2=1.209 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4632&r2=1.4633 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18614-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 Could someone please commit this one-liner to 3.4 branch?
Did you do a bootstrap & test cycle on 3.4 as well?
(In reply to comment #7) > Did you do a bootstrap & test cycle on 3.4 as well? Yes. But I need some kind of permission to install this patch & testcase on 3.4 branch.
Subject: Bug 18614 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: uros@gcc.gnu.org 2004-11-24 14:20:57 Modified files: gcc : ChangeLog simplify-rtx.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr18614-1.c Log message: PR rtl-optimization/18614 * simplify-rtx.c (simplify_binary_operation): Do not simplify inner elements of constant arguments of VEC_CONCAT insn. testsuite: * gcc.dg/pr18614-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.701&r2=2.2326.2.702 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/simplify-rtx.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.172.4.3&r2=1.172.4.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.311&r2=1.3389.2.312 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr18614-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed on 3.4 branch.