From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/100756 - niter analysis and folding
Date: Tue, 25 Oct 2022 10:02:30 +0200 (CEST) [thread overview]
Message-ID: <20221025080230.C01D613A64@imap2.suse-dmz.suse.de> (raw)
niter analysis, specifically the part trying to simplify the computed
maybe_zero condition against the loop header copying condition, is
confused by us now simplifying
_15 = n_8(D) * 4;
if (_15 > 0)
to
_15 = n_8(D) * 4;
if (n_8(D) > 0)
which is perfectly sound at the point we do this transform. One
solution might be to involve ranger in this simplification, another
is to be more aggressive when expanding expressions - the condition
we try to simplify is _15 > 0, so all we need is expanding that
to n_8(D) * 4 > 0.
The following does just that.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/100756
* tree-ssa-loop-niter.cc (expand_simple_operations): Also
expand multiplications by invariants.
* gcc.dg/vect/pr100756.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/pr100756.c | 15 +++++++++++++++
gcc/tree-ssa-loop-niter.cc | 1 +
2 files changed, 16 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/vect/pr100756.c
diff --git a/gcc/testsuite/gcc.dg/vect/pr100756.c b/gcc/testsuite/gcc.dg/vect/pr100756.c
new file mode 100644
index 00000000000..c1362f29ebe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr100756.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+int
+foo (int * restrict a, int n)
+{
+ int i, result = 0;
+
+ a = __builtin_assume_aligned (a, __BIGGEST_ALIGNMENT__);
+ for (i = 0; i < n * 4; i++)
+ result += a[i];
+ return result;
+}
+
+/* { dg-final { scan-tree-dump-not "epilog loop required" "vect" } } */
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 1e0f609d8b6..4ffcef4f4ff 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -2216,6 +2216,7 @@ expand_simple_operations (tree expr, tree stop, hash_map<tree, tree> &cache)
case PLUS_EXPR:
case MINUS_EXPR:
+ case MULT_EXPR:
if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (expr))
&& TYPE_OVERFLOW_TRAPS (TREE_TYPE (expr)))
return expr;
--
2.35.3
reply other threads:[~2022-10-25 8:02 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=20221025080230.C01D613A64@imap2.suse-dmz.suse.de \
--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).