public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: Jan Hubicka <hubicka@ucw.cz>
Subject: [PATCH] tree-optimization/106912 - IPA profile and pure/const
Date: Fri, 25 Nov 2022 08:59:44 +0100 (CET)	[thread overview]
Message-ID: <20221125075944.7DA6713A08@imap2.suse-dmz.suse.de> (raw)

IPA profile instrumentation tries to clear the pure and const
flags of functions but that's quite hopeless in particular for
const since that attribute prevails on the type and thus on each
call to the function leading to inconsistencies in the IL and
eventual checking ICEs.  There's no good reason to do this and
it wouldn't fixup any indirect calls so just don't.  No other
instrumentation GCC does bothers about this.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

	PR tree-optimization/106912
	* tree-profile.cc (tree_profiling): Do not clear pure/const
	flags.

	* gcc.dg/pr106912.c: New testcase.
---
 gcc/testsuite/gcc.dg/pr106912.c | 16 ++++++++++++++++
 gcc/tree-profile.cc             |  3 ---
 2 files changed, 16 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr106912.c

diff --git a/gcc/testsuite/gcc.dg/pr106912.c b/gcc/testsuite/gcc.dg/pr106912.c
new file mode 100644
index 00000000000..8faa877d8b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106912.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */
+
+__attribute__ ((__simd__))
+__attribute__ ((__nothrow__ , __leaf__ , __const__))
+double foo (double x);
+void bar(double *f, int n)
+{
+  int i;
+  for (i = 0; i < n; i++)
+    f[i] = foo(f[i]);
+}
+double foo(double x)
+{
+  return x * x / 3.0;
+}
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 2beb49241f2..5491b398870 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -814,9 +814,6 @@ tree_profiling (void)
 	/* Don't profile functions produced for builtin stuff.  */
 	if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
 	  continue;
-
-	node->set_const_flag (false, false);
-	node->set_pure_flag (false, false);
       }
 
   /* Update call statements and rebuild the cgraph.  */
-- 
2.35.3

             reply	other threads:[~2022-11-25  7:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25  7:59 Richard Biener [this message]
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
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=20221125075944.7DA6713A08@imap2.suse-dmz.suse.de \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    /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).