From: Richard Sandiford Date: Fri, 29 Nov 2019 13:04:56 +0000 (+0000) Subject: Don't pass booleans as mask types to simd clones [PR92710] X-Git-Tag: releases/gcc-9.3.0~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84a465171761faeceb87037a606f7834dab18942;p=thirdparty%2Fgcc.git Don't pass booleans as mask types to simd clones [PR92710] In this PR we assigned a vector mask type to the result of a comparison and then tried to pass that mask type to a simd clone, which expected a normal (non-mask) type instead. This patch simply punts on call arguments that have a mask type. A better fix would be to pattern-match the comparison to a COND_EXPR, like we would if the comparison was stored to memory, but doing that isn't gcc 9 or 10 material. Note that this doesn't affect x86_64-linux-gnu because the ABI promotes bool arguments to ints. 2020-02-18 Richard Sandiford gcc/ Backport from mainline 2019-11-29 Richard Sandiford PR tree-optimization/92710 * tree-vect-stmts.c (vectorizable_simd_clone_call): Reject vector mask arguments. gcc/testsuite/ PR tree-optimization/92710 * gcc.dg/vect/pr92710.c: New test. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8de081487299..91a64fff8f4b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2020-02-18 Richard Sandiford + + Backport from mainline + 2019-11-29 Richard Sandiford + + PR tree-optimization/92710 + * tree-vect-stmts.c (vectorizable_simd_clone_call): Reject + vector mask arguments. + 2020-02-18 Richard Sandiford Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ec4cf5addb1..fe9b6013e8f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-02-18 Richard Sandiford + + PR tree-optimization/92710 + * gcc.dg/vect/pr92710.c: New test. + 2020-02-18 Richard Sandiford PR tree-optimization/92420 diff --git a/gcc/testsuite/gcc.dg/vect/pr92710.c b/gcc/testsuite/gcc.dg/vect/pr92710.c new file mode 100644 index 000000000000..2986d4ce06a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr92710.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fopenmp-simd" } */ + +#pragma omp declare simd +_Bool foo (_Bool) __attribute__((const)); + +void +f (_Bool *restrict x, char *restrict y, char *restrict z) +{ + for (int i = 0; i < 128; ++i) + x[i] = foo (y[i] == z[i]); +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 8fd7af198175..507f81b0a0e8 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3915,7 +3915,16 @@ vectorizable_simd_clone_call (stmt_vec_info stmt_info, || thisarginfo.dt == vect_external_def) gcc_assert (thisarginfo.vectype == NULL_TREE); else - gcc_assert (thisarginfo.vectype != NULL_TREE); + { + gcc_assert (thisarginfo.vectype != NULL_TREE); + if (VECTOR_BOOLEAN_TYPE_P (thisarginfo.vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "vector mask arguments are not supported\n"); + return false; + } + } /* For linear arguments, the analyze phase should have saved the base and step in STMT_VINFO_SIMD_CLONE_INFO. */