From: Alexander Monakov <amonakov@ispras.ru>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: Jingwen Wu <elowen.jjw@gmail.com>, "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: issue: unexpected results in optimizations
Date: Tue, 12 Dec 2023 14:08:06 +0300 (MSK) [thread overview]
Message-ID: <60362582-7546-3dc4-6035-9be925db9b06@ispras.ru> (raw)
In-Reply-To: <CAH6eHdTrE8c_c31W_rXoVDDzJNdupDGVRbrm=dR-fMY2CfZy_A@mail.gmail.com>
On Tue, 12 Dec 2023, Jonathan Wakely via Gcc wrote:
> On Mon, 11 Dec 2023, 17:08 Jingwen Wu via Gcc, <gcc@gcc.gnu.org> wrote:
>
> > Hello, I'm sorry to bother you. And I have some gcc compiler optimization
> > questions to ask you.
> > First of all, I used csmith tools to generate c files randomly. Meanwhile,
> > the final running result was the checksum for global variables in a c file.
> > For the two c files in the attachment, I performed the equivalent
> > transformation of loop from *initial.**c* to *transformed.c*. And the two
> > files produced different results (i.e. different checksum values) when
> > using *-O2* optimization level, while the results of both were the same
> > when using other levels of optimization such as *-O0*, *-O1*, *-O3*, *-Os*,
> > *-Ofast*.
> > Please help me to explain why this is, thank you.
> >
>
> Sometimes csmith can generate invalid code that gets miscompiled. It looks
> like you're compiling with no warnings, which is a terrible idea:
>
>
> > command line: *gcc file.c -O2 -lm -I $CSMITH_HOME/include && ./a.out*
> >
>
> You should **at least** enable warnings and make sure gcc isn't pointing
> out any problems in the code.
>
> You should also try the options suggested at http://gcc.gnu.org/bugs/ which
> help identify invalid code.
Let me also link the "Testing Compilers Using Csmith" page, which is
currently available via the Wayback Machine, but not its original URL:
https://web.archive.org/web/20230316072811/http://embed.cs.utah.edu/csmith/using.html
It was written by the developers of Csmith.
Alexander
next prev parent reply other threads:[~2023-12-12 11:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 17:07 Jingwen Wu
2023-12-11 17:31 ` Dave Blanchard
2023-12-12 8:29 ` Jonathan Wakely
2023-12-12 9:02 ` Jonathan Wakely
2023-12-12 11:08 ` Alexander Monakov [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-12-11 17:14 Jingwen Wu
2023-12-12 8:39 ` David Brown
2023-12-13 18:49 ` James K. Lowden
2023-12-11 17:05 Jingwen Wu
2023-12-11 16:51 Jingwen Wu
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=60362582-7546-3dc4-6035-9be925db9b06@ispras.ru \
--to=amonakov@ispras.ru \
--cc=elowen.jjw@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=jwakely.gcc@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).