diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-10-12 09:37:25 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-10-12 09:37:25 +0200 |
commit | 8e1fe3f779185cc678493ceda42c2e620a5c1387 (patch) | |
tree | bc1d031d537edf06f7ab8513fb465143f9b32cb5 | |
parent | 4096bf82a0cda5f79d7e5921b73897f76e00a800 (diff) | |
download | gcc-8e1fe3f779185cc678493ceda42c2e620a5c1387.zip gcc-8e1fe3f779185cc678493ceda42c2e620a5c1387.tar.gz gcc-8e1fe3f779185cc678493ceda42c2e620a5c1387.tar.bz2 |
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.
-rw-r--r-- | gcc/c-family/c-omp.c | 4 | ||||
-rw-r--r-- | gcc/gimple-fold.c | 2 | ||||
-rw-r--r-- | 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 d8b9855..b9024cb 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 474d0f4..7fcfef4 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 2401646..397f4ae 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 *); |