From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fx408.security-mail.net (smtpout140.security-mail.net [85.31.212.148]) by sourceware.org (Postfix) with ESMTPS id C8EED3858404 for ; Tue, 11 Oct 2022 23:18:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8EED3858404 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=kalrayinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kalray.eu Received: from localhost (localhost [127.0.0.1]) by fx408.security-mail.net (Postfix) with ESMTP id 72BB11B7AD27 for ; Wed, 12 Oct 2022 01:18:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1665530301; bh=uKakTGKDSqmX+1A320iTCZXzyiJoKGKgVwdqetXy8bs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Cc1qz0PNUyxRSftVkUhls2yM70/ZwBE0a4Kxi9VftpI3NPmkl2cBn0YYv1j7AB1Li iYYeBVcAdS5Aorwcsc3RKm9U+K8OMet1rzoMYGtm50CIzJjzP1fqzHc9MHxCy9uYTI nUSvRUs+4E9bK4eh1DFkgSFpyO/t+MbQs062qEQ8= Received: from fx408 (localhost [127.0.0.1]) by fx408.security-mail.net (Postfix) with ESMTP id 574101B7AC06; Wed, 12 Oct 2022 01:18:21 +0200 (CEST) Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx408.security-mail.net (Postfix) with ESMTPS id AA2921B7ABC8; Wed, 12 Oct 2022 01:18:20 +0200 (CEST) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 5ADC327E0444; Wed, 12 Oct 2022 01:18:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 3B0B727E0456; Wed, 12 Oct 2022 01:18:20 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id dBpntV17QWxc; Wed, 12 Oct 2022 01:18:20 +0200 (CEST) Received: from localhost (unknown [192.168.37.51]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 1B75C27E0444; Wed, 12 Oct 2022 01:18:20 +0200 (CEST) X-Virus-Scanned: E-securemail Secumail-id: DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 3B0B727E0456 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=4F334102-7B72-11EB-A74E-42D0B9747555; t=1665530300; bh=JxuebIfBD+D0YLGvxfGB4+x+miWNdphCc3WQCuwv1IM=; h=Date:From:To:Message-ID:MIME-Version; b=EHhWNEJVUlgikHTwsTjwJjrNpTPMRH66e9bK8ffNgUyucY9Q+U7nJdLSpxOnBuGjE aBdOv3aO8kEyBF9LWPadzy5mDDk4BqrcrMvjoHnPc3ETc9ynPXV7re5cApsdUxUp3J IaFVGcE/BUJ5sOCbHnzhmIwnMFzgDHknGbZ3yNbhYz55zpa/ZDI9QOGCC9H5Tag6aG 8zcD7OOgrqP1OUfW9xBrzqs0M0QzrYbSPRkA94Atyt2YonIX1sP8S5SKRcOXeCuT9N SxTL+YPfEi0bQCm/Evk7SP6jdtumLzA/8+QBhved4+p0S23gbBFnBPygCKJf0WYfC0 AQF6uegkZDa3g== Date: Wed, 12 Oct 2022 01:18:19 +0200 From: Paul Iannetta To: Joseph Myers Cc: gcc-patches@gcc.gnu.org Subject: Re: [RFC] Add support for vectors in comparisons (like the C++ frontend does) Message-ID: <20221011231819.u25zufq4fqmapwzg@ws2202.lin.mbt.kalray.eu> References: <20221010141141.krpmtzmbgadlo3db@ws2202.lin.mbt.kalray.eu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-ALTERMIMEV2_out: done X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,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 List-Id: On Mon, Oct 10, 2022 at 11:07:06PM +0000, Joseph Myers wrote: > On Mon, 10 Oct 2022, Paul Iannetta via Gcc-patches wrote: > > > I have a patch to bring this feature to the C front-end as well, and > > would like to hear your opinion on it, especially since it may affect > > the feature-set of the objc front-end as well. > > > Currently, this is only a tentative patch and I did not add any tests > > to the testsuite. > > I think tests (possibly existing C++ tests moved to c-c++-common?) are > necessary to judge such a feature; it could better be judged based on > tests without implementation than based on implementation without tests. Currently, this feature has the following tests in g++.dg/ext/ - vector9.C - vector19.C - vector21.C - vector22.C - vector23.C - vector27.C - vector28.C provided by Marc Glisse when he implemented the feature for C++. They are all handled by my mirror implementation (after removing C++-only features), save for a case in vector19.C ( v ? '1' : '2', where v is a vector of unsigned char, but '1' and '2' are considered as int, which results in a type mismatch.) I'll move those tests to c-c++-common tomorrow, but will duplicate vector19.C and vector23.C which rely on C++-only features. During my tests, I've been using variations around this: typedef int v2si __attribute__((__vector_size__ (2 * sizeof(int)))); v2si f (v2si a, v2si b, v2si c) { v2si d = a + !b; v2si e = a || b; return c ? (a + !b) && (c - e && a) : (!!b ^ c && e); } It is already possible to express much of the same thing without the syntactic sugar but is is barely legible typedef int v2si __attribute__((__vector_size__ (2 * sizeof(int)))); v2si f (v2si a, v2si b, v2si c) { v2si d = a + (b == 0); v2si e = (a != 0) | (b != 0); return ((c != 0) & (((a + (b == 0)) != 0) & (((c - e) != 0) & (a != 0)))) | ((c == 0) & (((((b == 0) == 0) ^ c) != 0) & (e != 0))); } Paul