This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/5739] "const" and "pure" function attributes pessimize code
- From: "dann at godzilla dot ics dot uci dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 May 2004 22:59:18 -0000
- Subject: [Bug rtl-optimization/5739] "const" and "pure" function attributes pessimize code
- References: <20020220141600.5739.dann@godzilla.ics.uci.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From dann at godzilla dot ics dot uci dot edu 2004-05-27 22:59 -------
(In reply to comment #7)
> Note on the mainline now the loops are empty which is correct.
> This testcase will produce code but I cannot reproduce this on PPC or on x86:
[snip]
> Does this still happen on SPARC also?
Not with this example, tree-ssa is too smart and sees almost everything as dead
code, here is a slightly modified one:
#ifdef MY_PURE
extern double mycos (double) __attribute__ ((pure));
extern double mysin (double) __attribute__ ((pure));
#elif defined MY_CONST
extern double mycos (double) __attribute__ ((const));
extern double mysin (double) __attribute__ ((const));
#else
extern double mycos (double);
extern double mysin (double);
#endif
struct my_complex
{
double re;
double im;
};
void
foo (struct my_complex u[])
{
int i;
for (i = 0; i < 2048; ++i)
{
u[i].re = 1.0;
u[i].im = 0.0;
}
for (i = 0; i < 2048; ++i) {
struct my_complex *p = u;
unsigned int j;
for (j = 0; j < 2048; ++j) {
double ur = p->re;
double ui = p->im;
double u2 = ur * ur + ui * ui;
double cosv = mycos (u2);
double sinv = mysin (u2);
p->re = p->re * cosv - p->im * sinv;
p->im = p->im * sinv + p->re * cosv;
++p;
}
}
}
the difference between the MY_CONST/PURE code and the one without is smaller,
but it _still_ exists, the MY_CONST/PURE code has 2 extra stores.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5739