From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jan Hubicka <hubicka@ucw.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const
Date: Mon, 20 Mar 2023 08:33:04 +0000 (UTC) [thread overview]
Message-ID: <nycvar.YFH.7.77.849.2303200831270.18795@jbgna.fhfr.qr> (raw)
In-Reply-To: <ZBTFfqUQ+wluuWE/@tucnak>
On Fri, 17 Mar 2023, Jakub Jelinek wrote:
> On Fri, Mar 17, 2023 at 08:40:34PM +0100, Jan Hubicka wrote:
> > > + /* Drop the const attribute from the call type (the pure
> > > + attribute is not available on types). */
> > > + tree fntype = gimple_call_fntype (call);
> > > + if (fntype && TYPE_READONLY (fntype))
> > > + gimple_call_set_fntype
> > > + (call, build_qualified_type (fntype, (TYPE_QUALS (fntype)
> > > + & ~TYPE_QUAL_CONST)));
> >
> > Sorry, now I am bit confused on why Jakub's fix did not need similar
> > fixup. The flag is only set during the profiling stage and thus I would
> > expect it to still run into the problem that VOPs are missing.
> > Is it only becuase we do not sanity check?
>
> My patch started from this point ignoring all TYPE_READONLY bits on
> all FUNCTION_TYPE/METHOD_TYPEs, while Richi's patch instead makes it
> explicit in the IL, TYPE_READONLY is honored as before but it shouldn't
> show up in any of the gimple_call_fntype types unless it is a direct
> call to a const function for which we don't have a body.
>
> In either case, vops are added on the update_stmt a few lines later.
>
> > Here is a testcase that shows the problem:
> >
> > include <math.h>
> > float c;
> >
> > __attribute__ ((const))
> > float
> > instrument(float v)
> > {
> > return sin (v);
> > }
> > __attribute__ ((no_profile_instrument_function,const,noinline))
> > float noinstrument (float v)
> > {
> > return instrument (v);
> > }
> >
> > m()
> > {
> > c+=instrument(c);
> > if (!__builtin_expect (c,1))
> > {
> > c+=noinstrument (c);
> > }
> > c+=instrument(c);
> > }
> > main()
> > {
> > m();
> > }
> >
> > Compiling
> > gcc -O0 t.c -fprofile-arcs -fno-early-inlining --coverage -lm -ftest-coverage -S ; gcc t.s -ftest-coverage -lm -fprofile-arcs
> > makes gcov to report 3 executions on instrument while with -O3 it is 2.
With my proposed patch it works fine and reports 3 executions on
'instrument' with both -O0 and -O3. I checked it indeed reports only
2 executions with GCC 12.
So it seems the patch is a progression in general?
Thus, OK?
Thanks,
Richard.
next prev parent reply other threads:[~2023-03-20 8:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 7:59 Richard Biener
2022-11-25 10:05 ` Jan Hubicka
2022-11-25 12:05 ` Richard Biener
2022-11-25 12:11 ` Jan Hubicka
2022-11-25 13:05 ` Richard Biener
2022-11-25 13:18 ` Jan Hubicka
2022-11-25 20:26 ` Richard Biener
2023-03-16 11:21 ` Jakub Jelinek
2023-03-16 12:05 ` Richard Biener
2023-03-16 12:13 ` Jakub Jelinek
2023-03-16 12:22 ` Richard Biener
2023-03-16 14:11 ` Richard Biener
2023-03-16 14:27 ` Jakub Jelinek
2023-03-17 19:40 ` Jan Hubicka
2023-03-17 19:54 ` Jakub Jelinek
2023-03-20 8:33 ` Richard Biener [this message]
2023-03-24 10:25 ` Richard Biener
2023-03-24 11:49 ` Jan Hubicka
2023-03-24 13:05 ` Jan Hubicka
2023-03-24 13:07 ` Richard Biener
2023-03-24 13:18 ` Jan Hubicka
2023-03-17 19:09 ` Jan Hubicka
2023-03-17 19:27 ` Jakub Jelinek
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=nycvar.YFH.7.77.849.2303200831270.18795@jbgna.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=jakub@redhat.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).