* [PATCH] libgccjit: Allow comparing vector types
@ 2022-12-13 2:31 Antoni Boucher
2022-12-13 21:24 ` David Malcolm
0 siblings, 1 reply; 4+ messages in thread
From: Antoni Boucher @ 2022-12-13 2:31 UTC (permalink / raw)
To: gcc-patches, jit; +Cc: Guillaume Gomez
[-- Attachment #1: Type: text/plain, Size: 50 bytes --]
Hi.
This fixes bug 108078.
Thanks for the review.
[-- Attachment #2: 0001-libgccjit-Allow-comparing-vector-types.patch --]
[-- Type: text/x-patch, Size: 2413 bytes --]
From 016d23eeab1536e2ce0607d422fe4bb42b55c2dc Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Fri, 24 Jun 2022 21:05:29 -0400
Subject: [PATCH] libgccjit: Allow comparing vector types
gcc/jit/ChangeLog:
PR jit/108078
* jit-recording.h: Add vector_type::is_same_type_as method
gcc/testsuite/ChangeLog:
PR jit/108078
* jit.dg/test-vector-types.cc: Add tests for vector type comparison
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
---
gcc/jit/jit-recording.h | 9 +++++++++
gcc/testsuite/jit.dg/test-vector-types.cc | 13 +++++++++++++
2 files changed, 22 insertions(+)
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 5d7c7177cc3..4ec0fff4843 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -806,6 +806,15 @@ public:
void replay_into (replayer *) final override;
+ virtual bool is_same_type_as (type *other)
+ {
+ vector_type *other_vec_type = other->dyn_cast_vector_type ();
+ if (other_vec_type == NULL)
+ return false;
+ return get_num_units () == other_vec_type->get_num_units ()
+ && get_element_type () == other_vec_type->get_element_type ();
+ }
+
vector_type *is_vector () final override { return this; }
private:
diff --git a/gcc/testsuite/jit.dg/test-vector-types.cc b/gcc/testsuite/jit.dg/test-vector-types.cc
index 1f49be6b59f..5661d1b9eb4 100644
--- a/gcc/testsuite/jit.dg/test-vector-types.cc
+++ b/gcc/testsuite/jit.dg/test-vector-types.cc
@@ -105,6 +105,19 @@ create_code (gcc_jit_context *ctxt, void *user_data)
v4f_type, GCC_JIT_BINARY_OP_MULT);
create_vec_fn (ctxt, "jit_v4f_div",
v4f_type, GCC_JIT_BINARY_OP_DIVIDE);
+
+ // Checking compatibility between types.
+ CHECK_VALUE(gcc_jit_compatible_types(v4si_type, v4ui_type), 0);
+ CHECK_VALUE(gcc_jit_compatible_types(v4si_type, v4f_type), 0);
+ CHECK_VALUE(gcc_jit_compatible_types(v4ui_type, v4f_type), 0);
+
+ gcc_jit_type *v4si_type2 = gcc_jit_type_get_vector (int_type, 4);
+ gcc_jit_type *v4ui_type2 = gcc_jit_type_get_vector (unsigned_type, 4);
+ gcc_jit_type *v4f_type2 = gcc_jit_type_get_vector (float_type, 4);
+
+ CHECK_VALUE(gcc_jit_compatible_types(v4si_type, v4si_type2), 1);
+ CHECK_VALUE(gcc_jit_compatible_types(v4ui_type, v4ui_type2), 1);
+ CHECK_VALUE(gcc_jit_compatible_types(v4f_type, v4f_type2), 1);
}
template <typename T>
--
2.26.2.7.g19db9cfb68.dirty
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libgccjit: Allow comparing vector types
2022-12-13 2:31 [PATCH] libgccjit: Allow comparing vector types Antoni Boucher
@ 2022-12-13 21:24 ` David Malcolm
2022-12-13 21:27 ` Antoni Boucher
0 siblings, 1 reply; 4+ messages in thread
From: David Malcolm @ 2022-12-13 21:24 UTC (permalink / raw)
To: Antoni Boucher, gcc-patches, jit; +Cc: Guillaume Gomez
On Mon, 2022-12-12 at 21:31 -0500, Antoni Boucher via Jit wrote:
> Hi.
> This fixes bug 108078.
> Thanks for the review.
[...snip...]
> diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
> index 5d7c7177cc3..4ec0fff4843 100644
> --- a/gcc/jit/jit-recording.h
> +++ b/gcc/jit/jit-recording.h
> @@ -806,6 +806,15 @@ public:
>
> void replay_into (replayer *) final override;
>
> + virtual bool is_same_type_as (type *other)
This would be better with a "final override" (and without the
"virtual").
> + {
> + vector_type *other_vec_type = other->dyn_cast_vector_type ();
> + if (other_vec_type == NULL)
> + return false;
> + return get_num_units () == other_vec_type->get_num_units ()
> + && get_element_type () == other_vec_type->get_element_type ();
> + }
> +
OK for active branches with that nit fixed (though for gcc 10 you'd
have to spell final and override as "FINAL" and "OVERRIDE" due to
needing to be buildable with a C++98 compiler; not sure if gcc 10's
libgccjit even has vector types though).
[...snip...]
Thanks for the patch
Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libgccjit: Allow comparing vector types
2022-12-13 21:24 ` David Malcolm
@ 2022-12-13 21:27 ` Antoni Boucher
2022-12-13 21:45 ` David Malcolm
0 siblings, 1 reply; 4+ messages in thread
From: Antoni Boucher @ 2022-12-13 21:27 UTC (permalink / raw)
To: David Malcolm, gcc-patches, jit; +Cc: Guillaume Gomez
Thanks!
David: you mentioned gcc 10. For now, I only intend to make changes to
the next release (13). Is this OK or should I backport all my fixes to
all active releases? (I'm not sure what are GCC policies here.)
On Tue, 2022-12-13 at 16:24 -0500, David Malcolm wrote:
> On Mon, 2022-12-12 at 21:31 -0500, Antoni Boucher via Jit wrote:
> > Hi.
> > This fixes bug 108078.
> > Thanks for the review.
>
> [...snip...]
>
> > diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
> > index 5d7c7177cc3..4ec0fff4843 100644
> > --- a/gcc/jit/jit-recording.h
> > +++ b/gcc/jit/jit-recording.h
> > @@ -806,6 +806,15 @@ public:
> >
> > void replay_into (replayer *) final override;
> >
> > + virtual bool is_same_type_as (type *other)
>
> This would be better with a "final override" (and without the
> "virtual").
>
> > + {
> > + vector_type *other_vec_type = other->dyn_cast_vector_type ();
> > + if (other_vec_type == NULL)
> > + return false;
> > + return get_num_units () == other_vec_type->get_num_units ()
> > + && get_element_type () == other_vec_type->get_element_type
> > ();
> > + }
> > +
>
> OK for active branches with that nit fixed (though for gcc 10 you'd
> have to spell final and override as "FINAL" and "OVERRIDE" due to
> needing to be buildable with a C++98 compiler; not sure if gcc 10's
> libgccjit even has vector types though).
>
> [...snip...]
>
> Thanks for the patch
>
> Dave
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libgccjit: Allow comparing vector types
2022-12-13 21:27 ` Antoni Boucher
@ 2022-12-13 21:45 ` David Malcolm
0 siblings, 0 replies; 4+ messages in thread
From: David Malcolm @ 2022-12-13 21:45 UTC (permalink / raw)
To: Antoni Boucher, gcc-patches, jit; +Cc: Guillaume Gomez
On Tue, 2022-12-13 at 16:27 -0500, Antoni Boucher wrote:
> Thanks!
>
> David: you mentioned gcc 10. For now, I only intend to make changes
> to
> the next release (13). Is this OK or should I backport all my fixes
> to
> all active releases? (I'm not sure what are GCC policies here.)
I think it varies by subproject within GCC.
Given that this could arguably be an RFE rather than a bugfix, and that
rustc_codegen_gcc is likely the primary user of this stuff, I leave the
decision of which branches to you. If you only want it in trunk for
gcc 13 onwards, then that's fine by me.
Thanks again for the patch
Dave
>
> On Tue, 2022-12-13 at 16:24 -0500, David Malcolm wrote:
> > On Mon, 2022-12-12 at 21:31 -0500, Antoni Boucher via Jit wrote:
> > > Hi.
> > > This fixes bug 108078.
> > > Thanks for the review.
> >
> > [...snip...]
> >
> > > diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
> > > index 5d7c7177cc3..4ec0fff4843 100644
> > > --- a/gcc/jit/jit-recording.h
> > > +++ b/gcc/jit/jit-recording.h
> > > @@ -806,6 +806,15 @@ public:
> > >
> > > void replay_into (replayer *) final override;
> > >
> > > + virtual bool is_same_type_as (type *other)
> >
> > This would be better with a "final override" (and without the
> > "virtual").
> >
> > > + {
> > > + vector_type *other_vec_type = other->dyn_cast_vector_type
> > > ();
> > > + if (other_vec_type == NULL)
> > > + return false;
> > > + return get_num_units () == other_vec_type->get_num_units ()
> > > + && get_element_type () == other_vec_type->get_element_type
> > > ();
> > > + }
> > > +
> >
> > OK for active branches with that nit fixed (though for gcc 10 you'd
> > have to spell final and override as "FINAL" and "OVERRIDE" due to
> > needing to be buildable with a C++98 compiler; not sure if gcc 10's
> > libgccjit even has vector types though).
> >
> > [...snip...]
> >
> > Thanks for the patch
> >
> > Dave
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-13 21:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 2:31 [PATCH] libgccjit: Allow comparing vector types Antoni Boucher
2022-12-13 21:24 ` David Malcolm
2022-12-13 21:27 ` Antoni Boucher
2022-12-13 21:45 ` David Malcolm
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).