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.
--- /dev/null
+/* { 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];
+}
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);