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

https://gcc.gnu.org/g:8e1fe3f779185cc678493ceda42c2e620a5c1387

commit r12-4345-g8e1fe3f779185cc678493ceda42c2e620a5c1387
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Oct 12 09:37:25 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.

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

diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index d8b98552fb9..b9024cb15a9 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -381,7 +381,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 474d0f44375..7fcfef41f72 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -4632,7 +4632,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 2401646c484..397f4aeb7cf 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -36,6 +36,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  7:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  7:41 [gcc r12-4345] openmp: Avoid calling clear_type_padding_in_mask in the common case where there can't be any padding Jakub Jelinek

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