Bug 40669 - [4.3/4.4/4.5 Regression] ICE in gimple_assign_set_rhs1 from eliminate_tail_call
Summary: [4.3/4.4/4.5 Regression] ICE in gimple_assign_set_rhs1 from eliminate_tail_call
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.3.4
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on: 40328
Blocks:
  Show dependency treegraph
 
Reported: 2009-07-07 08:54 UTC by Jakub Jelinek
Modified: 2009-07-07 14:09 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-linux
Build:
Known to work: 4.3.4 4.4.1 4.5.0
Known to fail: 4.3.3 4.4.0
Last reconfirmed: 2009-07-07 09:15:44


Attachments
gcc45-pr40669.patch (859 bytes, patch)
2009-07-07 09:46 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2009-07-07 08:54:41 UTC
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.
Comment 1 Richard Biener 2009-07-07 09:15:43 UTC
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....
Comment 2 Richard Biener 2009-07-07 09:23:36 UTC
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.
Comment 3 Jakub Jelinek 2009-07-07 09:46:32 UTC
Created attachment 18150 [details]
gcc45-pr40669.patch

Patch I'm going to bootstrap/regtest.
Comment 4 Richard Biener 2009-07-07 10:01:03 UTC
4.4 will need a backport of PR40328 as well.  Your attached patch is ok.
Comment 5 Jakub Jelinek 2009-07-07 12:18:53 UTC
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

Comment 6 Richard Biener 2009-07-07 12:44:48 UTC
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

Comment 7 Jakub Jelinek 2009-07-07 14:07:42 UTC
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

Comment 8 Jakub Jelinek 2009-07-07 14:09:11 UTC
Fixed.