public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openmp: Avoid calling clear_type_padding_in_mask in the common case where there can't be any padding
@ 2021-10-12  8:06 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-10-12  8:06 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:377a7aaeb9d5cce6521e5c2ca3e284897dbed7e2

commit 377a7aaeb9d5cce6521e5c2ca3e284897dbed7e2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Oct 12 09:55:41 2021 +0200

    openmp: Avoid calling clear_type_padding_in_mask in the common case where there can't be any padding
    
    We can use the clear_padding_type_may_have_padding_p function, which
    is conservative for e.g. RECORD_TYPE/UNION_TYPE, but for the floating and
    complex floating types is accurate.  clear_type_padding_in_mask is
    more expensive because we need to allocate memory, fill it, call the function
    which itself is more expensive and then analyze the memory, so for the
    common case of float/double atomics or even long double on most targets
    we can avoid that.
    
    2021-10-12  Jakub Jelinek  <jakub@redhat.com>
    
    gcc/
            * gimple-fold.h (clear_padding_type_may_have_padding_p): Declare.
            * gimple-fold.c (clear_padding_type_may_have_padding_p): No longer
            static.
    gcc/c-family/
            * c-omp.c (c_finish_omp_atomic): Use
            clear_padding_type_may_have_padding_p.
    
    (cherry picked from commit 8e1fe3f779185cc678493ceda42c2e620a5c1387)

Diff:
---
 gcc/ChangeLog.omp          | 9 +++++++++
 gcc/c-family/ChangeLog.omp | 8 ++++++++
 gcc/c-family/c-omp.c       | 4 +++-
 gcc/gimple-fold.c          | 2 +-
 gcc/gimple-fold.h          | 1 +
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 34c16660513..88754626121 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-10-12  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+	* gimple-fold.h (clear_padding_type_may_have_padding_p): Declare.
+	* gimple-fold.c (clear_padding_type_may_have_padding_p): No longer
+	static.
+
 2021-10-11  Marcel Vollweiler  <marcel@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/c-family/ChangeLog.omp b/gcc/c-family/ChangeLog.omp
index 4d19a6e56c7..48ca80ae153 100644
--- a/gcc/c-family/ChangeLog.omp
+++ b/gcc/c-family/ChangeLog.omp
@@ -1,3 +1,11 @@
+2021-10-12  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+	* c-omp.c (c_finish_omp_atomic): Use
+	clear_padding_type_may_have_padding_p.
+
 2021-10-06  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 72552a6062d..e77aa462028 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -382,7 +382,9 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
 	  bool clear_padding = false;
 	  HOST_WIDE_INT non_padding_start = 0;
 	  HOST_WIDE_INT non_padding_end = 0;
-	  if (BITS_PER_UNIT == 8 && CHAR_BIT == 8)
+	  if (BITS_PER_UNIT == 8
+	      && CHAR_BIT == 8
+	      && clear_padding_type_may_have_padding_p (cmptype))
 	    {
 	      HOST_WIDE_INT sz = int_size_in_bytes (cmptype), i;
 	      gcc_assert (sz > 0);
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 0581338ea5f..999a3c961b7 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -4429,7 +4429,7 @@ clear_padding_real_needs_padding_p (tree type)
 
 /* Return true if TYPE might contain any padding bits.  */
 
-static bool
+bool
 clear_padding_type_may_have_padding_p (tree type)
 {
   switch (TREE_CODE (type))
diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index f495dac9e71..33f4ab09f31 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -35,6 +35,7 @@ extern tree maybe_fold_and_comparisons (tree, enum tree_code, tree, tree,
 					enum tree_code, tree, tree);
 extern tree maybe_fold_or_comparisons (tree, enum tree_code, tree, tree,
 				       enum tree_code, tree, tree);
+extern bool clear_padding_type_may_have_padding_p (tree);
 extern void clear_type_padding_in_mask (tree, unsigned char *);
 extern bool optimize_atomic_compare_exchange_p (gimple *);
 extern void fold_builtin_atomic_compare_exchange (gimple_stmt_iterator *);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-12  8:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  8:06 [gcc/devel/omp/gcc-11] openmp: Avoid calling clear_type_padding_in_mask in the common case where there can't be any padding Tobias Burnus

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).