We may not strip sign-conversions around MIN/MAX operations.
PR tree-optimization/122844
* tree-vect-slp.cc (vect_analyze_slp_reduc_chain): Only
try stripping sign conversions around ops where this is valid.
* gcc.dg/vect/vect-pr122844.c: New testcase.
--- /dev/null
+#include "tree-vect.h"
+
+short c = 2;
+short l = 6;
+unsigned char m;
+int k;
+int a = -1;
+unsigned long long t[2][2];
+
+static void b( short c, int k, short l, unsigned m)
+{
+ for( signed x=0; x<2; x++)
+ for( int ab=0; ab<k+2; ab++)
+ a = ({
+ int ac = a;
+ int ad = ({ int ac = l ? m : t[x][0];
+ unsigned long long ad = c ? m : t[x][x];
+ ac < ad ? ac : ad; });
+
+ ac < ad ? ac : ad;
+ });
+}
+
+int main()
+{
+ check_vect ();
+
+ long long ag;
+ b(c,k,l,m);
+ ag = a;
+ if (ag != -1)
+ abort ();
+}
+
/* When this linearization didn't produce a chain see if stripping
a wrapping sign conversion produces one. */
- if (scalar_stmts.length () == 1)
+ if (scalar_stmts.length () == 1
+ && (code == PLUS_EXPR || code == MULT_EXPR || code == BIT_IOR_EXPR
+ || code == BIT_AND_EXPR || code == BIT_XOR_EXPR))
{
gimple *stmt = scalar_stmts[0]->stmt;
if (!is_gimple_assign (stmt)