From patchwork Thu Jul 27 17:15:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 127074 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp1247655vqo; Thu, 27 Jul 2023 10:18:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKPzP799frfs6dlCcw7P+wXErKSVhbyIQolq3vhOH8ByirXayQoWx/9LFeaoh9wPpZc9Tq X-Received: by 2002:a05:6512:32d2:b0:4fb:89b3:3373 with SMTP id f18-20020a05651232d200b004fb89b33373mr2360825lfg.43.1690478321265; Thu, 27 Jul 2023 10:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690478321; cv=none; d=google.com; s=arc-20160816; b=cVC+OayGz65m1xSnr9lDFyZ4guEJb8jms8ccMczxw2w6bdJYRKVLIxeNusdaSz9F2I 3vFgKPvbcdmANwxJuVlKnXY2uD5OGJJJ+gKd3COHQWfP1h6VYbsgG3piuwd+DYlfvNxG G8ZLFFsJpPVZ/exeLse6NvVPEliqJjaS0rcFecQnnafbtfZeqI7OA+CJ7LvfO65W0Tz1 L/ES0gPl9QxoqAYFnkabwRdi0LBPtAEIB6mAduS+kELUdhdTsmZ4Q668c7S8Xwh8eDG7 O6fE6c/QPmgnSeNVx+pGeZsO/ZooevOHY2tCslR088rSQqT5of1gyhgbpLGwzuLlYAJf v5Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=HMrAapoN4gY5m4lXeqmC7u/uUU2pLViEfSHzE2R7sLY=; fh=WsnZmklt8G06AL40EcEdnVgOM8uIHnTd15u+ffpb1ek=; b=ywl1t1QyA/TPA3EPYsGbBHEtbX5YjM7zVJ0tcqo9fU/9FP22AydrlEAdLm8qo+J82I AcxA1Qu9HA963U/SRXSwbV/vrIZBgD3Vday85wHW1Byqh0Jje42JcKiUFPgc4lYjVZ5d oR3CbZs67VGXEG+RamHLqhDBNX+bWwYExhwepDPEXzPOvlWnQfEQeqkjuzO3EsO1jtR7 A+iOUttRG3qRwSQtxu9RxTCEDCIkg9D902ssHsjrgdSbHC3w+cO+F3QUN7rlrrg0vEp2 Zm0Cs9Ahw4S0RJp+1oN2eISje0CK3j6Gu1cjknFpbDWqZxawTcgmYO+K5CNtOuNuiEW3 POVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KfdYcas2; 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=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v26-20020aa7d65a000000b0052196e1378csi1173370edr.17.2023.07.27.10.18.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 10:18:41 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=KfdYcas2; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B65413854C6F for ; Thu, 27 Jul 2023 17:17:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B65413854C6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690478258; bh=HMrAapoN4gY5m4lXeqmC7u/uUU2pLViEfSHzE2R7sLY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=KfdYcas2JMilopK+r8pFtvjfztjuT35wJoA8wOuHORLjZcOEXI3ElomaSOWi7hcfI cSRvKgXvc6h0jC8Km2Z2qFe60oOysp9u5ZkatrinxXwYjSXyDt4SBM5asw8FkdHKtB 6uEeptDSCqmg0XP7rb+MXbNy9g2zb9Rhp5im17vA= 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 B2B703854C60 for ; Thu, 27 Jul 2023 17:15:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2B703854C60 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-210-py0OkUSDPi6ksnz748hV3g-1; Thu, 27 Jul 2023 13:15:34 -0400 X-MC-Unique: py0OkUSDPi6ksnz748hV3g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9AAF43803513; Thu, 27 Jul 2023 17:15:33 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9F0CC57965; Thu, 27 Jul 2023 17:15:32 +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 36RHFUR52823087 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 27 Jul 2023 19:15:30 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 36RHFTrH2823085; Thu, 27 Jul 2023 19:15:29 +0200 Date: Thu, 27 Jul 2023 19:15:28 +0200 To: gcc-patches@gcc.gnu.org Cc: Richard Biener , "Joseph S. Myers" Subject: [PATCH 4/5] testsuite part 1 for _BitInt support [PR102989] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_LOTSOFHASH, PDS_BTC_ID, PDS_BTC_MSGID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772594996187660660 X-GMAIL-MSGID: 1772594996187660660 Hi! This patch adds first part of the testsuite support. When creating the testcases, I've been using https://defuse.ca/big-number-calculator.htm tool, a randombitint tool I wrote (will post as a reply to this) plus LLVM trunk on godbolt and the WIP GCC support checking if both compilers agree on stuff (and in case of differences tried constant evaluation etc.). The whole testsuite has been also tested with make -j32 -k check-gcc GCC_TEST_RUN_EXPENSIVE=1 \ RUNTESTFLAGS='GCC_TEST_RUN_EXPENSIVE=1 --target_board=unix\{-m32,-m64\} ubsan.exp=bitint*.c dg.exp=bitint* dg-torture.exp=bitint*' to verify it in all modes, normally I'm limitting the torture tests to just -O0 and -O2 because they are quite large and expensive. Generally it is needed to test different _BitInt precisions because they are lowered differently (the small vs. medium vs. large vs. huge, precision of multiples of limb precision or some other etc.). 2023-07-27 Jakub Jelinek PR c/102989 gcc/testsuite/ * lib/target-supports.exp (check_effective_target_bitint, check_effective_target_bitint128, check_effective_target_bitint575): New effective targets. * gcc.dg/bitint-1.c: New test. * gcc.dg/bitint-2.c: New test. * gcc.dg/bitint-3.c: New test. * gcc.dg/bitint-4.c: New test. * gcc.dg/bitint-5.c: New test. * gcc.dg/bitint-6.c: New test. * gcc.dg/bitint-7.c: New test. * gcc.dg/bitint-8.c: New test. * gcc.dg/bitint-9.c: New test. * gcc.dg/bitint-10.c: New test. * gcc.dg/bitint-11.c: New test. * gcc.dg/bitint-12.c: New test. * gcc.dg/bitint-13.c: New test. * gcc.dg/bitint-14.c: New test. * gcc.dg/bitint-15.c: New test. * gcc.dg/torture/bitint-1.c: New test. * gcc.dg/torture/bitint-2.c: New test. * gcc.dg/torture/bitint-3.c: New test. * gcc.dg/torture/bitint-4.c: New test. * gcc.dg/torture/bitint-5.c: New test. * gcc.dg/torture/bitint-6.c: New test. * gcc.dg/torture/bitint-7.c: New test. * gcc.dg/torture/bitint-8.c: New test. * gcc.dg/torture/bitint-9.c: New test. * gcc.dg/torture/bitint-10.c: New test. * gcc.dg/torture/bitint-11.c: New test. * gcc.dg/torture/bitint-12.c: New test. * gcc.dg/torture/bitint-13.c: New test. * gcc.dg/torture/bitint-14.c: New test. * gcc.dg/torture/bitint-15.c: New test. * gcc.dg/torture/bitint-16.c: New test. * gcc.dg/torture/bitint-17.c: New test. * gcc.dg/torture/bitint-18.c: New test. * gcc.dg/torture/bitint-19.c: New test. Jakub --- gcc/testsuite/lib/target-supports.exp.jj 2023-07-24 17:48:26.528040081 +0200 +++ gcc/testsuite/lib/target-supports.exp 2023-07-27 15:03:24.244234312 +0200 @@ -3581,6 +3581,33 @@ proc check_effective_target_fixed_point }] } +# Return 1 if the target supports _BitInt(N), 0 otherwise. + +proc check_effective_target_bitint { } { + return [check_no_compiler_messages bitint object { + _BitInt (2) a = 1wb; + unsigned _BitInt (__BITINT_MAXWIDTH__) b = 0uwb; + } "-std=c2x"] +} + +# Return 1 if the target supports _BitInt(128), 0 otherwise. + +proc check_effective_target_bitint128 { } { + return [check_no_compiler_messages bitint128 object { + _BitInt (2) a = 1wb; + unsigned _BitInt (128) b = 0uwb; + } "-std=c2x"] +} + +# Return 1 if the target supports _BitInt(575), 0 otherwise. + +proc check_effective_target_bitint575 { } { + return [check_no_compiler_messages bitint575 object { + _BitInt (2) a = 1wb; + unsigned _BitInt (575) b = 0uwb; + } "-std=c2x"] +} + # Return 1 if the target supports compiling decimal floating point, # 0 otherwise. --- gcc/testsuite/gcc.dg/bitint-1.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-1.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,26 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x" } */ + +void +foo (int x) +{ + _BitInt (1) a; /* { dg-error "'signed _BitInt' argument must be at least 2" } */ + signed _BitInt (1) b; /* { dg-error "'signed _BitInt' argument must be at least 2" } */ + _BitInt (0) c; /* { dg-error "'_BitInt' argument '0' is not positive integer constant expression" } */ + unsigned _BitInt (0) d; /* { dg-error "'_BitInt' argument '0' is not positive integer constant expression" } */ + _BitInt (-42) e; /* { dg-error "'_BitInt' argument '-42' is not positive integer constant expression" } */ + _BitInt (-5) unsigned f; /* { dg-error "'_BitInt' argument '-5' is not positive integer constant expression" } */ + _BitInt (4294967295ULL) g; /* { dg-error "'_BitInt' argument '4294967295' is larger than 'BITINT_MAXWIDTH' '\[0-9]+'" } */ + long _BitInt (42) h; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + long long _BitInt (42) i; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) long j; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) long long k; /* { dg-error "both 'long' and '_BitInt' in declaration specifiers" } */ + short _BitInt (42) l; /* { dg-error "both 'short' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) short m; /* { dg-error "both 'short' and '_BitInt' in declaration specifiers" } */ + _Complex _BitInt (42) n; /* { dg-error "both 'complex' and '_BitInt' in declaration specifiers" } */ + _BitInt (42) _Complex o; /* { dg-error "both 'complex' and '_BitInt' in declaration specifiers" } */ + int _BitInt (42) p; /* { dg-error "two or more data types in declaration specifiers" } */ + _BitInt (42) int q; /* { dg-error "two or more data types in declaration specifiers" } */ + _BitInt (x) r; /* { dg-error "'_BitInt' argument is not an integer constant expression" } */ +} --- gcc/testsuite/gcc.dg/bitint-2.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-2.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,116 @@ +/* PR c/102989 */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#define expr_has_type(e, t) _Generic (e, default : 0, t : 1) + +#ifdef __BITINT_MAXWIDTH__ +void +foo (void) +{ + _BitInt(42) a = (_BitInt(42)) 1; + _BitInt(42) unsigned b = (unsigned _BitInt(42)) 2; + _BitInt(5) c = (_BitInt(5)) 3; + _BitInt(5) unsigned d = (unsigned _BitInt(5)) 4; + _BitInt(32) e = (_BitInt(32)) 5; + _BitInt(32) unsigned f = (unsigned _BitInt(32)) 6; + static_assert (expr_has_type (a, signed _BitInt(42)), ""); + static_assert (expr_has_type (a, _BitInt(42)), ""); + static_assert (!expr_has_type (a, unsigned _BitInt(42)), ""); + static_assert (!expr_has_type (b, signed _BitInt(42)), ""); + static_assert (!expr_has_type (b, _BitInt(42)), ""); + static_assert (expr_has_type (b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a + b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a * b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a - b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (a * a, _BitInt(42)), ""); + static_assert (expr_has_type (a / b, unsigned _BitInt(42)), ""); + static_assert (expr_has_type (c, signed _BitInt(5)), ""); + static_assert (expr_has_type (c, _BitInt(5)), ""); + static_assert (!expr_has_type (c, unsigned _BitInt(5)), ""); + static_assert (!expr_has_type (d, signed _BitInt(5)), ""); + static_assert (!expr_has_type (d, _BitInt(5)), ""); + static_assert (expr_has_type (d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c + d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c * d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c - d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (c * c, _BitInt(5)), ""); + static_assert (expr_has_type (c / d, unsigned _BitInt(5)), ""); + static_assert (expr_has_type (e, signed _BitInt(32)), ""); + static_assert (expr_has_type (e, _BitInt(32)), ""); + static_assert (!expr_has_type (e, unsigned _BitInt(32)), ""); + static_assert (!expr_has_type (f, signed _BitInt(32)), ""); + static_assert (!expr_has_type (f, _BitInt(32)), ""); + static_assert (expr_has_type (f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e + f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e * f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e - f, unsigned _BitInt(32)), ""); + static_assert (expr_has_type (e * e, _BitInt(32)), ""); + static_assert (expr_has_type (e / f, unsigned _BitInt(32)), ""); +#if __CHAR_BIT__ * __SIZEOF_INT__ == 32 + static_assert (expr_has_type (e + 1, int), ""); + static_assert (expr_has_type (f + 1, unsigned int), ""); + static_assert (expr_has_type (e + 1U, unsigned int), ""); + static_assert (expr_has_type (f + 1U, unsigned int), ""); + static_assert (expr_has_type (1 - e, int), ""); + static_assert (expr_has_type (1 - f, unsigned int), ""); + static_assert (expr_has_type (1U * e, unsigned int), ""); + static_assert (expr_has_type (1U / f, unsigned int), ""); +#endif + static_assert (expr_has_type (0wb, _BitInt(2)), ""); + static_assert (expr_has_type (-1WB, _BitInt(2)), ""); + static_assert (expr_has_type (-1wb - 1wb, _BitInt(2)), ""); + static_assert (expr_has_type (1wb, _BitInt(2)), ""); + static_assert (expr_has_type (2wb, _BitInt(3)), ""); + static_assert (expr_has_type (0wbu, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (-1UWB, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (1uWB, unsigned _BitInt(1)), ""); + static_assert (expr_has_type (2Uwb, unsigned _BitInt(2)), ""); + static_assert (0wb == 0, ""); + static_assert (-1wb == -1, ""); + static_assert (0xffffffffwb == 4294967295wb, ""); + static_assert (0xffffffffwb == 000000000000000000000000000037777777777wb, ""); + static_assert (0x0000000000000000000000000ffffffffwb == 0b00011111111111111111111111111111111wb, ""); +#if __BITINT_MAXWIDTH__ >= 128 + static_assert (expr_has_type (0xffffffffffffffffffffffffffffffffuwb, unsigned _BitInt(128)), ""); + static_assert (0xffffffffffffffffffffffffffffffffuwb == 340282366920938463463374607431768211455uwb, ""); + static_assert (200000000000000000000000000000000000000wb == 0x96769950b50d88f41314448000000000WB, ""); + static_assert (02263551452055206610750114242110000000000000wb == 200000000000000000000000000000000000000wb, ""); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static_assert (expr_has_type (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567UWB, unsigned _BitInt(575)), ""); + static_assert (expr_has_type (0x00000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwbu, unsigned _BitInt(575)), ""); + static_assert (expr_has_type (0377777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777uwb, unsigned _BitInt(575)), ""); + static_assert (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb == 0x00000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwbu, ""); + static_assert (0377777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777WBU == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffuWB, ""); + static_assert (100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb == 0X67815961'0903F797'4A7CB3F2'2F01FA5D'9A2CD603'9DE4A7A6'0F713676'CE7D7113'FF1A499D'9BFD0FDC'D2999652'EB4C7F39'8DE2A000'00000000'00000000'00000000'00000000'00000000UWB, ""); + static_assert (expr_has_type (-61'832600368'276133515'125630254'911797508'782837275'302959978'515764023'224306276'632966792'579100265'310761247'399417856'504034834'837841258'576687802'491886538'775473291'979151693'037174783wb, _BitInt(575)), ""); + static_assert (expr_has_type (0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, signed _BitInt(575)), ""); + static_assert (expr_has_type (0177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb, _BitInt(575)), ""); + static_assert (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783WB == -0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, ""); + static_assert (0177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb / 2wb * 2wb + 1wb == 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, ""); +#endif +#if (0wb != 0) || (0wbU != 0U) || (1wb != 1) || (1uWB != 1u) \ + || (-1wb >= 0) || (-1UWB < 0) || (4294967295uwb != 4294967295U) \ + || 18446744073709551615wbu != 18446744073709551615ULL +#error "" +#endif +} + +void +bar (void) +{ + _BitInt(2) a = (_BitInt(2)) 1; + unsigned _BitInt(1) b = 1uwb; + _BitInt(4) c; + c = 7; + _BitInt(2) d = 1; + _BitInt(5) e = 2wb; + unsigned _BitInt(6) f = 3uwb; +} +#endif + +int +main () +{ +} --- gcc/testsuite/gcc.dg/bitint-3.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-3.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,40 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_BitInt(32) a, b = 2147483647wb; +_BitInt(64) c, d = 9223372036854775807wb; +struct S { + _BitInt(2) a; + _BitInt(6) b; +} s, t = { -1wb - 1wb, 31wb }; + +void +foo (void) +{ + a = b; + c = d; + s.a = t.a; + s.b = t.b; +} + +void +bar (void) +{ + a += b; + c += d; + s.a += t.a; + s.b += t.b; +} + +#if __BITINT_MAXWIDTH__ >= 128 +unsigned _BitInt(128) e = 340282366920938463463374607431768211455uwb; +_BitInt(128) f = 20000000000000000000000000000000000000wb; +_BitInt(128) g = -20000000000000000000000000000000000000wb; +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +unsigned _BitInt(575) h = 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb; +_BitInt(575) i = 2000000000000000000000000000000000000000000wb; +_BitInt(575) j = -2000000000000000000000000000000000000000000wb; +#endif --- gcc/testsuite/gcc.dg/bitint-4.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-4.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,39 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_BitInt(2) +foo (_BitInt(2) x, _BitInt(15) y) +{ + return x + y; +} + +_BitInt(64) +bar (_BitInt(64) x, _BitInt(64) y) +{ + return x + y; +} + +#if __BITINT_MAXWIDTH__ >= 128 +_BitInt(128) a, b, c; + +_BitInt(128) +baz (_BitInt(128) x, _BitInt(128) y) +{ + a = x; + b = y; + return c; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) d, e, f; + +_BitInt(575) +qux (_BitInt(575) x, _BitInt(575) y) +{ + d = x; + e = y; + return f; +} +#endif --- gcc/testsuite/gcc.dg/bitint-5.c.jj 2023-07-27 15:03:24.245234299 +0200 +++ gcc/testsuite/gcc.dg/bitint-5.c 2023-07-27 15:03:24.245234299 +0200 @@ -0,0 +1,63 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include +#include + +#if __BITINT_MAXWIDTH__ >= 128 +unsigned _BitInt(128) b, c; +#endif +#if __BITINT_MAXWIDTH__ >= 575 +signed _BitInt(575) d, e; +#endif + +void +foo (int a, ...) +{ + va_list ap; + va_start (ap, a); + if (a == 1) + { + if (va_arg (ap, _BitInt(2)) != 1wb) + abort (); + if (va_arg (ap, _BitInt(3)) != 3wb) + abort (); + if (va_arg (ap, _BitInt(15)) != 16383wb) + abort (); + if (va_arg (ap, unsigned _BitInt(32)) != 4294967295uwb) + abort (); + if (va_arg (ap, _BitInt(64)) != 0x7fffffffffffffffwb) + abort (); + } +#if __BITINT_MAXWIDTH__ >= 128 + b = va_arg (ap, unsigned _BitInt(128)); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + d = va_arg (ap, _BitInt(575)); +#endif + if (va_arg (ap, int) != 42) + abort (); + va_end (ap); +} + +void +bar (void) +{ + foo (1, 1wb, 3wb, 16383wb, 4294967295uwb, 9223372036854775807wb, +#if __BITINT_MAXWIDTH__ >= 128 + c, +#endif +#if __BITINT_MAXWIDTH__ >= 575 + e, +#endif + 42); + foo (2, +#if __BITINT_MAXWIDTH__ >= 128 + c, +#endif +#if __BITINT_MAXWIDTH__ >= 575 + e, +#endif + 42); +} --- gcc/testsuite/gcc.dg/bitint-6.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/bitint-6.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,15 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +int *q, *r, *s; + +void +foo (int *p) +{ + p[4wb] = 0; + 6wb[p] = 0; + q = p + 8wb; + r = 10uwb + q; + s = r - 2wb; +} --- gcc/testsuite/gcc.dg/bitint-7.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/bitint-7.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,16 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 257 +void +foo (_BitInt(135) *p, _BitInt(193) *q, _BitInt(257) *r) +{ + r[0] = (((p[0] + p[1] + p[2]) + q[0] + (p[3] + p[4] + p[5])) + q[1]) + r[1] + (((p[6] + p[7] + p[8]) + q[2] + (p[9] + p[10] + p[11])) + q[3]) + r[2]; +} +#else +void +foo (void) +{ +} +#endif --- gcc/testsuite/gcc.dg/bitint-8.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/bitint-8.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,34 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -Wno-uninitialized" } */ + +#if __BITINT_MAXWIDTH__ >= 135 +_BitInt(135) +foo (void) +{ + _BitInt(135) d; + _BitInt(135) e = d + 2wb; + return e; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) +bar (void) +{ + _BitInt(575) d; + _BitInt(575) e = d * 42wb; + return e; +} + +_BitInt(575) +baz (int x) +{ + _BitInt(575) d; + if (x) + return 59843758943759843574wb; + return d; +} +#endif + +int x; --- gcc/testsuite/gcc.dg/bitint-9.c.jj 2023-07-27 15:03:24.245234299 +0200 +++ gcc/testsuite/gcc.dg/bitint-9.c 2023-07-27 15:03:24.245234299 +0200 @@ -0,0 +1,52 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint && exceptions } } } */ +/* { dg-options "-O2 -std=gnu2x -fnon-call-exceptions -fexceptions" } */ + +__attribute__((noipa)) void +baz (int *p) +{ +} + +#if __BITINT_MAXWIDTH__ >= 575 +void +foo (volatile _BitInt(575) *p, _BitInt(575) q) +{ + int a __attribute__((cleanup (baz))) = 1; + *p = q; +} + +_BitInt(575) +bar (volatile _BitInt(575) *p) +{ + int a __attribute__((cleanup (baz))) = 1; + return *p; +} + +_BitInt(575) +qux (long double l) +{ + int a __attribute__((cleanup (baz))) = 1; + return l; +} + +long double +corge (_BitInt(575) b) +{ + int a __attribute__((cleanup (baz))) = 1; + return b; +} + +_BitInt(575) +garply (_BitInt(575) x, _BitInt(575) y) +{ + int a __attribute__((cleanup (baz))) = 1; + return x / y; +} + +_BitInt(575) +waldo (_BitInt(575) x, _BitInt(575) y) +{ + int a __attribute__((cleanup (baz))) = 1; + return x % y; +} +#endif --- gcc/testsuite/gcc.dg/bitint-10.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/bitint-10.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,15 @@ +/* PR c/102989 */ +/* { dg-do compile { target { bitint && dfp } } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 129 +void +foo (_BitInt(129) *x, _Decimal64 *y) +{ + x[0] = y[0]; + y[1] = x[1]; +} +#endif + +/* _Decimal* <-> _BitInt conversions are unsupported for now. */ +/* { dg-prune-output "unsupported conversion between" } */ --- gcc/testsuite/gcc.dg/bitint-11.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-11.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,9 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +int +foo (_BitInt(127) x, _BitInt(127) y) +{ + return x < y; +} --- gcc/testsuite/gcc.dg/bitint-12.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-12.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,31 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=gnu2x -w" } */ + +_BitInt(37) +foo (_BitInt(37) x, _BitInt(37) y) +{ + _BitInt(37) w; + __asm ("# %0 %1 %2 %3" : "=r" (w) : "r" (x), "r" (x + y), "g" (68719476735wb)); + return w; +} + +#if __BITINT_MAXWIDTH__ >= 125 +_BitInt(125) +bar (_BitInt(125) x, _BitInt(125) y) +{ + _BitInt(125) w; + __asm ("# %0 %1 %2 %3" : "=g" (w) : "g" (x), "g" (x + y), "g" (21267647932558653966460912964485513215wb)); + return w; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +_BitInt(575) +baz (_BitInt(575) x, _BitInt(575) y) +{ + _BitInt(575) w; + __asm ("# %0 %1 %2 %3" : "=g" (w) : "g" (x), "g" (x + y), "g" (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb)); + return w; +} +#endif --- gcc/testsuite/gcc.dg/bitint-13.c.jj 2023-07-27 15:03:24.244234312 +0200 +++ gcc/testsuite/gcc.dg/bitint-13.c 2023-07-27 15:03:24.244234312 +0200 @@ -0,0 +1,17 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 315 +_Bool +foo (_BitInt (315) a, _BitInt (315) b, unsigned *c) +{ + if (a < -8 || a > 7) + __builtin_unreachable (); + if (b < 0 || b > 63) + __builtin_unreachable (); + return __builtin_add_overflow (a, b, c); +} +#else +int i; +#endif --- gcc/testsuite/gcc.dg/bitint-14.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/bitint-14.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,11 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +enum A : _BitInt(15) { A0 = 0, A1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum B : unsigned _BitInt(575) { B0 = 0, B1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum C { C0 = 459875743wb, C1 = 3298437354uwb }; +enum D { D0 = 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, D1 }; +/* { dg-error "enumerator value outside the range of 'intmax_t'" "" { target *-*-* } .-1 } */ +/* { dg-error "overflow in enumeration values" "" { target *-*-* } .-2 } */ +/* { dg-error "enumeration values exceed range of largest integer" "" { target *-*-* } .-3 } */ --- gcc/testsuite/gcc.dg/bitint-15.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/bitint-15.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,10 @@ +/* PR c/102989 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-std=gnu2x" } */ + +enum A : _BitInt(15) { A0 = 0, A1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum B : unsigned _BitInt(575) { B0 = 0, B1 = 1 }; /* { dg-error "invalid 'enum' underlying type" } */ +enum C { C0 = 459875743wb, C1 = 3298437354uwb }; +enum D { D0 = 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, D1 }; +/* { dg-error "overflow in enumeration values" "" { target *-*-* } .-1 } */ +/* { dg-warning "enumeration values exceed range of largest integer" "" { target *-*-* } .-2 } */ --- gcc/testsuite/gcc.dg/torture/bitint-1.c.jj 2023-07-27 15:03:24.247234271 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-1.c 2023-07-27 15:03:24.247234271 +0200 @@ -0,0 +1,114 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +__attribute__((noipa)) void +foo (_BitInt(6) a, _BitInt(27) b, _BitInt(6) *p, _BitInt(27) *q, float c) +{ + p[0] = b; + q[0] = a; + q[1] = (unsigned _BitInt(6)) a; + q[2] = (unsigned _BitInt(9)) a; + q[3] = c; + q[4] += a; + q[5] = a + b; + q[6] = a - b; + q[7] = a * b; + q[8] = a / b; + q[9] = a % b; + q[10] = b << (-20wb - a); + q[11] = (b * 131wb) >> (-20wb - a); + q[12]++; + ++q[13]; + q[14]--; + --q[15]; + q[16] = a == b; + q[17] = a != b; + q[18] = a > b; + q[19] = a < b; + q[20] = a >= b; + q[21] = a <= b; + q[22] = a && b; + q[23] = a || b; + q[24] = !a; + q[25] = a & b; + q[26] = a | b; + q[27] = a ^ b; + q[28] = ~a; + q[29] -= a; + q[30] *= b; + q[31] /= b; + q[32] %= a; + q[33] <<= b; + q[34] >>= b; + q[35] &= a; + q[36] |= b; + q[37] ^= a; + q[38] = sizeof (a); + q[39] = q[39] ? a : b; + q[40] = 12345wb; + switch (a) + { + case 31wb: + if (b != 8wb) + __builtin_abort (); + break; + case -18wb: + if (b != 9wb) + __builtin_abort (); + break; + case 26wb: + if (b != 12wb) + __builtin_abort (); + break; + case -25wb: + if (b != 6wb) + __builtin_abort (); + break; + case -19wb: + if (b != 15wb) + __builtin_abort (); + break; + default: + __builtin_abort (); + } +} + +int +main () +{ + _BitInt(6) p; + _BitInt(27) q[41]; + static _BitInt(27) qe[41] = { + -25wb, 39wb, 487wb, 17wb, -7wb, -19wb, -31wb, -150wb, -4wb, -1, + 192wb, 24wb, 8wb, 10wb, 10wb, 12wb, 0, 1wb, 0wb, 1, + 0, 1, 1, 1wbu, 0, 6wb, -25wb, -31wb, 24wb, 32wb, + -6wb, -2wb, 2uwb, 320wb, 192wb, 7wb, 30wb, -30wb, 1, -25wb, + 12345wb + }; + q[4] = 18wb; + q[12] = 7wb; + q[13] = 9wb; + q[14] = 11wb; + q[15] = 13wb; + q[29] = 7wb; + q[30] = -1wb; + q[31] = -13wb; + q[32] = 52wb; + q[33] = 5wb; + q[34] = 12345wb; + q[35] = 15wb; + q[36] = 28wb; + q[37] = 5wb; + q[39] = 2wb; + foo (-25wb, 6wb, &p, q, 17.0f); + if (p != 6wb) + __builtin_abort (); + q[38] -= sizeof (p) - 1; + for (int i = 0; i < 41; ++i) + if (q[i] != qe[i]) + __builtin_abort (); + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-2.c.jj 2023-07-27 15:03:24.246234285 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-2.c 2023-07-27 15:03:24.246234285 +0200 @@ -0,0 +1,118 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +__attribute__((noipa)) void +foo (unsigned _BitInt(25) a, unsigned _BitInt(27) b, unsigned _BitInt(25) *p, unsigned _BitInt(27) *q, float c) +{ + p[0] = b; + q[0] = a; + q[1] = (signed _BitInt(25)) a; + q[2] = (_BitInt(12)) a; + q[3] = c; + q[4] += a; + q[5] = a + b; + q[6] = a - b; + q[7] = a * b; + q[8] = a / b; + q[9] = a % b; + q[10] = b << (24320393uwb - a); + q[11] = (b * 131uwb) >> (24320393uwb - a); + q[12]++; + ++q[13]; + q[14]--; + --q[15]; + q[16] = a == b; + q[17] = a != b; + q[18] = a > b; + q[19] = a < b; + q[20] = a >= b; + q[21] = a <= b; + q[22] = a && b; + q[23] = a || b; + q[24] = !a; + q[25] = a & b; + q[26] = a | b; + q[27] = a ^ b; + q[28] = ~a; + q[29] -= a; + q[30] *= b; + q[31] /= b; + q[32] %= a; + q[33] <<= (125900uwb - b); + q[34] >>= (125901uwb - b); + q[35] &= a; + q[36] |= b; + q[37] ^= a; + q[38] = sizeof (a); + q[39] = q[39] ? a : b; + q[40] = 24196214uwb; + switch (a) + { + case 12345641uwb: + if (b != 1244wb) + __builtin_abort (); + break; + case 11821400uwb: + if (b != 133445uwb) + __builtin_abort (); + break; + case 12145uwb: + if (b != 1212uwb) + __builtin_abort (); + break; + case 24320389uwb: + if (b != 125897uwb) + __builtin_abort (); + break; + case 7128412uwb: + if (b != 150uwb) + __builtin_abort (); + break; + default: + __builtin_abort (); + } +} + +int +main () +{ + unsigned _BitInt(25) p; + unsigned _BitInt(27) q[41]; + static unsigned _BitInt(27) qe[41] = { + 24320389uwb, 124983685uwb, 134216069uwb, 42uwb, 24320407uwb, + 24446286uwb, 24194492uwb, 89202797uwb, 193uwb, 22268uwb, + 2014352uwb, 1030781uwb, 8uwb, 10uwb, 10uwb, + 12uwb, 0uwb, 1uwb, 1uwb, 0uwb, + 1uwb, 0uwb, 1uwb, 1uwb, 0uwb, + 67969uwb, 24378317uwb, 24310348uwb, 9234042uwb, 109897346uwb, + 125897uwb, 0uwb, 52uwb, 40uwb, 771uwb, + 5uwb, 125917uwb, 24320384uwb, 1uwb, 24320389uwb, + 24196214uwb + }; + q[4] = 18uwb; + q[12] = 7uwb; + q[13] = 9uwb; + q[14] = 11uwb; + q[15] = 13uwb; + q[29] = 7uwb; + q[30] = -1uwb; + q[31] = -13uwb; + q[32] = 52uwb; + q[33] = 5uwb; + q[34] = 12345uwb; + q[35] = 15uwb; + q[36] = 28uwb; + q[37] = 5uwb; + q[39] = 2uwb; + foo (24320389uwb, 125897uwb, &p, q, 42.0f); + if (p != 125897uwb) + __builtin_abort (); + q[38] -= sizeof (p) - 1; + for (int i = 0; i < 41; ++i) + if (q[i] != qe[i]) + __builtin_abort (); + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-3.c.jj 2023-07-27 15:03:24.245234299 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-3.c 2023-07-27 15:03:24.245234299 +0200 @@ -0,0 +1,134 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 128 +__attribute__((noipa)) void +foo (_BitInt(125) a, _BitInt(128) b, _BitInt(125) *p, _BitInt(128) *q, float c) +{ + p[0] = b; + q[0] = a; + q[1] = (unsigned _BitInt(125)) a; + q[2] = (unsigned _BitInt(68)) a; + q[3] = c; + q[4] += a; + q[5] = a + b; + q[6] = a - b; + q[7] = a * b; + q[8] = a / b; + q[9] = a % b; + q[10] = b << (-80694244678005661015504159217709wb - a); + q[11] = a >> (-80694244678005661015504159217709wb - a); + q[12]++; + ++q[13]; + q[14]--; + --q[15]; + q[16] = a == b; + q[17] = a != b; + q[18] = a > b; + q[19] = a < b; + q[20] = a >= b; + q[21] = a <= b; + q[22] = a && b; + q[23] = a || b; + q[24] = !a; + q[25] = a & b; + q[26] = a | b; + q[27] = a ^ b; + q[28] = ~a; + q[29] -= a; + q[30] *= b; + q[31] /= b; + q[32] %= a; + q[33] <<= (b - 468021wb); + q[34] >>= (b - 468021wb); + q[35] &= a; + q[36] |= b; + q[37] ^= a; + q[38] = sizeof (a); + q[39] = q[39] ? a : b; + q[40] = 80694244678005661015504159217732wb; + switch (a) + { + case 313298472398574896574578475487548wb: + if (b != 813298738947385454wb) + __builtin_abort (); + break; + case -18198347584784758927893783748374wb: + if (b != 9439847384738wb) + __builtin_abort (); + break; + case 261243875485748189278344574857484wb: + if (b != 12549857489574wb) + __builtin_abort (); + break; + case -80694244678005661015504159217733wb: + if (b != 468071wb) + __builtin_abort (); + break; + case -193984372895748547584754854wb: + if (b != 15549857489574wb) + __builtin_abort (); + break; + default: + __builtin_abort (); + } +} + +int +main () +{ + _BitInt(125) p; + _BitInt(128) q[41]; + static _BitInt(128) qe[41] = { + -80694244678005661015504159217733wb, 42535215170872629927260810424811808699wb, + 211591633426360068027wb, -42wb, + -80694244678005661015504143312912wb, -80694244678005661015504158749662wb, + -80694244678005661015504159685804wb, -37770635800678787757188047309203503043wb, + -172397445426026523786998466wb, -238647wb, + 7852928270336wb, -4809751789450982869595538wb, + 821095840985901334959wb, 13895798174897154898wb, + 1465897921835729857453wb, 154987847598437549873142wb, + 0, 1, 0, 1, 0, 1, 1, 1, 0, + 271395wb, -80694244678005661015504159021057wb, + -80694244678005661015504159292452wb, 80694244678005661015504159217732wb, + 80694244678240648474427914115297wb, -5822736520666880936123wb, + 9818355413803wb, 54398547589478975845wb, + 39390147499089156967386811811758080wb, 30486wb, + 5910462358441918751905wb, 1342984375894755194479wb, + -80694244535621434450947930710749wb, 1, -80694244678005661015504159217733wb, + 80694244678005661015504159217732wb + }; + q[4] = 15904821wb; + q[12] = 821095840985901334958wb; + q[13] = 13895798174897154897wb; + q[14] = 1465897921835729857454wb; + q[15] = 154987847598437549873143wb; + q[29] = 234987458923754897564wb; + q[30] = -12439857458947213wb; + q[31] = 4595687436894573685wb; + q[32] = 54398547589478975845wb; + q[33] = 34985478957495847545wb; + q[34] = 34324329847328473343wb; + q[35] = 5984758947589437584545wb; + q[36] = 1342984375894754857545wb; + q[37] = 159847589475894768597656wb; + q[39] = 394857584wb; + foo (-80694244678005661015504159217733wb, 468071wb, &p, q, -42.0f); + if (p != 468071wb) + __builtin_abort (); + q[38] -= sizeof (p) - 1; + for (int i = 0; i < 41; ++i) + if (q[i] != qe[i]) + __builtin_abort (); + return 0; +} +#else +int +main () +{ + return 0; +} +#endif --- gcc/testsuite/gcc.dg/torture/bitint-4.c.jj 2023-07-27 15:03:24.247234271 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-4.c 2023-07-27 15:03:24.247234271 +0200 @@ -0,0 +1,134 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 128 +__attribute__((noipa)) void +foo (unsigned _BitInt(125) a, unsigned _BitInt(127) b, unsigned _BitInt(125) *p, unsigned _BitInt(127) *q, float c) +{ + p[0] = b; + q[0] = a; + q[1] = (signed _BitInt(125)) a; + q[2] = (_BitInt(73)) a; + q[3] = c; + q[4] += a; + q[5] = a + b; + q[6] = a - b; + q[7] = a * b; + q[8] = a / b; + q[9] = a % b; + q[10] = b << (26105549790521884176764218952781428833uwb - a); + q[11] = (a * 131uwb) >> (26105549790521884176764218952781428833uwb - a); + q[12]++; + ++q[13]; + q[14]--; + --q[15]; + q[16] = a == b; + q[17] = a != b; + q[18] = a > b; + q[19] = a < b; + q[20] = a >= b; + q[21] = a <= b; + q[22] = a && b; + q[23] = a || b; + q[24] = !a; + q[25] = a & b; + q[26] = a | b; + q[27] = a ^ b; + q[28] = ~a; + q[29] -= a; + q[30] *= b; + q[31] /= b; + q[32] %= a; + q[33] <<= (12589712345465422uwb - b); + q[34] >>= (12589712345465417uwb - b); + q[35] &= a; + q[36] |= b; + q[37] ^= a; + q[38] = sizeof (a); + q[39] = q[39] ? a : b; + q[40] = 26105549790654675897348954738956342847uwb; + switch (a) + { + case 26105549790521884176764218952781428772uwb: + if (b != 1244154958745894754wb) + __builtin_abort (); + break; + case 11821400154985748973289734545487uwb: + if (b != 133445145984759847584574uwb) + __builtin_abort (); + break; + case 12145uwb: + if (b != 12121243985745894732uwb) + __builtin_abort (); + break; + case 26105549790521884176764218952781428771uwb: + if (b != 12589712345465342uwb) + __builtin_abort (); + break; + case 71284121548547895457123873874452345uwb: + if (b != 150123439857459847uwb) + __builtin_abort (); + break; + default: + __builtin_abort (); + } +} + +int +main () +{ + unsigned _BitInt(125) p; + unsigned _BitInt(127) q[41]; + static unsigned _BitInt(127) qe[41] = { + 26105549790521884176764218952781428771uwb, 153711437385873807975529696739694508067uwb, + 2816339038065666848803uwb, 97uwb, + 26105549790521884178598517527767103757uwb, 26105549790521884176776808665126894113uwb, + 26105549790521884176751629240435963429uwb, 49552990805035300718174502183957321146uwb, + 2073562054015060870989uwb, 8076837748665533uwb, + 58059800399605194176279512422023168uwb, 3687014528101034113uwb, + 7439587439856743895438uwb, 95435435436uwb, + 112349587439856746858975446545uwb, 13145398574895748967847348972322uwb, + 0, 1, 1, 0, 1, 0, 1, 1, 0, + 3439290896351266uwb, 26105549790521884176773369374230542847uwb, + 26105549790521884176769930083334191581uwb, 16429746074595423756157606976189597660uwb, + 144035633670022787123399980532060335632uwb, 63332113050644322882197117954233460326uwb, + 27442uwb, 3245984754897548957498574895745uwb, + 14236875428959659760604435112230125568uwb, 326775104184uwb, + 1170981383577634uwb, 2843243404090270511102uwb, + 26313477358277918295486482038303331024uwb, 1, 26105549790521884176764218952781428771uwb, + 26105549790654675897348954738956342847uwb + }; + q[4] = 1834298574985674986uwb; + q[12] = 7439587439856743895437uwb; + q[13] = 95435435435uwb; + q[14] = 112349587439856746858975446546uwb; + q[15] = 13145398574895748967847348972323uwb; + q[29] = 75439568476895768957658675uwb; + q[30] = 455984375894754983574895745485uwb; + q[31] = 345495847589475847548uwb; + q[32] = 3245984754897548957498574895745uwb; + q[33] = 32594875648957489754854664897464uwb; + q[34] = 12345214395483754897548574857485748uwb; + q[35] = 1523143544545454uwb; + q[36] = 2843243245456456576876uwb; + q[37] = 542359486759867589675986576895765235uwb; + q[39] = 5498657685976587653uwb; + foo (26105549790521884176764218952781428771UWB, 12589712345465342uwb, &p, q, 97.0f); + if (p != 12589712345465342uwb) + __builtin_abort (); + q[38] -= sizeof (p) - 1; + for (int i = 0; i < 41; ++i) + if (q[i] != qe[i]) + __builtin_abort (); + return 0; +} +#else +int +main () +{ + return 0; +} +#endif --- gcc/testsuite/gcc.dg/torture/bitint-5.c.jj 2023-07-27 15:03:24.248234257 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-5.c 2023-07-27 15:03:24.248234257 +0200 @@ -0,0 +1,359 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 135 +struct S135 { unsigned _BitInt(135) c, d; } s135[2]; +unsigned _BitInt(135) v135; + +__attribute__((noipa)) void +test135 (unsigned _BitInt(135) a, unsigned _BitInt(135) *b, int i, int *j) +{ + s135[0].c = a + (b[0] - b[i + 1]) + (b[2] << 7) - (b[3] + 42); + s135[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s135[1 - i].d == 0; + j[1] = b[7] == 41066216447087484049564603714591595841626uwb; + if (b[8] != (b[9] << 25)) + b[10] = -1; + v135 = b[11] + 42953568208323086417402824216666875252142uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check135 (void) +{ + static unsigned _BitInt(135) b[] = { + 8463654185126215364154304684888703364649uwb, + 13658636853650784933344312223424772115066uwb, + 18390507727765446703890200284988625150777uwb, + 39889350586873865111357164950780819590308uwb, + 33022475220127125972541408550886872946157uwb, + 11333291582071369827887273502665555805026uwb, + 3902203683482045798302423557190uwb, + 41066216447087484049564603714591595841626uwb, + 16784965627356370497109555127280042979599uwb, + 7643716056186238617582842123439581326016uwb, + 19836147734043931654921333860970539101678uwb, + 12432610573803574406235637996243202359232uwb, + 21082105046139319624321070809125021432333uwb, + 4451745762839330307043673589610uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(135) a + = 31187320352518101815881924683645645881322uwb; + s135[1].d = 11834999377838661704814127001992153922683uwb; + test135 (a, b, 0, &j[0]); + if (s135[0].c != 31612399059450309097747051855757230322507uwb + || s135[0].d != 42086989921663500164906031508060611173292uwb + || j[0] != 0 + || j[1] != 1 + || v135 != 11830035816246537500326512461643746545006uwb + || b[10] != (unsigned _BitInt(135)) -1wb + || b[12] != 43556142961428377560472619444222657476757uwb + || b[14] != 43556142961428377560472619444222657476758uwb) + __builtin_abort (); + static unsigned _BitInt(135) c[] = { + 1551285959809994210151290388254024769929uwb, + 9215997233892929635003694907344971975862uwb, + 39194975204437258458997572112485704553492uwb, + 30855703323230132032090704189294312024903uwb, + 21369469779496743410402906224964849075932uwb, + 14841665908022079679702934181971886622844uwb, + 19630534803796254511661738870561125391241uwb, + 43019675483091641860333234580998356788381uwb, + 39970634580048249544562112517644333613056uwb, + 1191217737795360372798505798508058uwb, + 37946572714876419093215575675176896482623uwb, + 4232750244223021640360996638731476646770uwb, + 4052758609491127849063467754379555742566uwb, + 39722275064055273051470447567883559006300uwb, + 0uwb + }; + a = 24657112304265243122405775577311943535949uwb; + s135[1].d = 0; + test135 (a, c, 0, &j[0]); + if (s135[0].c != 37693225764587199559589625622735125586095uwb + || s135[0].d != 28346681648428908942498835305586873104084uwb + || j[0] != 1 + || j[1] != 0 + || v135 != 3630175486665984734451871104132020832544uwb + || c[10] != 37946572714876419093215575675176896482623uwb + || c[12] != 3833867901824850271841502183382772060067uwb + || c[14] != 3833867901824850271841502183382772060068uwb) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +struct S192 { unsigned _BitInt(192) c, d; } s192[2]; +unsigned _BitInt(192) v192; + +__attribute__((noipa)) void +test192 (unsigned _BitInt(192) a, unsigned _BitInt(192) *b, int i, int *j) +{ + s192[0].c = a + (b[0] - b[i + 1]) + (b[2] << 7) - (b[3] + 42); + s192[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s192[1 - i].d == (unsigned _BitInt(192)) -1; + j[1] = (b[7] - b[6]) == 255187001951392025884741936737034599050205342889367592965uwb; + if (b[8] != (b[9] << 25)) + b[10] = -1; + v192 = b[11] + 2163738967454769289750177070635481073128375537642482578981uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check192 (void) +{ + static unsigned _BitInt(192) b[] = { + 3228866936540682691868394180939247213045089209876303887643uwb, + 3908758529346495655434258047388434965374712986050611884354uwb, + 1851532482363341717513713701170081412289228794495066903175uwb, + 5975293786133775194483789296663647337052708600272963495919uwb, + 2820057475559560607299380550839942093606275933232105346229uwb, + 5362817792426405848910790868188776921236918437924704229050uwb, + 979877290520863780830672004560233786791511895586353138705uwb, + 1235064292472255806715413941297268385841717238475720731670uwb, + 5829209170873343132786365572649959801760991694267006189140uwb, + 3298265737098071024465207026022448799296008756143231498035uwb, + 940670103332613157768642186014034108249816638700548072517uwb, + 2237128221585286673265910175884786455449703050136766895084uwb, + 5343797638430338971087457378870861887867024738000778783665uwb, + 2529390643742992876667887597532819348219532837015437654241uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(192) a + = 2618661874473674031833709426402867675358124955059180091771uwb; + s192[1].d = 3240880288967057869631914892069482190385384187140994012855uwb; + test192 (a, b, 0, &j[0]); + if (s192[0].c != 706870028734637453615201354376795963209926828811195228347uwb + || s192[0].d != 2285738979037264170090375369163685923831632419516523901418uwb + || j[0] != 0 + || j[1] != 1 + || v192 != 4400867189040055963016087246520267528578078587779249474065uwb + || b[10] != 6277101735386680763835789423207666416102355444464034512895uwb + || b[12] != 3747711091643687887167901825674847067882822607448596858654uwb + || b[14] != 3747711091643687887167901825674847067882822607448596858655uwb) + __builtin_abort (); + static unsigned _BitInt(192) c[] = { + 5056545299578942817419004982927444283363838129353580295745uwb, + 3531417693480247808623806953213145420554761387079781845903uwb, + 344995382910742860278210827312297947555943126346350032667uwb, + 1665878021517466104406447387862080652541968946313097848513uwb, + 3702336991937894056852499403052128743722086447309795810459uwb, + 3047176269106908247893091430981158526415914935872745232818uwb, + 5837808927599143324365016946161962633699774149391236391641uwb, + 616230573526655023040079960385747061734409792273035529358uwb, + 4899745987387470009167824739532983626288828402149586108416uwb, + 146023809533937871729368708715825784989858520095038uwb, + 1818078651877174878773673167465776979421635253130676590402uwb, + 708253875247724856385503140762213862078700660051492170198uwb, + 1918646725296468312732447651696775312079697668357127231420uwb, + 3407896467949241097221562008023866460487016701943186636216uwb, + 0uwb + }; + a = 4334425031127766761089651540568319387961460796342206894467uwb; + s192[1].d = -1; + test192 (a, c, 0, &j[0]); + if (s192[0].c != 4413371480577316434238862115941009972672800653387470086858uwb + || s192[0].d != 2226914616394806622299956064802345362767073196810043931466uwb + || j[0] != 1 + || j[1] != 0 + || v192 != 2871992842702494146135680211397694935207076197693974749179uwb + || c[10] != 1818078651877174878773673167465776979421635253130676590402uwb + || c[12] != 2869205267437439666614227415183799955615338742520847876679uwb + || c[14] != 2869205267437439666614227415183799955615338742520847876680uwb) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 255 +struct S255 { unsigned _BitInt(255) c, d; } s255[2]; +unsigned _BitInt(255) v255; + +__attribute__((noipa)) void +test255 (unsigned _BitInt(255) a, unsigned _BitInt(255) *b, int i, int *j) +{ + s255[0].c = a + (b[0] - b[i + 1]) + (b[2] << 12) - (b[3] + 42); + s255[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s255[1 - i].d == 255187001951392025884741936737034599050205342889367592965uwb; + j[1] = (b[7] - b[6]) == 35079516404010817908112229771536766101092256322770268596592519563335917296247uwb; + if (b[8] != (b[9] << 42)) + b[10] = -1; + v255 = b[11] + 9589198606702369375056479928174941699714421508271337355764754830579779054882uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check255 (void) +{ + static unsigned _BitInt(255) b[] = { + 3861714047960214860503769476754636024261469188339866686856553775336008577557uwb, + 51175255900783946984470019707544472774211315503709121319713624735134204561369uwb, + 17345603833958095509660462595097262634109622426516669177449315775424443341657uwb, + 42823701374562019745772585881781652129981403461863690469883912594099541433080uwb, + 51319674321995616727877469124404951867658380853042706770000900262120757183208uwb, + 52906636245432908656398520278306560145122955700637871390327152110192649720972uwb, + 17358815113825560149028333410813032121665286465083593038209986169266901681646uwb, + 52438331517836378057140563182349798222757542787853861634802505732602818977893uwb, + 2788004462553513100609800852000190119799062917794460119684836482863393638874uwb, + 1371934028037182110859712841210549299053627214483532073119322938817156900802uwb, + 27446425677305660137811201333992510946884519570968084003836788091973600281223uwb, + 26953886320773144921523720569352939441073773759009802807981124464100414571230uwb, + 4136701104931368824349366292837727313467036617036788061778000290667287672703uwb, + 16284209316703094594160217903483772091891615489911326105642136930965810318850uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(255) a + = 43671209527014657031076032832534182807479171149570250544322965577348390656271uwb; + s255[1].d = 255187001951392025884741936737034599050205342889367592965uwb; + test255 (a, b, 0, &j[0]); + if (s255[0].c != 20576567717160318081578175912662929186060780346948500086480401311222111385641uwb + || s255[0].d != 39177534735914878791230670587295539597881897796949856541813587771063479852129uwb + || j[0] != 1 + || j[1] != 1 + || v255 != 36543084927475514296580200497527881140788195267281140163745879294680193626112uwb + || b[10] != 57896044618658097711785492504343953926634992332820282019728792003956564819967uwb + || b[12] != 41611835301955003117625274600860181834743376842908955914086655072990754501117uwb + || b[14] != 41611835301955003117625274600860181834743376842908955914086655072990754501118uwb) + __builtin_abort (); + static unsigned _BitInt(255) c[] = { + 7981769630282326956199854914771456697123750044016665635797085873395082876412uwb, + 53388853971156757275720047407967538568298021437528793620790412040317130403689uwb, + 26701828432251973964608431737798795253412436987727543352462415534788835630812uwb, + 5440780860746561756714149436754163126067503344036226572647314943619048388690uwb, + 33986332817169953208946609849689345925961381637863140695485139248791268070886uwb, + 4100939267210968649446715463008507186522717252282546996073651959494281461390uwb, + 51781097727624204498405281053756240112648760803686514440326944560679935060229uwb, + 39871871446047940023148355012724181415135167919226806605949531421611900671463uwb, + 22669501989113495379481452050938385508947296877470428714787872701608093548544uwb, + 5154447987732395490520832948036146605988346181554886405771838486uwb, + 22291959629998533921508247788279156576466986919969930954212934913917085206989uwb, + 1961549937179049997528355604457213261448618818592679790977249627688612403787uwb, + 41836060567948575115843842705609341074148894754978250388257622994608010108015uwb, + 21250627322648087754897420116830444064785267321586891615233932456372363316960uwb, + 0uwb + }; + a = 4334425031127766761089651540568319387961460796342206894467uwb; + s255[1].d = 41611835301955003117625274600860181834743376842908955914086655072990754501117uwb; + test255 (a, c, 0, &j[0]); + if (s255[0].c != 12109153275975887113226632923657866254324254170345083268415546710877474684826uwb + || s255[0].d != 55850175013735185955402882706756822737483750660992935334535260602616242125954uwb + || j[0] != 0 + || j[1] != 0 + || v255 != 11550748543881419372584835532632154961163040326864017146742004458268391458669uwb + || c[10] != 22291959629998533921508247788279156576466986919969930954212934913917085206989uwb + || c[12] != 36645417296010009956888072387513509861849725011233390404494859547584201503007uwb + || c[14] != 36645417296010009956888072387513509861849725011233390404494859547584201503008uwb) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 256 +struct S256 { unsigned _BitInt(256) c, d; } s256[2]; +unsigned _BitInt(256) v256; + +__attribute__((noipa)) void +test256 (unsigned _BitInt(256) a, unsigned _BitInt(256) *b, int i, int *j) +{ + s256[0].c = a + (b[0] - b[i + 1]) + (b[2] << 15) - (b[3] - 135wb); + s256[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s256[1 - i].d == 53206656141818470791424256353006269277597513345110510288076840335108990485400uwb; + j[1] = (b[7] - b[6]) == 100099038883167575868168369054142100716577408309486879759875338591874183239821uwb; + if (b[8] != (b[9] << 63)) + b[10] = -1; + v256 = b[11] + 105302399496355811946682562261964785380738245520086820947909580844925217183297uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check256 (void) +{ + static unsigned _BitInt(256) b[] = { + 32009310487117026679674626072407603367594653139936438287667930528262453801915uwb, + 65176902468824044453790267089157089693737812535360753024943201863160377679656uwb, + 82344070090465165315955757521075336622529332575448066816076316414765425718982uwb, + 1700965766421539490938858830624234600098958435316757520284868641071726580981uwb, + 43634292917714777985622413899887802700784049405471615230478960221105984199159uwb, + 100631692904819207373422601372327472587552135350288379476708675217470156851657uwb, + 110129860579524893207321038633598210672223454232798756477691416433717017519769uwb, + 22023582511300831410026311598353795806875331462942548421790016502461571529072uwb, + 40138510211986216232290944684699787930583492725766883760868504701674647977984uwb, + 4351825997216706075548423101456944800498099170105917024323uwb, + 169752993639582224244050634348149779190985669780902142577260914458554153598uwb, + 32145284966541819913159374355840318160537667734553997019437196071417771295134uwb, + 54664388217936175028491213294153178079954834597579823229832063212225827892844uwb, + 20191860868728322538097431032697551245493230687142770900578302601765403775815uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(256) a + = 35032284611123531672148181265368654016291603806765316452453041084857012399819uwb; + s256[1].d = 18495552704607464237917826961539803493777535452633922395016139213747075459320uwb; + test256 (a, b, 0, &j[0]); + if (s256[0].c != 63389043283546287594263459568996583234036639501854425943006627750610451754736uwb + || s256[0].d != 85940937558229637292496709413287085767649546821453763197795096316568198990162uwb + || j[0] != 0 + || j[1] != 0 + || v256 != 21655595225581436436270951609117195688005928589000253927889192908429858838495uwb + || b[10] != 169752993639582224244050634348149779190985669780902142577260914458554153598uwb + || b[12] != 95600228368587872885473553975990356607776753978497793138879281406147725864120uwb + || b[14] != 95600228368587872885473553975990356607776753978497793138879281406147725864121uwb) + __builtin_abort (); + static unsigned _BitInt(256) c[] = { + 32343204662160194495085563951007642761735079004830363200819846414562640245919uwb, + 24084137699661809462548106377371635219349193031343667516905836190779613998386uwb, + 101379688603662938586655900818791548427393428573101695287405037352360497544008uwb, + 49527008749469396581891560939525147311301744659706134394761856095820111704400uwb, + 78611633605884634807198913241948438916640856307470257529328762903676002499180uwb, + 7725329946357185150163578923822973618563365182619444740561512924522337085644uwb, + 87230734821522736453376619836617027268082314423737558813724810260551555679101uwb, + 71537684467374116897974003882071220131389738067583874534142564844512609278986uwb, + 52523168514171623670932664104908233302972408272520282168521737371661091576905uwb, + 55534995177165851478287456502449363262630885721301994816018615193922251275498uwb, + 36185028875353330724983116385242607835574307465276274632872421166901316306305uwb, + 105156498492189914423239302852802412965634513221765962480547101568217183385322uwb, + 107291868576624602610288559845636897859595852848306710447908839132037475007641uwb, + 31763533437617266501468240129359520348601211969709950732394000355828663205766uwb, + 0uwb + }; + a = 9837521119254571559208641097198297536765546083418356216057243384350911670458uwb; + s256[1].d = 53206656141818470791424256353006269277597513345110510288076840335108990485400uwb; + test256 (a, c, 0, &j[0]); + if (s256[0].c != 18957614795124660722423653645379624133127098231408367194845756641321108143966uwb + || s256[0].d != 96521194298766978603491920349693757511095007817895085416680901426339418123139uwb + || j[0] != 1 + || j[1] != 1 + || v256 != 94666808751229530946350880106079290493102774076212219388999098405229270928683uwb + || c[10] != 115792089237316195423570985008687907853269984665640564039457584007913129639935uwb + || c[12] != 84028555799698928922102744879328387504668772695930613307063583652084466434169uwb + || c[14] != 84028555799698928922102744879328387504668772695930613307063583652084466434170uwb) + __builtin_abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + check135 (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check192 (); +#endif +#if __BITINT_MAXWIDTH__ >= 255 + check255 (); +#endif +#if __BITINT_MAXWIDTH__ >= 256 + check256 (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-6.c.jj 2023-07-27 15:03:24.248234257 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-6.c 2023-07-27 15:03:24.248234257 +0200 @@ -0,0 +1,359 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 259 +struct S259 { unsigned _BitInt(259) c, d; } s259[2]; +unsigned _BitInt(259) v259; + +__attribute__((noipa)) void +test259 (unsigned _BitInt(259) a, unsigned _BitInt(259) *b, int i, int *j) +{ + s259[0].c = a + (b[0] - b[i + 1]) + (b[2] << 7) - (b[3] + 42); + s259[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s259[1 - i].d == 0; + j[1] = b[7] == 853796348253166026572322331766419194644297857346047602312235759502541501989541uwb; + if (b[8] != (b[9] << 25)) + b[10] = -1; + v259 = b[11] + 131672585462768721291717421546274215675860478844820049742378853291513419577293uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check259 (void) +{ + static unsigned _BitInt(259) b[] = { + 918480562371960593090410127982602516965623024307296422252015063457072276190019uwb, + 805591267508470730905808815897672235976825560202638463105454632689132956230159uwb, + 918331245995907029502562304060195532137531507866437159352108797919955179870191uwb, + 813875127751611422577721650805025403235043641932299023318765404699420543383496uwb, + 312693756633721376836885884755241545403854394304071110713260437525889451361210uwb, + 649538941042539125892439630557027126879421922847150643068762916100064243451309uwb, + 773306487188996490948079630445764609771546927800966605886964877358699258715670uwb, + 853796348253166026572322331766419194644297857346047602312235759502541501989541uwb, + 76083267877106286558555438489752654093377337000667150108584195505702104870323uwb, + 433731305334336103344926930540791423313226370883401849111287164916738117506640uwb, + 57656267431091314368862950118941867863238118931858464589826085330125773498121uwb, + 64173041359832501449385133817329349658818599309611908558002991010875611848746uwb, + 42346589146173514762997245981921905757283138481803437257678854533030144461674uwb, + 61227931681037412178262565289688995250776671963152062289442760797238154015232uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(259) a + = 466268672176961050215569613615746490713100259736768099838759141406021022194231uwb; + s259[1].d = 289647636390911494735348665819031670280022785262945335571175835860869121921853uwb; + test259 (a, b, 0, &j[0]); + if (s259[0].c != 593256375550214279190871305843268365974742545847394880963235621252368145099513uwb + || s259[0].d != 258470741923291377781882672832254987468877297321140017579156131137149865493929uwb + || j[0] != 0 + || j[1] != 1 + || v259 != 195845626822601222741102555363603565334679078154431958300381844302389031426039uwb + || b[10] != 926336713898529563388567880069503262826159877325124512315660672063305037119487uwb + || b[12] != 865108782217492151210305314779814267575383205361972450026217911266066883104255uwb + || b[14] != 865108782217492151210305314779814267575383205361972450026217911266066883104256uwb) + __builtin_abort (); + static unsigned _BitInt(259) c[] = { + 280836731241256517108451767043891202691471765896401168847540724952507405972497uwb, + 840411222605516639870988613734990053662001382735609723401814266406994078815101uwb, + 315675972612806440596502686972210055502484407915611896031513380334465695474313uwb, + 203899119027212320906468030526379653925169232409139699654080707114835986996999uwb, + 128451577752218373908172046011152144714641252063864956677744337179480421046978uwb, + 287567473759168733146788470777196081514207657452235204870489646221804917429977uwb, + 750296306916736952737909920532226142314659927184810908344954406682013838424980uwb, + 656663422127941740082895518453608245693505586454580487767696297787796578828932uwb, + 879879542531872983872988522489746684941859186676324312036446053929728989986816uwb, + 26222453788872748132735148742489417938645457824359068633212031541160613uwb, + 721087878418777615469711741435156333032292047533740164381818331009890349325379uwb, + 441184423645775123821015863267700095523103297061220954332335218574744406423193uwb, + 84779661426980563874304295256885870100654945451373784779121036518843563800060uwb, + 720201829457536541913713975070870089885671802608506320469648510576137739651426uwb, + 0uwb + }; + a = 18070271922856865288654809596744903817727150511379287511935119712627107404963uwb; + s259[1].d = 0; + test259 (a, c, 0, &j[0]); + if (s259[0].c != 754979172232367155652142901903016464541317666806124208079545327296101909258886uwb + || s259[0].d != 726067720449610868402876758678941562623370067217056480941991810113614143071607uwb + || j[0] != 1 + || j[1] != 0 + || v259 != 572857009108543845112733284813974311198963775906041004074714071866257826000486uwb + || c[10] != 721087878418777615469711741435156333032292047533740164381818331009890349325379uwb + || c[12] != 206134884440993021474853904998633172940488074716618191846012161487167297468061uwb + || c[14] != 206134884440993021474853904998633172940488074716618191846012161487167297468062uwb) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 508 +struct S508 { unsigned _BitInt(508) c, d; } s508[2]; +unsigned _BitInt(508) v508; + +__attribute__((noipa)) void +test508 (unsigned _BitInt(508) a, unsigned _BitInt(508) *b, int i, int *j) +{ + s508[0].c = a + (b[0] - b[i + 1]) + (b[2] << 7) - (b[3] + 42); + s508[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s508[1 - i].d == (unsigned _BitInt(508)) -1; + j[1] = (b[7] - b[6]) == 323515224000201027366899758000237142291440124580568781353226908396916757538679852963577209476426722029505026752120305126905670783187399192585916919546571uwb; + if (b[8] != (b[9] << 25)) + b[10] = -1; + v508 = b[11] + 716024231508310591151659913627069746319678908481108351681014830741662356869311236055018626572200723297424975249553920015269741669328444662913268383663677uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check508 (void) +{ + static unsigned _BitInt(508) b[] = { + 832078183434045927540487103804907011739266549356223191691643561067749769975943908404638920166502402329694585519922110244852912407804057166046933883008194uwb, + 713936147229868929139293139988718979167626862529198392930772721993480948457421027732398866594698271934473685041618760204074421885407508961194284075992372uwb, + 617361847118081522653471977724056261996473287264427111568008587684000569753190215945768169015576241392153003921766059387579429385226558246856562678192104uwb, + 558345641413420470280223467353393511714120008866888151814287282910208158712080338084981427985120538158019424401062183786473300529579273867747687575759264uwb, + 499761439373420902958682462789094939629857960756907734602342350501615831252037617149223977152737393272833291045861050465948469241674239312800301147123184uwb, + 41458778840616754230715683890502356563717287755866620113981050014317462591845066532973853075702831495501272233490672301990969026267150137016150650508199uwb, + 418458681135681746732437152058641717690726059977788598152959959313259063414620594315807075298922056786187386710006952502872115288914005302859339669672594uwb, + 178590258028275731715530947756428839232212382672258470295756987295058447444774755851491768941934611483011083453873652899758014544959831694913681677646689uwb, + 356770203054529564617317933555709062197425817471944056561734674021988369183029131819074076937899959445814817800565023050865025285444839826004948142681410uwb, + 584112461551758657888253754473884153359686350173736669541862380483308304473624923065781205318194340854082383073991675143564628127579536789385040891716043uwb, + 680157864635886168227443104616994718021643051017205364932604743260844971234200794270551054794576522886616288751944237137476474081129540389630063933035924uwb, + 624234678396543393542036481071764142163163163113602945911969155623637623734341260164471554708546709676358706745261925658188877241381613170733888758848256uwb, + 454784507207582406161930055875861559038811204428592354757758685948743133937531828752051902975778637734147167150365830445107092680154259745175825282331123uwb, + 319986047127156205965562926466827182744423938150941443628321307635789163001042001590072115090024768392582441327268266695557745771318045725281606272507745uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(508) a + = 711291826680524221552366807721297346517830107349701196208230744872277012932938686554048942571552181657477920414828724120656294188547596916447951866844703uwb; + s508[1].d = 44300483028507681832691655975564116229472905643882332053402780694878295874197390896801387042830042144560060996721375070892413197614373985836807183707843uwb; + test508 (a, b, 0, &j[0]); + if (s508[0].c != 522533064172957689320353588403947403982656359176197029733990042723046927465640381488621700421437034411326731632519943219324383970178228415895248995946467uwb + || s508[0].d != 544171514892154666305054228710247267670694798806087644332682606744854247388929324492327007054644882499782210854566003344906189740262758953265414281741613uwb + || j[0] != 0 + || j[1] != 0 + || v508 != 502270914283441665970319832310968505515381707807686711485261396132689728724055810169373037645315968743156690858160467495099001234963397211995054079631677uwb + || b[10] != 837987995621412318723376562387865382967460363787024586107722590232610251879596686050117143635431464230626991136655378178359617675746660621652103062880255uwb + || b[12] != 518001948494256112757813635921038200223036425636083142479401282596821088878554684460045028545406695838044549809387111482801871904428614896370496790372510uwb + || b[14] != 518001948494256112757813635921038200223036425636083142479401282596821088878554684460045028545406695838044549809387111482801871904428614896370496790372511uwb) + __builtin_abort (); + static unsigned _BitInt(508) c[] = { + 647557698892184285650475800644782894130830134743039316064874048572238802447391019320461822795528468837172509913850428906715002084926186679743636685547834uwb, + 19893833808289543304534784415999074892775857443659529983103990809804459295154825463722400943836101951812379338522524133647269361956787413321377320775949uwb, + 167225090603369392131840179341189845624248307670461180275627141145612180756017010718187841360639781066493394970424816391919242343853725482848930838565833uwb, + 425038857255644658246682026149139094877872271690333163307937973752297810646903055053327010856106694556745086838630642887918900506053243909959679540607590uwb, + 710399860501404196180909731021634278197730505954614106387836731661196474327340462005364906935941520263965559590135721186838498741274345456365502514761552uwb, + 517100391187257228299118348633309855520848206928211390424040909382822545139910418018096605353580518981578830214711288569084195564658992133538762776045012uwb, + 337049882664509041243030742301206305462316697436525762870825130294272111721357923024083663351305745791606079615492796115999045732841532642628230422676768uwb, + 660565106664710068609930500301443447753756822017094544224052038691188869260037775987660872827732467821111106367613101242904716516028931835214147342223339uwb, + 264311519140803818482685788811186614544730978154943534367495114584051059508245461660412877555306257793689596804946554756871772168758950748494862728822784uwb, + 7877097104215735747894221210813123421213954036085114907249662714721294030792875935447599814990349346211242580561237178947680359147755823984589062uwb, + 67442667089892250469544199468501425015399920231234867688030078116216928480132993764590084699986918086331763703967003811392074730155208796825341891897256uwb, + 85129756049329066391994997807963865671611392223804816975886973237646888963379984739504507746795881579055447505908308844315081721803505794221196177586220uwb, + 707371868440287371388093572489945370955349752876981733417655198143352744491182974880452293708290631899668322081620029303621428033853319295154190475832548uwb, + 538419296440305382227520128849893548498555312954035671105518356624711212650496087782309622044337222159048223665137702366210806405686462563977378378472852uwb, + 0uwb + }; + a = 708586050532895903124837960170867540022772026063196035415656948205052808113573236752572838768221960601298200594769808975966326249462737081924621284351278uwb; + s508[1].d = -1; + test508 (a, c, 0, &j[0]); + if (s508[0].c != 528334769435707893291849283838312547132767955028634494668975752805681928519569910180983209404481539444766030992803736389428118910242578080095668810055499uwb + || s508[0].d != 626861153942807538339962839367652023698436836743736597401578432880275274177104419034373833881253982548479037772997711030061561577382993299825586823026782uwb + || j[0] != 1 + || j[1] != 1 + || v508 != 801153987557639657543654911435033611991290300704913168656901803979309245832691220794523134318996604876480422755462228859584823391131950457134464561249897uwb + || c[10] != 67442667089892250469544199468501425015399920231234867688030078116216928480132993764590084699986918086331763703967003811392074730155208796825341891897256uwb + || c[12] != 299568699181106936495856433537971834468905050832988915002204233607899039229100598267807521591094242071578767471517675812148811270060198057674724684407403uwb + || c[14] != 299568699181106936495856433537971834468905050832988915002204233607899039229100598267807521591094242071578767471517675812148811270060198057674724684407404uwb) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 512 +struct S512 { unsigned _BitInt(512) c, d; } s512[2]; +unsigned _BitInt(512) v512; + +__attribute__((noipa)) void +test512 (unsigned _BitInt(512) a, unsigned _BitInt(512) *b, int i, int *j) +{ + s512[0].c = a + (b[0] - b[i + 1]) + (b[2] << 15) - (b[3] - 259wb); + s512[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s512[1 - i].d == 4522353484324747955267125937291948655749617973066893955369024131525488299108320993071208813642361430492411037439152575330738596343613170269621629934531241uwb; + j[1] = (b[7] - b[6]) == 374577815990281408677256593783629954432691286119512435557712294960563169554809756081207157974945869359369961439855092584877150233312923919236788786326875uwb; + if (b[8] != (b[9] << 63)) + b[10] = -1; + v512 = b[11] + 105302399496355811946685122261964785380738245520086820947909580844925217183297uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check512 (void) +{ + static unsigned _BitInt(512) b[] = { + 6021199531765212801884676816470799034908236595092557744734057443805875347290483033829674243182977894869999446238486916822395301604705319217995654295432902uwb, + 2118944847509270465197760108216002226005910220953364492400962085188310835486567249208768553765555672830161371433385656186687932945648641289635143624153621uwb, + 2468011621780240906908738384251283152842243623265843874579649124218711735704146024693879862235081238297926460688162588400193067305227164327914340959869992uwb, + 7852261253584637784169919081877553866282673859198296203117153724887988256894439079095114803178078464315049063160714347766105329320309211116124084359320890uwb, + 6881429107351001058295162119545491230166185795246928525617516768009088834586165228975554760023030849264752345389888178729929909699157633918182461033495556uwb, + 7490938212743615293405934133782451317533822019734363666709765080515130781799097345699393688357934162148290248912225980297047575683793284504381422978757040uwb, + 10120569572654605122639402565568718563995238635532261987812601502126969028367382422209505735533685455107591090283702679606268593966759672963076962700307022uwb, + 6544115361584477201664859993249450245040478983518054359791236989888339451701690370158568050118785002344520392336988100105900733099550716973249399480839328uwb, + 7998211385715595185432216755958202893898483475426306631076103969688188023218591677753885970448355780373235280537235089173590925156414399326886601942858952uwb, + 1101608905235198391935063146859712526167216410759556463737474438201976460429148065105316982180322610546500122551969559689893274021338053420958788359583115uwb, + 5547339070657168956577880025794227235978722359584966491999832792960847505505357241452219444649567336517274817160074290099346053369308053580179899142505418uwb, + 1750269279776476441267578744631933548060353310561690992260040183595109596951578483669111308170823694772335056351746927981021331305166802991213646334514404uwb, + 4192336828386954798960532308463588917660266569128375313949004426859425573394438991510991296156896119249870038323974327749964728970306928745553011492449651uwb, + 1900177384209047479231940933911260783674256383613355641699143750453309311902806908717431412257630234621978137884266303399427482666060857148046946256701407uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(512) a + = 10930130497064002394702882970302938462793108526726281176439996378763909442554754292732278993783426604574021331155984114583431563021614093376741477610729300uwb; + s512[1].d = 1062548863735806614766555155689890005619504886385354582078741512313209800319722918322963204342249477855349130571262241563029708157593686639667293170464985uwb; + test512 (a, b, 0, &j[0]); + if (s512[0].c != 2887513008923639902240466565062692784517178403522406023075811881559011847285804098407629056403311082480905591628208975136041938382372340398331672243318734uwb + || s512[0].d != 972130803422634759391069517910461958937573607139260059384360471797756640789653835842301525452796103317707145350644624256211972219907968589876206212846874uwb + || j[0] != 0 + || j[1] != 0 + || v512 != 1750269279776476441267578744631933548060353310561690992260040183595109596951683786068607663982770379894597021137127666226541418126114712572058571551697701uwb + || b[10] != 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095uwb + || b[12] != 11507630545733549620342084064294585343805109436979037736024417693268454718170740068084442885909273193068053720302219747454326400145885712798386702749382688uwb + || b[14] != 11507630545733549620342084064294585343805109436979037736024417693268454718170740068084442885909273193068053720302219747454326400145885712798386702749382689uwb) + __builtin_abort (); + static unsigned _BitInt(512) c[] = { + 4310457364893777373602665157014873559135384447597675565065759273827483949324526981781306465942744538806150653124143200561193417791157963881792904451069362uwb, + 5958789020370015340565416950487013712033450466320460334048228974568661716557882588498670105211169302921483448876614084424938615986458325610065852828118306uwb, + 8284743202872517242207866690683488538720128091867223206119391935721931034359590521893173196995749495634003248491356217756384997245149844917613657244100946uwb, + 12664079984606974422077559239355618815941897900272441909795959033933251997534364342568914887960377305762259523811571861079808666818626009150755656127832627uwb, + 1277280061505669581991258509578719709995272247404983496353130395005685346463372196431685623256422418143892881140710485556437791815840558839002633040897782uwb, + 12215250731983666777320125323169237871547944066095330125912513738032966095255991063167892594205142430862706904005862880547898319287711754622854549074643186uwb, + 9251003287718566323105383813392168970560299412448652319116761599247007001244197366325250786747301353984616744521839526461090225556617577043580629233001099uwb, + 9625581103708847731782640407175798924992990698568164754674473894207570170799007122406457944722247223343986705961694619045967375789930500962817418019327974uwb, + 9625581103708847731782640407175798924992990698568164754674473894207570170799007122406457944722247223343986705961694619045967375789930495977475637258485760uwb, + 1043607594407655227216500911938969602142764645410552381359002950524059754591300096857049049719237072025508574484388968507628527351266845uwb, + 11998753448729239344000141538200052195237540636029454316657436691685826543599848607581685084378245778577663489979887014434647868686320656434403040763612551uwb, + 11434040832182557441766779829155897224389793286294752961027160601623012283276511030063398944055141766189843896068181650049692814441787333867085760205626564uwb, + 3023331158039332614691238368394682484299421409956298474635469941534054266475913779087200438226804802431840397460566948014999950457892777550113994388831586uwb, + 6643992699881938834553303739293839845351896246066261353792165016004958058241209888845214001951224186762526613611217678738912897449639764896432567428225735uwb, + 0uwb + }; + a = 8297086167455412951314345399041666622690871902388991853000149614722648899348042581378229717518281695539366926410544760114561024579207473131456671312516393uwb; + s512[1].d = 4522353484324747955267125937291948655749617973066893955369024131525488299108320993071208813642361430492411037439152575330738596343613170269621629934531241uwb; + test512 (a, c, 0, &j[0]); + if (s512[0].c != 562788706253718154365616008999801360288452754375064525508119581728036130536904720042355361715252120605188469823973820439731595153197657174657215322741897uwb + || s512[0].d != 2450664880034868237736952350867106482818480521222495256778680955285041346939852822760111651975591771880097571588399256063032055281563320405249761438168944uwb + || j[0] != 1 + || j[1] != 1 + || v512 != 11434040832182557441766779829155897224389793286294752961027160601623012283276616332462895299867088451312105860853562388295212901262735243447930685422809861uwb + || c[10] != 11998753448729239344000141538200052195237540636029454316657436691685826543599848607581685084378245778577663489979887014434647868686320656434403040763612551uwb + || c[12] != 6763815230060658265020721258912006282127469574526132023931396427716805971832337087956660296215679240927505244575268372114840985362306805050001081577858360uwb + || c[14] != 6763815230060658265020721258912006282127469574526132023931396427716805971832337087956660296215679240927505244575268372114840985362306805050001081577858361uwb) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +struct S575 { unsigned _BitInt(575) c, d; } s575[2]; +unsigned _BitInt(575) v575; + +__attribute__((noipa)) void +test575 (unsigned _BitInt(575) a, unsigned _BitInt(575) *b, int i, int *j) +{ + s575[0].c = a + (b[0] - b[i + 1]) + (b[2] << 27) - (b[3] + 4958475968475894375894357484535984375489wb); + s575[i].d = (a | (b[4] & b[5])) ^ b[6 + i]; + j[0] = s575[1 - i].d == 95573020206290249524150023772890126071219633117171019262766503336310672999410172030736216511031014256906040106668955921896748704905692143264499542165901631357858279597168868uwb; + j[1] = (b[7] - b[6]) == 27145700341365416267735847217275690336177396856349392593186862163108423829551399123342676161793491631779988040463555034191451268734796110296927769088083654195518127550378112uwb; + if (b[8] != (b[9] << 42)) + b[10] = -1; + v575 = b[11] + 23747340451678047735163360653763407761482933548732248545666538557842792154643066748753917518601117103336304219106042161459437965550611189291922027839274834493025750978734016uwb; + b[12] = ~b[13]; + b[14] = -b[i + 13]; +} + +__attribute__((noipa)) void +check575 (void) +{ + static unsigned _BitInt(575) b[] = { + 109629911866606562961096883957886177157168492273877379264846777289230149818443125999912223814388744273336157512735477622882702153104102811897060843654669684146016128756706531uwb, + 49737336835254330810961852329841465152166265671267895624334663745208596732097722057750738167775257956975985814734408710423060394871412870929476144910662495171305515147160358uwb, + 38554548935224072640061799348846572892670189944581591586656577942689453406789240916780049368436228529892778822796853383245767382205374048871923124561885190260824233296311215uwb, + 71058269942432013527315378010985114704370555413208353814319452373530227298981545120481154232525349782777377989106743248998743352091363716737509221664926215529843633715687782uwb, + 4160385932463020068352363207252688161266437324266506898550050263305674040252431030407032416831730109735167157770872898962184845623991414528191955840335425228637597057146575uwb, + 92940635878626680004989100258386964603204572877596438304889779253809889656868292370355114313083957669380421733891295145627252962536732023763637134129797695217583987460880286uwb, + 2497863814760324764248624507199774997376419692946013954829621482125467045874636227196983588067358574709667157879971660264026959433911373287725284674927778585806087674600393uwb, + 39669551656169181196901167730139627329430801053972757381518801156276770602506281629333177027704798069522455806177708556852756692341281267078419473323939938196300261349249844uwb, + 34099204187046170921511393567690620643856679870121903412545567510502014273081623781684214852562822343760228918685024070983005024483424026237793838354204070380961780255948800uwb, + 7753261385697935775513404580053843493227914193567335908607121271075360317145537870074853083807016069786238612933862912310133884712609875859423900318280191272825uwb, + 110004311053786619259986678143505471501869971439303158252331533020072292936027495587470733973742054917424528022233289606593259788774806137554470308009293095009499747765639537uwb, + 96833004631961538015767463838833105015474376492192681907732908245833058438294860656404685183010591497179132293246891860908865398765545161691520277203799562157174917228796219uwb, + 80702609348091643417538298383109408004428354134511559457823339372643632518010615100071083122949651809745536686693833088575054309697466950053942939485340693253073606951812769uwb, + 33407553983903825388268227905051448847634610694178184538233348977258089995501154824364933504268463263804419263252997491873433785923300213087774501277469095977333397324099995uwb, + 0uwb + }; + int j[2]; + unsigned _BitInt(575) a + = 37458390908651944486318701298774946253221298284079678879752196062749754015767054813622389341442171327838532365078549465402085621913002861059272532398763941224574356382919877uwb; + s575[1].d = 95573020206290249524150023772890126071219633117171019262766503336310672999410172030736216511031014256906040106668955921896748704905692143264499542165901631357858279597168868uwb; + test575 (a, b, 0, &j[0]); + if (s575[0].c != 71835056112914750846225746791835613082740285561642802348494468629675719606761159266011893596664019145187589550627068973430325671456228503438760044269704956730966806603380315uwb + || s575[0].d != 35092678436051398145450456092160957085574382283207240091541444540207322324444176804583959098631686867119531362746451350477963519431922701372937009164511004298364112449348870uwb + || j[0] != 1 + || j[1] != 0 + || v575 != 120580345083639585750930824492596512776957310040924930453399446803675850592937927405158602701611708600515436512352934022368303364316156350983442305043074396650200668207530235uwb + || b[10] != 110004311053786619259986678143505471501869971439303158252331533020072292936027495587470733973742054917424528022233289606593259788774806137554470308009293095009499747765639537uwb + || b[12] != 90257646752648441641983032604772146169931063856427735418798179069190522557764778760793267026353059230994416449755072177802248731230075391895998576273477487980969988750249572uwb + || b[14] != 90257646752648441641983032604772146169931063856427735418798179069190522557764778760793267026353059230994416449755072177802248731230075391895998576273477487980969988750249573uwb) + __builtin_abort (); + static unsigned _BitInt(575) c[] = { + 82504361427244542991820094956691549960754114745978822099335511938351682595536290531725259255179129363075052806202441257721202109466202003805606931995490008444343669600699853uwb, + 42079105016133747306704896727331693360594255070597992997150557389990664988368628699356162986776491822580146238976269442994821141806156379826188754250358560351182286381406736uwb, + 711769802844526498820507696850878181897548931161560217731770512934668229904523420294613194965001881326982097300327085293326593185529346399uwb, + 89175170277971754813127791070754356690231836881294855904530631438372575707050409381165002268066908066508189405070930638781220028058233443902931422213686026604811589591935872uwb, + 94050888747959189678836802993335292608994888939368012114118213842817585341848237784852826131167319219605431056321492019432538459246136124892413917192336008119041481208682712uwb, + 38239296209217737134837463059250986563276353222124626638871007389306434648840299613965667293607942327919361664341059433984563767109851991087195673676603874741464175459967356uwb, + 97333559006669714102408081289832637446384482871277430301688457830360630424953635234987417481437096537137502568526675247478692954009451991021793982942577536513823999917011895uwb, + 814058611482863339892667997284732764996205177020902937843791947020441701239100773171893112609065674118654895982160611994461705590872496334948674479714606751038741393040439uwb, + 97705579217072075210280690501837541720113857756901619907589735305607760170945080008347962500870233338612695073361639697585534957702253004388475713115759324045158713339246602uwb, + 10982982241715500518624383020617613623499620192753751475894180095116406586056643710374985626416110420394932716762424522515613555006307631143920933236927136144852926571503121uwb, + 55829504657908340201404797796793782979617205764045686020250304202907511578861596703885712251150659580577184194460916884943183841026041393794213790496185940144912189048827888uwb, + 100875306823715847300644682553337559470837966294108010157772959400031914000172409603541204719305055682465391367527242389796209306256295618004852296452270010541263847504922010uwb, + 15279010635266215057483690428202871735658936908535846754770399078825578981747757698046709583412828936255448971025234637952103022364332558473695317217263761931457640744952794uwb, + 48444770867335255303325633099437372188650970089231857000193390748362558989590160188759337817835818168773038925935268431818011879469195339807606486208276196817195956747180163uwb, + 0uwb + }; + a = 8297086167455412951314345399041666622690871902388991853000149614722648899348042581378229717518281695539366926410544760114561024579207473131456671312516393uwb; + s575[1].d = 4522353484324747955267125937291948655749617973066893955369024131525488299108320993071208813642361430492411037439152575330738596343613170269621629934531241uwb; + test575 (a, c, 0, &j[0]); + if (s575[0].c != 74915286869691307910535753931416633675608326651216782655214347437885792615716349010228495093791076801730572987413666208183802410598889783023687426699732483562656666028609189uwb + || s575[0].d != 67322626164534684432128142510263628633851970452429406664125475042690110884386765927066456699852665904022478919125681907729713202628765997176929559711053556150174518973540046uwb + || j[0] != 0 + || j[1] != 1 + || v575 != 957446538841628005556782697277372214755225292234338746407969911426093601549542767136921707284650291002859873625214881579964754653531202313001246740598261075986212409306458uwb + || c[10] != 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb + || c[12] != 75220429869217011726925627410386222828914704461374062956838137298086053563675773396398862712785704326025796787072801237857670637684180265176166591342670387141107429327169404uwb + || c[14] != 75220429869217011726925627410386222828914704461374062956838137298086053563675773396398862712785704326025796787072801237857670637684180265176166591342670387141107429327169405uwb) + __builtin_abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 259 + check259 (); +#endif +#if __BITINT_MAXWIDTH__ >= 508 + check508 (); +#endif +#if __BITINT_MAXWIDTH__ >= 512 + check512 (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check575 (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-7.c.jj 2023-07-27 15:03:24.249234243 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-7.c 2023-07-27 15:03:24.249234243 +0200 @@ -0,0 +1,386 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) void +test135 (unsigned _BitInt(135) *p, unsigned _BitInt(135) *q, + int n1, int n2, int n3, int n4) +{ + p[0] = q[0] << n1; + p[1] = q[1] >> n1; + p[2] = ((_BitInt(135)) q[2]) >> n1; + p[3] = ((_BitInt(135)) q[3]) >> n1; + p[4] = q[0] << n2; + p[5] = q[1] >> n2; + p[6] = ((_BitInt(135)) q[2]) >> n2; + p[7] = ((_BitInt(135)) q[3]) >> n2; + p[8] = q[0] << n3; + p[9] = q[1] >> n3; + p[10] = ((_BitInt(135)) q[2]) >> n3; + p[11] = ((_BitInt(135)) q[3]) >> n3; + p[12] = q[0] << n4; + p[13] = q[1] >> n4; + p[14] = ((_BitInt(135)) q[2]) >> n4; + p[15] = ((_BitInt(135)) q[3]) >> n4; + p[16] = q[0] << 42; + p[17] = q[1] >> 42; + p[18] = ((_BitInt(135)) q[2]) >> 42; + p[19] = ((_BitInt(135)) q[3]) >> 42; + p[20] = q[0] << 64; + p[21] = q[1] >> 64; + p[22] = ((_BitInt(135)) q[2]) >> 64; + p[23] = ((_BitInt(135)) q[3]) >> 64; + p[24] = q[0] << 128; + p[25] = q[1] >> 128; + p[26] = ((_BitInt(135)) q[2]) >> 128; + p[27] = ((_BitInt(135)) q[3]) >> 128; + p[28] = q[0] << 134; + p[29] = q[1] >> 134; + p[30] = ((_BitInt(135)) q[2]) >> 134; + p[31] = ((_BitInt(135)) q[3]) >> 134; + p[32] = 42476074745096429931122498134186165182882uwb << n1; + p[33] = ((unsigned _BitInt(135)) 7182038401320930422841151460488443466941uwb) >> n1; + p[34] = ((_BitInt(135)) 19085908020200472220560502294394961233399uwb) >> n1; + p[35] = ((_BitInt(135)) 22116103719729384017971523177401136866663uwb) >> n1; + p[36] = 42476074745096429931122498134186165182882uwb << n2; + p[37] = ((unsigned _BitInt(135)) 7182038401320930422841151460488443466941uwb) >> n2; + p[38] = ((_BitInt(135)) 19085908020200472220560502294394961233399uwb) >> n2; + p[39] = ((_BitInt(135)) 22116103719729384017971523177401136866663uwb) >> n2; + p[40] = 42476074745096429931122498134186165182882uwb << n3; + p[41] = ((unsigned _BitInt(135)) 7182038401320930422841151460488443466941uwb) >> n3; + p[42] = ((_BitInt(135)) 19085908020200472220560502294394961233399uwb) >> n3; + p[43] = ((_BitInt(135)) 22116103719729384017971523177401136866663uwb) >> n3; + p[44] = 42476074745096429931122498134186165182882uwb << n4; + p[45] = ((unsigned _BitInt(135)) 7182038401320930422841151460488443466941uwb) >> n4; + p[46] = ((_BitInt(135)) 19085908020200472220560502294394961233399uwb) >> n4; + p[47] = ((_BitInt(135)) 22116103719729384017971523177401136866663uwb) >> n4; +} + +__attribute__((noipa)) void +check135 (void) +{ + static unsigned _BitInt(135) q[] = { + 42476074745096429931122498134186165182882uwb, + 7182038401320930422841151460488443466941uwb, + 19085908020200472220560502294394961233399uwb, + 22116103719729384017971523177401136866663uwb + }; + static unsigned _BitInt(135) e[] = { + 42476074745096429931122498134186165182882uwb, + 7182038401320930422841151460488443466941uwb, + 19085908020200472220560502294394961233399uwb, + 22116103719729384017971523177401136866663uwb, + 20575191318237441766935416597984462241792uwb, + 1633006468482774476533711881uwb, + 4339633055724441924339885712uwb, + 43556142965875248422786905315316132038280uwb, + 37177976900770126499921313117382843039744uwb, + 389339081879323596127uwb, + 1034649146967993241391uwb, + 43556142965880123322149682894823775650690uwb, + 0uwb, + 0uwb, + 0uwb, + 43556142965880123323311949751266331066367uwb, + 20575191318237441766935416597984462241792uwb, + 1633006468482774476533711881uwb, + 4339633055724441924339885712uwb, + 43556142965875248422786905315316132038280uwb, + 37177976900770126499921313117382843039744uwb, + 389339081879323596127uwb, + 1034649146967993241391uwb, + 43556142965880123322149682894823775650690uwb, + 11569600475311907757754736652680119189504uwb, + 21uwb, + 56uwb, + 43556142965880123323311949751266331066304uwb, + 0uwb, + 0uwb, + 0uwb, + 43556142965880123323311949751266331066367uwb, + 42476074745096429931122498134186165182882uwb, + 7182038401320930422841151460488443466941uwb, + 19085908020200472220560502294394961233399uwb, + 22116103719729384017971523177401136866663uwb, + 20575191318237441766935416597984462241792uwb, + 1633006468482774476533711881uwb, + 4339633055724441924339885712uwb, + 43556142965875248422786905315316132038280uwb, + 37177976900770126499921313117382843039744uwb, + 389339081879323596127uwb, + 1034649146967993241391uwb, + 43556142965880123322149682894823775650690uwb, + 0uwb, + 0uwb, + 0uwb, + 43556142965880123323311949751266331066367uwb + }; + unsigned _BitInt(135) p[48]; + test135 (p, q, 0, 42, 64, 134); + for (int i = 0; i < 48; ++i) + if (p[i] != e[i]) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 512 +__attribute__((noipa)) void +test512 (unsigned _BitInt(512) *p, unsigned _BitInt(512) *q, + int n1, int n2, int n3, int n4) +{ + p[0] = q[0] << n1; + p[1] = q[1] >> n1; + p[2] = ((_BitInt(512)) q[2]) >> n1; + p[3] = ((_BitInt(512)) q[3]) >> n1; + p[4] = q[0] << n2; + p[5] = q[1] >> n2; + p[6] = ((_BitInt(512)) q[2]) >> n2; + p[7] = ((_BitInt(512)) q[3]) >> n2; + p[8] = q[0] << n3; + p[9] = q[1] >> n3; + p[10] = ((_BitInt(512)) q[2]) >> n3; + p[11] = ((_BitInt(512)) q[3]) >> n3; + p[12] = q[0] << n4; + p[13] = q[1] >> n4; + p[14] = ((_BitInt(512)) q[2]) >> n4; + p[15] = ((_BitInt(512)) q[3]) >> n4; + p[16] = q[0] << 42; + p[17] = q[1] >> 42; + p[18] = ((_BitInt(512)) q[2]) >> 42; + p[19] = ((_BitInt(512)) q[3]) >> 42; + p[20] = q[0] << 128; + p[21] = q[1] >> 128; + p[22] = ((_BitInt(512)) q[2]) >> 128; + p[23] = ((_BitInt(512)) q[3]) >> 128; + p[24] = q[0] << 448; + p[25] = q[1] >> 448; + p[26] = ((_BitInt(512)) q[2]) >> 448; + p[27] = ((_BitInt(512)) q[3]) >> 448; + p[28] = q[0] << 508; + p[29] = q[1] >> 508; + p[30] = ((_BitInt(512)) q[2]) >> 508; + p[31] = ((_BitInt(512)) q[3]) >> 508; + p[32] = 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb << n1; + p[33] = ((unsigned _BitInt(512)) 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb) >> n1; + p[34] = ((_BitInt(512)) 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb) >> n1; + p[35] = ((_BitInt(512)) 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb) >> n1; + p[36] = 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb << n2; + p[37] = ((unsigned _BitInt(512)) 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb) >> n2; + p[38] = ((_BitInt(512)) 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb) >> n2; + p[39] = ((_BitInt(512)) 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb) >> n2; + p[40] = 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb << n3; + p[41] = ((unsigned _BitInt(512)) 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb) >> n3; + p[42] = ((_BitInt(512)) 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb) >> n3; + p[43] = ((_BitInt(512)) 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb) >> n3; + p[44] = 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb << n4; + p[45] = ((unsigned _BitInt(512)) 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb) >> n4; + p[46] = ((_BitInt(512)) 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb) >> n4; + p[47] = ((_BitInt(512)) 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb) >> n4; +} + +__attribute__((noipa)) void +check512 (void) +{ + static unsigned _BitInt(512) q[] = { + 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb, + 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb, + 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb, + 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb + }; + static unsigned _BitInt(512) e[] = { + 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb, + 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb, + 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb, + 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb, + 10218316460994285180012649605314270523237657334799736878274366250937214257494608460860805097020820895335285270507764849854590883398363325859206256763338752uwb, + 2496685507255794194454446853132278798878918827021882395199712741806282457113788753934482872466652415380931962020389152658035575413780272415995uwb, + 13407807929942476349503027617752125851028760573258773505654590291089987162470240268148950606329516537581906483867747705640627526941493352884606809182595733uwb, + 969085030254540147052327290987383773044464127243093048207926179679468140554897112278845487588172918559506186738354258875941458688582335528613uwb, + 4525270648672298630142654159362692277322833548500556080109956060745476990024701673931929946646742265188085348185747949082408104800714710883682097140072448uwb, + 32268903863189288488713934263516911045475287395472229484457927100461194379105000512730600516708300749874729300692099uwb, + 13407807929942597099574024998205846127477805162503433459831226837705045157447168014945448530707208458194409230122434920121875298152320690554956588365115043uwb, + 12525130452217498057057362011967217536814658172404918356180491125021477447649640662315333513294816018260736989782778uwb, + 837987995621412318723376562387865382967460363787024586107722590232610251879596686050117143635431464230626991136655378178359617675746660621652103062880256uwb, + 13uwb, + 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095uwb, + 5uwb, + 10218316460994285180012649605314270523237657334799736878274366250937214257494608460860805097020820895335285270507764849854590883398363325859206256763338752uwb, + 2496685507255794194454446853132278798878918827021882395199712741806282457113788753934482872466652415380931962020389152658035575413780272415995uwb, + 13407807929942476349503027617752125851028760573258773505654590291089987162470240268148950606329516537581906483867747705640627526941493352884606809182595733uwb, + 969085030254540147052327290987383773044464127243093048207926179679468140554897112278845487588172918559506186738354258875941458688582335528613uwb, + 4525270648672298630142654159362692277322833548500556080109956060745476990024701673931929946646742265188085348185747949082408104800714710883682097140072448uwb, + 32268903863189288488713934263516911045475287395472229484457927100461194379105000512730600516708300749874729300692099uwb, + 13407807929942597099574024998205846127477805162503433459831226837705045157447168014945448530707208458194409230122434920121875298152320690554956588365115043uwb, + 12525130452217498057057362011967217536814658172404918356180491125021477447649640662315333513294816018260736989782778uwb, + 2707788752018291762501261467556359376968672839961555769866726160891698235759394800413405351174494371110296852192103378240576483613979086982233831308787712uwb, + 15107256420812902421uwb, + 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569215784041721807999uwb, + 5863860707758186186uwb, + 837987995621412318723376562387865382967460363787024586107722590232610251879596686050117143635431464230626991136655378178359617675746660621652103062880256uwb, + 13uwb, + 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095uwb, + 5uwb, + 9097527363082920087640486649000739646642554439676331761072078127377091353030522027251795224024156478638697322090297961146123620822988442336252791731131761uwb, + 10980538984510266134209038127076610665614456653719209946870695541404134523537659134772423950250404838052362402691773947760040210438889408262830474547160577uwb, + 12876743501477007697566238617479065502697488744690997490715841276784967745445096442239218949897451583348811842533777310497473584791607823667593623282470690uwb, + 4262081036274094578799387151850586986318909215082769698752506214098468276589787535239660955472257640044493313997722061552113957148668088011463028119497203uwb, + 10218316460994285180012649605314270523237657334799736878274366250937214257494608460860805097020820895335285270507764849854590883398363325859206256763338752uwb, + 2496685507255794194454446853132278798878918827021882395199712741806282457113788753934482872466652415380931962020389152658035575413780272415995uwb, + 13407807929942476349503027617752125851028760573258773505654590291089987162470240268148950606329516537581906483867747705640627526941493352884606809182595733uwb, + 969085030254540147052327290987383773044464127243093048207926179679468140554897112278845487588172918559506186738354258875941458688582335528613uwb, + 4525270648672298630142654159362692277322833548500556080109956060745476990024701673931929946646742265188085348185747949082408104800714710883682097140072448uwb, + 32268903863189288488713934263516911045475287395472229484457927100461194379105000512730600516708300749874729300692099uwb, + 13407807929942597099574024998205846127477805162503433459831226837705045157447168014945448530707208458194409230122434920121875298152320690554956588365115043uwb, + 12525130452217498057057362011967217536814658172404918356180491125021477447649640662315333513294816018260736989782778uwb, + 837987995621412318723376562387865382967460363787024586107722590232610251879596686050117143635431464230626991136655378178359617675746660621652103062880256uwb, + 13uwb, + 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095uwb, + 5uwb + }; + unsigned _BitInt(512) p[48]; + test512 (p, q, 0, 42, 128, 508); + for (int i = 0; i < 48; ++i) + if (p[i] != e[i]) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test575 (unsigned _BitInt(575) *p, unsigned _BitInt(575) *q, + int n1, int n2, int n3, int n4) +{ + p[0] = q[0] << n1; + p[1] = q[1] >> n1; + p[2] = ((_BitInt(575)) q[2]) >> n1; + p[3] = ((_BitInt(575)) q[3]) >> n1; + p[4] = q[0] << n2; + p[5] = q[1] >> n2; + p[6] = ((_BitInt(575)) q[2]) >> n2; + p[7] = ((_BitInt(575)) q[3]) >> n2; + p[8] = q[0] << n3; + p[9] = q[1] >> n3; + p[10] = ((_BitInt(575)) q[2]) >> n3; + p[11] = ((_BitInt(575)) q[3]) >> n3; + p[12] = q[0] << n4; + p[13] = q[1] >> n4; + p[14] = ((_BitInt(575)) q[2]) >> n4; + p[15] = ((_BitInt(575)) q[3]) >> n4; + p[16] = q[0] << 42; + p[17] = q[1] >> 42; + p[18] = ((_BitInt(575)) q[2]) >> 42; + p[19] = ((_BitInt(575)) q[3]) >> 42; + p[20] = q[0] << 192; + p[21] = q[1] >> 192; + p[22] = ((_BitInt(575)) q[2]) >> 192; + p[23] = ((_BitInt(575)) q[3]) >> 192; + p[24] = q[0] << 512; + p[25] = q[1] >> 512; + p[26] = ((_BitInt(575)) q[2]) >> 512; + p[27] = ((_BitInt(575)) q[3]) >> 512; + p[28] = q[0] << 571; + p[29] = q[1] >> 571; + p[30] = ((_BitInt(575)) q[2]) >> 571; + p[31] = ((_BitInt(575)) q[3]) >> 571; + p[32] = 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb << n1; + p[33] = ((unsigned _BitInt(575)) 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb) >> n1; + p[34] = ((_BitInt(575)) 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb) >> n1; + p[35] = ((_BitInt(575)) 146719349625858150924070326030117352429884uwb) >> n1; + p[36] = 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb << n2; + p[37] = ((unsigned _BitInt(575)) 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb) >> n2; + p[38] = ((_BitInt(575)) 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb) >> n2; + p[39] = ((_BitInt(575)) 146719349625858150924070326030117352429884uwb) >> n2; + p[40] = 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb << n3; + p[41] = ((unsigned _BitInt(575)) 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb) >> n3; + p[42] = ((_BitInt(575)) 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb) >> n3; + p[43] = ((_BitInt(575)) 146719349625858150924070326030117352429884uwb) >> n3; + p[44] = 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb << n4; + p[45] = ((unsigned _BitInt(575)) 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb) >> n4; + p[46] = ((_BitInt(575)) 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb) >> n4; + p[47] = ((_BitInt(575)) 146719349625858150924070326030117352429884uwb) >> n4; +} + +__attribute__((noipa)) void +check575 (void) +{ + static unsigned _BitInt(575) q[] = { + 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb, + 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb, + 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb, + 146719349625858150924070326030117352429884uwb + }; + static unsigned _BitInt(575) e[] = { + 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb, + 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb, + 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb, + 146719349625858150924070326030117352429884uwb, + 101455192616810418556035937342706675871010989953664553100414183440061081538258837413103429652228409332846843840874129218733451063018756151973814520650589185972971648957022208uwb, + 9426705271486518506775721962796496212479581187376392961820308506521488593386399890224411040421708368266404866319586947893875853523246846167443285623443607687449uwb, + 123665200736549141698114476634013378335753822194910362276561280288452288465223455053720457123832123393578819366656336301874379580455931868022178318582504526998711692029382704uwb, + 33360117783071962304363825303uwb, + 119335782055317388350429004017843053262176261916736710874511715722133065797591485333905865472877802228449910525321848531626543800663717410928997924003288981168896718112030720uwb, + 6604813810288358087498962398528278947817002383742106838987637054195488521780512729133747937326520831885279330684711uwb, + 123665200736552267030251260509823595017565674550605919957029338284886722431114354919535001603397736344270114443080692270543186446588141616503700255078449149331258830163424370uwb, + 0uwb, + 15458150092069033378781407563727949377195709318825739994628941005806076569158241698144775066327690311849854464126008708709460314644171950622971634693868322994787923259293696uwb, + 5uwb, + 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349566uwb, + 0uwb, + 101455192616810418556035937342706675871010989953664553100414183440061081538258837413103429652228409332846843840874129218733451063018756151973814520650589185972971648957022208uwb, + 9426705271486518506775721962796496212479581187376392961820308506521488593386399890224411040421708368266404866319586947893875853523246846167443285623443607687449uwb, + 123665200736549141698114476634013378335753822194910362276561280288452288465223455053720457123832123393578819366656336301874379580455931868022178318582504526998711692029382704uwb, + 33360117783071962304363825303uwb, + 119335782055317388350429004017843053262176261916736710874511715722133065797591485333905865472877802228449910525321848531626543800663717410928997924003288981168896718112030720uwb, + 6604813810288358087498962398528278947817002383742106838987637054195488521780512729133747937326520831885279330684711uwb, + 123665200736552267030251260509823595017565674550605919957029338284886722431114354919535001603397736344270114443080692270543186446588141616503700255078449149331258830163424370uwb, + 0uwb, + 71526316958236649113771106427618495658375006450241431334816139660708009688265701502532725246129480508017794237793207540593595178136921012216679830157648896249487052159057920uwb, + 3092160064277148905uwb, + 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946582933127893402865396uwb, + 0uwb, + 15458150092069033378781407563727949377195709318825739994628941005806076569158241698144775066327690311849854464126008708709460314644171950622971634693868322994787923259293696uwb, + 5uwb, + 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349566uwb, + 0uwb, + 113324867609914841703175642134276622099380829892372739396576941405077427208321982380320777205398087845718962965838410365091485839739660235868692128339145588495862488649829794uwb, + 41459088230466967850496491762687877054451372305979858752985908904079765739347588525764439571939913205917422711129986893243036538436025937944895336127976720299879937518567087uwb, + 109919844636328732719844961828946648695154594766841929826820254974351382414676962372262457317295280532708618631627677422093887137875656283935370428037454681114775307971502401uwb, + 146719349625858150924070326030117352429884uwb, + 101455192616810418556035937342706675871010989953664553100414183440061081538258837413103429652228409332846843840874129218733451063018756151973814520650589185972971648957022208uwb, + 9426705271486518506775721962796496212479581187376392961820308506521488593386399890224411040421708368266404866319586947893875853523246846167443285623443607687449uwb, + 123665200736549141698114476634013378335753822194910362276561280288452288465223455053720457123832123393578819366656336301874379580455931868022178318582504526998711692029382704uwb, + 33360117783071962304363825303uwb, + 119335782055317388350429004017843053262176261916736710874511715722133065797591485333905865472877802228449910525321848531626543800663717410928997924003288981168896718112030720uwb, + 6604813810288358087498962398528278947817002383742106838987637054195488521780512729133747937326520831885279330684711uwb, + 123665200736552267030251260509823595017565674550605919957029338284886722431114354919535001603397736344270114443080692270543186446588141616503700255078449149331258830163424370uwb, + 0uwb, + 15458150092069033378781407563727949377195709318825739994628941005806076569158241698144775066327690311849854464126008708709460314644171950622971634693868322994787923259293696uwb, + 5uwb, + 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349566uwb, + 0uwb + }; + unsigned _BitInt(575) p[48]; + test575 (p, q, 0, 42, 192, 571); + for (int i = 0; i < 48; ++i) + if (p[i] != e[i]) + __builtin_abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + check135 (); +#endif +#if __BITINT_MAXWIDTH__ >= 512 + check512 (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check575 (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-8.c.jj 2023-07-27 15:03:24.249234243 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-8.c 2023-07-27 15:03:24.249234243 +0200 @@ -0,0 +1,391 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +__attribute__((noipa)) void +foo (int *p) +{ + *p = 1; +} + +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) void +test135 (unsigned _BitInt(135) *p, _BitInt(135) *q, int *r, int i, int j, int k) +{ + int l; + for (l = 0; l < 15; ++l) + { + r[l * 4] = p[l * 2] < p[l * 2 + 1]; + r[l * 4 + 1] = p[l * 2 + i] <= p[l * 2 + 1 + i]; + r[l * 4 + 2] = p[l * 2 + j] > p[l * 2 + 1 + j]; + r[l * 4 + 3] = p[l * 2 + k] >= p[l * 2 + 1 + k]; + } + r[60] = 0; + if (p[30] < p[31]) + foo (r + 60); + r[61] = 0; + if (p[30 + i] <= p[31 + i]) + foo (r + 61); + r[62] = 0; + if (p[30 + j] > p[31 + j]) + foo (r + 62); + r[63] = 0; + if (p[30 + k] >= p[31 + k]) + foo (r + 63); + for (l = 0; l < 15; ++l) + { + r[64 + l * 4] = q[l * 2] < q[l * 2 + 1]; + r[64 + l * 4 + 1] = q[l * 2 + i] <= q[l * 2 + 1 + i]; + r[64 + l * 4 + 2] = q[l * 2 + j] > q[l * 2 + 1 + j]; + r[64 + l * 4 + 3] = q[l * 2 + k] >= q[l * 2 + 1 + k]; + } + r[124] = 0; + if (q[30] < q[31]) + foo (r + 124); + r[125] = 0; + if (q[30 + i] <= q[31 + i]) + foo (r + 125); + r[126] = 0; + if (q[30 + j] > q[31 + j]) + foo (r + 126); + r[127] = 0; + if (q[30 + k] >= q[31 + k]) + foo (r + 127); + r[128] = p[1] > 6186175750610900443940276860313653051587uwb; + r[129] = p[1 + i] >= 6186175750610900443940276860313653051587uwb; + r[130] = p[1 + j] < 6186175750610900443940276860313653051587uwb; + r[131] = p[1 + k] <= 6186175750610900443940276860313653051587uwb; + r[132] = p[9] > 532538687817519087313655352171198726194uwb; + r[133] = p[9 + i] >= 532538687817519087313655352171198726194uwb; + r[134] = p[9 + j] < 532538687817519087313655352171198726194uwb; + r[135] = p[9 + k] <= 532538687817519087313655352171198726194uwb; + r[136] = p[26] > 21437789116019123198192600268201397321728uwb; + r[137] = p[26 + i] >= 21437789116019123198192600268201397321728uwb; + r[138] = p[26 + j] < 21437789116019123198192600268201397321728uwb; + r[139] = p[26 + k] <= 21437789116019123198192600268201397321728uwb; + r[140] = 0; + if (p[27] > 21437789116019123198192600268201397321728uwb) + foo (r + 140); + r[141] = 0; + if (p[27 + i] >= 21437789116019123198192600268201397321728uwb) + foo (r + 141); + r[142] = 0; + if (p[27 + j] < 21437789116019123198192600268201397321728uwb) + foo (r + 142); + r[143] = 0; + if (p[27 + k] <= 21437789116019123198192600268201397321728uwb) + foo (r + 143); + r[144] = q[1] > -16254965323536794558278256870539623121621wb; + r[145] = q[1 + i] >= -16254965323536794558278256870539623121621wb; + r[146] = q[1 + j] < -16254965323536794558278256870539623121621wb; + r[147] = q[1 + k] <= -16254965323536794558278256870539623121621wb; + r[148] = q[9] > 18613347261447279579326452222842126033978wb; + r[149] = q[9 + i] >= 18613347261447279579326452222842126033978wb; + r[150] = q[9 + j] < 18613347261447279579326452222842126033978wb; + r[151] = q[9 + k] <= 18613347261447279579326452222842126033978wb; + r[152] = q[26] > -17354400712967861636632104979020178784256wb; + r[153] = q[26 + i] >= -17354400712967861636632104979020178784256wb; + r[154] = q[26 + j] < -17354400712967861636632104979020178784256wb; + r[155] = q[26 + k] <= -17354400712967861636632104979020178784256wb; + r[156] = 0; + if (q[27] > -17354400712967861636632104979020178784256wb) + foo (r + 156); + r[157] = 0; + if (q[27 + i] >= -17354400712967861636632104979020178784256wb) + foo (r + 157); + r[158] = 0; + if (q[27 + j] < -17354400712967861636632104979020178784256wb) + foo (r + 158); + r[159] = 0; + if (q[27 + k] <= -17354400712967861636632104979020178784256wb) + foo (r + 159); +} + +__attribute__((noipa)) void +check135 (void) +{ + static unsigned _BitInt(135) p[] = { + 6186175750610900443940276860313653051587uwb, + 1185851028480769106318384044302924011586uwb, + 2130297273067766631305678853840898568773uwb, + 41295820948916414032635520696820459346946uwb, + 37051876633129642187163899121207069631425uwb, + 15692033609114144435279308788278869814829uwb, + 34806164389591686493621017551199759953285uwb, + 39807523118275305743074861168614282970261uwb, + 532538687817519087313655352171198726194uwb, + 532538687817519087313655352171198726194uwb - 1, + 24327491730922412594497820631861542598095uwb, + 24327491730922412594497820631861542598095uwb + 1, + 19767147107472646435672732641055578521600uwb, + 19767147107472646435672732641055578521600uwb - 18446744073709551616uwb, + 19767147107472646435672732641055578521600uwb, + 19767147107472646435672732641055578521600uwb - 1, + 19767147107472646435672732641055578521600uwb, + 19767147107472646435672732641055578521600uwb + 1, + 19767147107472646435672732641055578521600uwb, + 19767147107472646435672732641055578521600uwb, + 21437789116019123198192600268201397321728uwb, + 21437789116019123198192600268201397321728uwb - 340282366920938463463374607431768211456uwb, + 21437789116019123198192600268201397321728uwb, + 21437789116019123198192600268201397321728uwb + 340282366920938463463374607431768211456uwb, + 21437789116019123198192600268201397321728uwb, + 21437789116019123198192600268201397321728uwb - 1, + 21437789116019123198192600268201397321728uwb, + 21437789116019123198192600268201397321728uwb + 1, + 21437789116019123198192600268201397321728uwb, + 21437789116019123198192600268201397321728uwb, + 40857776145745083896508605528597836546969uwb, + 40857776145745083896508605528597836546969uwb + }; + static _BitInt(135) q[] = { + -16254965323536794558278256870539623121621wb, + 3211106991591472362840917277276886624653wb, + -11957968557477998661714306628455379156870wb, + 573207689638265971114859293369887620578wb, + 13215265693976315010419972479490962566290wb, + -14420717597022955156949317923525514408615wb, + 9945875060497908168424655458843572357117wb, + 17414314981046040218358459297638362112560wb, + 18613347261447279579326452222842126033978wb, + 18613347261447279579326452222842126033978wb - 1, + -7726660695587525737931429184041790718605wb, + -7726660695587525737931429184041790718605wb + 1, + 10658663373399224161452650292046381187072wb, + 10658663373399224161452650292046381187072wb - 18446744073709551616wb, + 10658663373399224161452650292046381187072wb, + 10658663373399224161452650292046381187072wb - 1, + 10658663373399224161452650292046381187072wb, + 10658663373399224161452650292046381187072wb + 1, + 10658663373399224161452650292046381187072wb, + 10658663373399224161452650292046381187072wb, + -17354400712967861636632104979020178784256wb, + -17354400712967861636632104979020178784256wb - 340282366920938463463374607431768211456wb, + -17354400712967861636632104979020178784256wb, + -17354400712967861636632104979020178784256wb + 340282366920938463463374607431768211456wb, + -17354400712967861636632104979020178784256wb, + -17354400712967861636632104979020178784256wb - 1, + -17354400712967861636632104979020178784256wb, + -17354400712967861636632104979020178784256wb + 1, + -17354400712967861636632104979020178784256wb, + -17354400712967861636632104979020178784256wb, + -9715765131124575245669270443035217820180wb, + -9715765131124575245669270443035217820180wb + }; + int r[160]; + static int e[160] = { + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, + 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, + }; + test135 (p, q, r, 0, 0, 0); + for (int i = 0; i < 160; ++i) + if (r[i] != e[i]) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) void +test192 (unsigned _BitInt(192) *p, _BitInt(192) *q, int *r, int i, int j, int k) +{ + int l; + for (l = 0; l < 15; ++l) + { + r[l * 4] = p[l * 2] < p[l * 2 + 1]; + r[l * 4 + 1] = p[l * 2 + i] <= p[l * 2 + 1 + i]; + r[l * 4 + 2] = p[l * 2 + j] > p[l * 2 + 1 + j]; + r[l * 4 + 3] = p[l * 2 + k] >= p[l * 2 + 1 + k]; + } + r[60] = 0; + if (p[30] < p[31]) + foo (r + 60); + r[61] = 0; + if (p[30 + i] <= p[31 + i]) + foo (r + 61); + r[62] = 0; + if (p[30 + j] > p[31 + j]) + foo (r + 62); + r[63] = 0; + if (p[30 + k] >= p[31 + k]) + foo (r + 63); + for (l = 0; l < 15; ++l) + { + r[64 + l * 4] = q[l * 2] < q[l * 2 + 1]; + r[64 + l * 4 + 1] = q[l * 2 + i] <= q[l * 2 + 1 + i]; + r[64 + l * 4 + 2] = q[l * 2 + j] > q[l * 2 + 1 + j]; + r[64 + l * 4 + 3] = q[l * 2 + k] >= q[l * 2 + 1 + k]; + } + r[124] = 0; + if (q[30] < q[31]) + foo (r + 124); + r[125] = 0; + if (q[30 + i] <= q[31 + i]) + foo (r + 125); + r[126] = 0; + if (q[30 + j] > q[31 + j]) + foo (r + 126); + r[127] = 0; + if (q[30 + k] >= q[31 + k]) + foo (r + 127); + r[128] = p[1] > 1301676158706974885001669913388788249117177822518209770103uwb; + r[129] = p[1 + i] >= 1301676158706974885001669913388788249117177822518209770103uwb; + r[130] = p[1 + j] < 1301676158706974885001669913388788249117177822518209770103uwb; + r[131] = p[1 + k] <= 1301676158706974885001669913388788249117177822518209770103uwb; + r[132] = p[9] > 4156228030920822065505406977886113255775912982125511770811uwb; + r[133] = p[9 + i] >= 4156228030920822065505406977886113255775912982125511770811uwb; + r[134] = p[9 + j] < 4156228030920822065505406977886113255775912982125511770811uwb; + r[135] = p[9 + k] <= 4156228030920822065505406977886113255775912982125511770811uwb; + r[136] = p[26] > 2105720889788939126298431571815399749254098004540680830976uwb; + r[137] = p[26 + i] >= 2105720889788939126298431571815399749254098004540680830976uwb; + r[138] = p[26 + j] < 2105720889788939126298431571815399749254098004540680830976uwb; + r[139] = p[26 + k] <= 2105720889788939126298431571815399749254098004540680830976uwb; + r[140] = 0; + if (p[27] > 2105720889788939126298431571815399749254098004540680830976uwb) + foo (r + 140); + r[141] = 0; + if (p[27 + i] >= 2105720889788939126298431571815399749254098004540680830976uwb) + foo (r + 141); + r[142] = 0; + if (p[27 + j] < 2105720889788939126298431571815399749254098004540680830976uwb) + foo (r + 142); + r[143] = 0; + if (p[27 + k] <= 2105720889788939126298431571815399749254098004540680830976uwb) + foo (r + 143); + r[144] = q[1] > 1979551028038258779576810033088645171455206196499080052958wb; + r[145] = q[1 + i] >= 1979551028038258779576810033088645171455206196499080052958wb; + r[146] = q[1 + j] < 1979551028038258779576810033088645171455206196499080052958wb; + r[147] = q[1 + k] <= 1979551028038258779576810033088645171455206196499080052958wb; + r[148] = q[9] > -1885318755168553153865626302112859755681798781213110674779wb; + r[149] = q[9 + i] >= -1885318755168553153865626302112859755681798781213110674779wb; + r[150] = q[9 + j] < -1885318755168553153865626302112859755681798781213110674779wb; + r[151] = q[9 + k] <= -1885318755168553153865626302112859755681798781213110674779wb; + r[152] = q[26] > 2339763120586619043754378424358306157273374438118242910208wb; + r[153] = q[26 + i] >= 2339763120586619043754378424358306157273374438118242910208wb; + r[154] = q[26 + j] < 2339763120586619043754378424358306157273374438118242910208wb; + r[155] = q[26 + k] <= 2339763120586619043754378424358306157273374438118242910208wb; + r[156] = 0; + if (q[27] > 2339763120586619043754378424358306157273374438118242910208wb) + foo (r + 156); + r[157] = 0; + if (q[27 + i] >= 2339763120586619043754378424358306157273374438118242910208wb) + foo (r + 157); + r[158] = 0; + if (q[27 + j] < 2339763120586619043754378424358306157273374438118242910208wb) + foo (r + 158); + r[159] = 0; + if (q[27 + k] <= 2339763120586619043754378424358306157273374438118242910208wb) + foo (r + 159); +} + +__attribute__((noipa)) void +check192 (void) +{ + static unsigned _BitInt(192) p[] = { + 1301676158706974885001669913388788249117177822518209770103uwb, + 747337726037626556190542632789198678519387021556252140610uwb, + 3725653947307680330137362665700857624320118783723331730354uwb, + 5392755653771808504964234887707929379898418126658160517063uwb, + 909108582379360036592925704487999488985548889672948755121uwb, + 1640061693011887757120264107651184372780544025461004778485uwb, + 1730451763775632602140993282640477950273220311662029360199uwb, + 5445606583665251502205919499903327925600190799372595230746uwb, + 4156228030920822065505406977886113255775912982125511770811uwb, + 4156228030920822065505406977886113255775912982125511770811uwb - 1, + 4265142937033285044176150866007262334836422938393615775285uwb, + 4265142937033285044176150866007262334836422938393615775285uwb + 1, + 5906690378849769161966354556531052466604912051358709841920uwb, + 5906690378849769161966354556531052466604912051358709841920uwb - 18446744073709551616uwb, + 5906690378849769161966354556531052466604912051358709841920uwb, + 5906690378849769161966354556531052466604912051358709841920uwb - 1, + 5906690378849769161966354556531052466604912051358709841920uwb, + 5906690378849769161966354556531052466604912051358709841920uwb + 1, + 5906690378849769161966354556531052466604912051358709841920uwb, + 5906690378849769161966354556531052466604912051358709841920uwb, + 2105720889788939126298431571815399749254098004540680830976uwb, + 2105720889788939126298431571815399749254098004540680830976uwb - 340282366920938463463374607431768211456uwb, + 2105720889788939126298431571815399749254098004540680830976uwb, + 2105720889788939126298431571815399749254098004540680830976uwb + 340282366920938463463374607431768211456uwb, + 2105720889788939126298431571815399749254098004540680830976uwb, + 2105720889788939126298431571815399749254098004540680830976uwb - 1, + 2105720889788939126298431571815399749254098004540680830976uwb, + 2105720889788939126298431571815399749254098004540680830976uwb + 1, + 2105720889788939126298431571815399749254098004540680830976uwb, + 2105720889788939126298431571815399749254098004540680830976uwb, + 3158000566128353648045936726901376808119543972196705250436uwb, + 3158000566128353648045936726901376808119543972196705250436uwb + }; + static _BitInt(192) q[] = { + 1979551028038258779576810033088645171455206196499080052958wb, + -2365185798961627132333096424325796455553365108690644933803wb, + -72665485213084327598421838628274737858136897938197299611wb, + -2684371926785696941292431816009231520283744219656369376907wb, + 2328570543620873568764731049988092721657822189058449467691wb, + 1166480801277674369406023216484203046859890984318705969207wb, + 2554342282302399647952757689834517321971737916674443522004wb, + -844209391020771146100885710857828304368226088928768368272wb, + -1885318755168553153865626302112859755681798781213110674779wb, + -1885318755168553153865626302112859755681798781213110674779wb - 1, + -2489570249266057242333359792314407344590632488455880158241wb, + -2489570249266057242333359792314407344590632488455880158241wb + 1, + -1791854374279093549336635324484455337109530403038654627840wb, + -1791854374279093549336635324484455337109530403038654627840wb - 18446744073709551616wb, + -1791854374279093549336635324484455337109530403038654627840wb, + -1791854374279093549336635324484455337109530403038654627840wb - 1, + -1791854374279093549336635324484455337109530403038654627840wb, + -1791854374279093549336635324484455337109530403038654627840wb + 1, + -1791854374279093549336635324484455337109530403038654627840wb, + -1791854374279093549336635324484455337109530403038654627840wb, + 2339763120586619043754378424358306157273374438118242910208wb, + 2339763120586619043754378424358306157273374438118242910208wb - 340282366920938463463374607431768211456wb, + 2339763120586619043754378424358306157273374438118242910208wb, + 2339763120586619043754378424358306157273374438118242910208wb + 340282366920938463463374607431768211456wb, + 2339763120586619043754378424358306157273374438118242910208wb, + 2339763120586619043754378424358306157273374438118242910208wb - 1, + 2339763120586619043754378424358306157273374438118242910208wb, + 2339763120586619043754378424358306157273374438118242910208wb + 1, + 2339763120586619043754378424358306157273374438118242910208wb, + 2339763120586619043754378424358306157273374438118242910208wb, + -3052391096360403193678321062607799919228465512652019987951wb, + -3052391096360403193678321062607799919228465512652019987951wb + }; + int r[160]; + static int e[160] = { + 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0 + }; + test192 (p, q, r, 0, 0, 0); + for (int i = 0; i < 160; ++i) + if (r[i] != e[i]) + __builtin_abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + check135 (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + check192 (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-9.c.jj 2023-07-27 15:03:24.248234257 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-9.c 2023-07-27 15:03:24.248234257 +0200 @@ -0,0 +1,391 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +__attribute__((noipa)) void +foo (int *p) +{ + *p = 1; +} + +#if __BITINT_MAXWIDTH__ >= 512 +__attribute__((noipa)) void +test512 (unsigned _BitInt(512) *p, _BitInt(512) *q, int *r, int i, int j, int k) +{ + int l; + for (l = 0; l < 15; ++l) + { + r[l * 4] = p[l * 2] < p[l * 2 + 1]; + r[l * 4 + 1] = p[l * 2 + i] <= p[l * 2 + 1 + i]; + r[l * 4 + 2] = p[l * 2 + j] > p[l * 2 + 1 + j]; + r[l * 4 + 3] = p[l * 2 + k] >= p[l * 2 + 1 + k]; + } + r[60] = 0; + if (p[30] < p[31]) + foo (r + 60); + r[61] = 0; + if (p[30 + i] <= p[31 + i]) + foo (r + 61); + r[62] = 0; + if (p[30 + j] > p[31 + j]) + foo (r + 62); + r[63] = 0; + if (p[30 + k] >= p[31 + k]) + foo (r + 63); + for (l = 0; l < 15; ++l) + { + r[64 + l * 4] = q[l * 2] < q[l * 2 + 1]; + r[64 + l * 4 + 1] = q[l * 2 + i] <= q[l * 2 + 1 + i]; + r[64 + l * 4 + 2] = q[l * 2 + j] > q[l * 2 + 1 + j]; + r[64 + l * 4 + 3] = q[l * 2 + k] >= q[l * 2 + 1 + k]; + } + r[124] = 0; + if (q[30] < q[31]) + foo (r + 124); + r[125] = 0; + if (q[30 + i] <= q[31 + i]) + foo (r + 125); + r[126] = 0; + if (q[30 + j] > q[31 + j]) + foo (r + 126); + r[127] = 0; + if (q[30 + k] >= q[31 + k]) + foo (r + 127); + r[128] = p[1] > 6439347061437255154344143895240926184374246647113289384213701629724754669640618959339573646567333876513773564431668184949351528059730009728584631317244784uwb; + r[129] = p[1 + i] >= 6439347061437255154344143895240926184374246647113289384213701629724754669640618959339573646567333876513773564431668184949351528059730009728584631317244784uwb; + r[130] = p[1 + j] < 6439347061437255154344143895240926184374246647113289384213701629724754669640618959339573646567333876513773564431668184949351528059730009728584631317244784uwb; + r[131] = p[1 + k] <= 6439347061437255154344143895240926184374246647113289384213701629724754669640618959339573646567333876513773564431668184949351528059730009728584631317244784uwb; + r[132] = p[9] > 2716607166516370952811015778464637315429428288163165175168021720761495785980681441127279995453132974713988249553556243035771473482679750625718958791524521uwb; + r[133] = p[9 + i] >= 2716607166516370952811015778464637315429428288163165175168021720761495785980681441127279995453132974713988249553556243035771473482679750625718958791524521uwb; + r[134] = p[9 + j] < 2716607166516370952811015778464637315429428288163165175168021720761495785980681441127279995453132974713988249553556243035771473482679750625718958791524521uwb; + r[135] = p[9 + k] <= 2716607166516370952811015778464637315429428288163165175168021720761495785980681441127279995453132974713988249553556243035771473482679750625718958791524521uwb; + r[136] = p[26] > 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb; + r[137] = p[26 + i] >= 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb; + r[138] = p[26 + j] < 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb; + r[139] = p[26 + k] <= 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb; + r[140] = 0; + if (p[27] > 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb) + foo (r + 140); + r[141] = 0; + if (p[27 + i] >= 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb) + foo (r + 141); + r[142] = 0; + if (p[27 + j] < 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb) + foo (r + 142); + r[143] = 0; + if (p[27 + k] <= 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb) + foo (r + 143); + r[144] = q[1] > 2090630783083976726560608899307022527212315311978198188753257152565888263284874347844598962661131937985796633260411082466462809997821330828145983020205878wb; + r[145] = q[1 + i] >= 2090630783083976726560608899307022527212315311978198188753257152565888263284874347844598962661131937985796633260411082466462809997821330828145983020205878wb; + r[146] = q[1 + j] < 2090630783083976726560608899307022527212315311978198188753257152565888263284874347844598962661131937985796633260411082466462809997821330828145983020205878wb; + r[147] = q[1 + k] <= 2090630783083976726560608899307022527212315311978198188753257152565888263284874347844598962661131937985796633260411082466462809997821330828145983020205878wb; + r[148] = q[9] > -696290237363643551117711996671220443230309432588348036053438948181530078288074148843479004574555088489161912619769067173411081743987060302136728183033248wb; + r[149] = q[9 + i] >= -696290237363643551117711996671220443230309432588348036053438948181530078288074148843479004574555088489161912619769067173411081743987060302136728183033248wb; + r[150] = q[9 + j] < -696290237363643551117711996671220443230309432588348036053438948181530078288074148843479004574555088489161912619769067173411081743987060302136728183033248wb; + r[151] = q[9 + k] <= -696290237363643551117711996671220443230309432588348036053438948181530078288074148843479004574555088489161912619769067173411081743987060302136728183033248wb; + r[152] = q[26] > 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb; + r[153] = q[26 + i] >= 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb; + r[154] = q[26 + j] < 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb; + r[155] = q[26 + k] <= 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb; + r[156] = 0; + if (q[27] > 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb) + foo (r + 156); + r[157] = 0; + if (q[27 + i] >= 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb) + foo (r + 157); + r[158] = 0; + if (q[27 + j] < 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb) + foo (r + 158); + r[159] = 0; + if (q[27 + k] <= 3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb) + foo (r + 159); +} + +__attribute__((noipa)) void +check512 (void) +{ + static unsigned _BitInt(512) p[] = { + 6439347061437255154344143895240926184374246647113289384213701629724754669640618959339573646567333876513773564431668184949351528059730009728584631317244784uwb, + 6762041868534283027737681277586698577353418805123389711320743680311823204229693866395914533471197396356562852824213136960386892331859705466032560089589592uwb, + 7100250278744661687919272778464450926810863027145401799102911979534742186567792066709428057992170537490418870754413231800386208987723160090542309342698220uwb, + 7431268529135416278983437544316801791166063098864169546640210976381712748574214253654088092817057535251702063086179197094765059987561230250458545651487418uwb, + 9387962895034579582865984241538651927900235272350318828874682759815638374313243456156983345067518642781984662712425803679907225577643018022275640009873699uwb, + 3166230719682742738348931360884455391542162846555514350392658765013906649241346404508710229903813619084763077863317735446920504536945766338357887078773371uwb, + 11992372489178914246038509566828166672578807653701495597132497332700673199287169715202932677475715468669004681974601325099819634089747001502188758884172602uwb, + 7183772320147988217157628195460873099945185725664709745424293290802245140824151762181161628318220701467892891169914379357484378623421022918276231818933625uwb, + 2716607166516370952811015778464637315429428288163165175168021720761495785980681441127279995453132974713988249553556243035771473482679750625718958791524521uwb, + 2716607166516370952811015778464637315429428288163165175168021720761495785980681441127279995453132974713988249553556243035771473482679750625718958791524521uwb - 1, + 12641036253945464668613158871576838890244642877026977530604698385615142732677552062689011995329072722635530415107759810021792111602714418929346777947581722uwb, + 12641036253945464668613158871576838890244642877026977530604698385615142732677552062689011995329072722635530415107759810021792111602714418929346777947581722uwb + 1, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb - 18446744073709551616uwb, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb - 1, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb + 1, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb, + 8922448217105188951537312155524913197158477782806467330054048115953920100033906218746035610108190050394196228624539921400738404901092299164323787527159808uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb - 39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306816uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb + 39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306816uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb - 1, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb + 1, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb, + 419738665353613393951601598131892680944319219800892426789126665343642933931943588470723015570704289785844248033634460199784949778501149813068325535612928uwb, + 10128841244658791126648561211937592176780958236989426886389971194372978046367048331953118621224361972312674509897766160468914015517030880732802761461031257uwb, + 10128841244658791126648561211937592176780958236989426886389971194372978046367048331953118621224361972312674509897766160468914015517030880732802761461031257uwb + }; + static _BitInt(512) q[] = { + 2090630783083976726560608899307022527212315311978198188753257152565888263284874347844598962661131937985796633260411082466462809997821330828145983020205878wb, + 5297891122069759152190358277191301380039917110906456442739988947584072293285648331709545720897009753992228929981833882700804979946892323846480198848327132wb, + -5175455635851811471365509786771967259502175482181487858405840994248880218291771627060836702250940532261110768615360129062649520600089218199000819977507401wb, + -1197417987356054452650938717940723527397958134105969279763141389784758850378928132483783317153283733701258756175700200053452996288076889759098734389999989wb, + 376956342115769081675826480328100204258176592231230579846860212707171684351927919252138022581568644395505257039021425128449272854523981924151678168936546wb, + -3213922658862209387519332343658781663313426526489443455850614508466930839492348067449248688649920694680442694775272326426735943224604674195708324515087099wb, + -26226634446852143139032827542275726163637222096291661272058678439249826123155608154486599937246756733481215161556643451523636377101397790340001692756671wb, + 2387778007768951206967793842263829269147949222877356804856598206833350996940762526208017209413841449433410232587427590886259349063804766729190889440858025wb, + -696290237363643551117711996671220443230309432588348036053438948181530078288074148843479004574555088489161912619769067173411081743987060302136728183033248wb, + -696290237363643551117711996671220443230309432588348036053438948181530078288074148843479004574555088489161912619769067173411081743987060302136728183033248wb - 1, + 5076345582133566846688236290712078493812804531016237797772016838314392198062936803967594662767716104530499878914245621558744394736829525675805759950337585wb, + 5076345582133566846688236290712078493812804531016237797772016838314392198062936803967594662767716104530499878914245621558744394736829525675805759950337585wb + 1, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb - 18446744073709551616wb, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb - 1, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb + 1, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb, + 76333981980921012896605396538225276147251180731694673353838618004648399286703323410022822396010620396184658817947322688521663381589809974158923162189824wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb - 6277101735386680763835789423207666416102355444464034512896wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb + 6277101735386680763835789423207666416102355444464034512896wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb - 1, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb + 1, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb, + -3803169810302811951423866897603196308644585632212248377372707505362914913528085871414141191637221346044389898087027979721998214953093947532239443142377472wb, + -663334509177964622465622357697170286154368667858847871698225590542683746494347453401587549116942795508119009999390315794925881271012501058045923403034199wb, + -663334509177964622465622357697170286154368667858847871698225590542683746494347453401587549116942795508119009999390315794925881271012501058045923403034199wb + }; + int r[160]; + static int e[160] = { + 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, + 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 + }; + test512 (p, q, r, 0, 0, 0); + for (int i = 0; i < 160; ++i) + if (r[i] != e[i]) + __builtin_abort (); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test575 (unsigned _BitInt(575) *p, _BitInt(575) *q, int *r, int i, int j, int k) +{ + int l; + for (l = 0; l < 15; ++l) + { + r[l * 4] = p[l * 2] < p[l * 2 + 1]; + r[l * 4 + 1] = p[l * 2 + i] <= p[l * 2 + 1 + i]; + r[l * 4 + 2] = p[l * 2 + j] > p[l * 2 + 1 + j]; + r[l * 4 + 3] = p[l * 2 + k] >= p[l * 2 + 1 + k]; + } + r[60] = 0; + if (p[30] < p[31]) + foo (r + 60); + r[61] = 0; + if (p[30 + i] <= p[31 + i]) + foo (r + 61); + r[62] = 0; + if (p[30 + j] > p[31 + j]) + foo (r + 62); + r[63] = 0; + if (p[30 + k] >= p[31 + k]) + foo (r + 63); + for (l = 0; l < 15; ++l) + { + r[64 + l * 4] = q[l * 2] < q[l * 2 + 1]; + r[64 + l * 4 + 1] = q[l * 2 + i] <= q[l * 2 + 1 + i]; + r[64 + l * 4 + 2] = q[l * 2 + j] > q[l * 2 + 1 + j]; + r[64 + l * 4 + 3] = q[l * 2 + k] >= q[l * 2 + 1 + k]; + } + r[124] = 0; + if (q[30] < q[31]) + foo (r + 124); + r[125] = 0; + if (q[30 + i] <= q[31 + i]) + foo (r + 125); + r[126] = 0; + if (q[30 + j] > q[31 + j]) + foo (r + 126); + r[127] = 0; + if (q[30 + k] >= q[31 + k]) + foo (r + 127); + r[128] = p[1] > 20670903802240325105911328843875002676780679796965659887810279910476905646991707533359633196332088191362534479568251649420016839659631716684161458660332642627037004465943031uwb; + r[129] = p[1 + i] >= 20670903802240325105911328843875002676780679796965659887810279910476905646991707533359633196332088191362534479568251649420016839659631716684161458660332642627037004465943031uwb; + r[130] = p[1 + j] < 20670903802240325105911328843875002676780679796965659887810279910476905646991707533359633196332088191362534479568251649420016839659631716684161458660332642627037004465943031uwb; + r[131] = p[1 + k] <= 20670903802240325105911328843875002676780679796965659887810279910476905646991707533359633196332088191362534479568251649420016839659631716684161458660332642627037004465943031uwb; + r[132] = p[9] > 3090473864111819272422440709625579853033878497967848058942349684272558230226217367538319212654996864729950831478837556651015327221470111893258987353940473822396493825387378uwb; + r[133] = p[9 + i] >= 3090473864111819272422440709625579853033878497967848058942349684272558230226217367538319212654996864729950831478837556651015327221470111893258987353940473822396493825387378uwb; + r[134] = p[9 + j] < 3090473864111819272422440709625579853033878497967848058942349684272558230226217367538319212654996864729950831478837556651015327221470111893258987353940473822396493825387378uwb; + r[135] = p[9 + k] <= 3090473864111819272422440709625579853033878497967848058942349684272558230226217367538319212654996864729950831478837556651015327221470111893258987353940473822396493825387378uwb; + r[136] = p[26] > 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb; + r[137] = p[26 + i] >= 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb; + r[138] = p[26 + j] < 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb; + r[139] = p[26 + k] <= 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb; + r[140] = 0; + if (p[27] > 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb) + foo (r + 140); + r[141] = 0; + if (p[27 + i] >= 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb) + foo (r + 141); + r[142] = 0; + if (p[27 + j] < 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb) + foo (r + 142); + r[143] = 0; + if (p[27 + k] <= 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb) + foo (r + 143); + r[144] = q[1] > -16024899825125698861378150913416105280348720287461133876385645855428118759753753693038310256905822130840919293800517449664090240148479686087771461105141796446993957309177045wb; + r[145] = q[1 + i] >= -16024899825125698861378150913416105280348720287461133876385645855428118759753753693038310256905822130840919293800517449664090240148479686087771461105141796446993957309177045wb; + r[146] = q[1 + j] < -16024899825125698861378150913416105280348720287461133876385645855428118759753753693038310256905822130840919293800517449664090240148479686087771461105141796446993957309177045wb; + r[147] = q[1 + k] <= -16024899825125698861378150913416105280348720287461133876385645855428118759753753693038310256905822130840919293800517449664090240148479686087771461105141796446993957309177045wb; + r[148] = q[9] > 58304255896761105723976011538967955499349019141200282089271806304495956703405537252312168244240400239567714934306206832214441693408953280684020766705604407959670312862112067wb; + r[149] = q[9 + i] >= 58304255896761105723976011538967955499349019141200282089271806304495956703405537252312168244240400239567714934306206832214441693408953280684020766705604407959670312862112067wb; + r[150] = q[9 + j] < 58304255896761105723976011538967955499349019141200282089271806304495956703405537252312168244240400239567714934306206832214441693408953280684020766705604407959670312862112067wb; + r[151] = q[9 + k] <= 58304255896761105723976011538967955499349019141200282089271806304495956703405537252312168244240400239567714934306206832214441693408953280684020766705604407959670312862112067wb; + r[152] = q[26] > 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb; + r[153] = q[26 + i] >= 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb; + r[154] = q[26 + j] < 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb; + r[155] = q[26 + k] <= 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb; + r[156] = 0; + if (q[27] > 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb) + foo (r + 156); + r[157] = 0; + if (q[27 + i] >= 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb) + foo (r + 157); + r[158] = 0; + if (q[27 + j] < 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb) + foo (r + 158); + r[159] = 0; + if (q[27 + k] <= 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb) + foo (r + 159); +} + +__attribute__((noipa)) void +check575 (void) +{ + static unsigned _BitInt(575) p[] = { + 20670903802240325105911328843875002676780679796965659887810279910476905646991707533359633196332088191362534479568251649420016839659631716684161458660332642627037004465943031uwb, + 49836863281122150110976162564317489099243240060228310477726588559007020237654535886855965503007498301850523952960694293079759086994244623132359873685415478540406438465172529uwb, + 101667739273597064965717829455384743619074292631575734674415300078314703020971656449536574871164441895580568359346194993799527328879777131705988166820718349177377030581506226uwb, + 80233423044307189839832679537616515928636785173353789034947437038572207116613067927657166726935743880478344956088014540963626767254100174497579222671797940959076429057916182uwb, + 97607764806301954960180192904514327019672797546593465640967968069805351962335581135107484573411646213834310418744666537049560033943330633542409774950231074157796998179151769uwb, + 99099235847887185556638324204228969647146126640633556693610768362203817464971524250335424151842349844365719435719612388970493211957199457919255952798632861734037338994194966uwb, + 96074581713567517318016295073161521338909508333544695778644303001677582373061974284621003059876740600584228853347041280615851508249074891807094765318948991008650765902599128uwb, + 15041679461477111400649592642834193580709001861981524454028015552897618001389619787056916841370949982467368838858876017142572779037936015252240846631518852370288984853313032uwb, + 3090473864111819272422440709625579853033878497967848058942349684272558230226217367538319212654996864729950831478837556651015327221470111893258987353940473822396493825387378uwb, + 3090473864111819272422440709625579853033878497967848058942349684272558230226217367538319212654996864729950831478837556651015327221470111893258987353940473822396493825387378uwb - 1, + 24687788671445747328062841851441115170362216714281949080981056837718636733099501838839343860093294574222940008960321348311574274097362076438265776869659934585082628479484536uwb, + 24687788671445747328062841851441115170362216714281949080981056837718636733099501838839343860093294574222940008960321348311574274097362076438265776869659934585082628479484536uwb + 1,\ + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb - 18446744073709551616uwb, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb - 1, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb + 1, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb, + 47614907307737548529956044769514214288024476724410617147178248001248351816791887941016492346949195777207895982954879948136089705588820700968975703834863097085713265316593664uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb - 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb + 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb - 1, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb + 1, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb, + 32300371493042338295430399331232255118632292468465563882493105489267627026599093946004621996863635202389007853529819771477875971454599651226062726008225128378230201091358720uwb, + 51633735166516291946287076289285239234614696135400087552338648850396978875047534195381428791244881087469912840942965704049340728476496893527920582382910651979554452116116272uwb, + 51633735166516291946287076289285239234614696135400087552338648850396978875047534195381428791244881087469912840942965704049340728476496893527920582382910651979554452116116272uwb + }; + static _BitInt(575) q[] = { + -16024899825125698861378150913416105280348720287461133876385645855428118759753753693038310256905822130840919293800517449664090240148479686087771461105141796446993957309177045wb, + -51390644150207754083049224884205617519374685858021340086606047722946185332781222093929175551224144597441976819384400839391617209092608330883818358373143049025398242971422533wb, + -20809715567752942978812919265762383091400170370538364777815196254289178900619639932788104439550680105583194256562402043742602192720264733467556618411468069787890087436518391wb, + -43478068345605895172576873114727639397122657577727331984515310626703015763793150203012686140133812758008909595858389385754649550027270841464683283530974333174240307326289977wb, + 21067536974893828187213625307418104748755825376641087283640893104632378341787632507091012136429031707836504909794544075439508068134695815107226742106718247426895718454571312wb, + 21059037076325069627888376003421918344895371516177629929139897951865178711273978220082835739571514841970324298196012637442412751291560252279454786817442227655976906976548376wb, + 55073439925103775330639545123285198131334712919437487448183092392908579762995884122632962257443311586409720754276146674776790868518679130616646045890806469671103608966017526wb, + -3663639803402473230919436108605440689203511417836937035771974096034195998647953190615349428343475558818004598945205472788914786751065095519363354010927131384676070154882437wb, + 58304255896761105723976011538967955499349019141200282089271806304495956703405537252312168244240400239567714934306206832214441693408953280684020766705604407959670312862112067wb, + 58304255896761105723976011538967955499349019141200282089271806304495956703405537252312168244240400239567714934306206832214441693408953280684020766705604407959670312862112067wb - 1, + 19766430864130481024653308710810905134755769634549241890712862316488061577142782818791682881169095930184520701227673190291943682114543262971807474281675881316596313965163891wb, + 19766430864130481024653308710810905134755769634549241890712862316488061577142782818791682881169095930184520701227673190291943682114543262971807474281675881316596313965163891wb + 1, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb - 18446744073709551616wb, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb - 1, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb + 1, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb, + -34289018974597784349033110006663080173300111534374645051386853751555192083544833095189889341716428776365054335337832864819656266482761085202092232298171290655379977534439424wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb - 39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306816wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb + 39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806627990306816wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb - 1, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb + 1, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb, + 5792382359367624136729259459647895570083840504542461480157806156670329217124243749211279307138790818182646144303340305156516829311465729191448709861740266920986130350342144wb, + 8558311355808808607005104837820226337084035299904651624497753594925617942910238887167551309507473356128849516219332540284243795507166584146318106852798224239555032058705368wb, + 8558311355808808607005104837820226337084035299904651624497753594925617942910238887167551309507473356128849516219332540284243795507166584146318106852798224239555032058705368wb + }; + int r[160]; + static int e[160] = { + 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0 + }; + test575 (p, q, r, 0, 0, 0); + for (int i = 0; i < 160; ++i) + if (r[i] != e[i]) + __builtin_abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 512 + check512 (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + check575 (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-10.c.jj 2023-07-27 15:03:24.248234257 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-10.c 2023-07-27 15:03:24.248234257 +0200 @@ -0,0 +1,38 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) void +test135 (_BitInt(135) *p) +{ + *p = 18514202188641047858083570207027263585014wb; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 512 +__attribute__((noipa)) void +test512 (_BitInt(512) *p) +{ + *p = -3850276968594657220525735372507394006353780328347442833283734788531702263728014201878916354908375176401574990646289191313473197873422312093114382157952958wb; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + _BitInt(135) b135; + test135 (&b135); + if (b135 != 18514202188641047858083570207027263585014wb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 512 + _BitInt(512) b512; + test512 (&b512); + if (b512 != -3850276968594657220525735372507394006353780328347442833283734788531702263728014201878916354908375176401574990646289191313473197873422312093114382157952958wb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-11.c.jj 2023-07-27 15:03:24.247234271 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-11.c 2023-07-27 15:03:24.247234271 +0200 @@ -0,0 +1,77 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint && int32plus } } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#ifdef __SIZEOF_INT128__ +#define int128_val(x, y) x +#define int128_bitfld(x) x +#define int128 __int128 +#else +#define int128_val(x, y) y +#define int128_bitfld(x) 1 +#define int128 int +#endif + +struct S { + int i : 1; + int j : 27; + long long k : 56; + int128 l : int128_bitfld (120); + unsigned m : 3; + unsigned long long n : 42; + unsigned int128 o : int128_bitfld (125); +}; + +#if __BITINT_MAXWIDTH__ >= 188 +__attribute__((noipa)) _BitInt(188) +test188 (int a, long long b, int128 c, unsigned short d, + unsigned long long e, unsigned int128 f, _BitInt(188) *g, + struct S *p) +{ + return *g + a + b + c + d + e + f + p->i + p->j + p->k + p->l + p->m + p->n + p->o; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +test575 (int a, long long b, int128 c, unsigned short d, + unsigned long long e, unsigned int128 f, _BitInt(575) *g, + struct S *p) +{ + return *g + a + b + c + d + e + f + p->i + p->j + p->k + p->l + p->m + p->n + p->o; +} +#endif + +int +main () +{ + struct S s = { -1, 34877496, -5580713461260169LL, + int128_val (329913978417840804084945075673166782wb, 0), + 1U, 68262565354ULL, + int128_val (5169264897230903304574466460949339423uwb, 0) }; + (void) &s; +#if __BITINT_MAXWIDTH__ >= 188 + _BitInt(188) b188 = 51625354135609169507415940782602403562057573230992065937wb; + if (test188 (-943502954, 6037882847713389759LL, + int128_val (-83021930809076074533830959108195408798wb, 0), + 55564, 16536837072610496559ULL, + int128_val (237527410537432634851289433535592281366uwb, 0), + &b188, &s) + != int128_val (51625354135609169667420599386607708010744598469228066319wb, + 51625354135609169507415940782602403584626712505208687546wb)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) b575 = -20179593413257295974034559327597105210986698104682733481090257927308152867107766179792744096926808179875378122328280563720406829353405990702024578604764643194143342705864832wb; + if (test575 (-943502954, 6037882847713389759LL, + int128_val (-83021930809076074533830959108195408798wb, 0), + 55564, 16536837072610496559ULL, + int128_val (237527410537432634851289433535592281366uwb, 0), + &b575, &s) + != int128_val (-20179593413257295974034559327597105210986698104682733481090257927308152867107766179792744096926808179875378122328280563720406829353405830697365974599460194507118104469864450wb, + -20179593413257295974034559327597105210986698104682733481090257927308152867107766179792744096926808179875378122328280563720406829353405990702024578604764620625004068489243223wb)) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-12.c.jj 2023-07-27 15:03:24.246234285 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-12.c 2023-07-27 15:03:24.246234285 +0200 @@ -0,0 +1,128 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint && int32plus } } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#ifdef __SIZEOF_INT128__ +#define int128_val(x, y) x +#define int128 __int128 +#else +#define int128_val(x, y) y +#define int128 int +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test575 (_BitInt(575) *a, int b, int128 c, unsigned int d, unsigned int128 e, + int f, int g, int128 h, unsigned int i, unsigned int128 j, + _BitInt(575) *p, int *r) +{ + r[0] = *a > b; + r[1] = *a >= c; + r[2] = *a < d; + r[3] = *a <= e; + p[0] = ((_BitInt(575)) g) << f; + p[1] = ((_BitInt(575)) h) << f; + p[2] = ((_BitInt(575)) i) << f; + p[3] = ((_BitInt(575)) j) << f; + p[4] = ((unsigned _BitInt(575)) g) >> f; + p[5] = ((unsigned _BitInt(575)) h) >> f; + p[6] = ((unsigned _BitInt(575)) i) >> f; + p[7] = ((unsigned _BitInt(575)) j) >> f; +} + +_BitInt(575) a575 = -37335077053906536248085160049937130279057714970866686325204063930452920311842187828021093674979068589644104434897698233644810906211958229904753029173357201859433853689386323wb; +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 575 + int r[12]; + _BitInt(575) b575[24]; + int er[12] = { +#ifdef __SIZEOF_INT128__ + 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1 +#else + 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1 +#endif + }; + static _BitInt(575) eb575[24] = { +#ifdef __SIZEOF_INT128__ + 20329374714419634196895318109902140892207297977139593216wb, + -1712803473999893185713719997722323414959591613021414111612885795955340439235139207168wb, + 24459948786509903061037979887398299261116601758241521664wb, + 266261172647138617905132542512773540174694514212873439044818615992883558384930914304wb, + 0wb, + 10830740992659433045228180406808920716548582325686783496759685861775864483615725089999900023844295226942934417817982702456930303wb, + 0wb, + 0wb, + 7830590302633896968192wb, + -659747899885375730707839505890120862245951494946816wb, + 9421629561223530938368wb, + 102560073085756776493593811652595116491535756034048wb, + 0wb, + 28118211215894977392565865673037386617935606989386978956879722328823984879196799189494004288149317857187005691459505594520051662846839338948136222520490158359458wb, + 0wb, + 5302231504909973601023497wb, + 1780470098wb, + -150009304862891379049833518795394607479wb, + 2142230542wb, + 23319460771235020841594135084186545212wb, + 1780470098wb, + -150009304862891379049833518795394607479wb, + 2142230542wb, + 23319460771235020841594135084186545212wb +#else + 20329374714419634196895318109902140892207297977139593216wb, + 479555224749202520035584085735030365824602865664wb, + 24459948786509903061037979887398299261116601758241521664wb, + 171269723124715185726994316333939416365929594880wb, + 0wb, + 0wb, + 0wb, + 0wb, + 7830590302633896968192wb, + 184717953466368wb, + 9421629561223530938368wb, + 65970697666560wb, + 0wb, + 0wb, + 0wb, + 0wb, + 1780470098wb, + 42wb, + 2142230542wb, + 15wb, + 1780470098wb, + 42wb, + 2142230542wb, + 15wb +#endif + }; + test575 (&a575, 1780470098, int128_val (-150009304862891379049833518795394607479wb, 42), + 2142230542U, int128_val (23319460771235020841594135084186545212uwb, 15), + 153, 1780470098, int128_val (-150009304862891379049833518795394607479wb, 42), + 2142230542U, int128_val (23319460771235020841594135084186545212uwb, 15), + &b575[0], &r[0]); + a575 = 1780470099wb; + test575 (&a575, 1780470098, int128_val (-150009304862891379049833518795394607479wb, 42), + 2142230542U, int128_val (23319460771235020841594135084186545212uwb, 15), + 42, 1780470098, int128_val (-150009304862891379049833518795394607479wb, 42), + 2142230542U, int128_val (23319460771235020841594135084186545212uwb, 15), + &b575[8], &r[4]); + a575 = -150009304862891379049833518795394607478wb; + test575 (&a575, 1780470098, int128_val (-150009304862891379049833518795394607479wb, 42), + 2142230542U, int128_val (23319460771235020841594135084186545212uwb, 15), + 0, 1780470098, int128_val (-150009304862891379049833518795394607479wb, 42), + 2142230542U, int128_val (23319460771235020841594135084186545212uwb, 15), + &b575[16], &r[8]); + for (int i = 0; i < 12; ++i) + if (r[i] != er[i]) + __builtin_abort (); + for (int i = 0; i < 24; ++i) + if (b575[i] != eb575[i]) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-13.c.jj 2023-07-27 15:03:24.245234299 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-13.c 2023-07-27 15:03:24.245234299 +0200 @@ -0,0 +1,171 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint && int32plus } } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ * __CHAR_BIT__ == 128 +#define int128_val(x, y) x +#define int128_bitfld(x) x +#define int128 __int128 +#else +#define int128_val(x, y) y +#define int128_bitfld(x) 1 +#define int128 int +#endif +#if __SIZEOF_SHORT__ * __CHAR_BIT__ == 16 +#define shrt_val(x, y) x +#else +#define shrt_val(x, y) y +#endif +#if __SIZEOF_INT__ * __CHAR_BIT__ == 32 +#define int_val(x, y) x +#else +#define int_val(x, y) y +#endif +#if __SIZEOF_LONG_LONG__ * __CHAR_BIT__ == 64 +#define llong_val(x, y) x +#else +#define llong_val(x, y) y +#endif + +struct S { + int i : 1; + int j : 27; + long long k : 56; + int128 l : int128_bitfld (120); + unsigned m : 3; + unsigned long long n : 42; + unsigned int128 o : int128_bitfld (125); +}; + +#if __BITINT_MAXWIDTH__ >= 188 +__attribute__((noipa)) void +test188 (int *a, long long *b, int128 *c, unsigned short *d, + unsigned long long *e, unsigned int128 *f, _BitInt(188) *g, + struct S *p) +{ + *a = g[0] + g[1]; + *b = (_BitInt(188)) ((unsigned _BitInt(188)) g[2] - g[3]); + *c = g[4]; + *d = (_BitInt(188)) ((unsigned _BitInt(188)) g[5] << 3); + *e = (unsigned _BitInt(188)) g[6]; + *f = -g[7]; + p->i = g[8] | 256wb; + p->j = g[9] ^ 513wb; + p->k = g[10] & g[11]; + p->l = g[12]; + p->m = (g[13] | g[14]) + g[15]; + p->n = g[16]; + p->o = g[17]; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test575 (int *a, long long *b, int128 *c, unsigned short *d, + unsigned long long *e, unsigned int128 *f, _BitInt(575) *g, + struct S *p) +{ + *a = g[0] + g[1]; + *b = g[2] - g[3]; + *c = g[4]; + *d = g[5] << 3; + *e = (unsigned _BitInt(575)) g[6]; + *f = -g[7]; + p->i = g[8] | 256wb; + p->j = g[9] ^ 513wb; + p->k = g[10] & g[11]; + p->l = g[12]; + p->m = (g[13] | g[14]) + g[15]; + p->n = g[16]; + p->o = g[17]; +} +#endif + +int +main () +{ + struct S s; + int a; + long long b; + int128 c; + unsigned short d; + unsigned long long e; + unsigned int128 f; + (void) &s; +#if __BITINT_MAXWIDTH__ >= 188 + _BitInt(188) g188[18] = { + -159047363318536960484353065517373654721104396757490314295wb, + -3121544831087579708485147608149039646353048280619431708wb, + 159318071862725567512368472768918962735450536041547197357wb, + -40707507555068524326919847225737421498619613998666182429wb, + 165320903343659124097264390671505112912629878959843721491wb, + -127515148002861399222757129930766493340235768486498578219wb, + -105034079444454534611827588421185078564296081131064901461wb, + 92590184827335405203162269451222486819220604151446603018wb, + -180312039117739394533672196677501644999924031772292123301wb, + -144189136904129889279453036150725630022817508409138149279wb, + -149481812493652088098408785514342084106630686193276241281wb, + -167177289711809249257738519322903628222027157941774765457wb, + -143084017548841355414802324960482130843700645074551425158wb, + 58479706299212198491939673148493577279739517540183806582wb, + -56927106028567263826833143638316408260616106349933917222wb, + -51398435670153923584906245550632035515359744807385001406wb, + 42134285326135692487901360354060672379510798359809381879wb, + 88023866651707391895300914626945857947221302817073781445wb + }; + test188 (&a, &b, &c, &d, &e, &f, &g188[0], &s); + if (a != int_val (0x07181cad, (int) 230149950312043007546898625824956456638939770240892411053uwb) + || b != llong_val ((long long) 0xde59a69b154ddacaLL, (long long) 200025579417794091839288319994656384234070150040213379786uwb) + || c != int128_val ((int128) 0xd1d8047ea714e976fb0ddacd903a4113uwb, int_val ((int) 0x903a4113, (int) 165320903343659124097264390671505112912629878959843721491uwb)) + || d != shrt_val (0x86a8, (unsigned short) 156835391362111449437153477405305506297305497945017845416uwb) + || e != llong_val (0xf4603045301e40abULL, (unsigned long long) 287284779017213013127909250529294072442101134147937255595uwb) + || f != int128_val ((unsigned int128) 0x36333fc0e67c1648df996844ae607af6uwb, int_val ((unsigned) 0xae607af6, (unsigned) 299728673634332142536574569499256664187176611127555554038uwb)) + || s.i != -1 + || s.j != 0x3150a60 + || s.k != 0x0501922b16326fLL + || s.l != int128_val ((int128) 0xffa05b2a80ae9f589ff82df4ec30377auwb, 0) + || s.m != 0 + || s.n != 0xbea55655f7ULL + || s.o != int128_val ((unsigned int128) 0x11424021a09eb39f0078be56f505dac5uwb, 1)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) g575[18] = { + -47005092370981353509019585272930171576138837874594474940633343041444523868768398171568402914237822300343064860032430047905208253183368063860751727493912961793713775785286761wb, + 42995314282090421850185028248818616047989631648441809220202839707075135953582887789310579563290411495625582960818510026163313766713468119555853185204024156985186870447558448wb, + -4310949275737056279952323703666519147345926215446595910688661460043187233007608392215115192894183359414559767132447689960645444722310313612870802800517291553651832872230377wb, + -60174333254167907860375485189824486743221145295071697779574672977710903042875235567137515476943834663106195143844820080789913163377976708972634731997186324672887273760550843wb, + 514999616465082372590625134373624423612122508361343296847148750502235576952627411211915080142588943086581680871086375952582973053262315744074678352482468176498475765238014wb, + -34524529098838981071360498102806028847960079898011114995185678340915753622610778619950150604678383174181175565220899355393832542080300168653321490778607415279583262404019715wb, + 57435829357765689198701253918538231677782825819649130906117703766412930883719480639328241453985120284446411689340430788174994800799501628170332549761733355178989958217690176wb, + 55372038211321583831991526729411129160052836002754320808356246247126956944240411995457998940239431679806969029801755058644044152079840612142503912508386823751242378280351248wb, + 16465587034692152401588675199252528652333806863385560487958043658459465122879621696065063317705307064863781999117926295249319492796685349901264833471330673488325230233633156wb, + 29447367895156340838084654771430520820905636269084897202980661633115991361986283452296000775941804019961160709602424696981982973428884144037654036591675815222144356989137377wb, + -11405270033186719236304815495700559798454505639686440514251001395033465367140240658561115444561532342526965619895711017904459977515469290641005572154684851264335049868864497wb, + 108093905149568033165371492635656748567249268116953654298668927833251941040419562425217780888127352768755220577595921193600804563557700826867049089803222938826670338302530wb, + -31360750000107936163671456129190056884574874172627927813113803212980739137815442376155550405060248732467083955605320651972161402853892464960579922753500965033770359737153351wb, + -8682946747028473458400698043390376356896046446946536663094478822504353095327345833145506855874926356083877643554724567774187375944555393553847900623220497209797513931185240wb, + -22144855016132297032977142230889176517935104503579623594553342478323802903759572545707546713930097548953805249628758279309623598839610808070152925878316419950140234764905470wb, + -10411562563660012059020319572234253583259323305689321838048522585769451002745393609294442107707749261789472265492124615971403756074402546875951159988775650555291608910079211wb, + -35303144058707185327630269206553728380732193353770095499658757423571059983534369285427585500543929872684039303017125049206013674506050937891922504600168970885730004765890909wb, + -10288638308173362696633233706439807781761277611815792314525923347956953720054374840733498198399501888078817738532473821245337293721068994241744635656437058172223152460622488wb + }; + test575 (&a, &b, &c, &d, &e, &f, &g575[0], &s); + if (a != int_val (-0x2a104d39, (int) -4009778088890931658834557024111555528149206226152665720430503334369387915185510382257823350947410804717481899213920021741894486469899944304898542289888804808526905337728313wb) + || b != llong_val ((long long) 0xf6c7e117bacd11d2LL, (long long) 55863383978430851580423161486157967595875219079625101868886011517667715809867627174922400284049651303691635376712372390829267718655666395359763929196669033119235440888320466uwb) + || c != int128_val ((int128) 0x75504b73f68a3225400491eb337288feuwb, int_val ((int) 0x337288fe, (int) 514999616465082372590625134373624423612122508361343296847148750502235576952627411211915080142588943086581680871086375952582973053262315744074678352482468176498475765238014uwb)) + || d != shrt_val (0xcfe8, (unsigned short) 94799369418944952519869796707022554269016384467728839909609157412019808678911571795873396754437502090947102617257014165876387214817725465724747306423980429638244058990890984uwb) + || e != llong_val (0xa6a61a4adeb96c40ULL, (unsigned long long) 57435829357765689198701253918538231677782825819649130906117703766412930883719480639328241453985120284446411689340430788174994800799501628170332549761733355178989958217690176uwb) + || f != int128_val ((unsigned int128) 0xd2a8d84eae8410641083c38afaa549f0uwb, int_val ((unsigned) 0xfaa549f0, (unsigned) 68293162525230683198259733780412465857512838547851599148675281799321655609025521589700201590382090814991866683206314611031638365073534992841269165042559760207061007793998320uwb)) + || s.i != 0 + || s.j != -0x2920c20 + || s.k != -0x1bddffff3afffeLL + || s.l != int128_val ((int128) 0xffb52493069ee4e254bf24bbba7a08b9uwb, -1) + || s.m != 7 + || s.n != 0x1cbf11e26a3ULL + || s.o != int128_val ((unsigned int128) 0x12a63362222ec8f7f2c7e52793b49568uwb, 0)) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-14.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-14.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,140 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 256 +__attribute__((noipa)) void +test256 (_BitInt(256) *p, _BitInt(256) *q, unsigned n) +{ + _BitInt(256) x = q[0], y; + unsigned _BitInt(256) z; + p[0] = x >= 0 ? x : -x; + x = q[1]; + p[1] = (_BitInt(256)) (-(_BitInt(256)) (x < 0) | 1) * (unsigned _BitInt(256)) x; + x = q[2]; + y = q[3]; + p[2] = x > y ? x : y; + p[3] = x < y ? x : y; + z = q[4]; + p[4] = (z << n) | (z >> (-n) % 256); + z = q[5]; + p[5] = (z >> n) | (z << (-n) % 256); + z = q[6]; + p[6] = (z << 42) | (z >> (256 - 42)); + p[7] = (z << 196) | (z >> (256 - 196)); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test575 (_BitInt(575) *p, _BitInt(575) *q, unsigned n) +{ + _BitInt(575) x = q[0], y; + + p[0] = x >= 0 ? x : -x; + x = q[1]; + p[1] = (_BitInt(575)) (-(_BitInt(575)) (x < 0) | 1) * (unsigned _BitInt(575)) x; + x = q[2]; + y = q[3]; + p[2] = x > y ? x : y; + p[3] = x < y ? x : y; + x = q[4]; + p[4] = (x << n) | (x >> (-n) % 575); + x = q[5]; + p[5] = (x >> n) | (x << (-n) % 575); + x = q[6]; + p[6] = (x << 42) | (x >> (575 - 42)); + p[7] = (x << 196) | (x >> (575 - 196)); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 256 + _BitInt(256) p256[16]; + static _BitInt(256) q256[14] = { + 45345032714412617256156490782169070529322290545773058110333871537162440472587wb, + -57896044618658097711785492504343953926634992332820282019728792003956564819968wb, + 56362660930901219937245963089077503913881996661810533276822951833224961233515wb, + 51868771107222588126287278424861243128427600270521502351207927942060821222194wb, + -19284414951568262238262918143892955489617856897512953183940840506431869697041wb, + 2658782266882101281962762454025964999131551132761759005892140732613414118676wb, + 54220248433725687265393292224175077483742748899396150017145360542924235344802wb, + -37463226851796965187185951868838571299559805464590722337979740082646767802569wb, + -40419708661355022203345898421408637080086749636846240100217688555626587286030wb, + -55754487912560053024413264564540814098917966752804384445133242149913646068176wb, + 26265770627437470876117322526967897715823682246510518833106882615653395455635wb, + -52596268389191266164863111650546248051760002564726896605115288580144402763386wb, + -44308970341715903069333400701791033613751134794232782967956437254511180029758wb, + 4750616739884184263118039796682749720523215747547537773188931304361332774085wb + }; + static const _BitInt(256) r256[16] = { + 45345032714412617256156490782169070529322290545773058110333871537162440472587wb, + -57896044618658097711785492504343953926634992332820282019728792003956564819968wb, + 56362660930901219937245963089077503913881996661810533276822951833224961233515wb, + 51868771107222588126287278424861243128427600270521502351207927942060821222194wb, + 28504845637216227099157296646299447493773190228564580204434798695467761710135wb, + 13952419655888133019367679114949332038269119423004786217260238955159715384317wb, + 55062854366581286125448024237607745201868855087201663327097902939898842371913wb, + -48537283185021244092191938290513862066611838578912383503471331209866218456054wb, + 37463226851796965187185951868838571299559805464590722337979740082646767802569wb, + 40419708661355022203345898421408637080086749636846240100217688555626587286030wb, + 26265770627437470876117322526967897715823682246510518833106882615653395455635wb, + -55754487912560053024413264564540814098917966752804384445133242149913646068176wb, + -52596268389191266164863111650546248051760002564726896605115288580144402763386wb, + -44308970341715903069333400701791033613751134794232782967956437254511180029758wb, + -18143335929783282380882063933743228881911720395868748284571317433159558897346wb, + 29051936395101664965352348496634886321943246606527498619351354372469657269685wb + }; + test256 (p256, q256, 31); + test256 (p256 + 8, q256 + 7, 0); + for (int i = 0; i < 16; ++i) + if (p256[i] != r256[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + _BitInt(575) p575[16]; + static _BitInt(575) q575[14] = { + -22872451846054556417350916741013404184330732279497241442289048103235716890482482649099537178446621346041121532737887637378213104798444471078041166778940100084060290561371455wb, + 17785619680254441647827488871998638273432777299970128558821267200272839955229298488625220894043625699693270092672797162273950619203800446486815325568472958573446749051572825wb, + -734234098097989409262727998397700256489421637915860389242752385873657556883074595636809785650192226409399868870242355685621686958186408269916495700324885703256092385869434wb, + 38120499666250922171546613830180673200675976218799529299148065967941552755802535392332731940070002883710338820964987361658591561975335652756278138538832118604974787875400446wb, + 5684104948137619484333794789281535519196217253613879268155482366016410402198153437845962821374710383639946025491278662358930601323825409782517946368713730166779501012971475wb, + 32087820847816972971171692099083158156912701591228441301893931157856913053317602595432786417564970426631926727346659054532034068327088444234192931989166459782227197939321057wb, + -21721263360652995330393989849576970088245889949682845009460695472717466152081539971263312012527739590286540576183877575156900293418340395132947924863443109127173995560078279wb, + -15480195498062309558312832142884391233286002177523144097946171600675924728664105138320506609593544010951582863517501340004263677508611453722210182190275179605668158636665993wb, + 55995880469793772523539449728006933885804379190436425191858349409824731357990351725719664053451797096177518772823017250471021319053248877819795135618917529149253258308759354wb, + 24370295507731130004798276928243731386820125439099070643489522771145691875100529624831680686321147169119505764999828531144118172785865370931653507615753544737698580795350286wb, + -13016142173054302003336690685586422149429100823007010246177815738538602088089262263144796610097444570064192302085091825355979550567585055268099892750197109319237803857300389wb, + -35368478429854967484145020710656986046297257815593959870285507974957270671233443946755652228033821286859588583452449353741836352125387357246827468277473775502648515381353900wb, + 58764573942155814375791739663233093461596472170763698081763161612851239717416911428930198048960628406552049393162750872881771056037803284665755551481777372772007145066447638wb, + 44433183924809544824417284909271563263644800797277575618994531425499154930034075648536496209651260196970467671003251328672885483954369513730487082628591112972000580073953662wb, + }; + static const _BitInt(575) r575[16] = { + 22872451846054556417350916741013404184330732279497241442289048103235716890482482649099537178446621346041121532737887637378213104798444471078041166778940100084060290561371455wb, + 17785619680254441647827488871998638273432777299970128558821267200272839955229298488625220894043625699693270092672797162273950619203800446486815325568472958573446749051572825wb, + 38120499666250922171546613830180673200675976218799529299148065967941552755802535392332731940070002883710338820964987361658591561975335652756278138538832118604974787875400446wb, + -734234098097989409262727998397700256489421637915860389242752385873657556883074595636809785650192226409399868870242355685621686958186408269916495700324885703256092385869434wb, + 21703548306654828422881171931811440617567232925929621047938944826274955122606664179955511692787137409674737460976041867927943552583691691300165016729177283086471793752300456wb, + 26132710036535820372804820434723627712036525396244440920377271153766059995978577234280974829431879549681083853195499953729715766325604759212344321343859158691727036603084808wb, + -772498050957wb, + -17640736973552882046941821064235973435654602283914963062775wb, + 15480195498062309558312832142884391233286002177523144097946171600675924728664105138320506609593544010951582863517501340004263677508611453722210182190275179605668158636665993wb, + 55995880469793772523539449728006933885804379190436425191858349409824731357990351725719664053451797096177518772823017250471021319053248877819795135618917529149253258308759354wb, + 24370295507731130004798276928243731386820125439099070643489522771145691875100529624831680686321147169119505764999828531144118172785865370931653507615753544737698580795350286wb, + -13016142173054302003336690685586422149429100823007010246177815738538602088089262263144796610097444570064192302085091825355979550567585055268099892750197109319237803857300389wb, + -35368478429854967484145020710656986046297257815593959870285507974957270671233443946755652228033821286859588583452449353741836352125387357246827468277473775502648515381353900wb, + 58764573942155814375791739663233093461596472170763698081763161612851239717416911428930198048960628406552049393162750872881771056037803284665755551481777372772007145066447638wb, + -49246536424904916635319663180286717016047461257207957146338535716423124695209459892760482984419623560832895613229564098885770525356171820890930378678203734061651571774762747wb, + -24090226615157470281984717279507286428793968193916029900229071481754838071202669524668562579828294907607719783763180294251525168293397875645175326412340936012077133238990588wb + }; + test575 (p575, q575, 31); + test575 (p575 + 8, q575 + 7, 0); + for (int i = 0; i < 16; ++i) + if (p575[i] != r575[i]) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-15.c.jj 2023-07-27 15:03:24.249234243 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-15.c 2023-07-27 15:03:24.249234243 +0200 @@ -0,0 +1,264 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) void +test135_171_192 (_BitInt(135) *p, _BitInt(171) *q, _BitInt(192) *r, + unsigned _BitInt(135) *s, unsigned _BitInt(171) *t, + unsigned _BitInt(192) *u, int n) +{ + p[5] = q[0]; + q[5] = p[0] + p[1]; + p[6] = r[0]; + r[5] = p[1]; + q[6] = r[1] + r[0]; + r[6] = q[1]; + p[7] = (unsigned _BitInt(135)) t[0] + (_BitInt(135)) t[1]; + q[7] = s[0]; + p[8] = u[0]; + r[7] = s[1]; + q[8] = u[1]; + r[8] = t[1]; + s[5] = q[2] - q[3]; + t[5] = p[2]; + s[6] = r[2]; + u[5] = p[3]; + t[6] = r[3]; + u[6] = q[3]; + s[7] = t[2]; + t[7] = s[2]; + s[8] = u[2]; + u[7] = s[3]; + t[8] = u[3]; + u[8] = t[3]; + u[9] = ((_BitInt(171)) (p[2] + p[3]) + q[2]) + u[2]; + p[9] = q[4] < p[4]; + q[9] = t[4] >= u[4]; + s[9] = ((_BitInt(171)) p[4]) << n; + t[9] = ((_BitInt(171)) s[4]) >> n; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test522_547_575 (_BitInt(522) *p, _BitInt(547) *q, _BitInt(575) *r, + unsigned _BitInt(522) *s, unsigned _BitInt(547) *t, + unsigned _BitInt(575) *u, int n) +{ + p[5] = q[0]; + q[5] = p[0] + p[1]; + p[6] = r[0]; + r[5] = p[1]; + q[6] = r[1] + r[0]; + r[6] = q[1]; + p[7] = (unsigned _BitInt(522)) t[0] + (_BitInt(522)) t[1]; + q[7] = s[0]; + p[8] = u[0]; + r[7] = s[1]; + q[8] = u[1]; + r[8] = t[1]; + s[5] = q[2] - q[3]; + t[5] = p[2]; + s[6] = r[2]; + u[5] = p[3]; + t[6] = r[3]; + u[6] = q[3]; + s[7] = t[2]; + t[7] = s[2]; + s[8] = u[2]; + u[7] = s[3]; + t[8] = u[3]; + u[8] = t[3]; + u[9] = ((_BitInt(547)) (p[2] + p[3]) + q[2]) + u[2]; + p[9] = q[4] < p[4]; + q[9] = t[4] >= u[4]; + s[9] = ((_BitInt(547)) p[4]) << n; + t[9] = ((_BitInt(547)) s[4]) >> n; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + static _BitInt(135) p135[15] = { + -21017626881393060962682831099345275646127wb, + 3694296893212130938499913614460066245857wb, + -346978153630491292366720842786572608600wb, + -12051883812785324688960115817645360041052wb, + 894554736479161756765856528934783wb, + 0, 0, 0, 0, 0, + -10126751695395432170173641758862456728384wb, + 5972941260331487493885375988782293547456wb, + 1994359513041991206938472369666304432410wb, + -6563811307898601259032789037472160962572wb, + 0wb + }; + static _BitInt(171) q171[15] = { + -625366993761622480400669212262678861717858330946368wb, + 824211109381944261174032176940659654188131012437179wb, + 546292738086463798921197562372110173424343217923278wb, + 511148834019524346739032507408677732131367119592267wb, + 347611384453999342493570524785293850801864814800614wb, + 0, 0, 0, 0, 0, + -17323329988180930024182917484885209400270wb, + -1427703038865092853121951937517407564490420667866520wb, + 38147269358417182782171905780014948953272wb, + 467958077036848086326034408503276340843337835865495wb, + 0wb + }; + static _BitInt(192) r192[15] = { + 1392184189278706283348529493736576751111606618688367065536wb, + 1141852629791713898948497335488732622599274881068663548072wb, + -2714462128387415582772926191122594432964111301268533078042wb, + 2425769388758313376333650042373508250767256770936531653671wb, + 2720431110756499648348639705956093809255126267584967484234wb, + 0, 0, 0, 0, 0, + 3694296893212130938499913614460066245857wb, + 824211109381944261174032176940659654188131012437179wb, + 24158489198104933635096197097903724015499wb, + 606766803137851050688065717544996275384988908585315wb, + 0wb + }; + static unsigned _BitInt(135) s135[15] = { + 38147269358417182782171905780014948953272uwb, + 24158489198104933635096197097903724015499uwb, + 15056704170354189252536066857287800623071uwb, + 25206995790075003034339862074263410882988uwb, + 19207954769547491779143235037830592504231uwb, + 0, 0, 0, 0, 0, + 31754930256886813275958100253331871451523uwb, + 15245728220153286789447947809930478163942uwb, + 9156112246512545688879043617340759142722uwb, + 40264644850602433398431024975343109499285uwb, + 41168227647461841063600478959378800574464uwb + }; + static unsigned _BitInt(171) t171[15] = { + 485349495244621624686447991535899196145754495768503uwb, + 606766803137851050688065717544996275384988908585315uwb, + 333199438528630292656855934377866394553406065406274uwb, + 2139385105954223838532102833374805075850015235549769uwb, + 1678008128571185237771726930519720682651619103697237uwb, + 0, 0, 0, 0, 0, + 2993155353253342198327516046110580903412563275406248uwb, + 2550578100027524622604893738184060999550811074270247uwb, + 15056704170354189252536066857287800623071uwb, + 699234106698292061166730462199993896682394735156989uwb, + 4367383273699372643737486905uwb + }; + static unsigned _BitInt(192) u192[15] = { + 4671639464410605725298192070070307015392908693211956881396uwb, + 715636974522854835742140132808616653707176693849553888663uwb, + 457579096729186368426895847730802215502050535098936945045uwb, + 1103175995161405903311011421434916994075193954478175624957uwb, + 5439093776557462873830329048469734037495210381156250832820uwb, + 0, 0, 0, 0, 0, + 6277101735386680751783905610422341727142239626818674471844uwb, + 511148834019524346739032507408677732131367119592267uwb, + 25206995790075003034339862074263410882988uwb, + 2139385105954223838532102833374805075850015235549769uwb, + 457579643021924442491832802512548606285387299010222218671uwb + }; + test135_171_192 (p135, q171, r192, s135, t171, u192, 42); + for (int i = 5; i < 10; ++i) + if (p135[i] != p135[i + 5] + || q171[i] != q171[i + 5] + || r192[i] != r192[i + 5] + || s135[i] != s135[i + 5] + || t171[i] != t171[i + 5] + || u192[i] != u192[i + 5]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static _BitInt(522) p522[15] = { + 1688583697238081957015024340932764748327491668109158685467058555721380506305071231550264349039164029945469865795968233973631543964236809100573066960995245177wb, + 150663282285775450662414365350419405945541820765219523130929531002923088277160545114254251148525286476983773283235468282002045173141196158353616014355287094wb, + -479060863800931266429781304885104017131749664329186246406335179483194313801808166262041921602861985862332756318078499039394820190197870580545316549380449074wb, + 1359131269843466711194682581441372588504604777186075559309941421522168913086212721229905012023237380094986736934464910421922092415050027946837562847761546642wb, + 38005189198839309539384162035472227153066377585338581102543574055575777451369497515143095968263424053357137645031423561696064649082930963wb, + 0, 0, 0, 0, 0, + 1911076617401423887269840833410267237705130466676958152037861477885277722749139605040038160132075189228439111066941630564324402605816835862488337890450123441wb, + 2143747820933189266943449152733920616973804237879618575235243631855378946947754007625444647681930476713800905339559157073740302180956472245149919774437085550wb, + 3020328738802050781697314194154464021447637901030508296205170033161531452424686777206896481266404991349073132253866303142608091273541629412071886412132279688wb, + 3548552946267883916132218767540000478942702862442658213517298532968411704728913569849574500607350293984423898514369017381981825383513090204371793724097677500wb, + 0wb + }; + static _BitInt(547) q547[15] = { + -165353820935998006231385303476800492106677276950834360813262262140867129737290132086107434762098834639119492256272880571578714556242252134191835397505691625332102479wb, + 183695555784071631934553514377048200879108759149452364923958570648444896373196632060114376244737698247102365620343713172199496472928539579603161884440477984840044187wb, + 139975743565335456314316356647588328869546947948448304225648231332737456493208842047425843515598984558359834966436458515450535075922755618635258426884425597017306862wb, + -68977268331926408936317559581002324220146009615687701127254186456806021645364222184642001923334926042747842307638529875034306779796443629804024646337944171607895438wb, + 91932189605038085807227077574075596679601857184786010334359253878486168031464536332131456527844457578512045265477412819469725001337530261064906167819503147594853366wb, + 0, 0, 0, 0, 0, + 1839246979523857407677438706283184154273033488874378208597988086724303594582231776664518600187689316422453639079203702255633589137378005258926682975350532271wb, + 49151230401218799957130323446282917069028231656715550463945235235623430774823230155689924560414670278246826717504404635655151576036315823360722825188858286217308439wb, + 9553161692302515408090681902990032962274757557255101236499698228392460650767938620693069133770230123184487473131034348424915457011452743114281594442529356918wb, + 148466349169509850971880825885649862512888667929683428885486286008574376924695036417770580112507292038258577594242665019379719515779240480203475588034326681778827837wb, + 0wb + }; + static _BitInt(575) r575[15] = { + 26826731245669206245461391126964073367685598786847623620556904941634299886033194729072082303506281733460775551098898854360334228479162479457887049265892154734615530822766958wb, + -17252637235610200065109317402231975926530699783926188946291304643884915080832768297094963378392971235218154081350840664198841060114648240981027529664968282740385246545569879wb, + -52927846040946009564438022882734367309063070035915874157090678963969555482365010516321242268874731309847996546526357803037049653154886399755465425844249799943139498370138356wb, + 43797192926762436278400269352553576566711887692587698009480808423919842536790683665562833898774167035902777714908510813261288364232387952547718429572231820909634939092793538wb, + 20234448725793738746286884524404371396011280587539411448314107254021820060093226611203035940379115510914907477160212849326875709895927134019157662749025851187493640146044781wb, + 0, 0, 0, 0, 0, + 150663282285775450662414365350419405945541820765219523130929531002923088277160545114254251148525286476983773283235468282002045173141196158353616014355287094wb, + 183695555784071631934553514377048200879108759149452364923958570648444896373196632060114376244737698247102365620343713172199496472928539579603161884440477984840044187wb, + 4851258619379431619519122339214063398230494067942295987016754503060997355109186638667322723996572842157209194651881355085513631695628096402419719096882984119wb, + 270940858229872855030935066513853051367534588484589172383739756326100509416298021769516239928911004114519037087137992976731526127660469862578530915810061315551592797wb, + 0wb + }; + static unsigned _BitInt(522) s522[15] = { + 9553161692302515408090681902990032962274757557255101236499698228392460650767938620693069133770230123184487473131034348424915457011452743114281594442529356918uwb, + 4851258619379431619519122339214063398230494067942295987016754503060997355109186638667322723996572842157209194651881355085513631695628096402419719096882984119uwb, + 6042770678215430693640419990277820504092375118859355031950453294245655804901016852383090438332300632578629742514358616423826815593825261808316937209844323511uwb, + 12051208019451501933403724997574202861308205865422702777923943166771946439789370797531339169859679650622650974816793351928749417853531441599839154382248843947uwb, + 4221662083598509731422820533439331938122897651286500598721158769592271101088973546986107452648130743363570867708770978567950497328105753210259754199339698436uwb, + 0, 0, 0, 0, 0, + 7875787883122370015751284313157111317906983827437747001268058546750891954500439966161560575930887369730973089278944338386239832138713121400371960426603537532uwb, + 1744137654875073805109882450938570695232931878270397801451971688045434401366666192926859108662009962657770297731676696275736871955838688525022864084574797580uwb, + 1384759081458967898144776881134701550216992364037761109180860974761009009582780990796335747812536429464522433496147744197656107248393986692577240524935263967uwb, + 5124843933530741349702512002787631405197501632531242713014934699385673582868823319052853705098680028945536856890553829308345383420583019490169170519445809329uwb, + 167148589759802650246016819120863239719632156514525854640607511535259699817887971573240690630534000867480233158226351195963838422746014594980644913152uwb + }; + static unsigned _BitInt(547) t547[15] = { + 118704181285368794475444886856018739380810770111464325340905883331118179085356913273672350794295633026214255802587734669771992302197074150034392332589894477800891435uwb, + 270940858229872855030935066513853051367534588484589172383739756326100509416298021769516239928911004114519037087137992976731526127660469862578530915810061315551592797uwb, + 148318595435099152643319192673870560615622574014851374282185242873863044665507345404380126683143560616100080924441878075099797842853873146415865873849906128482858719uwb, + 400009336874533540769201404797235801738671871521831649835366524748844548359672560304665337919920648881530376390480880285772783211641574132727624581374918623770667162uwb, + 312402853341542293879363014443999872603984243465217297921316340174779530859340793778010030453656373118302384722907441723040044092150534190429029290814183834885671793uwb, + 0, 0, 0, 0, 0, + 460688772082162445798867876757263237463152967782366598900331124229116988777566044118861599994996502169289915386539783342538027404687796097956601373975276229385346254uwb, + 110154623692678850196652173379922527637463658741605878515537649114990721104784513051339522805651918716345423521491055109328010793688754512750702811781309047768676546uwb, + 6042770678215430693640419990277820504092375118859355031950453294245655804901016852383090438332300632578629742514358616423826815593825261808316937209844323511uwb, + 399932168246430744543441055162559648552560119213629719844739099564504242321283467689573394637126627461985951275205392441444721842415628268892060247464270805433239423uwb, + 959894824427126361893629230835206712554940543506404673899205310952372906533349475236288402049497277258426690357003048704416527773015730692863997uwb + }; + static unsigned _BitInt(575) u575[15] = { + 99465403292080375994166564143758974423715332054535509951564765439354460753284837794651681099567775806058182781885452212314717097157170419602135858778485292072068230160566460uwb, + 88608049883790202897201248133818379667781926476953929504091250051759382873398323059272759974739854128718622623196375150866798266503497028016169226040920220555730755500552765uwb, + 109996629797150279215121425420517668082012320009431263010584742106213909329388552729870453505045429145144806346761163201752908500506299217142569716987778685190706093716744369uwb, + 79085012468256116329498575277619682348270018511342269619476165669326091481750859826134218624634485255862979362030324907252864643018828592244764325998135532395602379128096639uwb, + 66159275290347502690275324386397674256469688848451250551469155682688473691401346605236603803735518810344975633814051516285290687587632060625865757225821322257077271128705141uwb, + 0, 0, 0, 0, 0, + 1359131269843466711194682581441372588504604777186075559309941421522168913086212721229905012023237380094986736934464910421922092415050027946837562847761546642uwb, + 123665200667574998698324851573506035436563350330459910341343826919194426096459911939793978345979520571463909670260227362037152642119068825187329447746921937620359214466454130uwb, + 12051208019451501933403724997574202861308205865422702777923943166771946439789370797531339169859679650622650974816793351928749417853531441599839154382248843947uwb, + 400009336874533540769201404797235801738671871521831649835366524748844548359672560304665337919920648881530376390480880285772783211641574132727624581374918623770667162uwb, + 109996629937126023660527287777369469494501925435246782331888159188751453565732251262053894836875827628606881325496392400843347632343245675592597560475194478367377989115148799uwb + }; + test522_547_575 (p522, q547, r575, s522, t547, u575, 42); + for (int i = 5; i < 10; ++i) + if (p522[i] != p522[i + 5] + || q547[i] != q547[i + 5] + || r575[i] != r575[i + 5] + || s522[i] != s522[i + 5] + || t547[i] != t547[i + 5] + || u575[i] != u575[i + 5]) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-16.c.jj 2023-07-27 15:03:24.247234271 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-16.c 2023-07-27 15:03:24.247234271 +0200 @@ -0,0 +1,385 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 256 +__attribute__((noipa)) void +test135_192_228_256 (unsigned _BitInt(135) *p, unsigned _BitInt(192) *q, + unsigned _BitInt(228) *r, unsigned _BitInt(256) *s) +{ + r[6] = (_BitInt(135)) (p[0] + p[1] + p[2]); + s[6] = (_BitInt(135)) (p[0] - p[1] + p[2]); + r[7] = p[0] + p[1] - p[2]; + s[7] = p[0] - p[1] - p[2]; + r[8] = (_BitInt(192)) (q[0] + q[1] + q[2]); + s[8] = (_BitInt(192)) (q[0] - q[1] + q[2]); + r[9] = q[0] + q[1] - q[2]; + s[9] = q[0] - q[1] - q[2]; + p[6] = (_BitInt(135)) (r[0] + r[1] + r[2]); + q[6] = (_BitInt(135)) (r[0] - r[1] + r[2]); + p[7] = r[0] + r[1] - r[2]; + q[7] = r[0] - r[1] - r[2]; + p[8] = (_BitInt(192)) (s[0] + s[1] + s[2]); + q[8] = (_BitInt(192)) (s[0] - s[1] + s[2]); + p[9] = s[0] + s[1] - s[2]; + q[9] = s[0] - s[1] - s[2]; + r[10] = ((unsigned _BitInt(228)) ((_BitInt(135)) p[3])) + ((_BitInt(135)) p[4]) + ((_BitInt(135)) p[5]); + s[10] = ((unsigned _BitInt(256)) ((_BitInt(135)) p[3])) + ((_BitInt(135)) p[4]) + ((_BitInt(135)) p[5]); + r[11] = ((unsigned _BitInt(228)) p[3]) + p[4] + p[5]; + s[11] = ((unsigned _BitInt(256)) p[3]) + p[4] + p[5]; + r[12] = ((unsigned _BitInt(228)) ((_BitInt(192)) q[3])) + ((_BitInt(192)) q[4]) + ((_BitInt(192)) q[5]); + s[12] = ((unsigned _BitInt(256)) ((_BitInt(192)) q[3])) + ((_BitInt(192)) q[4]) + ((_BitInt(192)) q[5]); + r[13] = ((unsigned _BitInt(228)) q[3]) + q[4] + q[5]; + s[13] = ((unsigned _BitInt(256)) q[3]) + q[4] + q[5]; + p[10] = ((unsigned _BitInt(135)) r[3]) + ((unsigned _BitInt(135)) r[4]) + ((unsigned _BitInt(135)) r[5]); + q[10] = ((unsigned _BitInt(192)) r[3]) + ((unsigned _BitInt(192)) r[4]) + ((unsigned _BitInt(192)) r[5]); + p[11] = ((unsigned _BitInt(135)) s[3]) + ((unsigned _BitInt(135)) s[4]) + ((unsigned _BitInt(135)) s[5]); + q[11] = ((unsigned _BitInt(192)) s[3]) + ((unsigned _BitInt(192)) s[4]) + ((unsigned _BitInt(192)) s[5]); + p[12] = ((_BitInt(228)) ((_BitInt(135)) p[3])) < ((_BitInt(228)) ((_BitInt(135)) p[4])); + q[12] = ((_BitInt(256)) ((_BitInt(135)) p[3])) > ((_BitInt(256)) ((_BitInt(135)) p[4])); + p[13] = ((_BitInt(228)) ((unsigned _BitInt(135)) p[3])) <= ((unsigned _BitInt(228)) ((_BitInt(135)) p[4])); + q[13] = ((_BitInt(256)) ((unsigned _BitInt(135)) p[3])) >= ((unsigned _BitInt(256)) ((_BitInt(135)) p[4])); + p[14] = ((_BitInt(228)) ((_BitInt(192)) q[3])) < ((_BitInt(228)) ((_BitInt(192)) q[4])); + q[14] = ((_BitInt(256)) ((_BitInt(192)) q[3])) <= ((_BitInt(256)) ((_BitInt(192)) q[4])); + r[14] = ((_BitInt(228)) ((unsigned _BitInt(192)) q[3])) >= ((unsigned _BitInt(228)) ((_BitInt(192)) q[4])); + s[14] = ((_BitInt(256)) ((unsigned _BitInt(192)) q[3])) > ((unsigned _BitInt(256)) ((_BitInt(192)) q[4])); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test470_512_519_575 (unsigned _BitInt(470) *p, unsigned _BitInt(512) *q, + unsigned _BitInt(519) *r, unsigned _BitInt(575) *s) +{ + r[6] = (_BitInt(470)) (p[0] + p[1] + p[2]); + s[6] = (_BitInt(470)) (p[0] - p[1] + p[2]); + r[7] = p[0] + p[1] - p[2]; + s[7] = p[0] - p[1] - p[2]; + r[8] = (_BitInt(512)) (q[0] + q[1] + q[2]); + s[8] = (_BitInt(512)) (q[0] - q[1] + q[2]); + r[9] = q[0] + q[1] - q[2]; + s[9] = q[0] - q[1] - q[2]; + p[6] = (_BitInt(470)) (r[0] + r[1] + r[2]); + q[6] = (_BitInt(470)) (r[0] - r[1] + r[2]); + p[7] = r[0] + r[1] - r[2]; + q[7] = r[0] - r[1] - r[2]; + p[8] = (_BitInt(512)) (s[0] + s[1] + s[2]); + q[8] = (_BitInt(512)) (s[0] - s[1] + s[2]); + p[9] = s[0] + s[1] - s[2]; + q[9] = s[0] - s[1] - s[2]; + r[10] = ((unsigned _BitInt(519)) ((_BitInt(470)) p[3])) + ((_BitInt(470)) p[4]) + ((_BitInt(470)) p[5]); + s[10] = ((unsigned _BitInt(575)) ((_BitInt(470)) p[3])) + ((_BitInt(470)) p[4]) + ((_BitInt(470)) p[5]); + r[11] = ((unsigned _BitInt(519)) p[3]) + p[4] + p[5]; + s[11] = ((unsigned _BitInt(575)) p[3]) + p[4] + p[5]; + r[12] = ((unsigned _BitInt(519)) ((_BitInt(512)) q[3])) + ((_BitInt(512)) q[4]) + ((_BitInt(512)) q[5]); + s[12] = ((unsigned _BitInt(575)) ((_BitInt(512)) q[3])) + ((_BitInt(512)) q[4]) + ((_BitInt(512)) q[5]); + r[13] = ((unsigned _BitInt(519)) q[3]) + q[4] + q[5]; + s[13] = ((unsigned _BitInt(575)) q[3]) + q[4] + q[5]; + p[10] = ((unsigned _BitInt(470)) r[3]) + ((unsigned _BitInt(470)) r[4]) + ((unsigned _BitInt(470)) r[5]); + q[10] = ((unsigned _BitInt(512)) r[3]) + ((unsigned _BitInt(512)) r[4]) + ((unsigned _BitInt(512)) r[5]); + p[11] = ((unsigned _BitInt(470)) s[3]) + ((unsigned _BitInt(470)) s[4]) + ((unsigned _BitInt(470)) s[5]); + q[11] = ((unsigned _BitInt(512)) s[3]) + ((unsigned _BitInt(512)) s[4]) + ((unsigned _BitInt(512)) s[5]); + p[12] = ((_BitInt(519)) ((_BitInt(470)) p[3])) < ((_BitInt(519)) ((_BitInt(470)) p[4])); + q[12] = ((_BitInt(575)) ((_BitInt(470)) p[3])) > ((_BitInt(575)) ((_BitInt(470)) p[4])); + p[13] = ((_BitInt(519)) ((unsigned _BitInt(470)) p[3])) <= ((unsigned _BitInt(519)) ((_BitInt(470)) p[4])); + q[13] = ((_BitInt(575)) ((unsigned _BitInt(470)) p[3])) >= ((unsigned _BitInt(575)) ((_BitInt(470)) p[4])); + p[14] = ((_BitInt(519)) ((_BitInt(512)) q[3])) < ((_BitInt(519)) ((_BitInt(512)) q[4])); + q[14] = ((_BitInt(575)) ((_BitInt(512)) q[3])) <= ((_BitInt(575)) ((_BitInt(512)) q[4])); + r[14] = ((_BitInt(519)) ((unsigned _BitInt(512)) q[3])) >= ((unsigned _BitInt(519)) ((_BitInt(512)) q[4])); + s[14] = ((_BitInt(575)) ((unsigned _BitInt(512)) q[3])) > ((unsigned _BitInt(575)) ((_BitInt(512)) q[4])); +} +#endif + +#if __BITINT_MAXWIDTH__ >= 574 +__attribute__((noipa)) void +test138_192_523_574 (unsigned _BitInt(138) *p, unsigned _BitInt(192) *q, + unsigned _BitInt(523) *r, unsigned _BitInt(574) *s) +{ + r[6] = (_BitInt(138)) (p[0] + p[1] + p[2]); + s[6] = (_BitInt(138)) (p[0] - p[1] + p[2]); + r[7] = p[0] + p[1] - p[2]; + s[7] = p[0] - p[1] - p[2]; + r[8] = (_BitInt(192)) (q[0] + q[1] + q[2]); + s[8] = (_BitInt(192)) (q[0] - q[1] + q[2]); + r[9] = q[0] + q[1] - q[2]; + s[9] = q[0] - q[1] - q[2]; + p[6] = (_BitInt(138)) (r[0] + r[1] + r[2]); + q[6] = (_BitInt(138)) (r[0] - r[1] + r[2]); + p[7] = r[0] + r[1] - r[2]; + q[7] = r[0] - r[1] - r[2]; + p[8] = (_BitInt(192)) (s[0] + s[1] + s[2]); + q[8] = (_BitInt(192)) (s[0] - s[1] + s[2]); + p[9] = s[0] + s[1] - s[2]; + q[9] = s[0] - s[1] - s[2]; + r[10] = ((unsigned _BitInt(523)) ((_BitInt(138)) p[3])) + ((_BitInt(138)) p[4]) + ((_BitInt(138)) p[5]); + s[10] = ((unsigned _BitInt(574)) ((_BitInt(138)) p[3])) + ((_BitInt(138)) p[4]) + ((_BitInt(138)) p[5]); + r[11] = ((unsigned _BitInt(523)) p[3]) + p[4] + p[5]; + s[11] = ((unsigned _BitInt(574)) p[3]) + p[4] + p[5]; + r[12] = ((unsigned _BitInt(523)) ((_BitInt(192)) q[3])) + ((_BitInt(192)) q[4]) + ((_BitInt(192)) q[5]); + s[12] = ((unsigned _BitInt(574)) ((_BitInt(192)) q[3])) + ((_BitInt(192)) q[4]) + ((_BitInt(192)) q[5]); + r[13] = ((unsigned _BitInt(523)) q[3]) + q[4] + q[5]; + s[13] = ((unsigned _BitInt(574)) q[3]) + q[4] + q[5]; + p[10] = ((unsigned _BitInt(138)) r[3]) + ((unsigned _BitInt(138)) r[4]) + ((unsigned _BitInt(138)) r[5]); + q[10] = ((unsigned _BitInt(192)) r[3]) + ((unsigned _BitInt(192)) r[4]) + ((unsigned _BitInt(192)) r[5]); + p[11] = ((unsigned _BitInt(138)) s[3]) + ((unsigned _BitInt(138)) s[4]) + ((unsigned _BitInt(138)) s[5]); + q[11] = ((unsigned _BitInt(192)) s[3]) + ((unsigned _BitInt(192)) s[4]) + ((unsigned _BitInt(192)) s[5]); + p[12] = ((_BitInt(523)) ((_BitInt(138)) p[3])) < ((_BitInt(523)) ((_BitInt(138)) p[4])); + q[12] = ((_BitInt(574)) ((_BitInt(138)) p[3])) > ((_BitInt(574)) ((_BitInt(138)) p[4])); + p[13] = ((_BitInt(523)) ((unsigned _BitInt(138)) p[3])) <= ((unsigned _BitInt(523)) ((_BitInt(138)) p[4])); + q[13] = ((_BitInt(574)) ((unsigned _BitInt(138)) p[3])) >= ((unsigned _BitInt(574)) ((_BitInt(138)) p[4])); + p[14] = ((_BitInt(523)) ((_BitInt(192)) q[3])) < ((_BitInt(523)) ((_BitInt(192)) q[4])); + q[14] = ((_BitInt(574)) ((_BitInt(192)) q[3])) <= ((_BitInt(574)) ((_BitInt(192)) q[4])); + r[14] = ((_BitInt(523)) ((unsigned _BitInt(192)) q[3])) >= ((unsigned _BitInt(523)) ((_BitInt(192)) q[4])); + s[14] = ((_BitInt(574)) ((unsigned _BitInt(192)) q[3])) > ((unsigned _BitInt(574)) ((_BitInt(192)) q[4])); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 256 + static unsigned _BitInt(135) p135[24] = { + 4187273188098476865668456823817923591884uwb, + 6807534906955493735159263291613578822092uwb, + 41026661032626929517457579844514879338728uwb, + 21107725719388574292787309710748598888876uwb, + 37762806761430755157975144430695583115875uwb, + 26495620887646122219041406684145481614415uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 24294442897610200845563470372394790405427uwb, + 14494728260279138634407444539578218061153uwb, + 35692618919905757032302955601299560733828uwb, + 2073608133107652132583703172274308589354uwb, + 23162446968047093866488519785733079173672uwb, + 23215356388255044329396934936113503903836uwb, + 0uwb, + 1uwb, + 0uwb + }; + static unsigned _BitInt(192) q192[24] = { + 2086085555369597859021791929925392355640686637062909369671uwb, + 2680579114698255110186052616880338377881530773942412775534uwb, + 3327728695296211902341553047509833116972847770197432421329uwb, + 5940317943727487997168783552089315457607206947999336887004uwb, + 5542354187267299678821667349861772942889507214082859925027uwb, + 3271998891636156295842018666243687525289384908182662772181uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 19403341198470336643414519815259741762743uwb, + 5896270732876306173690375572457711356577732208000026578149uwb, + 5124631678261056717896926088333660842277657529754581693718uwb, + 3443509077298665851293720223028023121358922119534917222332uwb, + 5756578284734093802702142887739107033567473420998759418408uwb, + 4630861060283249917347323439223922476602768583090317402204uwb, + 1uwb, + 0uwb, + 0uwb + }; + static unsigned _BitInt(228) r228[24] = { + 161966633757691155241945327015229701994331693366818788921573408319756uwb, + 38296346596827362616775983079516749483975676455899963878059782490174uwb, + 241591800199660287949868996521720659189646617902754527264229209396201uwb, + 428902738798964850544466128550714169355105701114620489106903291340964uwb, + 235528598555728562847947927417825731721784962388084030737368213942614uwb, + 256292789834236084059292238814861516121661392325304427878120090497070uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8465326161800776794973350208680050686336uwb, + 13524290028307164406682090022182954141616uwb, + 1817291629977384107713608171107897434392709736738720053638uwb, + 1438935974771641066866291499295897616549369640807889723876uwb, + 431359146674410236714672241390567958214899515783829121020714765473886uwb, + 85366153368465451669803860825589663619166uwb, + 431359146670333602531143143072639192076766087438128192434530520032980uwb, + 14754671022630943971832469568194775925786099070264859584212uwb, + 0uwb + }; + static unsigned _BitInt(256) s256[24] = { + 33689368506800899324387091792297880425309542585828646830789259960880991063584uwb, + 39571323848345650718084485253626478678560275338021939071625078673058668106679uwb, + 110504693488819055796063554254198165064817853023249665372075921323272516500141uwb, + 102297428517176642359444223748374693989314404662584768443522888625651626181283uwb, + 80244728165314710913956389448156622901095909768247496334097456157707270969074uwb, + 103665915010005983358711046736784166330673952063454224485339530724102504302279uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 115792089237316195423570985008687907848120241013530353364112407633366022682088uwb, + 43465363180276300259675513190222127563800uwb, + 2733235135967554651177292360554887094732003633317929015466uwb, + 2354879480761811610329975688742887276888663537387098685704uwb, + 115792089237316195423570985008687907851523852102345769062637545330970131126366uwb, + 85366153368465451669803860825589663619166uwb, + 115792089237316195419494350825158809533595085964212340716936616744785885685460uwb, + 14754671022630943971832469568194775925786099070264859584212uwb, + 0uwb + }; + test135_192_228_256 (p135, q192, r228, s256); + for (int i = 6; i < 15; ++i) + if (p135[i] != p135[i + 9] + || q192[i] != q192[i + 9] + || r228[i] != r228[i + 9] + || s256[i] != s256[i + 9]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static unsigned _BitInt(470) p470[24] = { + 290679861857217105576749510785172236097196317219002071340131005135259342235163792727727620685697644545754092322618593967328975789101613622756uwb, + 3007766161917260990990922308983802917798001363835330597758175849272351861703814650851622073672692222948955250827120638757725725607466346547961uwb, + 574060276709923148626402211078479568921550247040425483673763765831291153847648453629069366560426848580089729851582562589160127450838856742850uwb, + 1513032643015460548072615957037831807842396447090608200111284706851223881642236182620260811534047670872236957008209636843038402328412186623867uwb, + 736018121751614604248763744490396332128994581237940802611521314820643126961848250509301799425532301686788266718861244200351342613056372468552uwb, + 30155063271645468057678848208011195960933215968662731964986808367634269990062216294334734731269355557159014770813970386099476462377224708070uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2336276654669971355000545579045474018643499545251683574017489057360457587609182251538648565538596336349157530705582440962441081292975829750725uwb, + 2811887457092416012110559147431839355552932271928059605261212342070741952382405730371093476958614469776023370616340687057532287796176219869449uwb, + 1454614080118846581654283867177010224989739028600678358170065228650331074859011839166100981351630244514069807407054058295180885648638359156315uwb, + 1452099984535181412105251439415950646129930223001670876794248464265033550302786152371528494721306355739311614007226227128382131037961688117145uwb, + 1700131771206195433306793035837240564903007159128880173423363038992576767815643454391004339339329935701073991719473097155654566696420734301605uwb, + 687646008549017812028590579565520345681613774085522641973968443446824759773421489288886130070355380390157446333512774944224841451835655874095uwb, + 0uwb, + 0uwb, + 1uwb + }; + static unsigned _BitInt(512) q512[24] = { + 11999607180890662234640611094796125402682182607671756821443119677915957826104697013256706604957461530042481930446302956354396703791101848051437136984190670uwb, + 1669399929141703249463393746110522414573291237669539702537374904052097169767189303794997941915228747803109873985069631915369758962889453579386958506452828uwb, + 11378992935330313540343401440793120879643841271871581700686172052228324616806874974534345697693861690426360116949795282888644662188134499896194148433768387uwb, + 9993083190971384981726645923137348157759809443699348826766460590248782912389872021894301181692065821343040669086846645954670076835055767363529908044878460uwb, + 4194741102820399815388565886074911339757551809782406262401319165104710890785047966633447456093482200519894213755964462654816313685699735398967845201704233uwb, + 2421595337545745821088215118098296983215379552867408581490131959698723606384411644669422390261525987191387981272012502904825570949628276538570672660290088uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1513903473639259387274129463605791299347099137673287344952013483163916537193546764015586855259820134007663746976291793381162392640818043683999uwb, + 12277156682318352235712463688522823330952278031457456554222055921981909263024261498262481023121115845377546131965398459894872235113782544708914458317029859uwb, + 4027845254315197169423233647114376033430305844071443075105613565290966574715062841638133555232740863237407025233981863916917198547523085200055676796066563uwb, + 10707639349311374361511081362429794348061398948029634783963376915733257208356397594815368492279579755336561685612483789993986308827288890748132804532704321uwb, + 11909891944680678452073045961414477447224653685643721320079864331428768064778333088269746747399111241079878764522077445502337140106279379768026249427056037uwb, + 5596625625751028170955045723080584878265817548746738005171988990687430526534540571089022256509279287347335747951148567883951414510786508005390890674578991uwb, + 1uwb, + 1uwb, + 1uwb + }; + static unsigned _BitInt(519) r519[24] = { + 1030342010401113812244886675533462199253435182769422147430754601621146628252085744300635665226057568402783959871999680067593144181093412956713229194456894164uwb, + 1399286804337892133001051165724092281210924970185276871571622362921173888386145177372320997003882614750136133472548611361735698398271314700469097220046489491uwb, + 1187491577184187187658283970910931091626643735561997844498566871693437222121521301715871480084581538847004007675304538195851777836706064395267954449805214046uwb, + 1590038038660143030887559697627655997346700459420257472659393551660904723658903805269248515919541163543209428329235720802030325145482255847896549116166445779uwb, + 884402951942479884942778411278542758813719790602900630698855595508395145632292880569268024966776717352051287824788383446062053991609910742048548988449536210uwb, + 326292950770117959333132136682031715802512494345703440528331497456255817028879418424543059879797143305345789113287071774990765627898999338681127138076566016uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 823923731816440081735482986127565752359132554398497263261175151854750269095449533809682632145875337989030585578073140142878915098101850794143uwb, + 2724385747064554947941269608690495584973647434013907185424543088576320050091329989950280327797963018914619613298156670135894573945729103427867uwb, + 1714431799218129913570774556055636380759299408511854443817835408543138647401945680368622211813596383857215966052878410278731400359247393614777658018691007981uwb, + 2290014174702051943760603400113526937611632573469714823294322529739730379065011342517358849178828587419231687481577305381121800565856801734629947056875111uwb, + 2279205828038720620379058549736239335932324244297211734687792830039501278594146649423897345690849328116184238497884851429489221403845783800489uwb, + 2279205828038720620379058549736239335932324244297211734687792830039501278594146649423897345690849328116184238497884851429489221403845783800489uwb, + 3201611701394933518629401929104710353253374985756770292934350271330453379485784656395296729880170581364291005928337560660558078658437209354634776900788685uwb, + 16609419631337530618203426927310556480732740806349163670657911715052217409559331633197171028047074009054322864114823611514311961470383779301068425906872781uwb, + 1uwb + }; + static unsigned _BitInt(575) s575[24] = { + 96927313110651552741697906285845027560278665167912446772243994455709167318164555507475733363294500975052442014691905285678776198101396126432691790596947740988776944060654926uwb, + 102707772385622802706823804871287360126470122215207829602545757786870641626119828685986043329520959072898431094747590180228385563652833016000194460109692900249703592758013356uwb, + 110583747014804561196219218561034468168713024547408050239450245043477530907411843124501635977214033600051542621634445064425297114819990148482732834711384300709771384106312545uwb, + 54306775370484796829739172393424070839859954453514190131950827429084664762249620446751937114044786249494515203860165437770921772021031551664278887501083036990545747406428169uwb, + 46114759885997746928772223321204027410936673207704735367438056888037044881883997045448409583831956188379542065205564192543381437121786101651883495914008056100188006564313178uwb, + 35190453913973191463478013966823372048936778121696189495901809463574016396767724553244869787736619209084040172125210006605333310947417602727114932375121134023666009552590284uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 905556545317840426670820457599737857678360574120357846766614390078350723070174958903911342346373648262657058770329172970099291381779089937069uwb, + 2806018560565955292876607080162667690292875453735767768929982326799920504066055415044509037998461329188246086490412702963114950229406342570793uwb, + 123665200736552267025144844837017673343938243343672951569825529047137624617410727523806857743618811225191141477410357286961350974191432110603936918943400338433680414973687605uwb, + 12359022246361242544407840906098328235944415918723028795943134165357300069604179711729237263515274519503043797697924092404136165452024464522289679050053551uwb, + 2279205828038720620379058549736239335932324244297211734687792830039501278594146649423897345690849328116184238497884851429489221403845783800489uwb, + 2279205828038720620379058549736239335932324244297211734687792830039501278594146649423897345690849328116184238497884851429489221403845783800489uwb, + 3201611701394933518629401929104710353253374985756770292934350271330453379485784656395296729880170581364291005928337560660558078658437209354634776900788685uwb, + 16609419631337530618203426927310556480732740806349163670657911715052217409559331633197171028047074009054322864114823611514311961470383779301068425906872781uwb, + 1uwb + }; + test470_512_519_575 (p470, q512, r519, s575); + for (int i = 6; i < 15; ++i) + if (p470[i] != p470[i + 9] + || q512[i] != q512[i + 9] + || r519[i] != r519[i + 9] + || s575[i] != s575[i + 9]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 574 + static unsigned _BitInt(138) p138[24] = { + 101422284254667607392742201719883227411625uwb, + 160466466586635795278252037831376082677350uwb, + 25107605609849786823351214520760656620933uwb, + 295969175246745649031682884402595713219313uwb, + 13181527086641487248448136085636319944955uwb, + 235130534778709326353598872018612896874473uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 167302456247167982996160810773690897220075uwb, + 297389206356979455260412959683265332806635uwb, + 335394759052458807357434855405547433962500uwb, + 321901396962914134364671486134447068161226uwb, + 120351777790732110377699121565672639601425uwb, + 198373944314536120634408834917264425196481uwb, + 1uwb, + 0uwb, + 1uwb + }; + static unsigned _BitInt(192) t192[24] = { + 911018684451330895893338523816772465484522458698266889768uwb, + 2046183627271691614636061554682220483052698404211100534853uwb, + 4678069061913127216263854322789964375230426789917042687454uwb, + 3459784480694777343275716409755634649190978443376335561303uwb, + 3867595273303447369888355921671728883273018646069926566645uwb, + 4813052987333975223830750234077960301742057680559503213273uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 6277101735386680684990022390197371509564931202241440203909uwb, + 1278608194268128077434264942601213585924783150489231066757uwb, + 4029427835151946963573253373549922510624267261072515255840uwb, + 672033229033398034156049846020027986275380626166731032294uwb, + 1357991472586126795792080074222943985598370321805879319313uwb, + 2856538916789713009071224987092580961800045494832854440897uwb, + 0uwb, + 1uwb, + 1uwb + }; + static unsigned _BitInt(523) r523[24] = { + 3195765699538496998535864601292347963256629173162679399458238383409531673496364786350189170351629279748663665677408547146700561030889355712400808816914064440uwb, + 11159477301642000894502707350448750665412836731536210953742141163262563390545287499722678844509966339767235942912910312315832667904302744531360002727358824115uwb, + 22101560948582634345286310809677329764046784779464227969587135587282924532940609616951363156766482627364659628549350689295905244730986420796580267097794699008uwb, + 3492227525200477614910950479637037651613240112641204783475954014565794311494477327458692721172240707535504736878649393132370069751011176314509944329056779358uwb, + 4470424684397392413407392569484317542436005833167916532642765757801563745613041876920796693178762870199674360069594704277190939739704629258367293449899462004uwb, + 13549742618125959998093915668094856307843206900469464436576203440358812289708508455667681082349827642620118118540849103671482396581682398406739495271235801407uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 27459190640522438859927603196325572869077741200573221637577853836742172733590624208490238562645818219909185245565923370695700676111069483100152175053778407572uwb, + 236781145231453615847643025030498653468042uwb, + 1358169638249468962957464978081290907665292208362375599179uwb, + 4556234985196576058101335178916694989409149517456359250063uwb, + 27459190640522438859927603196325572869077741200573221637577853836742172733590624208490238562645818219909185245565923279531437610013356035988992599748093205461uwb, + 544281237112096462633729892506844930038741uwb, + 27459190640522438859927603196325572869077741200573221637577853836742172733590624208490238562645818213218312780738081077635942247881191161149284549778122031141uwb, + 12140432741332199936994822565505323834206054770005765341221uwb, + 0uwb + }; + static unsigned _BitInt(574) s574[24] = { + 49523656310311432476097096707674348247864532997580458449189999134679927949102290921020347613627600560130921641399166416960416734901407545116688589513670229626633588928674165uwb, + 42569658590233851212367348547775997184555788503209190045856322440515976044599442772511746833320065456241311597243171150757254859304810272116865990700066734780242713347731186uwb, + 19981999860412564491215269984435969976814910925473334223760435541572601828084228297697056388524273994976358111097326046010839057122757304450178767567932398574496781000082333uwb, + 8558322198907185372332169456108688881070480268559248312027066736995799133128362338305761323248219317368913715505110464564580744145522428754123209057064241016828671823488793uwb, + 43811765949130776561433192718564194559949284938162910217959397270715482324290476494691373258084890889610745910962659657029995968487465144041804156738366622609326192386149788uwb, + 45992921207674703917316226268947032522368981737128477902399950788131403664441772601690186531393245791394478464207683996776726761730838587963296718352656413407075666840676108uwb, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576653865915164420374411133357560960838529992uwb, + 264297355785223011877634547377877136644286uwb, + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504032100640224964662421487833755255625414851874551633211704257uwb, + 463867730653192828829212069552254023303752709034158180357uwb, + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576535185441544553264934030675638276670151637uwb, + 544281237112096462633729892506844930038741uwb, + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504028143965376430734333289946182421100059190967588306698977317uwb, + 12140432741332199936994822565505323834206054770005765341221uwb, + 0uwb + }; + test138_192_523_574 (p138, t192, r523, s574); + for (int i = 6; i < 15; ++i) + if (p138[i] != p138[i + 9] + || t192[i] != t192[i + 9] + || r523[i] != r523[i + 9] + || s574[i] != s574[i + 9]) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-17.c.jj 2023-07-27 15:03:24.249234243 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-17.c 2023-07-27 15:03:24.249234243 +0200 @@ -0,0 +1,82 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +test192 (int a, int b, int c, int d, int e, int f, int g) +{ + _BitInt(192) r; + if (a) + r = 0wb; + else if (b) + r = -1wb; + else if (c) + r = 8509079622807245684wb; + else if (d) + r = -906140470171472463wb; + else if (e) + r = 16213049720239626860wb; + else if (f) + r = 147892183939833533694801609136018843670wb; + else if (g) + r = -65591640145960897840899726907249505215wb; + else + r = 2430673202376479588648422478850704999441011825542092986793wb; + return r; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +test575 (int a, int b, int c, int d, int e, int f, int g) +{ + _BitInt(575) r; + if (a) + r = 0wb; + else if (b) + r = -1wb; + else if (c) + r = 8509079622807245684wb; + else if (d) + r = -906140470171472463wb; + else if (e) + r = 16213049720239626860wb; + else if (f) + r = 147892183939833533694801609136018843670wb; + else if (g) + r = -65591640145960897840899726907249505215wb; + else + r = -61793624342683909782972416440098036406501521208177932544452266579025268523357080574330290352054553626825262073339234752683755828499698570848704076099511077751520231100121930wb; + return r; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + if (test192 (1, 0, 0, 0, 0, 0, 0) != 0wb + || test192 (0, 1, 0, 0, 0, 0, 0) != -1wb + || test192 (0, 0, 1, 0, 0, 0, 0) != 8509079622807245684wb + || test192 (0, 0, 0, 1, 0, 0, 0) != -906140470171472463wb + || test192 (0, 0, 0, 0, 1, 0, 0) != 16213049720239626860wb + || test192 (0, 0, 0, 0, 0, 1, 0) != 147892183939833533694801609136018843670wb + || test192 (0, 0, 0, 0, 0, 0, 1) != -65591640145960897840899726907249505215wb + || test192 (0, 0, 0, 0, 0, 0, 0) != 2430673202376479588648422478850704999441011825542092986793wb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (test575 (1, 0, 0, 0, 0, 0, 0) != 0wb + || test575 (0, 1, 0, 0, 0, 0, 0) != -1wb + || test575 (0, 0, 1, 0, 0, 0, 0) != 8509079622807245684wb + || test575 (0, 0, 0, 1, 0, 0, 0) != -906140470171472463wb + || test575 (0, 0, 0, 0, 1, 0, 0) != 16213049720239626860wb + || test575 (0, 0, 0, 0, 0, 1, 0) != 147892183939833533694801609136018843670wb + || test575 (0, 0, 0, 0, 0, 0, 1) != -65591640145960897840899726907249505215wb + || test575 (0, 0, 0, 0, 0, 0, 0) != -61793624342683909782972416440098036406501521208177932544452266579025268523357080574330290352054553626825262073339234752683755828499698570848704076099511077751520231100121930wb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-18.c.jj 2023-07-27 15:03:24.246234285 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-18.c 2023-07-27 15:03:24.246234285 +0200 @@ -0,0 +1,117 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint && int32plus } } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 251 +__attribute__((noipa)) _BitInt(251) +foo_251 (_BitInt(251) x, _BitInt(251) y, _BitInt(251) z) +{ + return (x * 42) + (y + z) * -13295847598437589437584395wb; +} + +__attribute__((noipa)) _BitInt(251) +bar_251 (_BitInt(251) x, unsigned _BitInt(211) y, _BitInt(251) z) +{ + if (x >= 139845735984wb || x <= -139845735984wb) + __builtin_unreachable (); + return (x * 42) + y * z; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 274 && defined(__SIZEOF_INT128__) +__attribute__((noipa)) _BitInt(574) +foo_574 (_BitInt(574) x, __int128 y, int z) +{ + return x * y + x * z; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 274 +__attribute__((noipa)) unsigned _BitInt(574) +bar_574 (unsigned _BitInt(574) x, _BitInt(231) y, unsigned _BitInt(231) z, unsigned _BitInt(574) a) +{ + _BitInt(287) w = y; + _BitInt(231) v = (_BitInt(231)) z; + _BitInt(287) u = v; + return x * w + a * u; +} + +__attribute__((noipa)) unsigned _BitInt(271) +baz_574 (unsigned _BitInt(271) x, _BitInt(574) y) +{ + if (y >= 139845735984wb || y <= -139845735984wb) + __builtin_unreachable (); + return x * (unsigned _BitInt(271)) y; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 251 + static _BitInt(251) s251[] = { + 14492268074422240072381201900068160215333038638908804267546082474872103453wb, + 675218251468166080020913826378654880460963853057558284085495091870180550wb, + -675218251468166080020959605725458087975245668339558473870927889256690061wb, + -139845735981wb, + 324639141258847384727959753569292057577687203071371684930924253wb, + 1087290800830wb + }; + _BitInt(251) a251 = foo_251 (s251[0], s251[1], s251[2]); + if (a251 != 1217350477377202249120031439408588187131962868502518732097281406269161025871wb) + __builtin_abort (); + _BitInt(251) b251 = bar_251 (s251[3], s251[4], s251[5]); + if (b251 != 352977151880095667263614472150365012179801988966714554955131068402918618788wb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 574 + static _BitInt(574) s574 + = -219356128782553279814913626158411711140801689317931406799100755440262023325014648411412728943485405803043129187408541215111743475318581wb; +#ifdef __SIZEOF_INT128__ + _BitInt(574) a574 = foo_574 (s574, 82625523151678902953603407887262843433wb, -1845137725); + if (a574 != -18124414897185514989959611747585480593042904176332662608326479231051632926435887114574980277665683285141927551496724599123576825185653577703648854819279658769883513402160348wb) + __builtin_abort (); +#endif + static unsigned _BitInt(574) u574[] = { + 52437079816179410811636905891411754807147405868482583243559735153324503490239312503359712796401481190029201386135205713917847314204739635852931994918423899615130723009259686uwb, + 45269866460552189474732773540973151549203847819115194862112414296072167098695417407106646749337072175534165739911745591080506448641600205866240027517670273657001894552180234uwb, + 9180917912712609437909586196568830786346456714119640856730259437790973527459849487895103863584234525859590698749982125884487194000401583172193548884761272331911564480124878uwb, + 11049512233686559553687636036663446413022165259892524030717648180326957779916930880483808447448446584642734113622685260963900225478745988370450191005955141795745690734947571uwb, + 47663369272354253242910978827267365842851495123515313737663958515768452802250710665542640440990559573730917816406856556730100799652539291367902764980370386873495017607993411uwb, + 18215014622276393791745550421148998901660352490811211087424965165803902184090598141881549641537877241526565777992183348471991467868259791203907545956986039786453071578011434uwb, + 31740235950157332221439070489628722839769958133906789091713734411951000853909663917518016071789015372380206595539133512032995220911059581277451361109633464034310397164665564uwb, + 10450847162543795294901585004050399762545006892613453868263703161802323302908254646557151245191494710406620278412346326386062698341158038281632905480774145352377805385543092uwb, + 19453023158842453405396915599369210861261573519874550548893523502986640805175433191781338575797970717670733269190857402493766307964168520080852675173587364248259309552168430uwb, + 41244368675818170615108799247368989151384052534670384186902588532722396202878099538345240688084993610469542913084982675850069064350042690913662957238816036434888665664037846uwb, + 16719362016737006280008309688585219733130381598157287999202010698266470616548718462522730730476541950851348747767571521700255425942578137654761356039235313588531776459325708uwb, + 10475917472649802727102296550431840421435279490948846996006476240420369031587862359912739671064811272746210509826242404174149288385636488194271969135287801110662285317095981uwb, + 1163912911803352668493394805506325912661919234067386269274323760640925113542354050648690202267829712352143945896104268132186183304256748687336699391633352420957751382619669uwb, + 8802741787945718202007440863180520530918335416409181790035566968168103145420485853909047361251267032896173190843315221928932703515727560628431319297083973682964053958087246uwb, + 19791342948421817380238010195638893503615644292584928829415951859564239969766035100704913746176442012398341262166756998845831007892328794072245007765812537811265165604315700uwb, + 16642284329136906697237309134287786314682533828330755403465475806950133035971596597211127434533311710048393623437103786994963036388804007132262710130242198695003152238215628uwb, + 2155325970411161010229823956524370uwb, + 697446886254974788952071928578631979965uwb, + 108165657554251490446057511316485495uwb, + 9487120152929104576906851118100261958096487535uwb, + -136538663022088871346045694473572wb, + -1666960912074801530926062313122413146603wb, + -15940673946961553912565090695396320wb, + 264462353975419400604468749561884442664wb, + 50826882861731683785919742135963976479884717145067744452535625618737864973658554226615085532399945662542810296565555980855512176679463978891752486331179893311834461777517318uwb, + 16170033701813896205634802741964500343094214191596485883117074926829904835328260995277267910766680743976283458668064421272599104442706448899915189301332650772687724575723182uwb, + 13009027737564179578240898152688856367334005472217232817755080920783012286505432066490161649175068937710374621121911926344239719476459487715714492624089105621335225676985872uwb, + 49336707246523391872334763713437428863232354140618977476842520346079224652928216135156362963444355821534349959448992339768542254081420292190058456423815350822979116396882390uwb, + 1026180591140992942712368030740883182331172637458255292975945323684907793150051875uwb, + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761243411314314780717702156716099193191615778530561481120811604064555385654220uwb, + 3635377841759794164811391623635227990564259993543952474130713407348044048553863186uwb, + -139845735971wb + }; + for (int i = 0; i < 6; ++i) + if (bar_574 (u574[4 * i], u574[4 * i + 1], u574[4 * i + 2], u574[4 * i + 3]) != u574[i + 24]) + __builtin_abort (); + if (baz_574 (u574[30], u574[31]) != 1212103790378493380735221770817318414499452864884443699768488049528961780122040714uwb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-19.c.jj 2023-07-27 15:03:24.250234229 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-19.c 2023-07-27 15:03:24.250234229 +0200 @@ -0,0 +1,190 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint && int32plus } } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) void +test_135 (unsigned _BitInt(135) *p, unsigned _BitInt(39) *q, int i) +{ + p[3] = p[0] / p[1]; + p[4] = p[2] / *q; + p[5] = p[i] % p[1 + i]; + p[6] = p[2 + i] % q[i]; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) void +test_192 (unsigned _BitInt(192) *p, unsigned _BitInt(62) *q, int i) +{ + p[3] = p[0] / p[1]; + p[4] = p[2] / *q; + p[5] = p[i] % p[1 + i]; + p[6] = p[2 + i] % q[i]; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test_575 (unsigned _BitInt(575) *p, unsigned _BitInt(125) *q, int i) +{ + p[3] = p[0] / p[1]; + p[4] = p[2] / *q; + p[5] = p[i] % p[1 + i]; + p[6] = p[2 + i] % q[i]; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + static unsigned _BitInt(135) s135[] = { + 39967592296255191197035336461290090324829uwb, + 312558523056789678960549094065358uwb, + 32832062726968675550596542626872563693099uwb, + 0, 0, 0, 0, + 39684305085076546670125468925068uwb, + 6804617795530664696186192571276807994017uwb, + 908900452537968951389639987294090uwb, + 0, 0, 0, 0, + 20395215776806618633686937572550377003558uwb, + 1uwb, + 2017874535031304931048003948865783841241uwb, + 0, 0, 0, 0, + 16804502949303659647220377886348649uwb, + 15969624846496231063802991739581uwb, + 12583271616670577644431817717623569600333uwb, + 0, 0, 0, 0, + 127872348uwb, + 89851078235647451008683745245uwb, + 65571357606183724433879897404245uwb, + 87071527329uwb, + 0uwb, + 2093478262068616207802533uwb, + 39684305085076546670125468925068uwb, + 228138242uwb, + 20395215776806618633686937572550377003558uwb, + 12999486295301452164134194354389uwb, + 0uwb, + 65232213uwb, + 1052uwb, + 299601705158823277248376612324370704769uwb, + 4457610789624568099630576309437uwb, + 35uwb + }; + static unsigned _BitInt(39) s39[] = { + 365405328146uwb, + 434158056uwb, + 155227252uwb, + 42uwb + }; + for (int i = 0; i < 4; ++i) + { + test_135 (s135 + 7 * i, s39 + i, 0); + for (int j = 0; j < 4; ++j) + if (s135[7 * i + 3 + j] != s135[7 * 4 + 4 * i + j]) + __builtin_abort (); + } +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static unsigned _BitInt(192) s192[] = { + 1124505164324393257294640774883626666393496137407657383285uwb, + 267770052679215918410877624132556357420375522461819642uwb, + 4639722531344459905931256257525470190970246632351027146771uwb, + 0, 0, 0, 0, + 37076404019741709360338653279977uwb, + 4017103983634913740425503780735862298200532685100197316953uwb, + 3278541912894246916134094695331450716143029898422059693966uwb, + 0, 0, 0, 0, + 181260360652955273548771772757571198044332327135683350561uwb, + 3uwb, + 278424729322219534657080470631020618602047522343uwb, + 0, 0, 0, 0, + 1546922522984382736106987324181069322701408057466881095437uwb, + 2859498891267655913293729558067200232488079281528uwb, + 3754903553201168811081807274774774084224112858563658575772uwb, + 0, 0, 0, 0, + 4199uwb, + 1361868478710180046608174894774272890845uwb, + 138713124365615887365631151022521585339318590476706527uwb, + 704022636372799201uwb, + 0uwb, + 1800071738275562493471915107371110587374384505uwb, + 37076404019741709360338653279977uwb, + 989224815596uwb, + 60420120217651757849590590919190399348110775711894450187uwb, + 35811149155369659378220712438655uwb, + 0uwb, + 971271817233568uwb, + 540976787uwb, + 268207396657226343648700519626769577444579489897404183983uwb, + 356343883111794920610945410844353911944595204901uwb, + 10uwb + }; + static unsigned _BitInt(62) s62[] = { + 3406880035683564506uwb, + 1821339585074uwb, + 7774805776666105uwb, + 14uwb + }; + for (int i = 0; i < 4; ++i) + { + test_192 (s192 + 7 * i, s62 + i, 0); + for (int j = 0; j < 4; ++j) + if (s192[7 * i + 3 + j] != s192[7 * 4 + 4 * i + j]) + __builtin_abort (); + } +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static unsigned _BitInt(575) s575[] = { + 68262105478469356136430990337792292171975154797241096882998520215082649730969604949380226799284423285674920339289406073226899446201591827481846481242318203838114185414101609uwb, + 522191246473430521641066810210970739255168853016819760532584735359478867620239849176927824047731938802486584777452655079470889576128018146184619338332252916338uwb, + 3435470059299599312416077239534464560179043115309368866437635382063534713476732558299272800804091725646363342046360614869573337710790812486381755554721429381220646362uwb, + 0, 0, 0, 0, + 1395593888697848626057320338038084790564831152710988743807319327067660279846004696629681887779842129545558985841571482256386uwb, + 21441995702257150447349407715894435455050772126685461031315827571889336447926694701361700730379084806621691641000793333457504299685338550064151630805530260276144722300318378uwb, + 1810496946211232933828329287232831944898449501818263455079805575961543103376888822223202088001971904867510317357383306521333499198279246848350610021364570531uwb, + 0, 0, 0, 0, + 49645180073615279861687094823459626955281549193691328477580826482861925123118554141451230055925103484376691314925103229496483975307219087542024089047037648064847114147876643uwb, + 5uwb, + 107934287940096962208124285810972463665238866518161589834947495273979231095066254158254278656128778606292981405785821524489035396101282777095285918056890626313652996363360635uwb, + 0, 0, 0, 0, + 23608107814490548232484082204335368855445148092939475311496653239338164906367806895605948777993633707136572413097677855946274968766053297446456942019070196462866449343995194uwb, + 2583203116898176965174690967993977971553570592649244007260134674599130988578292547989776393639164uwb, + 275574884364090029934989506452294812428150053792728044335881034126425125444715551780251783116966457185581504439797097624639857491748084495990405201247685674533629814uwb, + 0, 0, 0, 0, + 130722423900191uwb, + 98209305532955450849963417931387543706587302562952677389372338515039360888927455577958981902466648551427758908831114835123178381uwb, + 452871192905895539483003814306315901853065835276102489810630370966701886335873219401733574293829636677996055324174200714778800368052970790656772945453428881051uwb, + 22873946842052620485494389199978222125uwb, + 0uwb, + 47552124733256427939572722329767524480111793387357122806941820665877774450470824535764237662603507442099431904312121406656289uwb, + 1395593888697848626057320338038084790564831152710988743807319327067660279846004696629681887779842129545558985841571482256386uwb, + 12402931424678892069400953011343uwb, + 9929036014723055972337418964691925391056309838738265695516165296572385024623710828290246011185020696875338262985020645899296795061443817508404817809407529612969422829575328uwb, + 765676291859168654790768770138076157159515580930329832291016877204190990758886004368955392441159337179098419446671535422387547862111454482076132380462913464uwb, + 3uwb, + 139483670059084867uwb, + 9139083047731208433628027573752517850138452745189939065766817977544782897707uwb, + 582502183871265798930967135317783829723227597448966288820692884195884049998974821351103238544771373433464199926206342695349404216240804690670860uwb, + 331751853749540937734694164624358910388009028150635800666238028944699092436048473910402462998246uwb, + 30656037717616877434uwb + }; + static unsigned _BitInt(125) s125[] = { + 34981105310298535974120492274604066977uwb, + 38073944253116192522082228985492uwb, + 140965952697865937uwb, + 473088156567311094933uwb + }; + for (int i = 0; i < 4; ++i) + { + test_575 (s575 + 7 * i, s125 + i, 0); + for (int j = 0; j < 4; ++j) + if (s575[7 * i + 3 + j] != s575[7 * 4 + 4 * i + j]) + __builtin_abort (); + } +#endif +}