From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 0DA3C3858C54 for ; Thu, 11 Jan 2024 08:40:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0DA3C3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0DA3C3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704962462; cv=none; b=a9aaLmcKGzoX2tzAaCbv975rbgIAXpo4yP3s1O+AeuGjJJpQ8u/qJYmqQ7hErDuhcksoY+lzgEGb2J+eb9J/oPFe+LkJLZ75hWXi+LQDQy2sSdJMu365epF09qWNzb14Vko0F9aajwYaaaL6fhRNpFXGE7PHHWL7OpO0AV06+LU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704962462; c=relaxed/simple; bh=PmPG7UKrdKNlBEMH1Chm0QRlzEy0WvW7A+7iG4ltbDs=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=MOfo9DLzZjYokhGJw/sbwn4/cBMEauTRc3EeKwho31k+bzRM3UDm4fsxmDmYyex9toLbCnK/A6hUexcKgBjhGVhqJxHRJMgdgqBFjRKAWOLJvF0E/156JcDWmGW8s2hLExz/38Hz8TNwhLEFIx+aAX4OEiL6EQtejVSSsq1r6xA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9C50C22113; Thu, 11 Jan 2024 08:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704962436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6E/Ayo2jws0fw5c++CpKNIIkE2vObcyYFo8I5uC9vcM=; b=2YRHPBiPMfuoZ76CClE2ifufQo/hYUqhlYhbftCbcxKr6x7MHznQQJtRBEJ/jvEKdXepmC k8CrhmsS+XVUreidpjl3+aqF3TS7CwhHwfJsJN6KpUpP47cqKSV0Q5FKXTb80xHMTmkg8F p/IId4pThOD3prb/SiK416Y61Pmjll8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704962436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6E/Ayo2jws0fw5c++CpKNIIkE2vObcyYFo8I5uC9vcM=; b=vbwtpuV9WnxfUK/p1ItOQTKrV2pN4vsZj8UaWU9lJFn7uBbCWgZZhCcjPM6NP1r1e6q+6a 6DX3euOkPddwYeBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1704962436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6E/Ayo2jws0fw5c++CpKNIIkE2vObcyYFo8I5uC9vcM=; b=2YRHPBiPMfuoZ76CClE2ifufQo/hYUqhlYhbftCbcxKr6x7MHznQQJtRBEJ/jvEKdXepmC k8CrhmsS+XVUreidpjl3+aqF3TS7CwhHwfJsJN6KpUpP47cqKSV0Q5FKXTb80xHMTmkg8F p/IId4pThOD3prb/SiK416Y61Pmjll8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1704962436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6E/Ayo2jws0fw5c++CpKNIIkE2vObcyYFo8I5uC9vcM=; b=vbwtpuV9WnxfUK/p1ItOQTKrV2pN4vsZj8UaWU9lJFn7uBbCWgZZhCcjPM6NP1r1e6q+6a 6DX3euOkPddwYeBw== Date: Thu, 11 Jan 2024 09:35:49 +0100 (CET) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] libgcc: Use may_alias attribute in bitint handlers In-Reply-To: Message-ID: <5qq80qp9-ps16-p7s3-1385-rqo9r0n368pn@fhfr.qr> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -4.29 X-Spamd-Result: default: False [-4.29 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.19)[-0.935]; RCPT_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Thu, 11 Jan 2024, Jakub Jelinek wrote: > Hi! > > As discussed on IRC, the following patch uses may_alias attribute, so that > on targets like aarch64 where abi_limb_mode != limb_mode the library > accesses the limbs (half limbs of the ABI) in the arrays with conservative > alias set. > > So far tested on x86_64-linux with > make check-gcc check-g++ -j32 -k GCC_TEST_RUN_EXPENSIVE=1 RUNTESTFLAGS="GCC_TEST_RUN_EXPENSIVE=1 dg.exp='*bitint* pr112673.c builtin-stdc-bit-*.c pr112566-2.c pr112511.c' dg-torture.exp=*bitint* dfp.exp=*bitint*" > Ok for trunk if it passes full bootstrap/regtest? OK. Richard. > 2024-01-11 Jakub Jelinek > > * libgcc2.h (UBILtype): New typedef with may_alias attribute. > (__mulbitint3, __divmodbitint4): Use UBILtype * instead of > UWtype * and const UBILtype * instead of const UWtype *. > * libgcc2.c (bitint_reduce_prec, bitint_mul_1, bitint_addmul_1, > __mulbitint3, bitint_negate, bitint_submul_1, __divmodbitint4): > Likewise. > * soft-fp/bitint.h (UBILtype): Change define into a typedef with > may_alias attribute. > > --- libgcc/libgcc2.h.jj 2024-01-03 12:07:28.134370411 +0100 > +++ libgcc/libgcc2.h 2024-01-11 08:42:02.417235956 +0100 > @@ -402,10 +402,12 @@ extern UDWtype __udivmoddi4 (UDWtype, UD > #if (defined(__BITINT_MAXWIDTH__) \ > && (defined(L_mulbitint3) || defined(L_divmodbitint4))) > /* _BitInt support. */ > -extern void __mulbitint3 (UWtype *, SItype, const UWtype *, SItype, > - const UWtype *, SItype); > -extern void __divmodbitint4 (UWtype *, SItype, UWtype *, SItype, > - const UWtype *, SItype, const UWtype *, SItype); > +typedef UWtype __attribute__((__may_alias__)) UBILtype; > +extern void __mulbitint3 (UBILtype *, SItype, const UBILtype *, SItype, > + const UBILtype *, SItype); > +extern void __divmodbitint4 (UBILtype *, SItype, UBILtype *, SItype, > + const UBILtype *, SItype, const UBILtype *, > + SItype); > #endif > > /* __negdi2 is static inline when building other libgcc2 portions. */ > --- libgcc/libgcc2.c.jj 2024-01-03 12:07:29.323353753 +0100 > +++ libgcc/libgcc2.c 2024-01-11 08:44:56.260727411 +0100 > @@ -1309,7 +1309,7 @@ __udivdi3 (UDWtype n, UDWtype d) > some narrower _BitInt value, reduce precision. */ > > static inline __attribute__((__always_inline__)) SItype > -bitint_reduce_prec (const UWtype **p, SItype prec) > +bitint_reduce_prec (const UBILtype **p, SItype prec) > { > UWtype mslimb; > SItype i; > @@ -1421,7 +1421,7 @@ bitint_reduce_prec (const UWtype **p, SI > /* D = S * L. */ > > static UWtype > -bitint_mul_1 (UWtype *d, const UWtype *s, UWtype l, SItype n) > +bitint_mul_1 (UBILtype *d, const UBILtype *s, UWtype l, SItype n) > { > UWtype sv, hi, lo, c = 0; > do > @@ -1440,7 +1440,7 @@ bitint_mul_1 (UWtype *d, const UWtype *s > /* D += S * L. */ > > static UWtype > -bitint_addmul_1 (UWtype *d, const UWtype *s, UWtype l, SItype n) > +bitint_addmul_1 (UBILtype *d, const UBILtype *s, UWtype l, SItype n) > { > UWtype sv, hi, lo, c = 0; > do > @@ -1465,9 +1465,9 @@ bitint_addmul_1 (UWtype *d, const UWtype > positive. */ > > void > -__mulbitint3 (UWtype *ret, SItype retprec, > - const UWtype *u, SItype uprec, > - const UWtype *v, SItype vprec) > +__mulbitint3 (UBILtype *ret, SItype retprec, > + const UBILtype *u, SItype uprec, > + const UBILtype *v, SItype vprec) > { > uprec = bitint_reduce_prec (&u, uprec); > vprec = bitint_reduce_prec (&v, vprec); > @@ -1480,7 +1480,7 @@ __mulbitint3 (UWtype *ret, SItype retpre > || (avprec > auprec && !(uprec >= 0 && vprec < 0))) > { > SItype p; > - const UWtype *t; > + const UBILtype *t; > p = uprec; uprec = vprec; vprec = p; > p = auprec; auprec = avprec; avprec = p; > t = u; u = v; v = t; > @@ -1643,7 +1643,7 @@ __mulbitint3 (UWtype *ret, SItype retpre > /* D = -S. */ > > static void > -bitint_negate (UWtype *d, const UWtype *s, SItype n) > +bitint_negate (UBILtype *d, const UBILtype *s, SItype n) > { > UWtype c = 1; > do > @@ -1660,7 +1660,7 @@ bitint_negate (UWtype *d, const UWtype * > /* D -= S * L. */ > > static UWtype > -bitint_submul_1 (UWtype *d, const UWtype *s, UWtype l, SItype n) > +bitint_submul_1 (UBILtype *d, const UBILtype *s, UWtype l, SItype n) > { > UWtype sv, hi, lo, c = 0; > do > @@ -1687,10 +1687,10 @@ bitint_submul_1 (UWtype *d, const UWtype > should be 0. */ > > void > -__divmodbitint4 (UWtype *q, SItype qprec, > - UWtype *r, SItype rprec, > - const UWtype *u, SItype uprec, > - const UWtype *v, SItype vprec) > +__divmodbitint4 (UBILtype *q, SItype qprec, > + UBILtype *r, SItype rprec, > + const UBILtype *u, SItype uprec, > + const UBILtype *v, SItype vprec) > { > uprec = bitint_reduce_prec (&u, uprec); > vprec = bitint_reduce_prec (&v, vprec); > @@ -1747,7 +1747,7 @@ __divmodbitint4 (UWtype *q, SItype qprec > if (qn >= qn2) > qn2 = 0; > USItype sz = un + 1 + vn + qn2; > - UWtype *buf = __builtin_alloca (sz * sizeof (UWtype)); > + UBILtype *buf = __builtin_alloca (sz * sizeof (UWtype)); > USItype uidx, vidx; > #if __LIBGCC_BITINT_ORDER__ == __ORDER_BIG_ENDIAN__ > uidx = un - 1; > @@ -1768,9 +1768,9 @@ __divmodbitint4 (UWtype *q, SItype qprec > __builtin_memcpy (buf + un + 1, v, vn * sizeof (UWtype)); > if (vp) > buf[un + 1 + BITINT_END (0, vn - 1)] &= (((UWtype) 1 << vp) - 1); > - UWtype *u2 = buf; > - UWtype *v2 = u2 + un + 1; > - UWtype *q2 = v2 + vn; > + UBILtype *u2 = buf; > + UBILtype *v2 = u2 + un + 1; > + UBILtype *q2 = v2 + vn; > if (!qn2) > q2 = q + BITINT_END (qn - (un - vn + 1), 0); > > --- libgcc/soft-fp/bitint.h.jj 2023-09-06 17:42:14.501093073 +0200 > +++ libgcc/soft-fp/bitint.h 2024-01-11 08:39:09.590746494 +0100 > @@ -33,19 +33,19 @@ see the files COPYING3 and COPYING.RUNTI > #if BIL_UNITS_PER_WORD == 8 > #define BIL_TYPE_SIZE (8 * __CHAR_BIT__) > #define BILtype DItype > -#define UBILtype UDItype > +typedef UDItype __attribute__ ((__may_alias__)) UBILtype; > #elif BIL_UNITS_PER_WORD == 4 > #define BIL_TYPE_SIZE (4 * __CHAR_BIT__) > #define BILtype SItype > -#define UBILtype USItype > +typedef USItype __attribute__ ((__may_alias__)) UBILtype; > #elif BIL_UNITS_PER_WORD == 2 > #define BIL_TYPE_SIZE (2 * __CHAR_BIT__) > #define BILtype HItype > -#define UBILtype UHItype > +typedef UHItype __attribute__ ((__may_alias__)) UBILtype; > #else > #define BIL_TYPE_SIZE __CHAR_BIT__ > #define BILtype QItype > -#define UBILtype UQItype > +typedef UQItype __attribute__ ((__may_alias__)) UBILtype; > #endif > > /* If *P is zero or sign extended (the latter only for PREC < 0) from > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)