From patchwork Sat Feb 10 09:50:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 199239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1383456dyd; Sat, 10 Feb 2024 01:51:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoLaqnrKhFIu387O6QqAf7AH4dvKsq7ITz3rW0DBLNZa2cMmexWG60tmHcQdjDvStqjsEF3AMJXI5q190gxZU3YUM66Q== X-Google-Smtp-Source: AGHT+IEpS5xwjwet8Cj++Na9W4ZVAqqmcX/2owrGVzUOJJu9GAQKhbHJnseZQ2miJlLMAC74txJ2 X-Received: by 2002:ad4:5f4f:0:b0:68c:4306:b8a7 with SMTP id p15-20020ad45f4f000000b0068c4306b8a7mr1983333qvg.9.1707558662591; Sat, 10 Feb 2024 01:51:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707558662; cv=pass; d=google.com; s=arc-20160816; b=jFPpFzRkKDpQZRhzs2ff6cERKQiLeX+jMD5urxTSPeZagBqnPWqnR5bI/MCd75ARgH 0n3fYwpvZKRRnzvQPnMTmZ0uFbReb30JkFjjE8/DFo0+T2rLEarYXGaZSXLTcqWbwiNC Dh8gRiMvtOrkwFP+YIyKQhdkXBFI9MAvLy7FdCELF7lL8ebhWhcH4XiCq+Rk6WXmb92H 94NQOxPoFPMkETdSY4QRh53WFBq746eqHu0qr/zIRM8wc7cIrBm0mLCSw+QUpf6LiBEK c6wNgmV25e2TkMTTAMRp7h/aZUL8M/MwOflPJAAwOtJMT4y+khriMfcZG5QLv+dMFAY8 aE1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=EdIDxIBP96q9+WLoRGVjtPWhVzvYiN+EYSdrBzI2UFY=; fh=XejiZsBkwsKuhRfKv45yuPFcu/61gJK8RZ4E6aDVnVY=; b=eLMDLq9BSZ6i8mP1fr+1tWwQhG8kDhtFGqG/EpuR4wXjLcFrDrdw4JXlhEJ0fX9NJy 2GHXXQAP0wY7l9G/jA+6l6D59+rffjbEcLaesGLjbXX3sTMUBNscV3TQHb9WFLvLHnOc OmqtaW6dIsbESlvQB8ijgAn4C7WIs5M/HPGGcIh/2xIr6+PBzifJ2NODTfQi8bX+6qdo hdoRfBSjvJN63vcXnTYaBdiCw+SzMxXyIBLQWUSaXmp1z31hm2Uam1lNtZ2wewGflhdM +M3xN/uBeX1JYOjYFebYsz/JN+IKQjFaP25qXPjkA5Lhv1dWzVjoi+atG3YMc+Y3OH/q xDGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LZGg19qq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWFIw08JGOBEaS+kAKe79DRSdCMQICmVitpW3rMRQN7o0wpZ5qLy5YmIRdFUCUfzGZ5TsNVQHEVsokTYratmcXxnJIP0Q== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id kc16-20020a056214411000b0068c4919b66fsi3816690qvb.147.2024.02.10.01.51.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 01:51:02 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LZGg19qq; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BFEF3858C5E for ; Sat, 10 Feb 2024 09:51:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B683C3858403 for ; Sat, 10 Feb 2024 09:50:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B683C3858403 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B683C3858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707558620; cv=none; b=NUaAoKA1kHWVePJY2jzbpVvfF7PtYawsPFAzsj3oIViFLjFflR7gn6urgrlvxX+GUBVewXk15ysg16OlaXv0umS/T3JQ08v/jm36cc1KqrEgorqC8mzBaT+BDtTEoT++fklxRh2UOveP8/8/Xh7redlVRnla/cLtmOtNZ4gYqpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707558620; c=relaxed/simple; bh=+zs/PxAiyE9G2y8k682GAI69Mvou1EIS47VAEbTq8CU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=COLz+HcikV49QdctG9ewZFfUWN+l1MSGZ9X7IznbuR/PhujHRbw9lvixAlAog8wEx05+6V43x+NBiHMig154syp9CHCnpV56nY/xlEu7m3xYsPLuhEPlc7h4KB1sHfm9Vr8QAgz/PyDH3xwYk7CR90eFfCUOq/UyN9SKfo1+6sc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707558617; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=EdIDxIBP96q9+WLoRGVjtPWhVzvYiN+EYSdrBzI2UFY=; b=LZGg19qqEStPE4aCSgOk0DkEOEPe+aPgk1HWTeqZqC//O6ZL/8K60bMOSIUAs8gHbjelPl ApTG53EreDN/Ien0XJWl2VGzc+MQ5fy8gREOOvoALo9qPK0A7XD4SXblZDHPBlyCNJ1AcZ jBiZ8QclK9cW883IpRMvIRcxPaLvr5g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-ButvdsKCOGKK-Yoyq35j_Q-1; Sat, 10 Feb 2024 04:50:15 -0500 X-MC-Unique: ButvdsKCOGKK-Yoyq35j_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85C3584F9D1; Sat, 10 Feb 2024 09:50:15 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4909D2026D06; Sat, 10 Feb 2024 09:50:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 41A9oCe34023449 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 10 Feb 2024 10:50:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41A9oCg94023448; Sat, 10 Feb 2024 10:50:12 +0100 Date: Sat, 10 Feb 2024 10:50:11 +0100 From: Jakub Jelinek To: Richard Biener , "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] libgcc: Fix BIL_TYPE_SIZE == 32 support in _BitInt <-> dfp support Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790505032061631769 X-GMAIL-MSGID: 1790505032061631769 Hi! I've tried last night to enable _BitInt support for i?86-linux, and a few spots in libgcc emitted -Wshift-count-overflow warnings and clearly didn't do what it was supposed to do. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux (together with patch which enabled the bitint support there), ok for trunk? 2024-02-10 Jakub Jelinek * soft-fp/fixddbitint.c (__bid_fixddbitint): Fix up BIL_TYPE_SIZE == 32 shifts. * soft-fp/fixsdbitint.c (__bid_fixsdbitint): Likewise. * soft-fp/fixtdbitint.c (__bid_fixtdbitint): Likewise. * soft-fp/floatbitintdd.c (__bid_floatbitintdd): Likewise. * soft-fp/floatbitinttd.c (__bid_floatbitinttd): Likewise. Jakub --- libgcc/soft-fp/fixddbitint.c.jj 2023-09-06 17:34:04.976510473 +0200 +++ libgcc/soft-fp/fixddbitint.c 2024-02-09 17:05:40.009794653 +0100 @@ -103,7 +103,7 @@ __bid_fixddbitint (UBILtype *r, SItype r #if BIL_TYPE_SIZE == 64 d = limbs[0]; #elif BIL_TYPE_SIZE == 32 - d = (limbs[BITINT_END (0, 1)] << 32) | limbs[BITINT_END (1, 0)]; + d = (UDItype) limbs[BITINT_END (0, 1)] << 32 | limbs[BITINT_END (1, 0)]; #else # error Unsupported BIL_TYPE_SIZE #endif --- libgcc/soft-fp/fixsdbitint.c.jj 2023-09-06 17:34:04.977510460 +0200 +++ libgcc/soft-fp/fixsdbitint.c 2024-02-09 17:05:58.104542321 +0100 @@ -104,7 +104,7 @@ __bid_fixsdbitint (UBILtype *r, SItype r #if BIL_TYPE_SIZE == 64 d = limbs[0]; #elif BIL_TYPE_SIZE == 32 - d = (limbs[BITINT_END (0, 1)] << 32) | limbs[BITINT_END (1, 0)]; + d = (UDItype) limbs[BITINT_END (0, 1)] << 32 | limbs[BITINT_END (1, 0)]; #else # error Unsupported BIL_TYPE_SIZE #endif --- libgcc/soft-fp/fixtdbitint.c.jj 2023-09-06 17:34:04.977510460 +0200 +++ libgcc/soft-fp/fixtdbitint.c 2024-02-09 17:06:15.781295825 +0100 @@ -126,9 +126,9 @@ __bid_fixtdbitint (UBILtype *r, SItype r mantissalo = limbs[BITINT_END (5, 4)]; rem = limbs[6] | limbs[7]; #elif BIL_TYPE_SIZE == 32 - mantissahi = limbs[BITINT_END (8, 11)] << 32; + mantissahi = (UDItype) limbs[BITINT_END (8, 11)] << 32; mantissahi |= limbs[BITINT_END (9, 10)]; - mantissalo = limbs[BITINT_END (10, 9)] << 32; + mantissalo = (UDItype) limbs[BITINT_END (10, 9)] << 32; mantissalo |= limbs[BITINT_END (11, 8)]; rem = limbs[12] | limbs[13] | limbs[14] | limbs[15]; #endif --- libgcc/soft-fp/floatbitintdd.c.jj 2023-09-06 17:34:04.977510460 +0200 +++ libgcc/soft-fp/floatbitintdd.c 2024-02-09 17:11:47.095675716 +0100 @@ -132,7 +132,7 @@ __bid_floatbitintdd (const UBILtype *i, #if BIL_TYPE_SIZE == 64 m = buf[BITINT_END (1, 0)]; #elif BIL_TYPE_SIZE == 32 - m = ((UDItype) buf[1] << 32) | buf[BITINT_END (2, 0)]; + m = (UDItype) buf[1] << 32 | buf[BITINT_END (2, 0)]; #else # error Unsupported BIL_TYPE_SIZE #endif @@ -212,7 +212,8 @@ __bid_floatbitintdd (const UBILtype *i, mantissa = buf[q_limbs + pow10_limbs * 2 + 1]; #else mantissa - = ((buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (0, 1)] << 32) + = ((UDItype) + buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (0, 1)] << 32 | buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (1, 0)]); #endif } @@ -220,8 +221,7 @@ __bid_floatbitintdd (const UBILtype *i, #if BIL_TYPE_SIZE == 64 mantissa = buf[BITINT_END (1, 0)]; #else - mantissa - = ((buf[1] << 32) | buf[BITINT_END (2, 0)]); + mantissa = (UDItype) buf[1] << 32 | buf[BITINT_END (2, 0)]; #endif } else @@ -232,7 +232,7 @@ __bid_floatbitintdd (const UBILtype *i, if (in == 1) mantissa = iprec < 0 ? (UDItype) (BILtype) msb : (UDItype) msb; else - mantissa = ((msb << 32) | i[BITINT_END (1, 0)]); + mantissa = (UDItype) msb << 32 | i[BITINT_END (1, 0)]; #endif if (iprec < 0) mantissa = -mantissa; --- libgcc/soft-fp/floatbitinttd.c.jj 2023-09-06 17:34:04.978510447 +0200 +++ libgcc/soft-fp/floatbitinttd.c 2024-02-09 17:14:17.485578556 +0100 @@ -196,10 +196,12 @@ __bid_floatbitinttd (const UBILtype *i, mantissalo = buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (1, 0)]; #else mantissahi - = ((buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (0, 3)] << 32) + = ((UDItype) + buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (0, 3)] << 32 | buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (1, 2)]); mantissalo - = ((buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (2, 1)] << 32) + = ((UDItype) + buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (2, 1)] << 32 | buf[q_limbs + pow10_limbs * 2 + 1 + BITINT_END (3, 0)]); #endif } @@ -209,8 +211,10 @@ __bid_floatbitinttd (const UBILtype *i, mantissahi = buf[BITINT_END (0, 1)]; mantissalo = buf[BITINT_END (1, 0)]; #else - mantissahi = (buf[BITINT_END (0, 3)] << 32) | buf[BITINT_END (1, 2)]; - mantissalo = (buf[BITINT_END (2, 1)] << 32) | buf[BITINT_END (3, 0)]; + mantissahi = ((UDItype) buf[BITINT_END (0, 3)] << 32 + | buf[BITINT_END (1, 2)]); + mantissalo = ((UDItype) buf[BITINT_END (2, 1)] << 32 + | buf[BITINT_END (3, 0)]); #endif } } @@ -231,15 +235,15 @@ __bid_floatbitinttd (const UBILtype *i, if (in == 1) mantissalo = iprec < 0 ? (UDItype) (BILtype) msb : (UDItype) msb; else - mantissalo = (msb << 32) | i[BITINT_END (1, 0)]; + mantissalo = (UDItype) msb << 32 | i[BITINT_END (1, 0)]; } else { if (in == 3) mantissahi = iprec < 0 ? (UDItype) (BILtype) msb : (UDItype) msb; else - mantissahi = (msb << 32) | i[BITINT_END (1, 2)]; - mantissalo = ((i[BITINT_END (in - 2, 1)] << 32) + mantissahi = (UDItype) msb << 32 | i[BITINT_END (1, 2)]; + mantissalo = ((UDItype) i[BITINT_END (in - 2, 1)] << 32 | i[BITINT_END (in - 1, 0)]); } #endif