From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7855) id 005A5383D8DA; Wed, 14 Dec 2022 04:55:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 005A5383D8DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670993730; bh=eDkbSXhPdM5sCnFwCzZlcwoZgSeYMJ97WbdxY8pIa/0=; h=From:To:Subject:Date:From; b=S4GegnnJu9T/nxdATeyflzcRVdRXvu060XrdVIherauOTJcXbUiA5zGk+UNUTiSQw qrEWYdGmByDLNQpKow2p45VZoKhFdcBQvQpe1gvDeMU5igDgwXVDITn8/A3ZIj+mCo UZKLvV8eX24sEJ3hQsJTETG8S6Df+C4AI4zkUeRQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Antoni Boucher To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4693] libgccjit: Allow comparing vector types X-Act-Checkin: gcc X-Git-Author: Antoni Boucher X-Git-Refname: refs/heads/master X-Git-Oldrev: f17ddf2c484427e6ddfd994b62fefcdac27ac02f X-Git-Newrev: 512098a3316f07d4b8bf0e035ab128ed2a50cb5e Message-Id: <20221214045530.005A5383D8DA@sourceware.org> Date: Wed, 14 Dec 2022 04:55:29 +0000 (GMT) List-Id: https://gcc.gnu.org/g:512098a3316f07d4b8bf0e035ab128ed2a50cb5e commit r13-4693-g512098a3316f07d4b8bf0e035ab128ed2a50cb5e Author: Antoni Boucher Date: Fri Jun 24 21:05:29 2022 -0400 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 Signed-off-by: Guillaume Gomez Diff: --- 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..e1236dec575 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -806,6 +806,15 @@ public: void replay_into (replayer *) final override; + bool is_same_type_as (type *other) final override + { + 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