diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-07-01 08:55:49 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-07-01 08:55:49 +0200 |
commit | 91c771ec8a3b649765de3e0a7b04cf946c6649ef (patch) | |
tree | 04986ff6554b6e58f6ea61494430d4ccf2bb7b7a /libgomp | |
parent | a688c284dd3848b6c4ea553035f0f9769fb4fbc9 (diff) | |
download | gcc-91c771ec8a3b649765de3e0a7b04cf946c6649ef.zip gcc-91c771ec8a3b649765de3e0a7b04cf946c6649ef.tar.gz gcc-91c771ec8a3b649765de3e0a7b04cf946c6649ef.tar.bz2 |
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.
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/testsuite/libgomp.c-c++-common/pr94366.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr94366.c b/libgomp/testsuite/libgomp.c-c++-common/pr94366.c new file mode 100644 index 0000000..5837cd0 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/pr94366.c @@ -0,0 +1,17 @@ +/* PR middle-end/94366 */ + +int +main () +{ + int a = 2; + #pragma omp parallel reduction(&& : a) + a = a && 1; + if (!a) + __builtin_abort (); + a = 4; + #pragma omp parallel reduction(|| : a) + a = a || 0; + if (!a) + __builtin_abort (); + return 0; +} |