From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Jingwen Wu <elowen.jjw@gmail.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: issue: unexpected results in optimizations
Date: Tue, 12 Dec 2023 09:02:25 +0000 [thread overview]
Message-ID: <CAH6eHdTrE8c_c31W_rXoVDDzJNdupDGVRbrm=dR-fMY2CfZy_A@mail.gmail.com> (raw)
In-Reply-To: <CAJAwgAxf9SE2YjE7d_ewiVFcctxKHe-U+ehdUOWTQWSceO+6eg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]
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.
version: gcc 12.2.0
> os: ubuntu 22.04
>
next prev parent reply other threads:[~2023-12-12 10:07 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 [this message]
2023-12-12 11:08 ` Alexander Monakov
-- 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='CAH6eHdTrE8c_c31W_rXoVDDzJNdupDGVRbrm=dR-fMY2CfZy_A@mail.gmail.com' \
--to=jwakely.gcc@gmail.com \
--cc=elowen.jjw@gmail.com \
--cc=gcc@gcc.gnu.org \
/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).