From patchwork Tue Dec 13 02:31:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoni Boucher X-Patchwork-Id: 61856 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE5B138469A9 for ; Tue, 13 Dec 2022 02:31:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE5B138469A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670898710; bh=RRHXPQeDTYDA2SfeB7O8k/2ILGMs29ZsOjrvPhDcJMo=; h=Subject:To:Cc:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nCwSxuDfXpnQQ7RQRV6+ZBSFozF4sYZVlzeyedsl5BGWVurdw0jaFvR7c82q0j5XW S5BX1dIvR2FvxVc7HXdiXZJ4y0UrJuYwqpLepYHoAwLFF6OhvwF+qfAGZ1RCMAE51T k+9V+Ytnk9bCEK62kMn2n+54jCmAFYXVb5S8JKc4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sender4-pp-o91.zoho.com (sender4-pp-o91.zoho.com [136.143.188.91]) by sourceware.org (Postfix) with ESMTPS id 2A7B13857400; Tue, 13 Dec 2022 02:31:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A7B13857400 ARC-Seal: i=1; a=rsa-sha256; t=1670898677; cv=none; d=zohomail.com; s=zohoarc; b=O3yEDGTTNFu+p9kGfgHOeDcDIl1B0bcZhUbHn3ATcQ59chLgKQqBeGd7wDCRZthqWZ9cLpN/32L4hrCAMxFbjKi9h4VUh4kXO/znke/DSgWJdh2qQCLsPEnrqIeaFLb4WmVTKsfnhMatPatRMbRcSbiIw2A4Pq2kwbEp1wA4wXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670898677; h=Content-Type:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=RRHXPQeDTYDA2SfeB7O8k/2ILGMs29ZsOjrvPhDcJMo=; b=l00qyBm+kyTOUdhRXW0mth+0+L5xfQq3hjY7IZSOiYWPvnyc6soRcg6/1ORlM7cWFb5unRvHFKULljTl3szV7GrF0FqFXXbSC2sL8UmP3pPzNTm2uBBxeEs7ZUu41PjP3RrUGujUItahpCZMylLCmipB8zEXwm2l43/bI2HKhGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= Received: from [192.168.1.174] (38.87.11.6 [38.87.11.6]) by mx.zohomail.com with SMTPS id 1670898676795255.90321145918404; Mon, 12 Dec 2022 18:31:16 -0800 (PST) Message-ID: <1aec893b44d81c5558db3c3b2ac8b63e8c456469.camel@zoho.com> Subject: [PATCH] libgccjit: Allow comparing vector types To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Cc: Guillaume Gomez Date: Mon, 12 Dec 2022 21:31:15 -0500 User-Agent: Evolution 3.46.2 MIME-Version: 1.0 X-Zoho-Virus-Status: 1 X-ZohoMailClient: External X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Antoni Boucher via Gcc-patches From: Antoni Boucher Reply-To: Antoni Boucher Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi. This fixes bug 108078. Thanks for the review. From 016d23eeab1536e2ce0607d422fe4bb42b55c2dc Mon Sep 17 00:00:00 2001 From: Antoni Boucher 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 --- 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 -- 2.26.2.7.g19db9cfb68.dirty