Bug 34966 - [4.3 Regression] ICE: verify_ssa fails when optimization trigonometric code
Summary: [4.3 Regression] ICE: verify_ssa fails when optimization trigonometric code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
: 34968 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-01-25 02:35 UTC by Doug Kwan
Modified: 2008-01-25 12:09 UTC (History)
4 users (show)

See Also:
Host: i686-unknown-linux-gnu
Target: i686-unknown-linux-gnu
Build: i686-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-01-25 10:01:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Kwan 2008-01-25 02:35:10 UTC
I got an internal compiler error when compiling the following.  The function my_atan is actaully derived from aton expanded from a C libray header. Other then its name, it is almost identical to atan().


dougkwan@f666g:~/delta-2006.08.03/verify_ssa$ ./gcc -O2 PJ_geos.4.c 
PJ_geos.4.c: In function 'e_forward':
PJ_geos.4.c:22: error: definition in block 2 follows the use
for SSA_NAME: result_9 in statement:
sincostmp.17_15 = __builtin_cexpi (result_9);
PJ_geos.4.c:22: internal compiler error: verify_ssa failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

--------------------
extern double hypot (double, double);
extern double cos (double);
extern double sin (double);

double
my_atan (double x)
{
  register double result;
  asm volatile ("fld1; fpatan"
                : "=t" (result)
                : "0" (x)
                : "st(1)");
  return result;
}

typedef struct {
   double phi;
} LP;

void
e_forward(LP lp, double x)
{
  lp.phi = my_atan (x);
  x = hypot(cos (lp.phi), sin (lp.phi));
}
---------------------
Comment 1 Andrew Pinski 2008-01-25 04:04:33 UTC
*** Bug 34968 has been marked as a duplicate of this bug. ***
Comment 2 Doug Kwan 2008-01-25 07:49:29 UTC
(In reply to comment #0)

A slightly simpler test case:

--------------
extern double sin (double), cos (double);

__inline double
atan (double __x)
{
  register double __result;
  __asm __volatile__ ("fld1; fpatan" : "=t" (__result) : "0" (__x) : "st(1)");
  return __result;
}

double
f(double x)
{
  double t = atan (x);
  return cos (t) + sin (t);
}
-------------
Comment 3 Richard Biener 2008-01-25 10:01:45 UTC
Mine.  Actually we do not see the SSA_NAME definition in the asm stmt and so
insert in the wrong place.
Comment 4 Richard Biener 2008-01-25 12:09:29 UTC
Fixed.
Comment 5 Richard Biener 2008-01-25 12:09:37 UTC
Subject: Bug 34966

Author: rguenth
Date: Fri Jan 25 12:08:52 2008
New Revision: 131824

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131824
Log:
2008-01-25  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/34966
	* tree-ssa-math-opts.c (execute_cse_sincos_1): For all but
	default defs and PHI_NODEs we have to insert after the
	defining statement.

	* gcc.c-torture/compile/pr34966.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr34966.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-math-opts.c