public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Krister Walfridsson <krister.walfridsson@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Translation validation
Date: Tue, 20 Sep 2022 23:40:51 +0000 (UTC)	[thread overview]
Message-ID: <Pine.NEB.4.64.2209202335290.18121@gateway.kwa> (raw)
In-Reply-To: <CAFiYyc2yfhk9M74wpj9-DmNdohSaL+ftH-VZXXJHXJbaWcfMBA@mail.gmail.com>

On Wed, 14 Sep 2022, Richard Biener wrote:

> Note that the folding/peephole optimizations done early can be avoided
> when you separate opportunities in the source to multiple statements,
> like change
>
>  int a, b;
>  a = b + 1 - b;
>
> to
>
> a = b + 1;
> a = a - b;
>
> note that parts of the folding optimizations are shared between GENERIC
> and GIMPLE (those generated from match.pd), so those will be exercised.
> Fully exercising and verifying the fold-const.cc only optimizations which
> happen on GENERIC only is indeed going to be difficult.
>
> Another way to avoid some of the pre-SSA optimizations is to feed the
> plugin with input from the GIMPLE frontend.  Look at
> gcc/testsuite/gcc.dg/gimplefe-*.c for examples, IL can be dumped
> roughly in a format suitable as GIMPLE frontend input by dumping
> with -fdump-tree-<opt>-gimple (but note all type, global variable and function
> declarations are missing ...)

This does not help when trying to find wrong-code bugs by compiling random 
source code with plugin1.py.  :(

But it helps when writing tests for plugin2.py, so I wrote a simple script 
that extracts the first operand from match.pd simplify expressions and 
uses that to generate test cases. For example,

   (simplify
    (mult (abs@1 @0) @1)
    (mult @0 @0))

is generated as

   int __GIMPLE () f (int a0)
   {
     int _0;
     int a1;
     int _2;
     int _3;

     _2 = a0;
     a1 = __ABS _2;
     _3 = a1;
     _0 = a1 * _3;
     return _0;
   }

This is not an optimal way to find bugs as many of the simplify 
expressions have additional restrictions in the replacement part, so many 
of my generated functions fail to trigger optimizations...

This did not find any wrong-code bugs, but it found two cases where 
match.pd is missing TYPE_OVERFLOW_SANITIZED checks: PR 106990.

    /Krister

      reply	other threads:[~2022-09-20 23:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 21:31 Krister Walfridsson
2022-09-14  6:10 ` Richard Biener
2022-09-20 23:40   ` Krister Walfridsson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.NEB.4.64.2209202335290.18121@gateway.kwa \
    --to=krister.walfridsson@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).