The following fixes placement of shift operand sanitization with
MIN when the original shift operand was external but the actual
one is not.
PR tree-optimization/111128
* tree-vect-patterns.cc (vect_recog_over_widening_pattern):
Emit external shift operand inline if we promoted it with
another pattern stmt.
* gcc.dg/torture/pr111128.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+
+int a, b, c, e, g;
+short *d;
+unsigned char f;
+int h() {
+ f &= g;
+ for (; b; b++) {
+ a = 2;
+ for (; a; a--)
+ c = 0;
+ if (c)
+ continue;
+ e = (unsigned short)*d >> f;
+ }
+}
= gimple_build_assign (new_var, MIN_EXPR, ops[1],
build_int_cst (op_type, new_precision - 1));
gimple_set_location (pattern_stmt, gimple_location (last_stmt));
- if (unprom[1].dt == vect_external_def)
+ if (ops[1] == unprom[1].op && unprom[1].dt == vect_external_def)
{
if (edge e = vect_get_external_def_edge (vinfo, ops[1]))
{