From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/111128 - fix shift pattern recog
Date: Thu, 24 Aug 2023 08:59:53 +0000 (UTC) [thread overview]
Message-ID: <20230824085953.534pI2ViNtT_BpULgzz7QKzwyFu8Q5t6-roYDCT2CyE@z> (raw)
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
reply other threads:[~2023-08-24 8:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230824085953.534pI2ViNtT_BpULgzz7QKzwyFu8Q5t6-roYDCT2CyE@z \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).