This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Location of "dg-final" directives? (was Re: [PATCH][GCC] Algorithmic optimization in match and simplify)
- From: Marek Polacek <polacek at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: Andre Vieira <Andre dot SimoesDiasVieira at arm dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 1 Sep 2015 18:54:59 +0200
- Subject: Re: Location of "dg-final" directives? (was Re: [PATCH][GCC] Algorithmic optimization in match and simplify)
- Authentication-results: sourceware.org; auth=none
- References: <55E092D9 dot 8070700 at arm dot com> <1441126227 dot 9002 dot 50 dot camel at surprise>
On Tue, Sep 01, 2015 at 12:50:27PM -0400, David Malcolm wrote:
> I can't comment on the patch itself, but I noticed that in the testsuite
> addition, you've gathered all the "dg-final" clauses at the end.
>
> I think that this is consistent with existing practice in gcc, but
> AFAIK, the dg-final clauses can appear anywhere in the file.
>
> Would it make test cases more readable if we put the dg-final clauses
> next to the code that they relate to? Or, at least after the function
> that they relate to?
>
> For example:
>
> unsigned short
> foo (unsigned short a)
> {
> a ^= 0x4002;
> a >>= 1;
> a |= 0x8000; /* Simplify to ((a >> 1) ^ 0xa001). */
> return a;
> }
> /* { dg-final { scan-tree-dump "\\^ 40961" "forwprop1" } } */
>
> unsigned short
> bar (unsigned short a)
> {
> /* snip */ /* Simplify to ((a << 1) | 0x8005). */
> }
> /* { dg-final { scan-tree-dump "\\| 32773" "forwprop1" } } */
>
> ... etc ...
>
> I think this may be more readable than the "group them all at the end of
> the file approach", especially with testcases with many files and
> dg-final directives.
Yeah, it's probably somewhat more readable. Same for dg-output. E.g. some
ubsan tests already use dg-outputs after functions they relate to.
Marek