tree-optimization/111128 - fix shift pattern recog
Checks
Commit Message
The following fixes placement of shift operand sanitization with
MIN when the original shift operand was external but the actual
one is not.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
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.
---
gcc/testsuite/gcc.dg/torture/pr111128.c | 16 ++++++++++++++++
gcc/tree-vect-patterns.cc | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr111128.c
new file mode 100644
@@ -0,0 +1,16 @@
+/* { 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;
+ }
+}
@@ -3121,7 +3121,7 @@ vect_recog_over_widening_pattern (vec_info *vinfo,
= 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]))
{