* [PATCH] vect: Move suggested_unroll_factor applying [PR105940]
@ 2022-06-13 10:02 Kewen.Lin
2022-06-13 11:38 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Kewen.Lin @ 2022-06-13 10:02 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Biener, Richard Sandiford
Hi,
As PR105940 shown, when rs6000 port tries to assign
m_suggested_unroll_factor by 4 or so, there will be ICE
on below statement:
exact_div (LOOP_VINFO_VECT_FACTOR (loop_vinfo),
loop_vinfo->suggested_unroll_factor);
In function vect_analyze_loop_2, the current place of
suggested_unroll_factor applying can't guarantee it's
applied for all cases. As the case shows, vectorizer
could retry with SLP forced off, the vf is reset by
saved_vectorization_factor which isn't applied with
suggested_unroll_factor before. It means it can end
up with one vf which neglects suggested_unroll_factor.
I think it's off design, we should move the applying
of suggested_unroll_factor after start_over.
Bootstrapped and regtested on x86_64-redhat-linux,
aarch64-linux-gnu and powerpc64{,le}-linux-gnu.
Is it ok for trunk?
BR,
Kewen
-----
PR tree-optimization/105940
gcc/ChangeLog:
* tree-vect-loop.cc (vect_analyze_loop_2): Move the place of
applying suggested_unroll_factor after start_over.
---
gcc/tree-vect-loop.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 896218f23ea..af955d26f8d 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -2393,15 +2393,15 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
set of rgroups. */
gcc_assert (LOOP_VINFO_MASKS (loop_vinfo).is_empty ());
+ /* This is the point where we can re-start analysis with SLP forced off. */
+start_over:
+
/* Apply the suggested unrolling factor, this was determined by the backend
during finish_cost the first time we ran the analyzis for this
vector mode. */
if (loop_vinfo->suggested_unroll_factor > 1)
LOOP_VINFO_VECT_FACTOR (loop_vinfo) *= loop_vinfo->suggested_unroll_factor;
- /* This is the point where we can re-start analysis with SLP forced off. */
-start_over:
-
/* Now the vectorization factor is final. */
poly_uint64 vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
gcc_assert (known_ne (vectorization_factor, 0U));
--
2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vect: Move suggested_unroll_factor applying [PR105940]
2022-06-13 10:02 [PATCH] vect: Move suggested_unroll_factor applying [PR105940] Kewen.Lin
@ 2022-06-13 11:38 ` Richard Biener
2022-06-14 6:03 ` Kewen.Lin
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2022-06-13 11:38 UTC (permalink / raw)
To: Kewen.Lin; +Cc: GCC Patches, Richard Sandiford
On Mon, Jun 13, 2022 at 12:02 PM Kewen.Lin <linkw@linux.ibm.com> wrote:
>
> Hi,
>
> As PR105940 shown, when rs6000 port tries to assign
> m_suggested_unroll_factor by 4 or so, there will be ICE
> on below statement:
>
> exact_div (LOOP_VINFO_VECT_FACTOR (loop_vinfo),
> loop_vinfo->suggested_unroll_factor);
>
> In function vect_analyze_loop_2, the current place of
> suggested_unroll_factor applying can't guarantee it's
> applied for all cases. As the case shows, vectorizer
> could retry with SLP forced off, the vf is reset by
> saved_vectorization_factor which isn't applied with
> suggested_unroll_factor before. It means it can end
> up with one vf which neglects suggested_unroll_factor.
> I think it's off design, we should move the applying
> of suggested_unroll_factor after start_over.
>
> Bootstrapped and regtested on x86_64-redhat-linux,
> aarch64-linux-gnu and powerpc64{,le}-linux-gnu.
>
> Is it ok for trunk?
OK (I think the GCC 12 branch is also affected).
Richard.
>
> BR,
> Kewen
> -----
> PR tree-optimization/105940
>
> gcc/ChangeLog:
>
> * tree-vect-loop.cc (vect_analyze_loop_2): Move the place of
> applying suggested_unroll_factor after start_over.
> ---
> gcc/tree-vect-loop.cc | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 896218f23ea..af955d26f8d 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -2393,15 +2393,15 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal,
> set of rgroups. */
> gcc_assert (LOOP_VINFO_MASKS (loop_vinfo).is_empty ());
>
> + /* This is the point where we can re-start analysis with SLP forced off. */
> +start_over:
> +
> /* Apply the suggested unrolling factor, this was determined by the backend
> during finish_cost the first time we ran the analyzis for this
> vector mode. */
> if (loop_vinfo->suggested_unroll_factor > 1)
> LOOP_VINFO_VECT_FACTOR (loop_vinfo) *= loop_vinfo->suggested_unroll_factor;
>
> - /* This is the point where we can re-start analysis with SLP forced off. */
> -start_over:
> -
> /* Now the vectorization factor is final. */
> poly_uint64 vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
> gcc_assert (known_ne (vectorization_factor, 0U));
> --
> 2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vect: Move suggested_unroll_factor applying [PR105940]
2022-06-13 11:38 ` Richard Biener
@ 2022-06-14 6:03 ` Kewen.Lin
0 siblings, 0 replies; 3+ messages in thread
From: Kewen.Lin @ 2022-06-14 6:03 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches, Richard Sandiford
on 2022/6/13 19:38, Richard Biener wrote:
> On Mon, Jun 13, 2022 at 12:02 PM Kewen.Lin <linkw@linux.ibm.com> wrote:
>>
>> Hi,
>>
>> As PR105940 shown, when rs6000 port tries to assign
>> m_suggested_unroll_factor by 4 or so, there will be ICE
>> on below statement:
>>
>> exact_div (LOOP_VINFO_VECT_FACTOR (loop_vinfo),
>> loop_vinfo->suggested_unroll_factor);
>>
>> In function vect_analyze_loop_2, the current place of
>> suggested_unroll_factor applying can't guarantee it's
>> applied for all cases. As the case shows, vectorizer
>> could retry with SLP forced off, the vf is reset by
>> saved_vectorization_factor which isn't applied with
>> suggested_unroll_factor before. It means it can end
>> up with one vf which neglects suggested_unroll_factor.
>> I think it's off design, we should move the applying
>> of suggested_unroll_factor after start_over.
>>
>> Bootstrapped and regtested on x86_64-redhat-linux,
>> aarch64-linux-gnu and powerpc64{,le}-linux-gnu.
>>
>> Is it ok for trunk?
>
> OK (I think the GCC 12 branch is also affected).
>
Thanks Richi! Committed as r13-1083.
I'll backport this to GCC12 branch in a week if it goes well in trunk.
BR,
Kewen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-14 6:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 10:02 [PATCH] vect: Move suggested_unroll_factor applying [PR105940] Kewen.Lin
2022-06-13 11:38 ` Richard Biener
2022-06-14 6:03 ` Kewen.Lin
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).