From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 705A43858427 for ; Wed, 23 Mar 2022 09:03:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 705A43858427 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4E498210DC; Wed, 23 Mar 2022 09:03:40 +0000 (UTC) Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 13EC4A3B94; Wed, 23 Mar 2022 09:03:40 +0000 (UTC) Date: Wed, 23 Mar 2022 10:03:39 +0100 (CET) From: Richard Biener To: Jakub Jelinek cc: Roger Sayle , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] testsuite: Fix up sse2-v1ti-shift-3.c test [PR102986] In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Wed, 23 Mar 2022 09:03:43 -0000 On Wed, 23 Mar 2022, Jakub Jelinek wrote: > Hi! > > This test is dg-do run and invokes UB when these rotate functions > are called with 0 as second argument. There are some other tests > that do this but they are dg-do compile only and not even call those > functions at all, so it IMHO doesn't matter that they are only well > defined for [1,127] and not [0,127]. > > The following patch fixes it, we pattern recognize both forms as rotates > and we emit identical assembly. > > Tested on x86_64-linux -m32/-m64, ok for trunk? OK. > 2022-03-23 Jakub Jelinek > > PR target/102986 > * gcc.target/i386/sse2-v1ti-shift-3.c (rotr_v1ti, rotl_v1ti, rotr_ti, > rotl_ti): Use -i&127 instead of 128-i to avoid UB on i == 0. > > --- gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c.jj 2021-12-30 15:12:43.709143657 +0100 > +++ gcc/testsuite/gcc.target/i386/sse2-v1ti-shift-3.c 2022-03-23 09:36:41.622181842 +0100 > @@ -14,14 +14,14 @@ typedef __int128 ti; > uv1ti ashl_v1ti(uv1ti x, unsigned int i) { return x << i; } > uv1ti lshr_v1ti(uv1ti x, unsigned int i) { return x >> i; } > sv1ti ashr_v1ti(sv1ti x, unsigned int i) { return x >> i; } > -uv1ti rotr_v1ti(uv1ti x, unsigned int i) { return (x >> i) | (x << (128-i)); } > -uv1ti rotl_v1ti(uv1ti x, unsigned int i) { return (x << i) | (x >> (128-i)); } > +uv1ti rotr_v1ti(uv1ti x, unsigned int i) { return (x >> i) | (x << (-i&127)); } > +uv1ti rotl_v1ti(uv1ti x, unsigned int i) { return (x << i) | (x >> (-i&127)); } > > uti ashl_ti(uti x, unsigned int i) { return x << i; } > uti lshr_ti(uti x, unsigned int i) { return x >> i; } > sti ashr_ti(sti x, unsigned int i) { return x >> i; } > -uti rotr_ti(uti x, unsigned int i) { return (x >> i) | (x << (128-i)); } > -uti rotl_ti(uti x, unsigned int i) { return (x << i) | (x >> (128-i)); } > +uti rotr_ti(uti x, unsigned int i) { return (x >> i) | (x << (-i&127)); } > +uti rotl_ti(uti x, unsigned int i) { return (x << i) | (x >> (-i&127)); } > > void test(ti x) > { > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)