* [PATCH] tree-optimization/111128 - fix shift pattern recog
@ 2023-08-24 8:59 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-08-24 8:59 UTC (permalink / raw)
To: gcc-patches
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
diff --git a/gcc/testsuite/gcc.dg/torture/pr111128.c b/gcc/testsuite/gcc.dg/torture/pr111128.c
new file mode 100644
index 00000000000..aa623b0d045
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr111128.c
@@ -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;
+ }
+}
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index cda27fed95b..a2ed0365b18 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -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]))
{
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-24 8:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-24 8:59 [PATCH] tree-optimization/111128 - fix shift pattern recog Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).