public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <richard.guenther@gmail.com>,
	Richard Sandiford <richard.sandiford@arm.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Peter Bergner <bergner@linux.ibm.com>
Subject: Re: PING^1 [PATCH v2] predict: Adjust optimize_function_for_size_p [PR105818]
Date: Thu, 15 Dec 2022 16:33:21 +0800	[thread overview]
Message-ID: <b97662db-5fbd-dc93-efac-03a5554f6d0a@linux.ibm.com> (raw)
In-Reply-To: <Y5nOCM5gxRVOEexX@kam.mff.cuni.cz>

Hi Honza,

Thanks for the comments.

on 2022/12/14 21:22, Jan Hubicka wrote:
>>> 	PR middle-end/105818
>>>
>>> gcc/ChangeLog:
>>>
>>> 	* predict.cc (optimize_function_for_size_p): Further check
>>> 	optimize_size of fun->decl when it is valid but no cgraph node.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 	* gcc.target/powerpc/pr105818.c: New test.
>>> 	* gcc.dg/guality/pr54693-2.c: Adjust for aarch64.
>>> diff --git a/gcc/testsuite/gcc.target/powerpc/pr105818.c b/gcc/testsuite/gcc.target/powerpc/pr105818.c
>>> new file mode 100644
>>> index 00000000000..679647e189d
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.target/powerpc/pr105818.c
>>> @@ -0,0 +1,11 @@
>>> +/* { dg-options "-Os -fno-tree-vectorize" } */
>>> +
>>> +/* Verify there is no ICE.  */
>>> +
>>> +#pragma GCC optimize "-fno-tree-vectorize"
>>> +
>>> +void
>>> +foo (void)
>>> +{
>>> +  void bar (void);
>>> +}
> So the testcase starts with optimize_size set but then it switches to
> optimize_size==0 due to the GCC optimize pragma.  I think this is
> behaviour Martin wants to change, so perhaps the testcase should be
> written with explicit -O2.

No, both the global context and the function context are to optimize
for size, Martin also clarified that.  So the issue is the inconsistent
information on optimizing for size when parsing bar, at that time
cfun->decl is available but no cgraph node, it says OPTIMIZE_SIZE_NO. 

> 
> I also wonder what happen when you add the attribute later?
> /* { dg-options "-Os -fno-tree-vectorize" } */
> 
> /* Verify there is no ICE.  */
> 
> #pragma GCC optimize "-fno-tree-vectorize"
>
// marker A

> void
> foo (void)
> {
>   void bar (void);
> }
> 
> __attribute__ ((optimize("-fno-tree-vectorize"))) void foo (void);

There is still one ICE with this additional decl.  Same ICE if I moved
it to "marker A" above.

> 
> I think we should generally avoid doing decisions about size/speed
> optimizations so early since the setting may change due to attribtes or
> profile feedback...
> 

Good point, I'll make a separated patch to move optimize_function_for_speed_p
uses out of function rs6000_option_override_internal, but I think it's a
separated issue which just results in imperfect "optimize for size" decision.
Fixing it can cover this exposed ICE, but IMHO this exposed inconsistent
information on "optimize for size" exposed here is still an issue, like: all
the context is to optimize for size, but it still returns OPTIMIZE_SIZE_NO.

Do you agree?

BR,
Kewen

      parent reply	other threads:[~2022-12-15  8:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  8:30 Kewen.Lin
2022-12-14 11:27 ` PING^1 " Kewen.Lin
2022-12-14 13:22   ` Jan Hubicka
2022-12-14 13:55     ` Martin Liška
2022-12-15  8:33     ` Kewen.Lin [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=b97662db-5fbd-dc93-efac-03a5554f6d0a@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=richard.guenther@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=segher@kernel.crashing.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).