* [PATCH] vect: Call vect_convert_output with the right vecitype [PR114108]
@ 2024-03-07 10:44 Tejas Belagod
2024-03-13 12:37 ` Tejas Belagod
0 siblings, 1 reply; 4+ messages in thread
From: Tejas Belagod @ 2024-03-07 10:44 UTC (permalink / raw)
To: gcc-patches; +Cc: Tejas Belagod, richard.sandiford
This patch fixes a bug where vect_recog_abd_pattern called vect_convert_output
with the incorrect vecitype for the corresponding pattern_stmt.
vect_convert_output expects vecitype to be the vector form of the scalar type
of the LHS of pattern_stmt, but we were passing in the vector form of the LHS
of the new impending conversion statement. This caused a skew in ABD's
pattern_stmt having the vectype of the following gimple pattern_stmt.
2024-03-06 Tejas Belagod <tejas.belagod@arm.com>
gcc/ChangeLog:
PR middle-end/114108
* tree-vect-patterns.cc (vect_recog_abd_pattern): Call
vect_convert_output with the correct vecitype.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/pr114108.c: New test.
---
gcc/testsuite/gcc.dg/vect/pr114108.c | 19 +++++++++++++++++++
gcc/tree-vect-patterns.cc | 5 ++---
2 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/pr114108.c
diff --git a/gcc/testsuite/gcc.dg/vect/pr114108.c b/gcc/testsuite/gcc.dg/vect/pr114108.c
new file mode 100644
index 00000000000..b3075d41398
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114108.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+#include "tree-vect.h"
+
+typedef signed char schar;
+
+__attribute__((noipa, noinline, optimize("O3")))
+void foo(const schar *a, const schar *b, schar *c, int n)
+{
+ for (int i = 0; i < n; i++)
+ {
+ unsigned u = __builtin_abs (a[i] - b[i]);
+ c[i] = u <= 7U ? u : 7U;
+ }
+}
+
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */
+/* { dg-final { scan-tree-dump "vect_recog_abd_pattern: detected" "vect" { target aarch64*-*-* } } } */
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index d562f57920f..4f491c6b833 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -1576,9 +1576,8 @@ vect_recog_abd_pattern (vec_info *vinfo,
&& !TYPE_UNSIGNED (abd_out_type))
{
tree unsign = unsigned_type_for (abd_out_type);
- tree unsign_vectype = get_vectype_for_scalar_type (vinfo, unsign);
- stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt,
- unsign_vectype);
+ stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt, vectype_out);
+ vectype_out = get_vectype_for_scalar_type (vinfo, unsign);
}
return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt, vectype_out);
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vect: Call vect_convert_output with the right vecitype [PR114108]
2024-03-07 10:44 [PATCH] vect: Call vect_convert_output with the right vecitype [PR114108] Tejas Belagod
@ 2024-03-13 12:37 ` Tejas Belagod
2024-03-14 10:13 ` Tejas Belagod
0 siblings, 1 reply; 4+ messages in thread
From: Tejas Belagod @ 2024-03-13 12:37 UTC (permalink / raw)
To: gcc-patches; +Cc: richard.sandiford
Ping!
On 3/7/24 4:14 PM, Tejas Belagod wrote:
> This patch fixes a bug where vect_recog_abd_pattern called vect_convert_output
> with the incorrect vecitype for the corresponding pattern_stmt.
> vect_convert_output expects vecitype to be the vector form of the scalar type
> of the LHS of pattern_stmt, but we were passing in the vector form of the LHS
> of the new impending conversion statement. This caused a skew in ABD's
> pattern_stmt having the vectype of the following gimple pattern_stmt.
>
> 2024-03-06 Tejas Belagod <tejas.belagod@arm.com>
>
> gcc/ChangeLog:
>
> PR middle-end/114108
> * tree-vect-patterns.cc (vect_recog_abd_pattern): Call
> vect_convert_output with the correct vecitype.
>
> gcc/testsuite/ChangeLog:
> * gcc.dg/vect/pr114108.c: New test.
> ---
> gcc/testsuite/gcc.dg/vect/pr114108.c | 19 +++++++++++++++++++
> gcc/tree-vect-patterns.cc | 5 ++---
> 2 files changed, 21 insertions(+), 3 deletions(-)
> create mode 100644 gcc/testsuite/gcc.dg/vect/pr114108.c
>
> diff --git a/gcc/testsuite/gcc.dg/vect/pr114108.c b/gcc/testsuite/gcc.dg/vect/pr114108.c
> new file mode 100644
> index 00000000000..b3075d41398
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/pr114108.c
> @@ -0,0 +1,19 @@
> +/* { dg-do compile } */
> +
> +#include "tree-vect.h"
> +
> +typedef signed char schar;
> +
> +__attribute__((noipa, noinline, optimize("O3")))
> +void foo(const schar *a, const schar *b, schar *c, int n)
> +{
> + for (int i = 0; i < n; i++)
> + {
> + unsigned u = __builtin_abs (a[i] - b[i]);
> + c[i] = u <= 7U ? u : 7U;
> + }
> +}
> +
> +
> +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target aarch64*-*-* } } } */
> +/* { dg-final { scan-tree-dump "vect_recog_abd_pattern: detected" "vect" { target aarch64*-*-* } } } */
> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
> index d562f57920f..4f491c6b833 100644
> --- a/gcc/tree-vect-patterns.cc
> +++ b/gcc/tree-vect-patterns.cc
> @@ -1576,9 +1576,8 @@ vect_recog_abd_pattern (vec_info *vinfo,
> && !TYPE_UNSIGNED (abd_out_type))
> {
> tree unsign = unsigned_type_for (abd_out_type);
> - tree unsign_vectype = get_vectype_for_scalar_type (vinfo, unsign);
> - stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt,
> - unsign_vectype);
> + stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt, vectype_out);
> + vectype_out = get_vectype_for_scalar_type (vinfo, unsign);
> }
>
> return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt, vectype_out);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vect: Call vect_convert_output with the right vecitype [PR114108]
2024-03-13 12:37 ` Tejas Belagod
@ 2024-03-14 10:13 ` Tejas Belagod
2024-03-14 10:26 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Tejas Belagod @ 2024-03-14 10:13 UTC (permalink / raw)
To: gcc-patches; +Cc: richard.sandiford, rguenther
Ping.
Thanks,
Tejas.
On 3/13/24 6:07 PM, Tejas Belagod wrote:
> Ping!
>
> On 3/7/24 4:14 PM, Tejas Belagod wrote:
>> This patch fixes a bug where vect_recog_abd_pattern called
>> vect_convert_output
>> with the incorrect vecitype for the corresponding pattern_stmt.
>> vect_convert_output expects vecitype to be the vector form of the
>> scalar type
>> of the LHS of pattern_stmt, but we were passing in the vector form of
>> the LHS
>> of the new impending conversion statement. This caused a skew in ABD's
>> pattern_stmt having the vectype of the following gimple pattern_stmt.
>>
>> 2024-03-06 Tejas Belagod <tejas.belagod@arm.com>
>>
>> gcc/ChangeLog:
>>
>> PR middle-end/114108
>> * tree-vect-patterns.cc (vect_recog_abd_pattern): Call
>> vect_convert_output with the correct vecitype.
>>
>> gcc/testsuite/ChangeLog:
>> * gcc.dg/vect/pr114108.c: New test.
>> ---
>> gcc/testsuite/gcc.dg/vect/pr114108.c | 19 +++++++++++++++++++
>> gcc/tree-vect-patterns.cc | 5 ++---
>> 2 files changed, 21 insertions(+), 3 deletions(-)
>> create mode 100644 gcc/testsuite/gcc.dg/vect/pr114108.c
>>
>> diff --git a/gcc/testsuite/gcc.dg/vect/pr114108.c
>> b/gcc/testsuite/gcc.dg/vect/pr114108.c
>> new file mode 100644
>> index 00000000000..b3075d41398
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.dg/vect/pr114108.c
>> @@ -0,0 +1,19 @@
>> +/* { dg-do compile } */
>> +
>> +#include "tree-vect.h"
>> +
>> +typedef signed char schar;
>> +
>> +__attribute__((noipa, noinline, optimize("O3")))
>> +void foo(const schar *a, const schar *b, schar *c, int n)
>> +{
>> + for (int i = 0; i < n; i++)
>> + {
>> + unsigned u = __builtin_abs (a[i] - b[i]);
>> + c[i] = u <= 7U ? u : 7U;
>> + }
>> +}
>> +
>> +
>> +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target
>> aarch64*-*-* } } } */
>> +/* { dg-final { scan-tree-dump "vect_recog_abd_pattern: detected"
>> "vect" { target aarch64*-*-* } } } */
>> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
>> index d562f57920f..4f491c6b833 100644
>> --- a/gcc/tree-vect-patterns.cc
>> +++ b/gcc/tree-vect-patterns.cc
>> @@ -1576,9 +1576,8 @@ vect_recog_abd_pattern (vec_info *vinfo,
>> && !TYPE_UNSIGNED (abd_out_type))
>> {
>> tree unsign = unsigned_type_for (abd_out_type);
>> - tree unsign_vectype = get_vectype_for_scalar_type (vinfo, unsign);
>> - stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt,
>> - unsign_vectype);
>> + stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt,
>> vectype_out);
>> + vectype_out = get_vectype_for_scalar_type (vinfo, unsign);
>> }
>> return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt,
>> vectype_out);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vect: Call vect_convert_output with the right vecitype [PR114108]
2024-03-14 10:13 ` Tejas Belagod
@ 2024-03-14 10:26 ` Richard Biener
0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2024-03-14 10:26 UTC (permalink / raw)
To: Tejas Belagod; +Cc: gcc-patches, richard.sandiford, rguenther
On Thu, Mar 14, 2024 at 11:14 AM Tejas Belagod <tejas.belagod@arm.com> wrote:
>
>
> Ping.
>
> Thanks,
> Tejas.
>
> On 3/13/24 6:07 PM, Tejas Belagod wrote:
> > Ping!
> >
> > On 3/7/24 4:14 PM, Tejas Belagod wrote:
> >> This patch fixes a bug where vect_recog_abd_pattern called
> >> vect_convert_output
> >> with the incorrect vecitype for the corresponding pattern_stmt.
> >> vect_convert_output expects vecitype to be the vector form of the
> >> scalar type
> >> of the LHS of pattern_stmt, but we were passing in the vector form of
> >> the LHS
> >> of the new impending conversion statement. This caused a skew in ABD's
> >> pattern_stmt having the vectype of the following gimple pattern_stmt.
OK
> >> 2024-03-06 Tejas Belagod <tejas.belagod@arm.com>
> >>
> >> gcc/ChangeLog:
> >>
> >> PR middle-end/114108
> >> * tree-vect-patterns.cc (vect_recog_abd_pattern): Call
> >> vect_convert_output with the correct vecitype.
> >>
> >> gcc/testsuite/ChangeLog:
> >> * gcc.dg/vect/pr114108.c: New test.
> >> ---
> >> gcc/testsuite/gcc.dg/vect/pr114108.c | 19 +++++++++++++++++++
> >> gcc/tree-vect-patterns.cc | 5 ++---
> >> 2 files changed, 21 insertions(+), 3 deletions(-)
> >> create mode 100644 gcc/testsuite/gcc.dg/vect/pr114108.c
> >>
> >> diff --git a/gcc/testsuite/gcc.dg/vect/pr114108.c
> >> b/gcc/testsuite/gcc.dg/vect/pr114108.c
> >> new file mode 100644
> >> index 00000000000..b3075d41398
> >> --- /dev/null
> >> +++ b/gcc/testsuite/gcc.dg/vect/pr114108.c
> >> @@ -0,0 +1,19 @@
> >> +/* { dg-do compile } */
> >> +
> >> +#include "tree-vect.h"
> >> +
> >> +typedef signed char schar;
> >> +
> >> +__attribute__((noipa, noinline, optimize("O3")))
> >> +void foo(const schar *a, const schar *b, schar *c, int n)
> >> +{
> >> + for (int i = 0; i < n; i++)
> >> + {
> >> + unsigned u = __builtin_abs (a[i] - b[i]);
> >> + c[i] = u <= 7U ? u : 7U;
> >> + }
> >> +}
> >> +
> >> +
> >> +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target
> >> aarch64*-*-* } } } */
> >> +/* { dg-final { scan-tree-dump "vect_recog_abd_pattern: detected"
> >> "vect" { target aarch64*-*-* } } } */
> >> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
> >> index d562f57920f..4f491c6b833 100644
> >> --- a/gcc/tree-vect-patterns.cc
> >> +++ b/gcc/tree-vect-patterns.cc
> >> @@ -1576,9 +1576,8 @@ vect_recog_abd_pattern (vec_info *vinfo,
> >> && !TYPE_UNSIGNED (abd_out_type))
> >> {
> >> tree unsign = unsigned_type_for (abd_out_type);
> >> - tree unsign_vectype = get_vectype_for_scalar_type (vinfo, unsign);
> >> - stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt,
> >> - unsign_vectype);
> >> + stmt = vect_convert_output (vinfo, stmt_vinfo, unsign, stmt,
> >> vectype_out);
> >> + vectype_out = get_vectype_for_scalar_type (vinfo, unsign);
> >> }
> >> return vect_convert_output (vinfo, stmt_vinfo, out_type, stmt,
> >> vectype_out);
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-14 10:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07 10:44 [PATCH] vect: Call vect_convert_output with the right vecitype [PR114108] Tejas Belagod
2024-03-13 12:37 ` Tejas Belagod
2024-03-14 10:13 ` Tejas Belagod
2024-03-14 10:26 ` 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).