openmp - Fix up && and || reductions [PR94366]
authorJakub Jelinek <jakub@redhat.com>
Thu, 1 Jul 2021 06:55:49 +0000 (08:55 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 1 Jul 2021 06:55:49 +0000 (08:55 +0200)
commit91c771ec8a3b649765de3e0a7b04cf946c6649ef
tree04986ff6554b6e58f6ea61494430d4ccf2bb7b7a
parenta688c284dd3848b6c4ea553035f0f9769fb4fbc9
openmp - Fix up && and || reductions [PR94366]

As the testcase shows, the special treatment of && and || reduction combiners
where we expand them as omp_out = (omp_out != 0) && (omp_in != 0) (or with ||)
is not needed just for &&/|| on floating point or complex types, but for all
&&/|| reductions - when expanded as omp_out = omp_out && omp_in (not in C but
GENERIC) it is actually gimplified into NOP_EXPRs to bool from both operands,
which turns non-zero values multiple of 2 into 0 rather than 1.

This patch just treats all &&/|| the same and furthermore uses bool type
instead of int for the comparisons.

2021-07-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/94366
gcc/
* omp-low.c (lower_rec_input_clauses): Rename is_fp_and_or to
is_truth_op, set it for TRUTH_*IF_EXPR regardless of new_var's type,
use boolean_type_node instead of integer_type_node as NE_EXPR type.
(lower_reduction_clauses): Likewise.
libgomp/
* testsuite/libgomp.c-c++-common/pr94366.c: New test.
gcc/omp-low.c
libgomp/testsuite/libgomp.c-c++-common/pr94366.c [new file with mode: 0644]