openmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if...
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Oct 2021 08:40:12 +0000 (10:40 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 6 Oct 2021 08:40:12 +0000 (10:40 +0200)
commitba837323dbda2bca5a1c8a4c78092a88241dcfa3
treed40c513e48bc98f7c1a2f9564bffcb1e6bacbc2c
parent8892d532d66910e518bc135a851a104322385ca2
openmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if possible

For the few long double types that do have padding bits, e.g. on x86
the clear_type_padding_in_mask computed mask is
ff ff ff ff ff ff ff ff ff ff 00 00 for 32-bit and
ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 for 64-bit.
Instead of doing __builtin_clear_padding on both operands that will clear the
last 2 or 6 bytes and then memcmp on the whole 12/16 bytes, we can just
memcmp 10 bytes.  The code also handles if the padding would be at the start
or both at the start and end, but everything on byte boundaries only and
non-padding bits being contiguous.
This works around a tree-ssa-dse.c bug (but we need to fix it anyway,
as libstdc++ won't do this and as it can deal with arbitrary types, it even
can't do that generally).

2021-10-06  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/102571
* c-omp.c (c_finish_omp_atomic): Optimize the case where type has
padding, but the non-padding bits are contiguous set of bytes
by adjusting the memcmp call arguments instead of emitting
__builtin_clear_padding and then comparing all the type's bytes.
gcc/c-family/c-omp.c