diff options
author | Richard Biener <rguenther@suse.de> | 2023-08-21 11:07:18 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-08-21 11:46:48 +0200 |
commit | e10cb804e658dbd1e9d58f528f3985362e4e72e7 (patch) | |
tree | 3a21af0b535cac057e653f5e540063cf0102b690 | |
parent | 03cb6904d1ab6de1f42d06bcf2988bf7b3e7709a (diff) | |
download | gcc-e10cb804e658dbd1e9d58f528f3985362e4e72e7.zip gcc-e10cb804e658dbd1e9d58f528f3985362e4e72e7.tar.gz gcc-e10cb804e658dbd1e9d58f528f3985362e4e72e7.tar.bz2 |
tree-optimization/111082 - bogus promoted min
vectorize_slp_instance_root_stmt promotes operations with undefined
overflow to unsigned arithmetic but fails to consider operations
that do not overflow like MIN which it turned into MIN with wrong
signedness and in the case of the PR an unsupported operation.
The following rectifies this.
PR tree-optimization/111082
* tree-vect-slp.cc (vectorize_slp_instance_root_stmt): Only
pun operations that can overflow.
* gcc.dg/pr111082.c: New testcase.
-rw-r--r-- | gcc/testsuite/gcc.dg/pr111082.c | 10 | ||||
-rw-r--r-- | gcc/tree-vect-slp.cc | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/pr111082.c b/gcc/testsuite/gcc.dg/pr111082.c new file mode 100644 index 0000000..46e36e3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111082.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-vect-cost-model" } */ +/* { dg-additional-options "-mavx512f" { target { x86_64-*-* i?86-*-* } } } */ + +long minarray2(const long *input) +{ + if (input[0] < input[1]) + return input[0] ; + return input[1]; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 89c3216..b5f9333 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -9161,7 +9161,8 @@ vectorize_slp_instance_root_stmt (slp_tree node, slp_instance instance) tree vectype = TREE_TYPE (vec_def); tree compute_vectype = vectype; bool pun_for_overflow_p = (ANY_INTEGRAL_TYPE_P (vectype) - && TYPE_OVERFLOW_UNDEFINED (vectype)); + && TYPE_OVERFLOW_UNDEFINED (vectype) + && operation_can_overflow (reduc_code)); if (pun_for_overflow_p) { compute_vectype = unsigned_type_for (vectype); |