* [PATCH] vect: Look through pattern stmt in fold_left_reduction.
@ 2023-11-10 9:06 Robin Dapp
2023-11-10 10:07 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Robin Dapp @ 2023-11-10 9:06 UTC (permalink / raw)
To: gcc-patches; +Cc: rdapp.gcc
Hi,
more fallout from the COND_OP change was shown in PR112464.
It appears as if we "look through" a statement pattern in
vect_finish_replace_stmt but not before when we replace the newly
created vector statement's lhs. Then the lhs is the statement pattern's
lhs while in vect_finish_replace_stmt we assert that it's from the
statement the pattern replaced.
This patch uses vect_orig_stmt on the scalar destination's definition
so the replaced statement is used everywhere.
Bootstrapped and regtested on x86 and aarch64, riscv testsuite
unchanged.
Regards
Robin
gcc/ChangeLog:
PR tree-optimization/112464
* tree-vect-loop.cc (vectorize_fold_left_reduction): Use
vect_orig_stmt on scalar_dest_def_info.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr112464.c: New test.
---
gcc/testsuite/gcc.target/i386/pr112464.c | 10 ++++++++++
gcc/tree-vect-loop.cc | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr112464.c
diff --git a/gcc/testsuite/gcc.target/i386/pr112464.c b/gcc/testsuite/gcc.target/i386/pr112464.c
new file mode 100644
index 00000000000..2290c714986
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr112464.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -mavx512dq -ftrapv" } */
+
+long *e;
+int n, i, err;
+void fn() {
+ for (; i < n; i++)
+ if (e[i])
+ err++;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 8abc1937d74..f61adad1ca3 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7087,7 +7087,7 @@ vectorize_fold_left_reduction (loop_vec_info loop_vinfo,
opmask, &vec_opmask);
}
- gimple *sdef = scalar_dest_def_info->stmt;
+ gimple *sdef = vect_orig_stmt (scalar_dest_def_info)->stmt;
tree scalar_dest = gimple_get_lhs (sdef);
tree scalar_type = TREE_TYPE (scalar_dest);
tree reduc_var = gimple_phi_result (reduc_def_stmt);
--
2.41.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] vect: Look through pattern stmt in fold_left_reduction.
2023-11-10 9:06 [PATCH] vect: Look through pattern stmt in fold_left_reduction Robin Dapp
@ 2023-11-10 10:07 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-11-10 10:07 UTC (permalink / raw)
To: Robin Dapp; +Cc: gcc-patches
On Fri, Nov 10, 2023 at 10:06 AM Robin Dapp <rdapp.gcc@gmail.com> wrote:
>
> Hi,
>
> more fallout from the COND_OP change was shown in PR112464.
>
> It appears as if we "look through" a statement pattern in
> vect_finish_replace_stmt but not before when we replace the newly
> created vector statement's lhs. Then the lhs is the statement pattern's
> lhs while in vect_finish_replace_stmt we assert that it's from the
> statement the pattern replaced.
>
> This patch uses vect_orig_stmt on the scalar destination's definition
> so the replaced statement is used everywhere.
>
> Bootstrapped and regtested on x86 and aarch64, riscv testsuite
> unchanged.
OK
> Regards
> Robin
>
> gcc/ChangeLog:
>
> PR tree-optimization/112464
>
> * tree-vect-loop.cc (vectorize_fold_left_reduction): Use
> vect_orig_stmt on scalar_dest_def_info.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/i386/pr112464.c: New test.
> ---
> gcc/testsuite/gcc.target/i386/pr112464.c | 10 ++++++++++
> gcc/tree-vect-loop.cc | 2 +-
> 2 files changed, 11 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.target/i386/pr112464.c
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr112464.c b/gcc/testsuite/gcc.target/i386/pr112464.c
> new file mode 100644
> index 00000000000..2290c714986
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr112464.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-options "-Ofast -mavx512dq -ftrapv" } */
> +
> +long *e;
> +int n, i, err;
> +void fn() {
> + for (; i < n; i++)
> + if (e[i])
> + err++;
> +}
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 8abc1937d74..f61adad1ca3 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -7087,7 +7087,7 @@ vectorize_fold_left_reduction (loop_vec_info loop_vinfo,
> opmask, &vec_opmask);
> }
>
> - gimple *sdef = scalar_dest_def_info->stmt;
> + gimple *sdef = vect_orig_stmt (scalar_dest_def_info)->stmt;
> tree scalar_dest = gimple_get_lhs (sdef);
> tree scalar_type = TREE_TYPE (scalar_dest);
> tree reduc_var = gimple_phi_result (reduc_def_stmt);
> --
> 2.41.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-10 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 9:06 [PATCH] vect: Look through pattern stmt in fold_left_reduction Robin Dapp
2023-11-10 10:07 ` 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).