This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Testsuite and constant-folding?


Brooks Moses <brooks.moses@codesourcery.com> wrote on Fri, 05 Jan 2007:

(Note: This issue came up in considering the Fortran testsuite, but I
think it's sufficiently relevant to GCC as a whole (and I'm hoping for
some comments from people familiar with the non-Fortran parts of GCC
that it seemed reasonable to crosspost it.)


I've been recently poking at some bugs in Fortran's intrinsics (specifically, ISHFTC and IBCLR and the like), and one of the tricky bits is that there are two entirely separate code paths to consider -- there's the GMP-based one in gcc/fortran/simplify.c that does constant-folding, and there's the native-code one in libgfortran that does the runtime work.

However, as best I can tell, the relevant testcases completely ignore
this issue, and thus end up only testing the constant-folding case.
This strikes me as likely to be an endemic problem in the Fortran
testsuite, and I would guess that substantial portions of libgfortran
are not actually tested by "make check-fortran".

(To avoid further confusion downthread: there are two types of constant folding in a gfortran compilation:
1. Fortran expressions are folded during parsing to determine if an expression is a valid initialization / constant expression
2. when building trees from the frontend representation (completely folded per 1.), the middleend fold machinery comes into play.)


So, three questions:

(1) For a given Fortran testcase, is there a reliable way of ensuring
that a given expression is not constant-folded and instead gets
evaluated at runtime?

Yes, or no, depending on how you look at it. Simply set a variable to the value you want to test the library for, and then pass that to the intrinsic. The frontend folders will not propagate the value into the intrisic's argument (which is what you want), but the optimizers may (and this is hard to avoid, but testing -O0 should be sufficient for this).


(2) Is there a way to turn off (essentially) all of the
constant-folding machinery in a given compilation?

No, since then validity of a program couldn't be established, as pointed out above.


(3) How do GCC testsuites other than the Fortran one handle this issue?

Don't know, this is certainly a FE specific issue.


I think that this is probably a significant enough issue that it would
be worth implementing an option in the Fortran front end to turn off
the majority (or even all) of the constant folding, and then adding a
testsuite pass that uses this option.  Is there a relevant flag already
present in GCC, or would we need to add one?  Thoughts on this proposal?

I don't think it's doable. What we've been doing in the past is to add testcases when we find out that the library or the frontend was broken. Most testcases are probably still FE only.


Cheers,
- Tobi


---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]