double _Complex test (int d, int t, double *x, double *y, double *z, int n, double _Complex (*fnp) (double)) { int m = n / 2; double min = y[t], max = z[t], med = x[m * d + t]; double _Complex result = 0.0; if (n == 0) return 0.0; if (min > med) result += test (d, (t + 1) % d, x + (m + 1) * d, y, z, n - m - 1, fnp); else if (max < med) result += test (d, (t + 1) % d, x, y, z, m, fnp); else { result += fnp (y[0] + x[m]); result += test (d, (t + 1) % d, x + (m + 1) * d, y, z, n - m - 1, fnp); } return result; } ICEs at -O2 -ffast-math on x86_64-linux, in 4.4/4.5 with: x.i: In function 'test': x.i:22:1: internal compiler error: in gimple_assign_set_rhs1, at gimple.h:1683 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. and in 4.3 with: x.i: In function 'test': x.i:4: internal compiler error: in set_ssa_val_to, at tree-ssa-sccvn.c:1071 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Compiles just fine with 4.1 and 4.2.
With my local 4.3 copy it prints t.i: In function ‘test’: t.i:22: error: PHI def is not a GIMPLE value add_acc.0_64 = PHI <COMPLEX_EXPR <0.0, 0.0>(0), add_acc.0_60(7), add_acc.0_64(6), add_acc.0_64(4)> COMPLEX_EXPR <0.0, 0.0>; t.i:22: error: invalid operand to binary operator add_acc.0_64 t.i:22: error: invalid operand to binary operator add_acc.0_64 t.i:22: internal compiler error: verify_stmts failed Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. which is because COMPLEX_EXPR <0.0, 0.0> should be COMPLEX_CST <0.0, 0.0> to be valid. Didn't I fix that lately....
Yeah, PR40328. Then we are left with t.i: In function ‘test’: t.i:22: error: invalid operand to binary operator add_acc.0_64 t.i:22: error: invalid operand to binary operator add_acc.0_64 t.i:22: internal compiler error: verify_stmts failed Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. which means the decl doesn't have DECL_GIMPLE_REG_P set. I'll take care of 4.3.
Created attachment 18150 [details] gcc45-pr40669.patch Patch I'm going to bootstrap/regtest.
4.4 will need a backport of PR40328 as well. Your attached patch is ok.
Subject: Bug 40669 Author: jakub Date: Tue Jul 7 12:18:38 2009 New Revision: 149319 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149319 Log: PR middle-end/40669 * tree-tailcall.c (adjust_return_value_with_ops, create_tailcall_accumulator): Set DECL_GIMPLE_REG_P on the temporary if it has complex or vector type. * gcc.dg/pr40669.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr40669.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-tailcall.c
Subject: Bug 40669 Author: rguenth Date: Tue Jul 7 12:44:32 2009 New Revision: 149321 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149321 Log: 2009-07-07 Richard Guenther <rguenther@suse.de> PR middle-end/40328 PR tree-optimization/40669 * tree-tailcall.c (adjust_accumulator_values): Properly set DECL_GIMPLE_REG_P. (adjust_return_value): Likewise. (tree_optimize_tail_calls_1): Likewise. * fold-const.c (fold_convert): Fold the built COMPLEX_EXPR. * gcc.dg/pr40669.c: New testcase. * gcc.dg/torture/pr40328.c: Likewise. Added: branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/pr40669.c branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/torture/pr40328.c Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/fold-const.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog branches/gcc-4_3-branch/gcc/tree-tailcall.c
Subject: Bug 40669 Author: jakub Date: Tue Jul 7 14:07:19 2009 New Revision: 149329 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149329 Log: PR middle-end/40669 * tree-tailcall.c (adjust_return_value_with_ops, create_tailcall_accumulator): Set DECL_GIMPLE_REG_P on the temporary if it has complex or vector type. Backport from mainline: 2009-06-03 Richard Guenther <rguenther@suse.de> PR middle-end/40328 * fold-const.c (fold_convert): Fold the build COMPLEX_EXPR. * gcc.dg/pr40669.c: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40669.c Modified: branches/gcc-4_4-branch/gcc/ChangeLog branches/gcc-4_4-branch/gcc/fold-const.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/tree-tailcall.c
Fixed.