With the recent change went in tree-complex.c causing the galgel's runtime failure with miscompare output. http://gcc.gnu.org/ml/gcc-cvs/2005-06/msg00767.html
It fails everywhere, not just on ppc.
I guess a reduced testcase might help.
I think that bifgel.f90 is being miscompiled.
Created attachment 9306 [details] Fortran 90 code to compute spherical bessel functions The attached code computes the spherical bessel functions with a complex argument. Complex arithmetic has been broken. Here's the results of compiling the code The 3rd and 4th columns should be the same. troutmask:sgk[207] gfc -o z zy.f90 troutmask:sgk[208] ./z 0 2.2900E+01 -3.4445E-02 -3.4445E-02 0.0000E+00 1 2.2900E+01 2.5337E-02 2.5337E-02 0.0000E+00 2 2.2900E+01 3.7765E-02 3.7765E-02 0.0000E+00 3 2.2900E+01 -1.7091E-02 -1.7091E-02 0.0000E+00 4 2.2900E+01 -4.2989E-02 -4.2989E-02 0.0000E+00 troutmask:sgk[209] gfc -o z -O zy.f90 troutmask:sgk[211] ./z 0 2.2900E+01 -3.4445E-02 -3.4445E-02 0.0000E+00 1 2.2900E+01 2.5337E-02 3.9638E-02 0.0000E+00 2 2.2900E+01 3.7765E-02 -5.0710E-02 0.0000E+00 3 2.2900E+01 -1.7091E-02 7.3035E-02 0.0000E+00 4 2.2900E+01 -4.2989E-02 -1.2032E-01 0.0000E+00 troutmask:sgk[213] gfc --version GNU Fortran 95 (GCC 4.1.0 20050712 (experimental))
Reduced testcase. The program should print 6.00E+00 0.00E+00 but prints 4.00E+00 0.00E+00 when compiled with -O: ========================= program FOO integer i complex a, b, c b = 2 c = 0 do i = 1, 2 a = 2 * b - c c = b b = a end do print '(2ES10.2)', a end program FOO =========================
Thanks for the reduction; I see the problem clearly now. For the record, b$real_193 = CR.53_187; b$imag_194 = CI.54_188; c$real_195 = b$real_193; c$imag_196 = b$imag_194; we had a ring of copies to perform, and they came out in the wrong order. I'll have to give this some thought...
Subject: Bug 22504 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2005-07-22 00:33:48 Modified files: gcc : ChangeLog tree-complex.c Log message: PR tree-opt/22504 * tree-complex.c (complex_ssa_name_components): New. (cvc_lookup): Allow entry not found. (create_components): Remove. (create_one_component_var, get_component_var): New. (get_component_ssa_name, set_component_ssa_name): New. (extract_component): Use get_component_ssa_name. (update_complex_components): Use set_component_ssa_name. (update_complex_components_on_edge): Likewise. (update_phi_components): Create new PHI nodes directly, instead of adding insns to edges. (tree_lower_complex): Allocate and free complex_variable_components and complex_ssa_name_components here. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9507&r2=2.9508 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-complex.c.diff?cvsroot=gcc&r1=2.36&r2=2.37
Richard, are you going to add a testcase for this? Can somebody confirm that the benchmark testcase is fixed, too?
galgel still fails for me even with the patch.
This is miscompiled: SUBROUTINE foo (A, B) IMPLICIT NONE COMPLEX*16 A, Im1 REAL*8 B Im1 = Dcmplx(0.D0, 1.D0) A = A + Im1 * B RETURN END SUBROUTINE foo t.f90.t35.ch: ;; Function foo (foo_) foo (a, b) { complex8 im1; complex8 D.808; complex8 D.807; complex8 D.806; real8 D.805; complex8 D.804; <bb 0>: D.804_3 = *a_2; D.805_5 = *b_4; D.806_6 = COMPLEX_EXPR <D.805_5, 0.0>; D.807_7 = D.806_6 * __complex__ (0.0, 1.0e+0); D.808_8 = D.804_3 + D.807_7; *a_2 = D.808_8; return; } t.f90.t37.cplxlower: foo (a, b) { real8 CI.14; real8 D.834; real8 CI.13; real8 CR.12; real8 D.831; real8 D.830; complex8 im1; complex8 D.808; complex8 D.807; complex8 D.806; real8 D.805; complex8 D.804; <bb 0>: D.830_15 = REALPART_EXPR <*a_2>; D.831_16 = IMAGPART_EXPR <*a_2>; D.804_3 = COMPLEX_EXPR <D.830_15, D.831_16>; CR.12_12 = D.830_15; CI.13_13 = D.831_16; D.805_5 = *b_4; D.806_6 = COMPLEX_EXPR <D.805_5, 0.0>; D.807_7 = COMPLEX_EXPR <0.0, D.805_5>; D.834_17 = CI.13_13 - D.805_5; D.808_8 = COMPLEX_EXPR <CR.12_12, D.834_17>; CI.14_14 = D.834_17; REALPART_EXPR <*a_2> = CR.12_12; IMAGPART_EXPR <*a_2> = CI.14_14; return; }
These are the only bugs I could find in expand_complex_addition: Index: tree-complex.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-complex.c,v retrieving revision 2.39 diff -u -3 -p -r2.39 tree-complex.c --- tree-complex.c 25 Jul 2005 23:04:33 -0000 2.39 +++ tree-complex.c 26 Jul 2005 08:26:07 -0000 @@ -844,7 +844,7 @@ expand_complex_addition (block_stmt_iter case PAIR (VARYING, ONLY_IMAG): rr = ar; - ri = gimplify_build2 (bsi, MINUS_EXPR, inner_type, ai, bi); + ri = gimplify_build2 (bsi, code, inner_type, ai, bi); break; case PAIR (ONLY_REAL, VARYING): @@ -858,7 +858,7 @@ expand_complex_addition (block_stmt_iter if (code == MINUS_EXPR) goto general; rr = br; - ri = gimplify_build2 (bsi, MINUS_EXPR, inner_type, ai, bi); + ri = gimplify_build2 (bsi, code, inner_type, ai, bi); break;
Steven's patch has fixed the galgel failure. I've verified it on Powerpc.
Subject: Bug 22504 CVSROOT: /cvs/gcc Module name: gcc Changes by: steven@gcc.gnu.org 2005-07-26 21:38:46 Modified files: gcc : ChangeLog tree-complex.c Log message: PR tree-optimization/22504 * tree-complex.c (expand_complex_addition): Use 'code' instead of MINUS_EXPR for (VARYING, ONLY_IMAG) and (ONLY_IMAG, VARYING). Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9556&r2=2.9557 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-complex.c.diff?cvsroot=gcc&r1=2.39&r2=2.40
The bug is fixed. I still have to add test cases.