From patchwork Wed Aug 9 18:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 133416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2994384vqr; Wed, 9 Aug 2023 11:28:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFg8yq8+zpCZqOOQ51+1nGRFsKg4YRxuQnOfM5K++fmbOb0dMltM9T9+8kxBxaTps/BFzSJ X-Received: by 2002:a17:906:290:b0:99b:c830:cf23 with SMTP id 16-20020a170906029000b0099bc830cf23mr3308461ejf.27.1691605729050; Wed, 09 Aug 2023 11:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691605729; cv=none; d=google.com; s=arc-20160816; b=zpFhVlpHTkbs0VaWWyLM8cGkR66z9ClkTgr8ZRpsrUMGCp/L6RYcWNpGLVwQaukt1O AjE+5jogz99g61MKXb8tQbHj/R2fL2E0zgMu2JOyaphTN/lU6PTQOsXqJH49/Tpplhph Y0fq8ius0UXL7pwG+Rk32aOimTBO37AJjBsOrPyt9TCEGAqtBXSP1Ud21y2l6laKE2lK ewV2bIHganqPdYsqgDmnbTFDXPB7mu5eB6SPYJHAYvlH5YBupJKysFZsXRh0m566zHLB 4eGG8UMuydcGwM+uMinCD74G2LCs5lClh8PKc2dJoiH56qvlVS6v2NCsHtd/JUxvIRkf Dqmw== 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=/yhbi1tUTbeKDVfqS5Wtec4yPtJt6D5grPLYB6nzTKg=; fh=7ssu/fi36bU4aQaYzNG+jm0+RaedZIlpx6vlii65CBI=; b=goJ2d/NRQyGF7ntt9prWVuz0ZgL+L4CsYHvwRVx6tCVhtw/I3JKEzFpo55TRiFsWsp swWC5xxyt//HITg/DG6wIxkyBe1oGJFNsLhiif54ZIhA6C36spyrSjJFHzlPZhcfUR+8 0qmY8mi/S+1OVbOEmvLHfMxgP8Qbm1kjYoul1tEaRSbmx6LJzK7yvNTAVmtH0f8PJL7d ViOSjGXYmSGz9zkS9sH5Tux8/0jn9EOLRYpXo8W1/s+QGIr0wyZqaU4jknLmWzgqndrE J6WV577qCmdTSTtgJ4iJ/+XS1t8gyTXgFFX3oiiruzzndcPevoRvtu5/10IuOgl5po3v xUxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kvXx8LUt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jp10-20020a170906f74a00b00992dc9d6b8bsi3751458ejb.789.2023.08.09.11.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 11:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kvXx8LUt; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 88DB33858298 for ; Wed, 9 Aug 2023 18:28:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88DB33858298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691605727; bh=/yhbi1tUTbeKDVfqS5Wtec4yPtJt6D5grPLYB6nzTKg=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=kvXx8LUtuW65h1+AiEO0H6hnbukWj+AI830+H6BTqikNSs5zlyLLpIqBN/Oy2I0jV +sjkvUw1vBxX4edGc4JnMX0fTAbV/KGaBc0CxH/95MMRXVHPtzD39r5vupRD67GwVk AtBL8jz9C2Qk5ajMerCo6mk0BRh1Osi6/LhrtkRs= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 2AFCB3858002 for ; Wed, 9 Aug 2023 18:27:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AFCB3858002 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-KQfWr9S2MLuvud7ZQqtS3g-1; Wed, 09 Aug 2023 14:27:35 -0400 X-MC-Unique: KQfWr9S2MLuvud7ZQqtS3g-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 B086280557B; Wed, 9 Aug 2023 18:27:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D95C3C15BAE; Wed, 9 Aug 2023 18:27:33 +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 379IRVW52043037 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 9 Aug 2023 20:27:31 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 379IRUeE2043036; Wed, 9 Aug 2023 20:27:30 +0200 Date: Wed, 9 Aug 2023 20:27:30 +0200 To: "Joseph S. Myers" , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 12/12] testsuite part 2 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.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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: 1773777169029221791 X-GMAIL-MSGID: 1773777169029221791 Hi! This is second part of the testcase additions in order to fit into mailing lists limits. Most of these tests are for the floating point conversions, atomics, __builtin_*_overflow and -fsanitize=undefined. 2023-08-09 Jakub Jelinek PR c/102989 gcc/testsuite/ * gcc.dg/torture/bitint-20.c: New test. * gcc.dg/torture/bitint-21.c: New test. * gcc.dg/torture/bitint-22.c: New test. * gcc.dg/torture/bitint-23.c: New test. * gcc.dg/torture/bitint-24.c: New test. * gcc.dg/torture/bitint-25.c: New test. * gcc.dg/torture/bitint-26.c: New test. * gcc.dg/torture/bitint-27.c: New test. * gcc.dg/torture/bitint-28.c: New test. * gcc.dg/torture/bitint-29.c: New test. * gcc.dg/torture/bitint-30.c: New test. * gcc.dg/torture/bitint-31.c: New test. * gcc.dg/torture/bitint-32.c: New test. * gcc.dg/torture/bitint-33.c: New test. * gcc.dg/torture/bitint-34.c: New test. * gcc.dg/torture/bitint-35.c: New test. * gcc.dg/torture/bitint-36.c: New test. * gcc.dg/torture/bitint-37.c: New test. * gcc.dg/torture/bitint-38.c: New test. * gcc.dg/torture/bitint-39.c: New test. * gcc.dg/torture/bitint-40.c: New test. * gcc.dg/torture/bitint-41.c: New test. * gcc.dg/torture/bitint-42.c: New test. * gcc.dg/atomic/stdatomic-bitint-1.c: New test. * gcc.dg/atomic/stdatomic-bitint-2.c: New test. * gcc.dg/dfp/bitint-1.c: New test. * gcc.dg/dfp/bitint-2.c: New test. * gcc.dg/dfp/bitint-3.c: New test. * gcc.dg/dfp/bitint-4.c: New test. * gcc.dg/dfp/bitint-5.c: New test. * gcc.dg/dfp/bitint-6.c: New test. * gcc.dg/ubsan/bitint-1.c: New test. * gcc.dg/ubsan/bitint-2.c: New test. * gcc.dg/ubsan/bitint-3.c: New test. Jakub --- gcc/testsuite/gcc.dg/torture/bitint-20.c.jj 2023-08-08 16:12:02.343939602 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-20.c 2023-08-08 16:12:02.343939602 +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 (_BitInt(135) *p, _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 (_BitInt(192) *p, _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 (_BitInt(575) *p, _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 _BitInt(135) s135[] = { + 11379259456099690377988816293288418659013wb, + -18507519859761926375595173102925837392wb, + -3487341362606172228883239379216537732914wb, + 0, 0, 0, 0, + -18302253895694594136150902133229wb, + 2910721282054679865681699220999829323779wb, + -17020765241462394475777917185801328548533wb, + 0, 0, 0, 0, + 18652952612120070842749648336935165019219wb, + -1wb, + -2328827552140837061029007041281845428062wb, + 0, 0, 0, 0, + 4586448317141516754412034429451793085778wb, + 302326133131500453732826275685wb, + -13254392454085872482685218784341305341217wb, + 0, 0, 0, 0, + -614wb, + 16712959282178433685159137405wb, + 15642262205867583373380008091954500325wb, + -27731730774wb, + 0wb, + -75263829692564968827327018348wb, + -18302253895694594136150902133229wb, + -35227765213wb, + -18652952612120070842749648336935165019219wb, + 112934753510539598517482519823570410wb, + 0wb, + -3452wb, + 15170532132wb, + -315580772716330297206790923436697746219wb, + 126779339685614070998610275358wb, + -19wb + }; + static _BitInt(39) s39[] = { + -208660914188wb, + 226148009090wb, + -20621wb, + 42wb + }; + 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 _BitInt(192) s192[] = { + -2179289138164349400542345646041597314396798352437085702063wb, + -79910962432789464031897580939163427724139130993wb, + -3036473005246707700116012885952806814462013063553154406939wb, + 0, 0, 0, 0, + 641265343041674918120574087098wb, + -72968858271155659573911879940731439944647195520825153965wb, + 2701717062040203003887103138051480805185032453926240220524wb, + 0, 0, 0, 0, + -841691204113630961349106466971783187865820857103239354134wb, + 3wb, + -87971197399776002207343095550078219wb, + 0, 0, 0, 0, + 1975530920339244356926809414608241391203379490466789216052wb, + -1491609620853264847219953011450130087411551266523269wb, + -1446625088493520499379069533952596205wb, + 0, 0, 0, 0, + 27271466539wb, + 1706692225050149442221770028739016905019wb, + -79245495764706738784157700565393118980948358836wb, + -1501915295097973757wb, + 0wb, + 4771029735868622050569106388224414265428wb, + 641265343041674918120574087098wb, + 333711124246457812wb, + -280563734704543653783035488990594395955273619034413118044wb, + -11314906111712376578wb, + -2wb, + -2479408421589529wb, + -1324428wb, + -11301758503855628901398980734004657wb, + 1373411796501852981487559368499793073469647909100920wb, + -109wb + }; + static _BitInt(62) s62[] = { + -1779156757544544378wb, + 566275460772898254wb, + 7774805776666105wb, + 128wb + }; + 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 _BitInt(575) s575[] = { + -46295454425650349106237210715560972814514774894381316941718135777652722445546437187679065682949497046056192846156902024414635126978980056110286059194406244047429103543013567wb, + 8168911130831183937943637579544406842555974190640492967747336926965525847745100099776294868623258477082653103560744709659980631459947315392636659059426713543595666476280533wb, + -35562636740560878776057515364478086997557966107967281638887951768166903062463010597490396666936792092197907362468852658846219038084825902297279012227062238709275022706654710wb, + 0, 0, 0, 0, + 8943720225181967953483417970wb, + -5686323784402794959708902425053022672027524027657863695096812917030055678499948429234881641591266594283291408732579354863768974925810198523510127753699305465302067821wb, + 45545655058039702583745674825335158540648677810736798412180196426599514263661272184545433928331514411963531127261916383264154901783937763805071704477825859668914160192614845wb, + 0, 0, 0, 0, + 50424935157410302671220896696045811569932594372403814676921199727418115659236492512040645301161966980307514350263276765199536014825688175664310129375564263158984wb, + -7wb, + -1570414268527860342275074326241251266943768106178059338676497087694509262100926288185672140837995480549018141550944901112529623354869552332831768648238175848946606383367442wb, + 0, 0, 0, 0, + 33743599683183012321962199340752013311691198627837686174760810997243129260923502613536719907475631360213576483574943246620765095970215288302282988013296681749186377007244629wb, + -241344364975185779312145695113143874342953936016290256207617251781961618409457239212648767218870128884542434148wb, + 264442076257762743508952577439304094891926651736030778233607159152726518015778933421402285405943871924053070093963838538880775338376789919798084050039162wb, + 0, 0, 0, 0, + -5wb, + 5102554304763340573123278154007968305825944534675387388100485979831828339912883404866537264221784637582259122678928387415569088293221166wb, + -5450898771494429416519022817838938601734903941178852102981451142825093206820936688797591339833204660642927328353178476114731969679243479147102763897272676329450771161610902wb, + -27841416716804082903535753217607970wb, + 0wb, + 2845786405948228702992300882035725001599103765023382470517698884483710061812613500615722877137078798659301720051530203483092161498954792wb, + 8943720225181967953483417970wb, + 14857023063025350938701283170104334549wb, + -7203562165344328953031556670863687367133227767486259239560171389631159379890927501720092185880280997186787764323325252171362287832241167952044304196509180451283wb, + 193782868826267453015550702420724985315443493285153355021508389301944425453072371810496604181725982879795555170278476391923261741289049794434571591514767wb, + 3wb, + -5203319495353646668wb, + -139815154526820696318711149230487844769233301636772309388492158wb, + -323204355193745164479045143032958628560847774063940216640778815817376770038460708119250193248428869489076997487384931038wb, + 180305213672139436589458419226578301650781616412684462286468318018185661952458180767935939240752755560277833245wb, + 316649622804067950787613592683370wb + }; + static _BitInt(125) s125[] = { + -6969575357064287919545125499931812390wb, + 16004593655673074838414651760840291513wb, + -8103989160857077722wb, + -818188468095495446473587377169784wb + }; + 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 +} --- gcc/testsuite/gcc.dg/torture/bitint-21.c.jj 2023-08-08 16:12:02.343939602 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-21.c 2023-08-08 16:12:02.343939602 +0200 @@ -0,0 +1,282 @@ +/* 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 __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testflt_135 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testfltu_135 (float d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testflt_192 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testfltu_192 (float d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testflt_575 (float d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testfltu_575 (float d) +{ + return d; +} +#endif +#endif + +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testdbl_135 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testdblu_135 (double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testdbl_192 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testdblu_192 (double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testdbl_575 (double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testdblu_575 (double d) +{ + return d; +} +#endif +#endif + +int +main () +{ +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 + static float flt_135[] = { + 0.25f, 0.0f, 1.0f, -42.0f, 16777215.25f, + -50855501824.5f, 39580962846540824576.0f, + -122147759335346835551823516808712814592.0f, + -85070591730234615865843651857942052864.0f + }; + static _BitInt(135) fltr_135[] = { + 0wb, 0wb, 1wb, -42wb, 16777215wb, + -50855501824wb, 39580962846540824576wb, + -122147759335346835551823516808712814592wb, + -85070591730234615865843651857942052864wb + }; + for (int i = 0; i < 9; ++i) + if (testflt_135 (flt_135[i]) != fltr_135[i]) + __builtin_abort (); + static float fltu_135[] = { + 0.125f, 0.0f, 1.0f, 42.59375f, 16777215.75f, + 397530272.5f, 1557145973265213792232550652968960.0f, + 69722182498815269047577928656018735104.0f + }; + static unsigned _BitInt(135) fltur_135[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 16777216uwb, + 397530272uwb, 1557145973265213792232550652968960uwb, + 69722182498815269047577928656018735104uwb + }; + for (int i = 0; i < 8; ++i) + if (testfltu_135 (fltu_135[i]) != fltur_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static float flt_192[] = { + 0.625f, 0.0f, 1.0f, -42.0f, 16777215.25f, + -166724322197504.5f, 7557890186859550768856301568.0f, + 6614377725485260848635133905887821824.0f, + -85070591730234615865843651857942052864.0f + }; + static _BitInt(192) fltr_192[] = { + 0wb, 0wb, 1wb, -42wb, 16777215wb, + -166724322197504wb, 7557890186859550768856301568wb, + 6614377725485260848635133905887821824wb, + -85070591730234615865843651857942052864wb + }; + for (int i = 0; i < 9; ++i) + if (testflt_192 (flt_192[i]) != fltr_192[i]) + __builtin_abort (); + static float fltu_192[] = { + __FLT_MIN__, 0.0f, 1.0f, 42.125f, 16777216.75f, + 2197600337920.75f, 4591683053408742366929307227985543168.0f, + 89668786387864080590151097276117811200.0f + }; + static unsigned _BitInt(192) fltur_192[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 16777216uwb, + 2197600337920uwb, 4591683053408742366929307227985543168uwb, + 89668786387864080590151097276117811200uwb + }; + for (int i = 0; i < 8; ++i) + if (testfltu_192 (fltu_192[i]) != fltur_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static float flt_575[] = { + 0.0001f, 0.0f, 1.0f, -28.0f, 16777214.75f, + -1321998852554752.5f, 3447217350995641328695097279119360.0f, + -153684583933125564944797950598195445760.0f, + -6614377725485260848635133905887821824.0f + }; + static _BitInt(575) fltr_575[] = { + 0wb, 0wb, 1wb, -28wb, 16777215wb, + -1321998852554752wb, 3447217350995641328695097279119360wb, + -153684583933125564944797950598195445760wb, + -6614377725485260848635133905887821824wb + }; + for (int i = 0; i < 9; ++i) + if (testflt_575 (flt_575[i]) != fltr_575[i]) + __builtin_abort (); + static float fltu_575[] = { + 4.0f * __FLT_MIN__, 0.0f, 1.0f, 38.125f, 16777210.75f, + 450604433408.75f, 49420393052787309452540595771398946816.0f, + 144076816645080570490809349637635309568.0f + }; + static unsigned _BitInt(575) fltur_575[] = { + 0uwb, 0uwb, 1uwb, 38uwb, 16777211uwb, + 450604433408uwb, 49420393052787309452540595771398946816uwb, + 144076816645080570490809349637635309568uwb + }; + for (int i = 0; i < 8; ++i) + if (testfltu_575 (fltu_575[i]) != fltur_575[i]) + __builtin_abort (); +#endif +#endif +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 + static double dbl_135[] = { + 0.25, 0.0, 1.0, -42.0, 4294967295.25, + -600381955574889.5, 31830517255028909053694705664.0, + -18738990071541038357046558935673124945920.0, + -21778071482940061661655974875633165533184.0 + }; + static _BitInt(135) dblr_135[] = { + 0wb, 0wb, 1wb, -42wb, 4294967295wb, + -600381955574889wb, 31830517255028909053694705664wb, + -18738990071541038357046558935673124945920wb, + -21778071482940061661655974875633165533183wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testdbl_135 (dbl_135[i]) != dblr_135[i]) + __builtin_abort (); + static double dblu_135[] = { + 0.125, 0.0, 1.0, 42.59375, 4294967295.75, + 1379919377114330.5, 1887176628826898072984354816.0, + 28122698032432725461429202074509590396928.0 + }; + static unsigned _BitInt(135) dblur_135[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 4294967295uwb, + 1379919377114330uwb, 1887176628826898072984354816uwb, + 28122698032432725461429202074509590396928uwb + }; + for (int i = 0; i < 8; ++i) + if (testdblu_135 (dblu_135[i]) != dblur_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static double dbl_192[] = { + 0.625, 0.0, 1.0, -42.0, 4294967295.25, + -334692618508390720.5, 7241713824636372052614321786924022698463985664.0, + 1051470826442514757151114043324296190023320100185399361536.0, + -3138550867693340381917894711603833208051177722232017256448.0 + }; + static _BitInt(192) dblr_192[] = { + 0wb, 0wb, 1wb, -42wb, 4294967295wb, + -334692618508390720wb, 7241713824636372052614321786924022698463985664wb, + 1051470826442514757151114043324296190023320100185399361536wb, + -3138550867693340381917894711603833208051177722232017256447wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testdbl_192 (dbl_192[i]) != dblr_192[i]) + __builtin_abort (); + static double dblu_192[] = { + __DBL_MIN__, 0.0, 1.0, 42.125, 4294967296.75, + 85543274084479312.75, 1452517026416706854711122198528.0, + 4878159368183578289135952951143197426988727705359645409280.0 + }; + static unsigned _BitInt(192) dblur_192[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 4294967296uwb, + 85543274084479312uwb, 1452517026416706854711122198528uwb, + 4878159368183578289135952951143197426988727705359645409280uwb + }; + for (int i = 0; i < 8; ++i) + if (testdblu_192 (dblu_192[i]) != dblur_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static double dbl_575[] = { + 0.0001, 0.0, 1.0, -28.0, 4294967294.75, + -37518052491018912.5, 103740344328578397848785318842252129922803939603530145015162908477052192630505472.0, + -60264112735379285992549557294906950572505306720710356591257742566415478531569283626542380634430345616295459560427283714375540825055746407845009719778430303250931745441185792.0, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174784.0 + }; + static _BitInt(575) dblr_575[] = { + 0wb, 0wb, 1wb, -28wb, 4294967294wb, + -37518052491018912wb, 103740344328578397848785318842252129922803939603530145015162908477052192630505472wb, + -60264112735379285992549557294906950572505306720710356591257742566415478531569283626542380634430345616295459560427283714375540825055746407845009719778430303250931745441185792wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testdbl_575 (dbl_575[i]) != dblr_575[i]) + __builtin_abort (); + static double dblu_575[] = { + 4.0 * __DBL_MIN__, 0.0, 1.0, 38.125, 4294967297.75, + 138240328005104064.75, 1588129215384992270224118343146332410113351482118715170651778867930903010675691494429363974899842924150784.0, + 106390366882040443685518677989907085524608028099417390750037507495093586319031581000179209552004867195248003952212636389496136628539779816025838629984567658036669448510767104.0 + }; + static unsigned _BitInt(575) dblur_575[] = { + 0uwb, 0uwb, 1uwb, 38uwb, 4294967297uwb, + 138240328005104064uwb, 1588129215384992270224118343146332410113351482118715170651778867930903010675691494429363974899842924150784uwb, + 106390366882040443685518677989907085524608028099417390750037507495093586319031581000179209552004867195248003952212636389496136628539779816025838629984567658036669448510767104uwb + }; + for (int i = 0; i < 8; ++i) + if (testdblu_575 (dblu_575[i]) != dblur_575[i]) + __builtin_abort (); +#endif +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-22.c.jj 2023-08-08 16:12:02.343939602 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-22.c 2023-08-08 16:12:02.343939602 +0200 @@ -0,0 +1,282 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testldbl_135 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testldblu_135 (long double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testldbl_192 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testldblu_192 (long double d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testldbl_575 (long double d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testldblu_575 (long double d) +{ + return d; +} +#endif +#endif + +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _BitInt(135) +testflt128_135 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(135) +testflt128u_135 (_Float128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +testflt128_192 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testflt128u_192 (_Float128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +testflt128_575 (_Float128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testflt128u_575 (_Float128 d) +{ + return d; +} +#endif +#endif + +int +main () +{ +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 + static long double ldbl_135[] = { + 0.25L, 0.0L, 1.0L, -42.0L, 4294967295.25L, + -8790480341948727187.25L, 27274375615880435204096.0L, + -14925443517338257613013233930892304449536.0L, + -21778071482940061661655974875633165533184.0L + }; + static _BitInt(135) ldblr_135[] = { + 0wb, 0wb, 1wb, -42wb, 4294967295wb, + -8790480341948727187wb, 27274375615880435204096wb, + -14925443517338257613013233930892304449536wb, + -21778071482940061661655974875633165533183wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testldbl_135 (ldbl_135[i]) != ldblr_135[i]) + __builtin_abort (); + static long double ldblu_135[] = { + 0.125L, 0.0L, 1.0L, 42.59375L, 4294967295.75L, + 176563931524327024.5L, 33864941055480177570480471932928.0L, + 25454535165593017203571842988709209178112.0L + }; + static unsigned _BitInt(135) ldblur_135[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 4294967295uwb, + 176563931524327024uwb, 33864941055480177570480471932928uwb, + 25454535165593017203571842988709209178112uwb + }; + for (int i = 0; i < 8; ++i) + if (testldblu_135 (ldblu_135[i]) != ldblur_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static long double ldbl_192[] = { + 0.625L, 0.0L, 1.0L, -42.0L, 4294967295.25L, + -5824742198306330891.5L, 440458331210868742661519441920.0L, + 1835666805014205039814897225189119947560942436848001613824.0L, + -3138550867693340381917894711603833208051177722232017256448.0L + }; + static _BitInt(192) ldblr_192[] = { + 0wb, 0wb, 1wb, -42wb, 4294967295wb, + -5824742198306330891wb, 440458331210868742661519441920wb, + 1835666805014205039814897225189119947560942436848001613824wb, + -3138550867693340381917894711603833208051177722232017256447wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testldbl_192 (ldbl_192[i]) != ldblr_192[i]) + __builtin_abort (); + static long double ldblu_192[] = { + __LDBL_MIN__, 0.0L, 1.0L, 42.125L, 4294967296.75L, + 2076918887405157419.75L, 20675944534182826922963677915852149395069559898112.0L, + 5501434424609388038261967254007295028886638351806353113088.0L + }; + static unsigned _BitInt(192) ldblur_192[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 4294967296uwb, + 2076918887405157419uwb, 20675944534182826922963677915852149395069559898112uwb, + 5501434424609388038261967254007295028886638351806353113088uwb + }; + for (int i = 0; i < 8; ++i) + if (testldblu_192 (ldblu_192[i]) != ldblur_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static long double ldbl_575[] = { + 0.0001L, 0.0L, 1.0L, -28.0L, 4294967294.75L, + -3665832965020207456.5L, 163698889538251840454153874702336.0L, + 32915174451748642699300864037265677114762093753017270154115822402734463611341115095984060833654391570465670441530007982951775959694729040694137686724336684263404019031998464.0L, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174784.0L + }; + static _BitInt(575) ldblr_575[] = { + 0wb, 0wb, 1wb, -28wb, 4294967294wb, + -3665832965020207456wb, 163698889538251840454153874702336wb, + 32915174451748642699300864037265677114762093753017270154115822402734463611341115095984060833654391570465670441530007982951775959694729040694137686724336684263404019031998464wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testldbl_575 (ldbl_575[i]) != ldblr_575[i]) + __builtin_abort (); + static long double ldblu_575[] = { + 4.0L * __LDBL_MIN__, 0.0L, 1.0L, 38.125L, 4294967297.75L, + 1378703406647015633.75L, 611519358004879551476944320883148018860550235384446976.0L, + 115943866857281393364910134541262519802574312323472821552898049002204954780753923929784955305825114286696121504922573067409422635510048274769753298552619702526028834918105088.0L + }; + static unsigned _BitInt(575) ldblur_575[] = { + 0uwb, 0uwb, 1uwb, 38uwb, 4294967297uwb, + 1378703406647015633uwb, 611519358004879551476944320883148018860550235384446976uwb, + 115943866857281393364910134541262519802574312323472821552898049002204954780753923929784955305825114286696121504922573067409422635510048274769753298552619702526028834918105088uwb + }; + for (int i = 0; i < 8; ++i) + if (testldblu_575 (ldblu_575[i]) != ldblur_575[i]) + __builtin_abort (); +#endif +#endif +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 + static _Float128 flt128_135[] = { + 0.25F128, 0.0F128, 1.0F128, -42.0F128, 4294967295.25F128, + -622114258022893415468272077014949.5F128, 6846686534183872435237780851340978176.0F128, + -18109992041001989671440396535501724581888.0F128, + -21778071482940061661655974875633165533184.0F128 + }; + static _BitInt(135) flt128r_135[] = { + 0wb, 0wb, 1wb, -42wb, 4294967295wb, + -622114258022893415468272077014949wb, 6846686534183872435237780851340978176wb, + -18109992041001989671440396535501724581888wb, + -21778071482940061661655974875633165533183wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testflt128_135 (flt128_135[i]) != flt128r_135[i]) + __builtin_abort (); + static _Float128 flt128u_135[] = { + 0.125F128, 0.0F128, 1.0F128, 42.59375F128, 4294967295.75F128, + 3866883549893778868343627501393297.5F128, 1884508847679496004639718578196282112.0F128, + 40418154190724512480670668005754087145472.0F128 + }; + static unsigned _BitInt(135) flt128ur_135[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 4294967295uwb, + 3866883549893778868343627501393297uwb, 1884508847679496004639718578196282112uwb, + 40418154190724512480670668005754087145472uwb + }; + for (int i = 0; i < 8; ++i) + if (testflt128u_135 (flt128u_135[i]) != flt128ur_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static _Float128 flt128_192[] = { + 0.625F128, 0.0F128, 1.0F128, -42.0F128, 4294967295.25F128, + -2985198467222342042164811285508981.5F128, 431282768955649236431442335280406747022360576.0F128, + 1589969577168452878096502186670522088231011726426596442112.0F128, + -3138550867693340381917894711603833208051177722232017256448.0F128 + }; + static _BitInt(192) flt128r_192[] = { + 0wb, 0wb, 1wb, -42wb, 4294967295wb, + -2985198467222342042164811285508981wb, 431282768955649236431442335280406747022360576wb, + 1589969577168452878096502186670522088231011726426596442112wb, + -3138550867693340381917894711603833208051177722232017256447wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testflt128_192 (flt128_192[i]) != flt128r_192[i]) + __builtin_abort (); + static _Float128 flt128u_192[] = { + __FLT128_MIN__, 0.0F128, 1.0F128, 42.125F128, 4294967296.75F128, + 1198221816583045676753413578483973.75F128, 321058543109670204450967161534914741927936.0F128, + 4124250833671183507048495617931376186682553019928355536896.0F128 + }; + static unsigned _BitInt(192) flt128ur_192[] = { + 0uwb, 0uwb, 1uwb, 42uwb, 4294967296uwb, + 1198221816583045676753413578483973uwb, 321058543109670204450967161534914741927936uwb, + 4124250833671183507048495617931376186682553019928355536896uwb + }; + for (int i = 0; i < 8; ++i) + if (testflt128u_192 (flt128u_192[i]) != flt128ur_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static _Float128 flt128_575[] = { + 0.0001F128, 0.0F128, 1.0F128, -28.0F128, 4294967294.75F128, + -4434536963340205213805292449887836.5F128, 7798956314177801818163892326325236647148010864640.0F128, + -48379475169482975928082617475070980956970510451882414558095669485086407691242420689411465910847147042640064381848760072045866350077715681395831023828798188292450661613699072.0F128, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174784.0F128 + }; + static _BitInt(575) flt128r_575[] = { + 0wb, 0wb, 1wb, -28wb, 4294967294wb, + -4434536963340205213805292449887836wb, 7798956314177801818163892326325236647148010864640wb, + -48379475169482975928082617475070980956970510451882414558095669485086407691242420689411465910847147042640064381848760072045866350077715681395831023828798188292450661613699072wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb + }; + for (int i = 0; i < 9; ++i) + if (testflt128_575 (flt128_575[i]) != flt128r_575[i]) + __builtin_abort (); + static _Float128 flt128u_575[] = { + 4.0F128 * __FLT128_MIN__, 0.0F128, 1.0F128, 38.125F128, 4294967297.75F128, + 1286565442597535616086070715374552.75F128, 2888274376848382435313359223769917404575136171432777745913780227423600640.0F128, + 101012352069182509789055890148950528106809264092697629422634347377509770791198015780931797016594366657511165718215124632216959526129296364564413818230848005073384975475146752.0F128 + }; + static unsigned _BitInt(575) flt128ur_575[] = { + 0uwb, 0uwb, 1uwb, 38uwb, 4294967297uwb, + 1286565442597535616086070715374552uwb, 2888274376848382435313359223769917404575136171432777745913780227423600640uwb, + 101012352069182509789055890148950528106809264092697629422634347377509770791198015780931797016594366657511165718215124632216959526129296364564413818230848005073384975475146752uwb + }; + for (int i = 0; i < 8; ++i) + if (testflt128u_575 (flt128u_575[i]) != flt128ur_575[i]) + __builtin_abort (); +#endif +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-23.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-23.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,804 @@ +/* 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 __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) float +testflt_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) float +testflt_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) float +testflt_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) float +testfltu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) double +testdbl_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) double +testdbl_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) double +testdbl_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) double +testdblu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + static _BitInt(135) s_135[] = { + -39242093wb, + -36246971635108657318127321wb, + -816440703352wb, + 8409360wb, + 231875wb, + -1859wb, + 8123250453541347379290840008816194983wb, + 42642091wb, + -2499664813007708583619356686wb, + -14022533493907734339644wb, + 737816709430180009697449492wb, + 3094418595787172583521548578719419wb, + 84096wb, + -3856393637064417wb, + 5494wb, + -7227655824382622730861wb, + 185250722103742953wb, + -266695839223233222300219080587185431wb, + 124wb, + -4540724906728461994579131745203067wb, + -34474123wb, + 6171186wb, + -1738448518309495501564259945530043942wb, + 3714wb, + 22759310366655438105064084505115489wb, + -461wb, + -1891475049610273521994429918325638525836wb, + -350wb, + 3721759411106519959861226774340wb, + -42485872965031409753wb, + 4362279409022137273490486629950wb, + 521928664204421037572709995195346211111wb, + -50129wb, + -21525556783117336078661729wb + }; + static unsigned _BitInt(135) u_135[] = { + 773802493804221964748670742461281016363uwb, + 897485218654369665002411485681173uwb, + 37306898634990773758633uwb, + 3uwb, + 920156uwb, + 15230973698181139105641901258312096uwb, + 1383843491123931387484696uwb, + 143810081711544975903357370071668200uwb, + 83615891310230331473978uwb, + 1239150390uwb, + 39792042288uwb, + 20985035121604uwb, + 3700707uwb, + 14510535740825uwb, + 5675982879048653163399531637816917uwb, + 593909622129190124122830uwb, + 413008891327830587264uwb, + 34694483328uwb, + 592129uwb, + 2649uwb, + 154468451808267466822214091328849uwb, + 8905088171048376399858691570634230197204uwb, + 456uwb, + 12101uwb, + 5879086272uwb, + 115170058487623uwb, + 2274163249406113742515726136586945854500uwb, + 63923152267905666653uwb, + 624302860090054295150365837280525227924uwb, + 9uwb, + 5703520721951508439418uwb, + 44653119094uwb, + 1440439605268989101uwb, + 3496654014361uwb + }; +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static _BitInt(192) s_192[] = { + 81945579384314684613279565479277935940wb, + 1640150770700583136800158704601080wb, + 432402469012491481987292073086668wb, + -15369197386440508323548800500962985157137866798390wb, + 217705797486262wb, + 1wb, + -150837356854711044278780637wb, + 1247354027519369533750440146304wb, + -700073531555662209687924602081wb, + -441651351073606706893667405889558445894wb, + -743993151249791392844844248857961054wb, + 1681039wb, + -170386616439159353410812029301398243129730wb, + -97703172400304820221345002831889wb, + 9wb, + 7277656199366069102639319241893wb, + 7201222364wb, + -4671533967546296507223686237333335wb, + 13311155734490577635922550wb, + 76150533189365685907637983428512213977569647wb, + -283560863483321465221194695455688610811wb, + 6438368552004797088499844257634549000496626110080371wb, + 1122038765213390728664343086041576wb, + -9541613313421359977755878156940wb, + 21551012076757076795102244535269250wb, + -4794294047755173531367558272wb, + -5708612827808554221wb, + -2649648007071280662902443553973167294046518180wb, + -35698660478241255546377wb, + -79587921140918wb, + 469393710173925646wb, + -261330983098092746969723637867599382044980841179747207wb, + -115wb, + -1717706681396wb + }; + static unsigned _BitInt(192) u_192[] = { + 87197051833867272589618945858714291675632402028uwb, + 175207476610687227705633653396153452205075322355946uwb, + 289472685412214318981767004188uwb, + 58352315342320048378103056601781218026976uwb, + 68512267071922032916894194298300228491490143452269uwb, + 8654067584750856592691725728280108682858075uwb, + 57027948061283099317671673937496946487124629uwb, + 512829256101uwb, + 8815296701808550493421309771596155666520uwb, + 1918805208198312310092547265227uwb, + 99680639255733807uwb, + 313647272226958893709907781719uwb, + 534434342549592762863366619879590694414818uwb, + 1751643652514709uwb, + 24084146046683127013882581681582087uwb, + 1282076uwb, + 13590701668411111769uwb, + 62207549230439503653uwb, + 144040025133692457990548614076288499046uwb, + 11981724905403945793356785358565398049196880116uwb, + 1823479497818478859136796209626920064416489979129893695uwb, + 4649uwb, + 2095541338428713427585867932062430293488017906261402uwb, + 605377488765896342050766363050545164888333863362uwb, + 11488350477184223uwb, + 9492972359709013710789022084605392630683565515935199uwb, + 36826148417259uwb, + 554404239122129842026250702689uwb, + 2804528919100uwb, + 127uwb, + 66823885107232870336040073990324uwb, + 297736625249uwb, + 3701132312864550550157874952341371502832960625370598966uwb, + 107247048428uwb + }; +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static _BitInt(575) s_575[] = { + 822555268170764275096048134868384963633463468104839796862654006268369616wb, + -960580267694575830808697063169243963045681635800151938720065734940592300657700227419337766780029829446319203wb, + 33504080263976494448954627475165765154890874061543914469206217657999706310163279811015042121096338719830090426757797138233202615461wb, + 275983725374553564148936957707321552749wb, + 5534912144897227754137156977371639235252437172582938580045103986268272085395760563838753817115093434280932847973705994570261258933419373885658991359441723005813683395590541wb, + 1412920302762671055711845665320769771488824036206881359103417821581950493952853265134760513685359011001836948515905971331797139790wb, + -262974997977953570994865210107604152900839198803859287819970850481583440338320059wb, + -92488905333378799268618025132022462336176863903734682501838771365453998891689279398wb, + 242604167696163732697906496386839396751068wb, + -3523803651131338645439245946293wb, + -5147220779398204849222374563179412010462379234108857688330486391319694172748210918710342389194957287070617133280194810193962683650761347126311504766504260691wb, + -126995956651641937332005246092202755154992252553028943468563459072746155379181900761169956344678911600wb, + 8137926360495wb, + -15994393111836746332671329788635258wb, + -277068516868681202554828866807401284583187899477211188256772654837767448404666578906477389363058609157862574wb, + 12643256666940489874033990964997310860090310878838229112053311027168830831623703103010815387wb, + 197250790460297242975596746662998763328365874997wb, + 2003391279347376998472wb, + -199877387236416475658211887841938073691092213166438343739wb, + 683783725793437346966376731991835336458591392078548990419792641719902684445391913394174240265031277360362886303597899811253111402611797905136669wb, + 13527430925075101894748577029275389339063875642859674079897983403256wb, + 539267000300803493510458136103246878203019746178696339759252798818676107273127463057162208073142618039409911wb, + 25132435181738021677664552852329012363786311024121402747618663944355967806315928846073722774898wb, + -24501129715197464074815490290653wb, + -26621511339033230503491791253914731850253401wb, + 219726795681725191949095808767196099036895435893837474958165415185577738548053399820419849wb, + 142706206515281341916417852232439287400819155237127620529348000437671770471697052705666056232742428920527wb, + -1272097813202031618710288063584910456400985264371503722255927680393419899507092728461wb, + 104580584066897755717617980935051171929519336855902844943415231226523598033953128466889325153396268078513996620240379420239887wb, + -10163452549280413821027501723364683075067110986059205073343287754152825761658667193285948456506970145368258900765489010580419998927374372004822965287098902519382wb, + -1462817702603947401421838547412731208810505797188084686210372939517152226213737422286025118826482655559744680456146694118022879735528111700409wb, + -1004473459167555639043426932334304398038355185104669wb, + 383945882095471823332216311173956104021530654187057868803605149628498470119801535759629951357637987556377174553957515312582545289930138018wb, + 147266903774875157001493887893421901156259749590403482558013070wb + }; + static unsigned _BitInt(575) u_575[] = { + 340315902121482071031uwb, + 9193736781349493374149172723522049938732355975055uwb, + 121133456126887617775249483436586396232697894267611535022240817951287068117843073672uwb, + 1253811282917666038992497uwb, + 279807426767721176279253888473522991149118862415710500804613956730247764438409575562386uwb, + 4763192686302836059965684032432862167583119264783uwb, + 19433750446582365356875213925336734177599085624532213292961813424848222698351037862663241858724337375675uwb, + 8615689860907972907203187028321798323548254692780962654211537619771698680316938530412569744897459065621193843349775333790731199245018643579445580816793381624810616262uwb, + 126055589776274659515356020606486923511478187977197128509709117843059226901071386846700207970626608150351060714322162254429913496135590117225450775153364768928781244uwb, + 34636325529158225079379169125604752070369970834816893592982969115088710130160324580864333959889906313467177163564702338046445540uwb, + 2295982750677874548137685137480985649627965059590627454944uwb, + 22288650253829612832302454550260146151077393473uwb, + 61551827uwb, + 948415991495935226718622697967024251064408554619458611515264819726244946850447758605031396753280209023664964305741301009407513619686102uwb, + 7599947921908039117808602805272900633862767543347735124983729771592896283177667324402886239291446uwb, + 3064098671438076295010586583414642866550259610904044948559784636731818131096680869327433283805326015689481397549653557650965154282598345191654721039973597171695049076467uwb, + 26163216482276433755253744705785501134309546797499410671258175352214852627310317854549342428286751107453875459uwb, + 1083530146709801198539441549736949256980046185455966999062614188586191607484611079705240990524552846829821534154580456458426794497253838343299379036578711641930103uwb, + 241446995995054305582384233456322509709013171336859127uwb, + 224319712854uwb, + 1851847735563213275uwb, + 3517907813008404838784133683859253992uwb, + 57026061017409510123542169719303829618100077009666501089739966522905673377916488253uwb, + 218054639772618074096850378810323560503313926757275788155487065187235936858569852576120793613879980uwb, + 1035184782769221379uwb, + 20229959242348674822834301353257599618846169820699281424077697412860273533283192155424030349307384555863768665398854990uwb, + 48688062002166777196074419660880812175599377353811333642743225865182422320253615211852611218169059717666168172585704763331192485699241038689921302806665184uwb, + 38974159722814402881994907079236516884965127718714589284306855526034875317101125387287977578141556918226042568695412232uwb, + 195268331869690963115384309853070889302314974440838447729079592004150231uwb, + 131384791058457562831689753115846222538215620945564207628285200123621656731679644407994773520965uwb, + 1334982489788592107403503927792629194402uwb, + 2146uwb, + 25165296015221802429838428736907886uwb, + 6254uwb + }; +#endif +#if __FLT_MANT_DIG__ == 24 +#if __BITINT_MAXWIDTH__ >= 135 + static float flt_135[] = { + -39242092.0f, + -36246971272809749294350336.0f, + -816440672256.0f, + 8409360.0f, + 231875.0f, + -1859.0f, + 8123250192256220137057345512566423552.0f, + 42642092.0f, + -2499664867657543876622680064.0f, + -14022533900570342719488.0f, + 737816710112426075969552384.0f, + 3094418676109759732222008215207936.0f, + 84096.0f, + -3856393689890816.0f, + 5494.0f, + -7227655905181068951552.0f, + 185250718389633024.0f, + -266695840144413128032863408636297216.0f, + 124.0f, + -4540724759502527537506259606437888.0f, + -34474124.0f, + 6171186.0f, + -1738448585705717460364844982721314816.0f, + 3714.0f, + 22759309744814802127092016612376576.0f, + -461.0f, + -__builtin_inff (), + -350.0f, + 3721759435945004998144961806336.0f, + -42485872567125016576.0f, + 4362279465016690611605542535168.0f, + __builtin_inff (), + -50129.0f, + -21525556388157878481977344.0f + }; + static float fltu_135[] = { + __builtin_inff (), + 897485251387475481828390233702400.0f, + 37306898327013391597568.0f, + 3.0f, + 920156.0f, + 15230974228367008360756701604872192.0f, + 1383843467413878101508096.0f, + 143810078160377684059996776503967744.0f, + 83615893330389964423168.0f, + 1239150336.0f, + 39792041984.0f, + 20985036144640.0f, + 3700707.0f, + 14510535475200.0f, + 5675982933774352481468669797335040.0f, + 593909606786098794594304.0f, + 413008901830615236608.0f, + 34694483968.0f, + 592129.0f, + 2649.0f, + 154468455934475733304034734374912.0f, + __builtin_inff (), + 456.0f, + 12101.0f, + 5879086080.0f, + 115170059747328.0f, + __builtin_inff (), + 63923151928943443968.0f, + __builtin_inff (), + 9.0f, + 5703520697688581472256.0f, + 44653117440.0f, + 1440439672101666816.0f, + 3496654143488.0f + }; + for (int i = 0; i < 34; ++i) + if (testflt_135 (s_135[i]) != flt_135[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testfltu_135 (u_135[i]) != fltu_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static float flt_192[] = { + 81945579470551984745273979116049137664.0f, + 1640150781354328003699743106531328.0f, + 432402474830816591643797717254144.0f, + -__builtin_inff (), + 217705802104832.0f, + 1.0f, + -150837356860384332849610752.0f, + 1247354020200583118196884635648.0f, + -700073528334631668550369017856.0f, + -__builtin_inff (), + -743993169284474461872900775245512704.0f, + 1681039.0f, + -__builtin_inff (), + -97703169989152795899105082605568.0f, + 9.0f, + 7277656062827612295463998324736.0f, + 7201222144.0f, + -4671533860148685993668956641034240.0f, + 13311155535609252557094912.0f, + __builtin_inff (), + -283560864177100653079149659746813870080.0f, + __builtin_inff (), + 1122038754191063555360632711675904.0f, + -9541613258608657772880016179200.0f, + 21551010941830070997495077018796032.0f, + -4794294027361853497357107200.0f, + -5708612694366486528.0f, + -__builtin_inff (), + -35698660648279573790720.0f, + -79587925032960.0f, + 469393711604695040.0f, + -__builtin_inff (), + -115.0f, + -1717706686464.0f + }; + static float fltu_192[] = { + __builtin_inff (), + __builtin_inff (), + 289472678477035675109665275904.0f, + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + 512829259776.0f, + __builtin_inff (), + 1918805247503610004149880487936.0f, + 99680641842413568.0f, + 313647265860414511058971000832.0f, + __builtin_inff (), + 1751643624308736.0f, + 24084145747217780385007409962156032.0f, + 1282076.0f, + 13590701491613597696.0f, + 62207548751752462336.0f, + 144040024354059546360660309323802476544.0f, + __builtin_inff (), + __builtin_inff (), + 4649.0f, + __builtin_inff (), + __builtin_inff (), + 11488350322032640.0f, + __builtin_inff (), + 36826148503552.0f, + 554404238373758103887118598144.0f, + 2804528971776.0f, + 127.0f, + 66823887263746144234653953818624.0f, + 297736634368.0f, + __builtin_inff (), + 107247050752.0f + }; + for (int i = 0; i < 34; ++i) + if (testflt_192 (s_192[i]) != flt_192[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testfltu_192 (u_192[i]) != fltu_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static float flt_575[] = { + __builtin_inff (), + -__builtin_inff (), + __builtin_inff (), + 275983721032549254738830597716881440768.0f, + __builtin_inff (), + __builtin_inff (), + -__builtin_inff (), + -__builtin_inff (), + __builtin_inff (), + -3523803575380752640275405340672.0f, + -__builtin_inff (), + -__builtin_inff (), + 8137926508544.0f, + -15994393281493713095582868026949632.0f, + -__builtin_inff (), + __builtin_inff (), + __builtin_inff (), + 2003391250601164668928.0f, + -__builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + -24501130336514943435685610127360.0f, + -__builtin_inff (), + __builtin_inff (), + __builtin_inff (), + -__builtin_inff (), + __builtin_inff (), + -__builtin_inff (), + -__builtin_inff (), + -__builtin_inff (), + __builtin_inff (), + __builtin_inff () + }; + static float fltu_575[] = { + 340315913217135083520.0f, + __builtin_inff (), + __builtin_inff (), + 1253811215516794865319936.0f, + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + 61551828.0f, + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + 224319717376.0f, + 1851847786157309952.0f, + 3517907886717368541269560933367152640.0f, + __builtin_inff (), + __builtin_inff (), + 1035184768712441856.0f, + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + __builtin_inff (), + 2146.0f, + 25165295728767510106569460506689536.0f, + 6254.0f + }; + for (int i = 0; i < 34; ++i) + if (testflt_575 (s_575[i]) != flt_575[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testfltu_575 (u_575[i]) != fltu_575[i]) + __builtin_abort (); +#endif +#endif +#if __DBL_MANT_DIG__ == 53 +#if __BITINT_MAXWIDTH__ >= 135 + static double dbl_135[] = { + -39242093.0, + -36246971635108657531715584.0, + -816440703352.0, + 8409360.0, + 231875.0, + -1859.0, + 8123250453541346905042562585110511616.0, + 42642091.0, + -2499664813007708750469922816.0, + -14022533493907733348352.0, + 737816709430180073007218688.0, + 3094418595787172340280288631324672.0, + 84096.0, + -3856393637064417.0, + 5494.0, + -7227655824382622695424.0, + 185250722103742944.0, + -266695839223233236177082217685581824.0, + 124.0, + -4540724906728462124105811223379968.0, + -34474123.0, + 6171186.0, + -1738448518309495524665904679484391424.0, + 3714.0, + 22759310366655439518928576500989952.0, + -461.0, + -1891475049610273567723258005078180626432.0, + -350.0, + 3721759411106519834940439265280.0, + -42485872965031411712.0, + 4362279409022137156015669379072.0, + 521928664204421058633672118513103273984.0, + -50129.0, + -21525556783117337240797184.0 + }; + static double dblu_135[] = { + 773802493804221992623001034499154771968.0, + 897485218654369723848104601452544.0, + 37306898634990774386688.0, + 3.0, + 920156.0, + 15230973698181137968871516305096704.0, + 1383843491123931258028032.0, + 143810081711544982658521010624528384.0, + 83615891310230336700416.0, + 1239150390.0, + 39792042288.0, + 20985035121604.0, + 3700707.0, + 14510535740825.0, + 5675982879048652786568565738176512.0, + 593909622129190116524032.0, + 413008891327830556672.0, + 34694483328.0, + 592129.0, + 2649.0, + 154468451808267468485637384962048.0, + 8905088171048376547587929854079236308992.0, + 456.0, + 12101.0, + 5879086272.0, + 115170058487623.0, + 2274163249406113722963963066981556420608.0, + 63923152267905662976.0, + 624302860090054299856857502421553774592.0, + 9.0, + 5703520721951508135936.0, + 44653119094.0, + 1440439605268989184.0, + 3496654014361.0 + }; + for (int i = 0; i < 34; ++i) + if (testdbl_135 (s_135[i]) != dbl_135[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testdblu_135 (u_135[i]) != dblu_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static double dbl_192[] = { + 81945579384314687557742233571238608896.0, + 1640150770700583037463354142621696.0, + 432402469012491501348574281596928.0, + -15369197386440508938509968376382119346509732380672.0, + 217705797486262.0, + 1.0, + -150837356854711041828847616.0, + 1247354027519369502575283929088.0, + -700073531555662276303601532928.0, + -441651351073606679519160525300938309632.0, + -743993151249791396098631688421113856.0, + 1681039.0, + -170386616439159361826828161968707433660416.0, + -97703172400304826279491553722368.0, + 9.0, + 7277656199366069333121407385600.0, + 7201222364.0, + -4671533967546296379435628906938368.0, + 13311155734490577941561344.0, + 76150533189365686624757419076841278552408064.0, + -283560863483321472582205283908875976704.0, + 6438368552004797730833578371043525700779108699471872.0, + 1122038765213390753205991088586752.0, + -9541613313421359725756721135616.0, + 21551012076757076520029583197601792.0, + -4794294047755173506637103104.0, + -5708612827808553984.0, + -2649648007071280532341234166535418312753414144.0, + -35698660478241256505344.0, + -79587921140918.0, + 469393710173925632.0, + -261330983098092727670915068943820759127419298070396928.0, + -115.0, + -1717706681396.0 + }; + static double dblu_192[] = { + 87197051833867272390202829166908318800909697024.0, + 175207476610687217879860344599290566299997853188096.0, + 289472685412214309690412105728.0, + 58352315342320052737011578650960945217536.0, + 68512267071922037583525562378571212344840731754496.0, + 8654067584750856522039960763727020807946240.0, + 57027948061283101680073163019018106591772672.0, + 512829256101.0, + 8815296701808550079625439512864915193856.0, + 1918805208198312244509799350272.0, + 99680639255733808.0, + 313647272226958910616850399232.0, + 534434342549592748637063994840786615140352.0, + 1751643652514709.0, + 24084146046683127568067882664329216.0, + 1282076.0, + 13590701668411111424.0, + 62207549230439505920.0, + 144040025133692463994664792383004082176.0, + 11981724905403944877595374666928320404518862848.0, + 1823479497818478827998416063488921051624645800235106304.0, + 4649.0, + 2095541338428713553559812835366404384524126144954368.0, + 605377488765896315082607405999750595789425999872.0, + 11488350477184224.0, + 9492972359709013522794710883315474336917948771336192.0, + 36826148417259.0, + 554404239122129838954063593472.0, + 2804528919100.0, + 127.0, + 66823885107232869968562331058176.0, + 297736625249.0, + 3701132312864550589964164920177814261972243111315767296.0, + 107247048428.0 + }; + for (int i = 0; i < 34; ++i) + if (testdbl_192 (s_192[i]) != dbl_192[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testdblu_192 (u_192[i]) != dblu_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static double dbl_575[] = { + 822555268170764297634225399451759946746992540590809881338557024729825280.0, + -960580267694575822855611495941585347204287976360447994911667455476231250947192048882720653908949004193890304.0, + 33504080263976494977558165276907141142985667083206076858318677497395449849522674033540660299812700936436629271063580537369602818048.0, + 275983725374553560382241222733294731264.0, + 5534912144897227981721785252365318913099024300479520929615780375858014135428545244514013933284386952701873840884059278413011909801315647098618874845818373456314285330268160.0, + 1412920302762670981724654587829101441064363178039081649317449002875219686863615617096481906597938056255380563207859934619548778496.0, + -262974997977953547412616819382246513411941636601411079958856272578116216992825344.0, + -92488905333378800887332041285981414442679115849793894833270926171369794209000194048.0, + 242604167696163745705487164545064266366976.0, + -3523803651131338905043794395136.0, + -5147220779398204956062097693667869669268514878983078506579452381903246893001528080183706343394366450560829994902536411900094807055106480897434592050304516096.0, + -126995956651641932664992814931771424612524306428042763656077526441611704177400372487041993300114407424.0, + 8137926360495.0, + -15994393111836745817684083180830720.0, + -277068516868681208843378539444762089120272250101874770818281861285776026097252118136221894703961747524419584.0, + 12643256666940490094502018407000917191440297183002304612995222607645672663994449919572180992.0, + 197250790460297249337611855831853736085011038208.0, + 2003391279347377111040.0, + -199877387236416487880239440186867935179678108631030562816.0, + 683783725793437376953847532054635915450883103104150353591684114076623183460343349044869993313461680324691804857056989176851941526653681669242880.0, + 13527430925075103137395594360375039920265895975276069404569617039360.0, + 539267000300803467143224409095377978528526384444410994726548852694612047977432378724606879533366903144710144.0, + 25132435181738021158181758368227989609664280796006529821958155232496895580737809559413590065152.0, + -24501129715197465145324272091136.0, + -26621511339033229577933593130365525581365248.0, + 219726795681725203086615878008721704050996541338139327356409273606611142342004775592132608.0, + 142706206515281338563561427905630882997359612390115520631287147248801675296196390219660900162069776564224.0, + -1272097813202031695774673850580967606153271008283204619545732236750677292631566843904.0, + 104580584066897764106493049954563517551311873970918028573957449051117037877644455167894862496406485527470814840408584063287296.0, + -10163452549280414266636885849517652803498703924514090324303688401722691539656540095676077155202913299163727204412770763270991539282383353646632785170429061890048.0, + -1462817702603947424514705987528105462111189926351038186632282100495484739291866737828490405005509893174352599206536639203945990323918788886528.0, + -1004473459167555693379448563952458083163231922159616.0, + 383945882095471809778477642717090299126500715170441296829413124731981221073489411436597060515704853514279862909459893170581511755452645376.0, + 147266903774875160122803299680751368800498930915627484017852416.0 + }; + static double dblu_575[] = { + 340315902121482059776.0, + 9193736781349493621405581031201638729956693377024.0, + 121133456126887614949840563267333164930922114527830924098169755757644187539060293632.0, + 1253811282917665907146752.0, + 279807426767721167224232624903862775521562023356169096523467570552357504424852523581440.0, + 4763192686302836266016084152796744123294035214336.0, + 19433750446582363914783523863519537892469170046699527182095230312993931481088146791402683275534315552768.0, + 8615689860907973684813089916677872622369301590036773127424335682014143120538819857749267776316706246365207593078790418785926108454964638864284607647395585351338688512.0, + 126055589776274664055563357164473926765229686711256362550309370211691455811892471436667901827515295553040869973224666092493870267949222939304809964524921924217733120.0, + 34636325529158225609732004478359404024810355780116436151965488784911880463832346975056353708910319963631363476007842111096356864.0, + 2295982750677874440830690242430022722310395038479306194944.0, + 22288650253829611656582899585105561922738061312.0, + 61551827.0, + 948415991495935277158065207187216102893971687538169358437498088171511819979329197955070708594226287655578579327935243978625908341735424.0, + 7599947921908039201020389523460283262016591366306988284476594385856376859892071911998135440769024.0, + 3064098671438076262631558926659124050612030123593391586289496610357367704588066201089697403929948683093930760302363801622713089626566308942422673109893593769913375260672.0, + 26163216482276434323059552752807045466093212833119225389172469300377369630622147477953596829696868035573317632.0, + 1083530146709801287488575139896111218252634145778954464029109940268038137024528653987999105697728348938546608345738475665376063185384327227976954513446733080428544.0, + 241446995995054294694559180878245213888164982782164992.0, + 224319712854.0, + 1851847735563213312.0, + 3517907813008404560136740290886107136.0, + 57026061017409511227244639666735331364603008817984523485318163959373956415485902848.0, + 218054639772618086702097627512642011917064593803091900409463425864524464099706282773581011770933248.0, + 1035184782769221376.0, + 20229959242348673341261734187831508959698424427160892456742004821954487315365414763816110107652513076773401171962363904.0, + 48688062002166779121886848500298978377358186775166569744218208875095511886249915901603271262547063601222998163903380246886122115788425950691666910366400512.0, + 38974159722814403783188765470424741900583576369459629735378952745201038923704525454001059605107694314700748523810324480.0, + 195268331869690962780067959053006275481517082721312675880802634445094912.0, + 131384791058457555617616111281677184113372650274571562034279153020161645779289769480396688326656.0, + 1334982489788592098527293353260669206528.0, + 2146.0, + 25165296015221801457062319885385728.0, + 6254.0 + }; + for (int i = 0; i < 34; ++i) + if (testdbl_575 (s_575[i]) != dbl_575[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testdblu_575 (u_575[i]) != dblu_575[i]) + __builtin_abort (); +#endif +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-24.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-24.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,804 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) long double +testldbl_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) long double +testldbl_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) long double +testldbl_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) long double +testldblu_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) _Float128 +testflt128_135 (_BitInt(135) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_135 (unsigned _BitInt(135) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _Float128 +testflt128_192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _Float128 +testflt128_575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) _Float128 +testflt128u_575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + static _BitInt(135) s_135[] = { + -39242093wb, + -36246971635108657318127321wb, + -816440703352wb, + 8409360wb, + 231875wb, + -1859wb, + 8123250453541347379290840008816194983wb, + 42642091wb, + -2499664813007708583619356686wb, + -14022533493907734339644wb, + 737816709430180009697449492wb, + 3094418595787172583521548578719419wb, + 84096wb, + -3856393637064417wb, + 5494wb, + -7227655824382622730861wb, + 185250722103742953wb, + -266695839223233222300219080587185431wb, + 124wb, + -4540724906728461994579131745203067wb, + -34474123wb, + 6171186wb, + -1738448518309495501564259945530043942wb, + 3714wb, + 22759310366655438105064084505115489wb, + -461wb, + -1891475049610273521994429918325638525836wb, + -350wb, + 3721759411106519959861226774340wb, + -42485872965031409753wb, + 4362279409022137273490486629950wb, + 521928664204421037572709995195346211111wb, + -50129wb, + -21525556783117336078661729wb + }; + static unsigned _BitInt(135) u_135[] = { + 773802493804221964748670742461281016363uwb, + 897485218654369665002411485681173uwb, + 37306898634990773758633uwb, + 3uwb, + 920156uwb, + 15230973698181139105641901258312096uwb, + 1383843491123931387484696uwb, + 143810081711544975903357370071668200uwb, + 83615891310230331473978uwb, + 1239150390uwb, + 39792042288uwb, + 20985035121604uwb, + 3700707uwb, + 14510535740825uwb, + 5675982879048653163399531637816917uwb, + 593909622129190124122830uwb, + 413008891327830587264uwb, + 34694483328uwb, + 592129uwb, + 2649uwb, + 154468451808267466822214091328849uwb, + 8905088171048376399858691570634230197204uwb, + 456uwb, + 12101uwb, + 5879086272uwb, + 115170058487623uwb, + 2274163249406113742515726136586945854500uwb, + 63923152267905666653uwb, + 624302860090054295150365837280525227924uwb, + 9uwb, + 5703520721951508439418uwb, + 44653119094uwb, + 1440439605268989101uwb, + 3496654014361uwb + }; +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static _BitInt(192) s_192[] = { + 81945579384314684613279565479277935940wb, + 1640150770700583136800158704601080wb, + 432402469012491481987292073086668wb, + -15369197386440508323548800500962985157137866798390wb, + 217705797486262wb, + 1wb, + -150837356854711044278780637wb, + 1247354027519369533750440146304wb, + -700073531555662209687924602081wb, + -441651351073606706893667405889558445894wb, + -743993151249791392844844248857961054wb, + 1681039wb, + -170386616439159353410812029301398243129730wb, + -97703172400304820221345002831889wb, + 9wb, + 7277656199366069102639319241893wb, + 7201222364wb, + -4671533967546296507223686237333335wb, + 13311155734490577635922550wb, + 76150533189365685907637983428512213977569647wb, + -283560863483321465221194695455688610811wb, + 6438368552004797088499844257634549000496626110080371wb, + 1122038765213390728664343086041576wb, + -9541613313421359977755878156940wb, + 21551012076757076795102244535269250wb, + -4794294047755173531367558272wb, + -5708612827808554221wb, + -2649648007071280662902443553973167294046518180wb, + -35698660478241255546377wb, + -79587921140918wb, + 469393710173925646wb, + -261330983098092746969723637867599382044980841179747207wb, + -115wb, + -1717706681396wb + }; + static unsigned _BitInt(192) u_192[] = { + 87197051833867272589618945858714291675632402028uwb, + 175207476610687227705633653396153452205075322355946uwb, + 289472685412214318981767004188uwb, + 58352315342320048378103056601781218026976uwb, + 68512267071922032916894194298300228491490143452269uwb, + 8654067584750856592691725728280108682858075uwb, + 57027948061283099317671673937496946487124629uwb, + 512829256101uwb, + 8815296701808550493421309771596155666520uwb, + 1918805208198312310092547265227uwb, + 99680639255733807uwb, + 313647272226958893709907781719uwb, + 534434342549592762863366619879590694414818uwb, + 1751643652514709uwb, + 24084146046683127013882581681582087uwb, + 1282076uwb, + 13590701668411111769uwb, + 62207549230439503653uwb, + 144040025133692457990548614076288499046uwb, + 11981724905403945793356785358565398049196880116uwb, + 1823479497818478859136796209626920064416489979129893695uwb, + 4649uwb, + 2095541338428713427585867932062430293488017906261402uwb, + 605377488765896342050766363050545164888333863362uwb, + 11488350477184223uwb, + 9492972359709013710789022084605392630683565515935199uwb, + 36826148417259uwb, + 554404239122129842026250702689uwb, + 2804528919100uwb, + 127uwb, + 66823885107232870336040073990324uwb, + 297736625249uwb, + 3701132312864550550157874952341371502832960625370598966uwb, + 107247048428uwb + }; +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static _BitInt(575) s_575[] = { + 822555268170764275096048134868384963633463468104839796862654006268369616wb, + -960580267694575830808697063169243963045681635800151938720065734940592300657700227419337766780029829446319203wb, + 33504080263976494448954627475165765154890874061543914469206217657999706310163279811015042121096338719830090426757797138233202615461wb, + 275983725374553564148936957707321552749wb, + 5534912144897227754137156977371639235252437172582938580045103986268272085395760563838753817115093434280932847973705994570261258933419373885658991359441723005813683395590541wb, + 1412920302762671055711845665320769771488824036206881359103417821581950493952853265134760513685359011001836948515905971331797139790wb, + -262974997977953570994865210107604152900839198803859287819970850481583440338320059wb, + -92488905333378799268618025132022462336176863903734682501838771365453998891689279398wb, + 242604167696163732697906496386839396751068wb, + -3523803651131338645439245946293wb, + -5147220779398204849222374563179412010462379234108857688330486391319694172748210918710342389194957287070617133280194810193962683650761347126311504766504260691wb, + -126995956651641937332005246092202755154992252553028943468563459072746155379181900761169956344678911600wb, + 8137926360495wb, + -15994393111836746332671329788635258wb, + -277068516868681202554828866807401284583187899477211188256772654837767448404666578906477389363058609157862574wb, + 12643256666940489874033990964997310860090310878838229112053311027168830831623703103010815387wb, + 197250790460297242975596746662998763328365874997wb, + 2003391279347376998472wb, + -199877387236416475658211887841938073691092213166438343739wb, + 683783725793437346966376731991835336458591392078548990419792641719902684445391913394174240265031277360362886303597899811253111402611797905136669wb, + 13527430925075101894748577029275389339063875642859674079897983403256wb, + 539267000300803493510458136103246878203019746178696339759252798818676107273127463057162208073142618039409911wb, + 25132435181738021677664552852329012363786311024121402747618663944355967806315928846073722774898wb, + -24501129715197464074815490290653wb, + -26621511339033230503491791253914731850253401wb, + 219726795681725191949095808767196099036895435893837474958165415185577738548053399820419849wb, + 142706206515281341916417852232439287400819155237127620529348000437671770471697052705666056232742428920527wb, + -1272097813202031618710288063584910456400985264371503722255927680393419899507092728461wb, + 104580584066897755717617980935051171929519336855902844943415231226523598033953128466889325153396268078513996620240379420239887wb, + -10163452549280413821027501723364683075067110986059205073343287754152825761658667193285948456506970145368258900765489010580419998927374372004822965287098902519382wb, + -1462817702603947401421838547412731208810505797188084686210372939517152226213737422286025118826482655559744680456146694118022879735528111700409wb, + -1004473459167555639043426932334304398038355185104669wb, + 383945882095471823332216311173956104021530654187057868803605149628498470119801535759629951357637987556377174553957515312582545289930138018wb, + 147266903774875157001493887893421901156259749590403482558013070wb + }; + static unsigned _BitInt(575) u_575[] = { + 340315902121482071031uwb, + 9193736781349493374149172723522049938732355975055uwb, + 121133456126887617775249483436586396232697894267611535022240817951287068117843073672uwb, + 1253811282917666038992497uwb, + 279807426767721176279253888473522991149118862415710500804613956730247764438409575562386uwb, + 4763192686302836059965684032432862167583119264783uwb, + 19433750446582365356875213925336734177599085624532213292961813424848222698351037862663241858724337375675uwb, + 8615689860907972907203187028321798323548254692780962654211537619771698680316938530412569744897459065621193843349775333790731199245018643579445580816793381624810616262uwb, + 126055589776274659515356020606486923511478187977197128509709117843059226901071386846700207970626608150351060714322162254429913496135590117225450775153364768928781244uwb, + 34636325529158225079379169125604752070369970834816893592982969115088710130160324580864333959889906313467177163564702338046445540uwb, + 2295982750677874548137685137480985649627965059590627454944uwb, + 22288650253829612832302454550260146151077393473uwb, + 61551827uwb, + 948415991495935226718622697967024251064408554619458611515264819726244946850447758605031396753280209023664964305741301009407513619686102uwb, + 7599947921908039117808602805272900633862767543347735124983729771592896283177667324402886239291446uwb, + 3064098671438076295010586583414642866550259610904044948559784636731818131096680869327433283805326015689481397549653557650965154282598345191654721039973597171695049076467uwb, + 26163216482276433755253744705785501134309546797499410671258175352214852627310317854549342428286751107453875459uwb, + 1083530146709801198539441549736949256980046185455966999062614188586191607484611079705240990524552846829821534154580456458426794497253838343299379036578711641930103uwb, + 241446995995054305582384233456322509709013171336859127uwb, + 224319712854uwb, + 1851847735563213275uwb, + 3517907813008404838784133683859253992uwb, + 57026061017409510123542169719303829618100077009666501089739966522905673377916488253uwb, + 218054639772618074096850378810323560503313926757275788155487065187235936858569852576120793613879980uwb, + 1035184782769221379uwb, + 20229959242348674822834301353257599618846169820699281424077697412860273533283192155424030349307384555863768665398854990uwb, + 48688062002166777196074419660880812175599377353811333642743225865182422320253615211852611218169059717666168172585704763331192485699241038689921302806665184uwb, + 38974159722814402881994907079236516884965127718714589284306855526034875317101125387287977578141556918226042568695412232uwb, + 195268331869690963115384309853070889302314974440838447729079592004150231uwb, + 131384791058457562831689753115846222538215620945564207628285200123621656731679644407994773520965uwb, + 1334982489788592107403503927792629194402uwb, + 2146uwb, + 25165296015221802429838428736907886uwb, + 6254uwb + }; +#endif +#if __LDBL_MANT_DIG__ == 64 +#if __BITINT_MAXWIDTH__ >= 135 + static long double ldbl_135[] = { + -39242093.0L, + -36246971635108657317806080.0L, + -816440703352.0L, + 8409360.0L, + 231875.0L, + -1859.0L, + 8123250453541347379469761730828042240.0L, + 42642091.0L, + -2499664813007708583503069184.0L, + -14022533493907734339584.0L, + 737816709430180009723559936.0L, + 3094418595787172583474668509331456.0L, + 84096.0L, + -3856393637064417.0L, + 5494.0L, + -7227655824382622730752.0L, + 185250722103742953.0L, + -266695839223233222305995365384454144.0L, + 124.0L, + -4540724906728461994627321936478208.0L, + -34474123.0L, + 6171186.0L, + -1738448518309495501607474587347451904.0L, + 3714.0L, + 22759310366655438104798293506654208.0L, + -461.0L, + -1891475049610273521975332702278492618752.0L, + -350.0L, + 3721759411106519959735009017856.0L, + -42485872965031409752.0L, + 4362279409022137273388535644160.0L, + 521928664204421037567490386336795328512.0L, + -50129.0L, + -21525556783117336078974976.0L + }; + static long double ldblu_135[] = { + 773802493804221964731523995050312728576.0L, + 897485218654369665019834468925440.0L, + 37306898634990773757952.0L, + 3.0L, + 920156.0L, + 15230973698181139106030422216146944.0L, + 1383843491123931387527168.0L, + 143810081711544975903121569568784384.0L, + 83615891310230331473920.0L, + 1239150390.0L, + 39792042288.0L, + 20985035121604.0L, + 3700707.0L, + 14510535740825.0L, + 5675982879048653163182084577034240.0L, + 593909622129190124126208.0L, + 413008891327830587264.0L, + 34694483328.0L, + 592129.0L, + 2649.0L, + 154468451808267466823175803764736.0L, + 8905088171048376400013977264402823380992.0L, + 456.0L, + 12101.0L, + 5879086272.0L, + 115170058487623.0L, + 2274163249406113742443724808818842927104.0L, + 63923152267905666652.0L, + 624302860090054295134491019551908560896.0L, + 9.0L, + 5703520721951508439552.0L, + 44653119094.0L, + 1440439605268989101.0L, + 3496654014361.0L + }; + for (int i = 0; i < 34; ++i) + if (testldbl_135 (s_135[i]) != ldbl_135[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testldblu_135 (u_135[i]) != ldblu_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static long double ldbl_192[] = { + 81945579384314684615486553814565126144.0L, + 1640150770700583136824020921483264.0L, + 432402469012491481997169632739328.0L, + -15369197386440508323699427265690859620608677773312.0L, + 217705797486262.0L, + 1.0L, + -150837356854711044278321152.0L, + 1247354027519369533773926367232.0L, + -700073531555662209714428575744.0L, + -441651351073606706894128730685912907776.0L, + -743993151249791392856039956714356736.0L, + 1681039.0L, + -170386616439159353411571089494999662854144.0L, + -97703172400304820218983461421056.0L, + 9.0L, + 7277656199366069102773721366528.0L, + 7201222364.0L, + -4671533967546296507225268333576192.0L, + 13311155734490577636425728.0L, + 76150533189365685909073333864980807126351872.0L, + -283560863483321465221954398498764881920.0L, + 6438368552004797088286842127358606670130187958484992.0L, + 1122038765213390728647299370582016.0L, + -9541613313421359977544883896320.0L, + 21551012076757076794749160467202048.0L, + -4794294047755173531333165056.0L, + -5708612827808554221.0L, + -2649648007071280662943908311143037314611019776.0L, + -35698660478241255546880.0L, + -79587921140918.0L, + 469393710173925646.0L, + -261330983098092746965490195259240226746743657452273664.0L, + -115.0L, + -1717706681396.0L + }; + static long double ldblu_192[] = { + 87197051833867272588273235452569162784769572864.0L, + 175207476610687227706687797568524886702441101262848.0L, + 289472685412214318984721334272.0L, + 58352315342320048378267314962278412976128.0L, + 68512267071922032918571353538687014836972935970816.0L, + 8654067584750856592762121211182827528257536.0L, + 57027948061283099315414259852803440866492416.0L, + 512829256101.0L, + 8815296701808550493422802574317577043968.0L, + 1918805208198312310068180156416.0L, + 99680639255733807.0L, + 313647272226958893711859122176.0L, + 534434342549592762879721307175636579647488.0L, + 1751643652514709.0L, + 24084146046683127014125128497758208.0L, + 1282076.0L, + 13590701668411111769.0L, + 62207549230439503652.0L, + 144040025133692457990249596390545031168.0L, + 11981724905403945793671003738109723829870788608.0L, + 1823479497818478859069120464961329580751135834288160768.0L, + 4649.0L, + 2095541338428713427646614015896834392659590161367040.0L, + 605377488765896342059796742106757546391141089280.0L, + 11488350477184223.0L, + 9492972359709013711015472005202975871148440705564672.0L, + 36826148417259.0L, + 554404239122129842012080308224.0L, + 2804528919100.0L, + 127.0L, + 66823885107232870337998237990912.0L, + 297736625249.0L, + 3701132312864550550087325046630338074858031302905430016.0L, + 107247048428.0L + }; + for (int i = 0; i < 34; ++i) + if (testldbl_192 (s_192[i]) != ldbl_192[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testldblu_192 (u_192[i]) != ldblu_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static long double ldbl_575[] = { + 822555268170764275077806657331958312785072234722196584950240570089930752.0L, + -960580267694575830812783278498171621690403946709581436518965868233794729994615679173272606109483012722786304.0L, + 33504080263976494448478492229617991564043478238504231331124912879329149376584163966764611121993710792934518914942887118335291424768.0L, + 275983725374553564145377013770043260928.0L, + 5534912144897227754208044441151874379702287612174069453950291607680839007181861996360330547973886690095069343864416739797783816199380471673982675880600014677768303758278656.0L, + 1412920302762671055675563434211562120848328209741725967322941102900395775694793728702679689406728724040334624347456855689117302784.0L, + -262974997977953570989611804750151836163609455430948784164618597359252696534614016.0L, + -92488905333378799268155556881914668962189440213360997930258834387927208673968914432.0L, + 242604167696163732690645137756322057420800.0L, + -3523803651131338645559050240000.0L, + -5147220779398204849257508190774210744388677252688140210517976277065981842998232251783846790859222005317012238819263034139406832143929230632126090335152504832.0L, + -126995956651641937331951286489675247329200371648605762035297081195775007184684091195737834711064510464.0L, + 8137926360495.0L, + -15994393111836746332220340607909888.0L, + -277068516868681202557212831225058932276240633526059351948516115207300877649787450206685852465539880786591744.0L, + 12643256666940489873646135309702875993528109590137490134559735498193302898793674757994708992.0L, + 197250790460297242979551814062140644203109023744.0L, + 2003391279347376998528.0L, + -199877387236416475651341878965641904464653154051860463616.0L, + 683783725793437346957771892228315489408774085809131650337993219889398577200119614673432810174598052160906191944536223932553104679193775255322624.0L, + 13527430925075101895119202629107559447133788166435502697026955509760.0L, + 539267000300803493497377352922791719626542478240740953329921195747662290582499442246914945221535539392413696.0L, + 25132435181738021677436908541817803462240416694341366601465742717478799945180412844899030794240.0L, + -24501129715197464074399946637312.0L, + -26621511339033230503970770955171473406296064.0L, + 219726795681725191947197274288751751131300579623020247100319392523607242309690678380068864.0L, + 142706206515281341912722598102787801262511939753862115682796537774690209934320984609531887855849227419648.0L, + -1272097813202031618686076349197106943277274743836448162114522403548727854475931287552.0L, + 104580584066897755721462109894862071102150680746488173021715848651881249493019658369304827516906027223482984669789074019581952.0L, + -10163452549280413820781685181828332647679763634230328394877439998644536448688077844493834184118223902098524496370094218227350253632267534838755399334577766924288.0L, + -1462817702603947401460379075968185573663143558708148172616668782116177216739740002633588435639151707520878885121466080144202470951229168025600.0L, + -1004473459167555639022590826165981346984598475636736.0L, + 383945882095471823335289502673360394820076368186253637060368537085404663434451033274997076104121125319917967630183508209073164612376985600.0L, + 147266903774875157000698971886464128985498372744856873180594176.0L + }; + static long double ldblu_575[] = { + 340315902121482071040.0L, + 9193736781349493374213713986696905438099568328704.0L, + 121133456126887617773526383630522733268849231796244390648544501184867233045273378816.0L, + 1253811282917666039005184.0L, + 279807426767721176282774705066477746529679092594765002865548096525989858075665567318016.0L, + 4763192686302836060022861615709466380079764340736.0L, + 19433750446582365356243841895010508514709904909750555910761104889681456249932954817669662897799021199360.0L, + 8615689860907972907222987015567999691990010815316564361117521521881809095333131098584672097178927461838400993199702306526955489286031755082939241644835174978131329024.0L, + 126055589776274659510297467904389237873624120132406221380350474491493460160959938222126650105936552657875183912780356083785858555181180003532557375481178518259236864.0L, + 34636325529158225078961380771473094521787740905726267965061232731631589683984587408777114033008811740835389841050115225879052288.0L, + 2295982750677874548189777005986107945005083683202176909312.0L, + 22288650253829612832625936906216823076906074112.0L, + 61551827.0L, + 948415991495935226723497275802282711176800359354343687935431821975740085005513640520546841077796705045317773075243223746142080749010944.0L, + 7599947921908039117650085272592622557045482160051694630122205426595170751482611426300682100015104.0L, + 3064098671438076294956291179633525016992278379765933214428836815032632500735568461039018643426109912566222922020667353487719095386222010158443081500511850171532585205760.0L, + 26163216482276433754726515355485427397196865766902718455812787467581155703138962108081214195725927010405449728.0L, + 1083530146709801198518741455890332623877113096673714750194062874316360337538555304664904549334408175509822671036217297610308526225295574707709647653730601851158528.0L, + 241446995995054305577613396367243923288085288827486208.0L, + 224319712854.0L, + 1851847735563213275.0L, + 3517907813008404838855514029591363584.0L, + 57026061017409510124756586261527283120773656504559685146885133984875447971917856768.0L, + 218054639772618074103918318492639949832541424857847525973689094242831096606721142712632506945896448.0L, + 1035184782769221379.0L, + 20229959242348674822030474865930581759882432185790556800837709536659306775612115303354290565630013099091822016569802752.0L, + 48688062002166777197217906565531932202748743487730562775775885775077288260863868471270436338269362633469095873857458641986964902395586782692041797794791424.0L, + 38974159722814402882041466859823829059112658796999627209873147217197515116287035613100423934964813946613319590312148992.0L, + 195268331869690963115301358617419463247405494910442809797401817422757888.0L, + 131384791058457562832910671881942611444639653628436820141165072497889292487990472973483579015168.0L, + 1334982489788592107381730508641253982208.0L, + 2146.0L, + 25165296015221802429839839397412864.0L, + 6254.0L + }; + for (int i = 0; i < 34; ++i) + if (testldbl_575 (s_575[i]) != ldbl_575[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testldblu_575 (u_575[i]) != ldblu_575[i]) + __builtin_abort (); +#endif +#endif +#if __FLT128_MANT_DIG__ == 113 +#if __BITINT_MAXWIDTH__ >= 135 + static _Float128 flt128_135[] = { + -39242093.0F128, + -36246971635108657318127321.0F128, + -816440703352.0F128, + 8409360.0F128, + 231875.0F128, + -1859.0F128, + 8123250453541347379290840008816194560.0F128, + 42642091.0F128, + -2499664813007708583619356686.0F128, + -14022533493907734339644.0F128, + 737816709430180009697449492.0F128, + 3094418595787172583521548578719419.0F128, + 84096.0F128, + -3856393637064417.0F128, + 5494.0F128, + -7227655824382622730861.0F128, + 185250722103742953.0F128, + -266695839223233222300219080587185440.0F128, + 124.0F128, + -4540724906728461994579131745203067.0F128, + -34474123.0F128, + 6171186.0F128, + -1738448518309495501564259945530043904.0F128, + 3714.0F128, + 22759310366655438105064084505115488.0F128, + -461.0F128, + -1891475049610273521994429918325638430720.0F128, + -350.0F128, + 3721759411106519959861226774340.0F128, + -42485872965031409753.0F128, + 4362279409022137273490486629950.0F128, + 521928664204421037572709995195346190336.0F128, + -50129.0F128, + -21525556783117336078661729.0F128 + }; + static _Float128 flt128u_135[] = { + 773802493804221964748670742461281075200.0F128, + 897485218654369665002411485681173.0F128, + 37306898634990773758633.0F128, + 3.0F128, + 920156.0F128, + 15230973698181139105641901258312096.0F128, + 1383843491123931387484696.0F128, + 143810081711544975903357370071668192.0F128, + 83615891310230331473978.0F128, + 1239150390.0F128, + 39792042288.0F128, + 20985035121604.0F128, + 3700707.0F128, + 14510535740825.0F128, + 5675982879048653163399531637816917.0F128, + 593909622129190124122830.0F128, + 413008891327830587264.0F128, + 34694483328.0F128, + 592129.0F128, + 2649.0F128, + 154468451808267466822214091328849.0F128, + 8905088171048376399858691570634230595584.0F128, + 456.0F128, + 12101.0F128, + 5879086272.0F128, + 115170058487623.0F128, + 2274163249406113742515726136586945953792.0F128, + 63923152267905666653.0F128, + 624302860090054295150365837280525221888.0F128, + 9.0F128, + 5703520721951508439418.0F128, + 44653119094.0F128, + 1440439605268989101.0F128, + 3496654014361.0F128, + }; + for (int i = 0; i < 34; ++i) + if (testflt128_135 (s_135[i]) != flt128_135[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testflt128u_135 (u_135[i]) != flt128u_135[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static _Float128 flt128_192[] = { + 81945579384314684613279565479277936640.0F128, + 1640150770700583136800158704601080.0F128, + 432402469012491481987292073086668.0F128, + -15369197386440508323548800500962985275185701060608.0F128, + 217705797486262.0F128, + 1.0F128, + -150837356854711044278780637.0F128, + 1247354027519369533750440146304.0F128, + -700073531555662209687924602081.0F128, + -441651351073606706893667405889558413312.0F128, + -743993151249791392844844248857961088.0F128, + 1681039.0F128, + -170386616439159353410812029301398240755712.0F128, + -97703172400304820221345002831889.0F128, + 9.0F128, + 7277656199366069102639319241893.0F128, + 7201222364.0F128, + -4671533967546296507223686237333335.0F128, + 13311155734490577635922550.0F128, + 76150533189365685907637983428512210753683456.0F128, + -283560863483321465221194695455688622080.0F128, + 6438368552004797088499844257634549357780509986390016.0F128, + 1122038765213390728664343086041576.0F128, + -9541613313421359977755878156940.0F128, + 21551012076757076795102244535269248.0F128, + -4794294047755173531367558272.0F128, + -5708612827808554221.0F128, + -2649648007071280662902443553973167373493993472.0F128, + -35698660478241255546377.0F128, + -79587921140918.0F128, + 469393710173925646.0F128, + -261330983098092746969723637867599366653101971873988608.0F128, + -115.0F128, + -1717706681396.0F128 + }; + static _Float128 flt128u_192[] = { + 87197051833867272589618945858714289326891466752.0F128, + 175207476610687227705633653396153448946982933495808.0F128, + 289472685412214318981767004188.0F128, + 58352315342320048378103056601781215690752.0F128, + 68512267071922032916894194298300226631128387158016.0F128, + 8654067584750856592691725728280108697911296.0F128, + 57027948061283099317671673937496946996412416.0F128, + 512829256101.0F128, + 8815296701808550493421309771596155584512.0F128, + 1918805208198312310092547265227.0F128, + 99680639255733807.0F128, + 313647272226958893709907781719.0F128, + 534434342549592762863366619879590707855360.0F128, + 1751643652514709.0F128, + 24084146046683127013882581681582088.0F128, + 1282076.0F128, + 13590701668411111769.0F128, + 62207549230439503653.0F128, + 144040025133692457990548614076288499712.0F128, + 11981724905403945793356785358565397335132602368.0F128, + 1823479497818478859136796209626919944362858664695955456.0F128, + 4649.0F128, + 2095541338428713427585867932062430298743231209275392.0F128, + 605377488765896342050766363050545174870818291712.0F128, + 11488350477184223.0F128, + 9492972359709013710789022084605392379617455653257216.0F128, + 36826148417259.0F128, + 554404239122129842026250702689.0F128, + 2804528919100.0F128, + 127.0F128, + 66823885107232870336040073990324.0F128, + 297736625249.0F128, + 3701132312864550550157874952341371337719347203092250624.0F128, + 107247048428.0F128 + }; + for (int i = 0; i < 34; ++i) + if (testflt128_192 (s_192[i]) != flt128_192[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testflt128u_192 (u_192[i]) != flt128u_192[i]) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static _Float128 flt128_575[] = { + 822555268170764275096048134868384975231305202380698070398256893835345920.0F128, + -960580267694575830808697063169243925424347053477730475548747760281578375092219925810414573005477242346668032.0F128, + 33504080263976494448954627475165766133582184724974885918953650948043300306793972216863395126909133067122418159809305365193504587776.0F128, + 275983725374553564148936957707321540608.0F128, + 5534912144897227754137156977371639095192412221957522338641107839687274928618580082609389790489874004597965113744368228739650952266120186965187634240183436521269153476116480.0F128, + 1412920302762671055711845665320769739585982745090302228751251561257591917233120715027663177911819317605963828665882521916923707392.0F128, + -262974997977953570994865210107604174211285573449595140085961138156042539763761152.0F128, + -92488905333378799268618025132022457141142846570320249542701164032605273639863975936.0F128, + 242604167696163732697906496386839380754432.0F128, + -3523803651131338645439245946293.0F128, + -5147220779398204849222374563179412133730483913244844947741095427844771020506369407923839149503287374038736861390994705329184147880909168291858806583886610432.0F128, + -126995956651641937332005246092202760396991711130361124184051111962275756857424469430504968451843424256.0F128, + 8137926360495.0F128, + -15994393111836746332671329788635258.0F128, + -277068516868681202554828866807401284897736575250260327862135188106751832616437168642952110232327515317207040.0F128, + 12643256666940489874033990964997310311509982541568852403544135424197738165753506401380990976.0F128, + 197250790460297242975596746662998771990764978176.0F128, + 2003391279347376998472.0F128, + -199877387236416475658211887841938078116745459015943716864.0F128, + 683783725793437346966376731991835350216389560350369725901413018663785858547865033572885485563448799017573485017347368404816660544180811049467904.0F128, + 13527430925075101894748577029275390536381026872613143284679822016512.0F128, + 539267000300803493510458136103246882259019817595681864105782809148075261013592028608675098514927074416787456.0F128, + 25132435181738021677664552852329012575221796248107329953164935247044160207130354864627942162432.0F128, + -24501129715197464074815490290653.0F128, + -26621511339033230503491791253914733242220544.0F128, + 219726795681725191949095808767196088027323027463729625239897408186970438805069530998505472.0F128, + 142706206515281341916417852232439290189748851664859866651282555201592789754864805842059991220441617268736.0F128, + -1272097813202031618710288063584910381967486400606337174633920325485235383013308628992.0F128, + 104580584066897755717617980935051170305797669115984125432799736278374300011999760896397625133977276440200975782266619201323008.0F128, + -10163452549280413821027501723364683055953700133730297193238300661557892457130680244331940377983114543931479834308368189407852102459256936746559008186557007921152.0F128, + -1462817702603947401421838547412731245576629932826602450317303690796368281340685443455159080277069867736216994863788876540424722028886424027136.0F128, + -1004473459167555639043426932334304453164309296447488.0F128, + 383945882095471823332216311173956128684860565442900813809054240626596219564185981250247929792487147923720686617427927221102360379955085312.0F128, + 147266903774875157001493887893421894471609745020407505370480640.0F128 + }; + static _Float128 flt128u_575[] = { + 340315902121482071031.0F128, + 9193736781349493374149172723522049989237037596672.0F128, + 121133456126887617775249483436586393077503068671965236572261282102895601164339904512.0F128, + 1253811282917666038992497.0F128, + 279807426767721176279253888473523001912720192704990464927491539867791671603022985691136.0F128, + 4763192686302836059965684032432862322867369410560.0F128, + 19433750446582365356875213925336732513880424973437320406724993874129714386347241802580335495811686203392.0F128, + 8615689860907972907203187028321797859877386013383767881250826182682427913148188824772809437492048511967461413139431335435390421932095562711387007040942408370667651072.0F128, + 126055589776274659515356020606486933259536337762793314648917307764206055685941649262118277933003906979239670868955670671312897309994725986907806357486538234999603200.0F128, + 34636325529158225079379169125604750695785810484482739930710385070599465675115027923570016766582469711320673437462251387815460864.0F128, + 2295982750677874548137685137480985746757882615322149650432.0F128, + 22288650253829612832302454550260146257726013440.0F128, + 61551827.0F128, + 948415991495935226718622697967024239258764159275032239689900905479457935391294424204960412146551901344394652585549587358170098052366336.0F128, + 7599947921908039117808602805272900645537701743475990438308994289927813380793983514791799884349440.0F128, + 3064098671438076295010586583414642942579869059363710430687661115226367832562244997089071440248013792356608654440236754254640577193658338300579944911876551907294312398848.0F128, + 26163216482276433755253744705785501643665555701904644656073951369763934041725743914298920119135277939192496128.0F128, + 1083530146709801198539441549736949272615707866142747675126337487600174059213906750437224937669383865518151504262638122920877713397402240447485732907072897115226112.0F128, + 241446995995054305582384233456322524985744615968604160.0F128, + 224319712854.0F128, + 1851847735563213275.0F128, + 3517907813008404838784133683859253760.0F128, + 57026061017409510123542169719303831161096310734855482941686454210514675616939245568.0F128, + 218054639772618074096850378810323562095353038053985944696037552052916135283715799629412817614929920.0F128, + 1035184782769221379.0F128, + 20229959242348674822834301353257600173306714018005091825486635184900252137125196224692061477495530409091482128339697664.0F128, + 48688062002166777196074419660880812364369698930536203875840059698600317657977119368587792531578529291152047948106379901115479025495192432692355212848922624.0F128, + 38974159722814402881994907079236517852974167599450685098668223152330886687288507721175784841029076691372600892770484224.0F128, + 195268331869690963115384309853070885336463825745125450367383853651197952.0F128, + 131384791058457562831689753115846222841883611947373268365763186683292391066729693706687923355648.0F128, + 1334982489788592107403503927792629186560.0F128, + 2146.0F128, + 25165296015221802429838428736907888.0F128, + 6254.0F128 + }; + for (int i = 0; i < 34; ++i) + if (testflt128_575 (s_575[i]) != flt128_575[i]) + __builtin_abort (); + for (int i = 0; i < 34; ++i) + if (testflt128u_575 (u_575[i]) != flt128u_575[i]) + __builtin_abort (); +#endif +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-25.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-25.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,91 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint && float16_runtime } } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ +/* { dg-add-options float16 } */ + +int +main () +{ +#if __FLT16_MANT_DIG__ == 11 + static volatile _Float16 s[] = { + 0.0F16, + 42.0F16, + -65504.0F16, + 65504.0F16 + }; + static volatile _Float16 u[] = { + 0.0F16, + 1.0F16, + 178.0F16, + 65504.0F16 + }; +#if __BITINT_MAXWIDTH__ >= 135 + static volatile _BitInt(135) s_135[] = { + 0wb, + 42wb, + -65504wb, + 65504wb + }; + static volatile unsigned _BitInt(135) u_135[] = { + 0uwb, + 1uwb, + 178uwb, + 65504uwb + }; + for (int i = 0; i < 4; ++i) + { + if (s[i] != (_Float16) s_135[i] + || u[i] != (_Float16) u_135[i] + || (_BitInt(135)) s[i] != s_135[i] + || (unsigned _BitInt(135)) u[i] != u_135[i]) + __builtin_abort (); + } +#endif +#if __BITINT_MAXWIDTH__ >= 192 + static volatile _BitInt(192) s_192[] = { + 0wb, + 42wb, + -65504wb, + 65504wb + }; + static volatile unsigned _BitInt(192) u_192[] = { + 0uwb, + 1uwb, + 178uwb, + 65504uwb + }; + for (int i = 0; i < 4; ++i) + { + if (s[i] != (_Float16) s_192[i] + || u[i] != (_Float16) u_192[i] + || (_BitInt(192)) s[i] != s_192[i] + || (unsigned _BitInt(192)) u[i] != u_192[i]) + __builtin_abort (); + } +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static volatile _BitInt(575) s_575[] = { + 0wb, + 42wb, + -65504wb, + 65504wb + }; + static volatile unsigned _BitInt(575) u_575[] = { + 0uwb, + 1uwb, + 178uwb, + 65504uwb + }; + for (int i = 0; i < 4; ++i) + { + if (s[i] != (_Float16) s_575[i] + || u[i] != (_Float16) u_575[i] + || (_BitInt(575)) s[i] != s_575[i] + || (unsigned _BitInt(575)) u[i] != u_575[i]) + __builtin_abort (); + } +#endif +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-26.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-26.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,66 @@ +/* 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)) _BitInt(135) +test_135 (_BitInt(135) x) +{ + return x; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) unsigned _BitInt(192) +test_192 (unsigned _BitInt(192) x) +{ + return x; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +test_575 (_BitInt(575) x) +{ + return x; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + if (test_135 (-3544625980220396993429741165699996713118wb) + != -3544625980220396993429741165699996713118wb) + __builtin_abort (); + if (test_135 (2169804wb) != 2169804wb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 192 + if (test_192 (3548247468860296534428690122730090696161878417599647607527uwb) + != 3548247468860296534428690122730090696161878417599647607527uwb) + __builtin_abort (); + if (test_192 (2169804wb) != 2169804wb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (test_575 (-33874713055088145128482141398907153733216500583643955589065159154103468056485975553675944430696955474989655597693729139818286384955989466009330817447458608627989731550807841wb) + != -33874713055088145128482141398907153733216500583643955589065159154103468056485975553675944430696955474989655597693729139818286384955989466009330817447458608627989731550807841wb) + __builtin_abort (); + if (test_575 (-3433547832854987708194667330190358661244810661613962474981319303539871wb) + != -3433547832854987708194667330190358661244810661613962474981319303539871wb) + __builtin_abort (); + if (test_575 (-49693319wb) != -49693319wb) + __builtin_abort (); + if (test_575 (57563058931861084391041643822550577259264793697002277417254009715684553274763772399490655207001200602249198262962055591804634113396033194657392511369609233430583407788096333wb) + != 57563058931861084391041643822550577259264793697002277417254009715684553274763772399490655207001200602249198262962055591804634113396033194657392511369609233430583407788096333wb) + __builtin_abort (); + if (test_575 (158093724114624905837287422406159616673122916308832353wb) + != 158093724114624905837287422406159616673122916308832353wb) + __builtin_abort (); + if (test_575 (3807354285642wb) != 3807354285642wb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-27.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-27.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,373 @@ +/* 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" } { "" } } */ + +int expected; + +__attribute__((noipa)) void +test (int x, int y, int z) +{ + (void) x; + (void) y; + if (z != expected) + __builtin_abort (); +} + +#if __BITINT_MAXWIDTH__ >= 135 +__attribute__((noipa)) void +test_135 (_BitInt(135) a) +{ + switch (a) + { + case -33841133710wb: + test (1, 2, 1); break; + case -55283508608004252890371630137wb: + test (2, 3, 2); break; + case -1065119162618253595246332535wb: + test (3, 4, 3); break; + case 265225687803630460135wb: + test (4, 5, 4); break; + case 12802219454007328327057691wb: + test (5, 6, 5); break; + case -59157301wb: + test (6, 7, 6); break; + case 28029296819738wb: + test (7, 8, 7); break; + case 23771967952817687922824184198772908114wb: + test (8, 9, 8); break; + case -528wb: + test (10, 9, 9); break; + case -21743705968wb: + test (11, 8, 10); break; + case 3761322442803929370621734404255158wb: + test (12, 7, 11); break; + case 7581882536870984828946588790215963wb: + test (13, 6, 12); break; + case -3601335158354600803149652143011wb: + test (14, 5, 13); break; + case 104802210847691888333394846958wb: + test (15, 4, 14); break; + case 145823237253137988087297wb: + test (16, 3, 15); break; + case 3871725619091wb: + test (17, 2, 16); break; + case -480987385702wb: + test (18, 1, 17); break; + case -1084968414543030wb: + test (19, 0, 18); break; + case -12928976wb: + test (20, -1, 19); break; + case -268774wb: + test (21, -2, 20); break; + case 532464351235328336949014678wb: + test (22, -3, 21); break; + case -1145290618187237284790705482290160wb: + test (23, -4, 22); break; + case -249459466889744wb: + test (24, -5, 23); break; + case -1403065236wb: + test (25, 1, 24); break; + case -25456270573862478377606wb: + test (26, 2, 25); break; + case 33340794611915791wb: + test (27, 3, 26); break; + case -674079586163272813wb: + test (28, 4, 27); break; + case -41952758959718119236303556590897001668wb: + test (29, 5, 28); break; + case 2947453415wb: + test (30, 6, 29); break; + case -677wb: + test (31, 7, 30); break; + case -463646803422851872253575745194919wb: + test (32, 8, 31); break; + case -71367919591514155952975401251963194wb: + test (33, 7, 32); break; + case -14346961913818709867962386609601wb: + test (34, 6, 33); break; + case 690wb: + test (35, 5, 34); break; + default: + test (36, 4, 35); break; + break; + } +} +#endif + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) int +test_192 (unsigned _BitInt(192) a) +{ + switch (a) + { + case 1505160143063006983093195408894239764415303566721254616896uwb + 48: + case 1505160143063006983093195408894239764415303566721254616896uwb + 49: + case 1505160143063006983093195408894239764415303566721254616896uwb + 50: + case 1505160143063006983093195408894239764415303566721254616896uwb + 51: + case 1505160143063006983093195408894239764415303566721254616896uwb + 52: + case 1505160143063006983093195408894239764415303566721254616896uwb + 53: + case 1505160143063006983093195408894239764415303566721254616896uwb + 54: + case 1505160143063006983093195408894239764415303566721254616896uwb + 55: + case 1505160143063006983093195408894239764415303566721254616896uwb + 56: + case 1505160143063006983093195408894239764415303566721254616896uwb + 57: + case 1505160143063006983093195408894239764415303566721254616896uwb + 65: + case 1505160143063006983093195408894239764415303566721254616896uwb + 66: + case 1505160143063006983093195408894239764415303566721254616896uwb + 67: + case 1505160143063006983093195408894239764415303566721254616896uwb + 68: + case 1505160143063006983093195408894239764415303566721254616896uwb + 69: + case 1505160143063006983093195408894239764415303566721254616896uwb + 70: + return 1; + default: + return 0; + } +} +#endif + +#if __BITINT_MAXWIDTH__ >= 574 +__attribute__((noipa)) void +test_574 (unsigned _BitInt(574) a) +{ + switch (a) + { + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb: + test (22, -3, 1); break; + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891247uwb: + test (23, -4, 2); break; + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891248uwb: + test (24, -5, 3); break; + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891249uwb: + test (25, 1, 4); break; + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891250uwb: + test (26, 2, 5); break; + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891251uwb: + test (27, 3, 6); break; + case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891257uwb: + test (28, 4, 7); break; + default: + test (29, 5, 8); break; + break; + } +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) void +test_575 (_BitInt(575) a) +{ + switch (a) + { + case 57158236877324191282832099954551676419657688516114213070568173374483038461911230482096734270573673572006270803057167488583704wb: + test (1, 2, 1); break; + case 55932752002978259755258693759201176077252755664748wb: + test (2, 3, 2); break; + case -4218363291370143377367234486177453689054229233132334373089588356145503900632432151470684730299990106009156255994430506676467506300235609892554834254413957477779209219867825wb: + test (3, 4, 3); break; + case -19380856704203460544565443028wb: + test (4, 5, 4); break; + case 37691457600250454282496246135038751153145234859661859831059667050412054918743986000946778819692986258358820458161034213280wb: + test (5, 6, 5); break; + case 827003152758795459486819489974390601625339063627401335603123746581523657253393870961575744071183196915560771288079061574485309986042624106685495948664669wb: + test (6, 7, 6); break; + case 2001882657256786505981789524889669355393757203160978wb: + test (7, 8, 7); break; + case 2273951349206310803215316642428483249009583047771549wb: + test (8, 9, 8); break; + case -63640037492105525397657594648433413082358686497544854829581174487203243151113011293858381773246wb: + test (10, 9, 9); break; + case -5043989193130150016980754467018673356423436330428309162407512361831163237wb: + test (11, 8, 10); break; + case -86904413785414524864201428752820860524832869110219388825241400306401wb: + test (12, 7, 11); break; + case -7159581406wb: + test (13, 6, 12); break; + case -430416863734662045942802859497964wb: + test (14, 5, 13); break; + case -282099469984391093781566wb: + test (15, 4, 14); break; + case 259191242782270578340350840252447902477249511321245827805053349778984004438373803812874430619356951005300429wb: + test (16, 3, 15); break; + case -17427431700557396203431wb: + test (17, 2, 16); break; + case -324305733281944621534wb: + test (18, 1, 17); break; + case 39167932287702074309519944575154814029176054304655900600154735991016090154633448789399330wb: + test (19, 0, 18); break; + case 198828227576458371467364915441164050473274232622009526563856039032wb: + test (20, -1, 19); break; + case 7522018863556878842079508104211164618555wb: + test (21, -2, 20); break; + case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246wb: + test (22, -3, 21); break; + case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891247wb: + test (23, -4, 22); break; + case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891248wb: + test (24, -5, 23); break; + case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891249wb: + test (25, 1, 24); break; + case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891250wb: + test (26, 2, 25); break; + case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891251wb: + test (27, 3, 26); break; + case 25232715496072790939146860623749108256506615788345509143038026592127702780903347954226870163752427434085269890371577229233150314692259399042327414965711510629wb: + test (28, 4, 27); break; + case 21376200838998904075479297127185224975235208544658573531790808467114261325514834503383673531634166234wb: + test (29, 5, 28); break; + case -12950763061001084589012736558965423479147155000678492177259830314151681149963956790935448632739537613359984550457633150573373wb: + test (30, 6, 29); break; + case -2588834879960231787797472372536501710262304078735816335394876043103825991870347510560085648304946wb: + test (31, 7, 30); break; + case -2701643349985817058465875459099740236751728453427684wb: + test (32, 8, 31); break; + case 5836201004021438163265930908885473220627459728279406489088525555799694670629946003808237930825748wb: + test (33, 7, 32); break; + case 44108809764408326456612205445124618284924483635588993217673301668963284129265963564132943970751645671455967029559660507196902756491684232894669648136319146730wb: + test (34, 6, 33); break; + case 2296104972770686523043774188826290903188890257660332269411533641473619626906874515994186550107564291006924533677263136416982312042wb: + test (35, 5, 34); break; + case 2194074380385385359486226752708738wb: + test (36, 4, 35); break; + case 538995045833371297308662695915673724930785814100527903453604wb: + test (37, 3, 36); break; + case 2085626377217975761550063150555904902911153438008474368944585344266562733501648381wb: + test (38, 2, 37); break; + case -33688835949886075020354777490957071wb: + test (39, 1, 38); break; + case 1391419408329070356813886663340861253838000363084420822349730519562112746630131027735880100996653wb: + test (40, 0, 39); break; + default: + test (41, -1, 40); break; + break; + } +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + static _BitInt(135) a_135[] = { + -33841133710wb, + -55283508608004252890371630137wb, + -1065119162618253595246332535wb, + 265225687803630460135wb, + 12802219454007328327057691wb, + -59157301wb, + 28029296819738wb, + 23771967952817687922824184198772908114wb, + -528wb, + -21743705968wb, + 3761322442803929370621734404255158wb, + 7581882536870984828946588790215963wb, + -3601335158354600803149652143011wb, + 104802210847691888333394846958wb, + 145823237253137988087297wb, + 3871725619091wb, + -480987385702wb, + -1084968414543030wb, + -12928976wb, + -268774wb, + 532464351235328336949014678wb, + -1145290618187237284790705482290160wb, + -249459466889744wb, + -1403065236wb, + -25456270573862478377606wb, + 33340794611915791wb, + -674079586163272813wb, + -41952758959718119236303556590897001668wb, + 2947453415wb, + -677wb, + -463646803422851872253575745194919wb, + -71367919591514155952975401251963194wb, + -14346961913818709867962386609601wb, + 690wb + }; + for (int i = 0; i < 34; ++i) + { + expected = i + 1; + test_135 (a_135[i]); + expected = 35; + test_135 (a_135[i] - 1); + test_135 (a_135[i] + 1); + } +#endif +#if __BITINT_MAXWIDTH__ >= 192 + if (test_192 (0uwb) + || test_192 (1505160143063006983093195408894239764415303566721254616896uwb) + || test_192 (1505160143063006983093195408894239764415303566721254616896uwb + 47) + || test_192 (1505160143063006983093195408894239764415303566721254616896uwb + 71) + || test_192 (-1uwb)) + __builtin_abort (); + for (int i = 48; i <= 70; ++i) + if (test_192 (1505160143063006983093195408894239764415303566721254616896uwb + i) != (i < 58 || i > 64)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 574 + expected = 8; + test_574 (0uwb); + test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb - 0x10000000000000000uwb); + test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891245uwb); + test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891258uwb); + test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb + 0x10000000000000000uwb); + test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891258uwb + 0x10000000000000000uwb); + for (int i = 0; i <= 11; ++i) + { + expected = i == 11 ? 7 : i > 5 ? 8 : i + 1; + test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb + i); + } +#endif +#if __BITINT_MAXWIDTH__ >= 575 + static _BitInt(575) a_575[] = { + 57158236877324191282832099954551676419657688516114213070568173374483038461911230482096734270573673572006270803057167488583704wb, + 55932752002978259755258693759201176077252755664748wb, + -4218363291370143377367234486177453689054229233132334373089588356145503900632432151470684730299990106009156255994430506676467506300235609892554834254413957477779209219867825wb, + -19380856704203460544565443028wb, + 37691457600250454282496246135038751153145234859661859831059667050412054918743986000946778819692986258358820458161034213280wb, + 827003152758795459486819489974390601625339063627401335603123746581523657253393870961575744071183196915560771288079061574485309986042624106685495948664669wb, + 2001882657256786505981789524889669355393757203160978wb, + 2273951349206310803215316642428483249009583047771549wb, + -63640037492105525397657594648433413082358686497544854829581174487203243151113011293858381773246wb, + -5043989193130150016980754467018673356423436330428309162407512361831163237wb, + -86904413785414524864201428752820860524832869110219388825241400306401wb, + -7159581406wb, + -430416863734662045942802859497964wb, + -282099469984391093781566wb, + 259191242782270578340350840252447902477249511321245827805053349778984004438373803812874430619356951005300429wb, + -17427431700557396203431wb, + -324305733281944621534wb, + 39167932287702074309519944575154814029176054304655900600154735991016090154633448789399330wb, + 198828227576458371467364915441164050473274232622009526563856039032wb, + 7522018863556878842079508104211164618555wb, + -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246wb, + -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891247wb, + -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891248wb, + -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891249wb, + -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891250wb, + -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891251wb, + 25232715496072790939146860623749108256506615788345509143038026592127702780903347954226870163752427434085269890371577229233150314692259399042327414965711510629wb, + 21376200838998904075479297127185224975235208544658573531790808467114261325514834503383673531634166234wb, + -12950763061001084589012736558965423479147155000678492177259830314151681149963956790935448632739537613359984550457633150573373wb, + -2588834879960231787797472372536501710262304078735816335394876043103825991870347510560085648304946wb, + -2701643349985817058465875459099740236751728453427684wb, + 5836201004021438163265930908885473220627459728279406489088525555799694670629946003808237930825748wb, + 44108809764408326456612205445124618284924483635588993217673301668963284129265963564132943970751645671455967029559660507196902756491684232894669648136319146730wb, + 2296104972770686523043774188826290903188890257660332269411533641473619626906874515994186550107564291006924533677263136416982312042wb, + 2194074380385385359486226752708738wb, + 538995045833371297308662695915673724930785814100527903453604wb, + 2085626377217975761550063150555904902911153438008474368944585344266562733501648381wb, + -33688835949886075020354777490957071wb, + 1391419408329070356813886663340861253838000363084420822349730519562112746630131027735880100996653wb + }; + for (int i = 0; i < 39; ++i) + { + expected = i + 1; + test_575 (a_575[i]); + expected = 40; + if (i < 20 || i >= 25) + test_575 (a_575[i] - 1); + if (i <= 20 || i > 25) + test_575 (a_575[i] + 1); + } +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-28.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-28.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,20 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#include "../../c-c++-common/torture/builtin-arith-overflow-1.h" + +#define U(s, op) op +TESTS (_BitInt(19), (-262143wb - 1), 262143wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); + +int +main () +{ + TESTS (_BitInt(19), (-262143wb - 1), 262143wb) + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-29.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-29.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,24 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 119 +#include "../../c-c++-common/torture/builtin-arith-overflow-1.h" + +#define U(s, op) op +TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 119 + TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-30.c.jj 2023-08-08 16:12:02.344939588 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-30.c 2023-08-08 16:12:02.344939588 +0200 @@ -0,0 +1,19 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#include "../../c-c++-common/torture/builtin-arith-overflow-12.h" + +TESTS (_BitInt(19), (-262143wb - 1), 262143wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); + +int +main () +{ + TESTS (_BitInt(19), (-262143wb - 1), 262143wb) + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-31.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-31.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,23 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 119 +#include "../../c-c++-common/torture/builtin-arith-overflow-12.h" + +TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 119 + TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-32.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-32.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,24 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 135 +#include "../../c-c++-common/torture/builtin-arith-overflow-1.h" + +#define U(s, op) op +TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-33.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-33.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,24 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 192 +#include "../../c-c++-common/torture/builtin-arith-overflow-1.h" + +#define U(s, op) op +TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-34.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-34.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,24 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 575 +#include "../../c-c++-common/torture/builtin-arith-overflow-1.h" + +#define U(s, op) op +TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 575 + TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-35.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-35.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,23 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 135 +#include "../../c-c++-common/torture/builtin-arith-overflow-12.h" + +TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 135 + TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-36.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-36.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,23 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 192 +#include "../../c-c++-common/torture/builtin-arith-overflow-12.h" + +TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-37.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-37.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,23 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 575 +#include "../../c-c++-common/torture/builtin-arith-overflow-12.h" + +TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb) + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 575 + TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb) +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-38.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-38.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,56 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 575 +#include "../../c-c++-common/torture/builtin-arith-overflow.h" + +#ifdef __SIZEOF_INT128__ +#define WTYPE __int128 +#else +#define WTYPE long long int +#endif + +#define TESTS \ +T (100, signed _BitInt(38), signed char, unsigned _BitInt(162), -1wb, 0, -1wb, add, 1) \ +T (101, unsigned char, unsigned _BitInt(38), unsigned _BitInt(162), 5, 5wb, 10wb, add, 0) \ +T (102, signed _BitInt(38), unsigned short, unsigned _BitInt(162), 5wb, 5, 0wb, sub, 0) \ +T (103, signed _BitInt(38), unsigned _BitInt(72), unsigned _BitInt(162), 5wb, 6wb, -1wb, sub, 1) \ +T (104, signed _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), -1wb, -1wb, 1wb, mul, 0) \ +T (105, unsigned _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), 17wb, -2wb, -34wb, mul, 1) \ +T (106, unsigned _BitInt(162), signed _BitInt(162), signed _BitInt(38), 5wb, -2wb, -10wb, mul, 0) \ +T (107, signed _BitInt(321), signed _BitInt(321), unsigned _BitInt(38), -3wb, 5wb, 2wb, add, 0) \ +T (108, signed _BitInt(321), int, unsigned _BitInt(38), -5wb, 3, -2wb, add, 1) \ +T (109, int, _BitInt(162), unsigned _BitInt(38), -3, 5wb, 2wb, add, 0) \ +T (110, unsigned _BitInt(38), unsigned _BitInt(38), unsigned _BitInt(162), 137438953471wb - 1, (unsigned _BitInt(38)) 137438953471wb + 4, -5wb, sub, 1) \ +T (111, signed _BitInt(315), signed _BitInt(315), unsigned, -1wb, 0wb, -1, add, 1) \ +T (112, signed _BitInt(315), signed _BitInt(315), unsigned, 5wb, 42wb, 47, add, 0) \ +T (113, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, -1wb, 0wb, -1, add, 1) \ +T (114, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, 15wb, 5wb, 20, add, 0) +T (115, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), -1wb, 0wb, -1wb, add, 1) \ +T (116, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), 5wb, 125wb, 130wb, add, 0) \ +T (117, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), -1wb, 0wb, -1wb, add, 1) \ +T (118, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), 5wb, 125wb, 130wb, add, 0) \ +T (119, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475137wb, -191561942608236107294793378393788647952342390272950271wb - 1, add, 1) \ +T (120, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475136wb, 191561942608236107294793378393788647952342390272950271wb, add, 0) \ +T (121, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628225wb, -3138550867693340381917894711603833208051177722232017256447wb - 1, add, 1) \ +T (122, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628224wb, 3138550867693340381917894711603833208051177722232017256447wb, add, 0) \ +T (123, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256449wb, -6277101735386680763835789423207666416102355444464034512895wb - 1, add, 1) \ +T (124, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256448wb, 6277101735386680763835789423207666416102355444464034512895wb, add, 0) + +TESTS + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 575 + TESTS +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-39.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-39.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,57 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=gnu2x" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 575 +#define OVFP +#include "../../c-c++-common/torture/builtin-arith-overflow.h" + +#ifdef __SIZEOF_INT128__ +#define WTYPE __int128 +#else +#define WTYPE long long int +#endif + +#define TESTS \ +T (100, signed _BitInt(38), signed char, unsigned _BitInt(162), -1wb, 0, -1wb, add, 1) \ +T (101, unsigned char, unsigned _BitInt(38), unsigned _BitInt(162), 5, 5wb, 10wb, add, 0) \ +T (102, signed _BitInt(38), unsigned short, unsigned _BitInt(162), 5wb, 5, 0wb, sub, 0) \ +T (103, signed _BitInt(38), unsigned _BitInt(72), unsigned _BitInt(162), 5wb, 6wb, -1wb, sub, 1) \ +T (104, signed _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), -1wb, -1wb, 1wb, mul, 0) \ +T (105, unsigned _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), 17wb, -2wb, -34wb, mul, 1) \ +T (106, unsigned _BitInt(162), signed _BitInt(162), signed _BitInt(38), 5wb, -2wb, -10wb, mul, 0) \ +T (107, signed _BitInt(321), signed _BitInt(321), unsigned _BitInt(38), -3wb, 5wb, 2wb, add, 0) \ +T (108, signed _BitInt(321), int, unsigned _BitInt(38), -5wb, 3, -2wb, add, 1) \ +T (109, int, _BitInt(162), unsigned _BitInt(38), -3, 5wb, 2wb, add, 0) \ +T (110, unsigned _BitInt(38), unsigned _BitInt(38), unsigned _BitInt(162), 137438953471wb - 1, (unsigned _BitInt(38)) 137438953471wb + 4, -5wb, sub, 1) \ +T (111, signed _BitInt(315), signed _BitInt(315), unsigned, -1wb, 0wb, -1, add, 1) \ +T (112, signed _BitInt(315), signed _BitInt(315), unsigned, 5wb, 42wb, 47, add, 0) \ +T (113, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, -1wb, 0wb, -1, add, 1) \ +T (114, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, 15wb, 5wb, 20, add, 0) +T (115, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), -1wb, 0wb, -1wb, add, 1) \ +T (116, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), 5wb, 125wb, 130wb, add, 0) \ +T (117, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), -1wb, 0wb, -1wb, add, 1) \ +T (118, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), 5wb, 125wb, 130wb, add, 0) \ +T (119, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475137wb, -191561942608236107294793378393788647952342390272950271wb - 1, add, 1) \ +T (120, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475136wb, 191561942608236107294793378393788647952342390272950271wb, add, 0) \ +T (121, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628225wb, -3138550867693340381917894711603833208051177722232017256447wb - 1, add, 1) \ +T (122, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628224wb, 3138550867693340381917894711603833208051177722232017256447wb, add, 0) \ +T (123, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256449wb, -6277101735386680763835789423207666416102355444464034512895wb - 1, add, 1) \ +T (124, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256448wb, 6277101735386680763835789423207666416102355444464034512895wb, add, 0) + +TESTS + +#undef T +#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b (); +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 575 + TESTS +#endif + return 0; +} --- gcc/testsuite/gcc.dg/torture/bitint-40.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-40.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,40 @@ +/* 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__ >= 323 +__attribute__((noipa)) _BitInt(323) +foo (_BitInt(318) x, _BitInt(323) y) +{ + return x + y; +} + +__attribute__((noipa)) _BitInt(323) +bar (_BitInt(117) x, _BitInt(323) y) +{ + return x + y; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 323 + if (foo (-27733041854193447641086572824547940096595738628642819753407953445763239714154199953745005898992wb, + 4767458710334760668834645815738583537909191474644120198636728988961922824468904018596948147773722wb) + != 4739725668480567221193559242914035597812595736015477378883321035516159584754749818643203141874730wb + || (foo (22167179033351019542845489620035412963406090796537167425591583962059414367893933412196721063711wb, + 5235750662037407195417484618645691209305675673195256409842928988743249911043551311451335001624960wb) + != 5257917841070758214960330108265726622269081763991793577268520572705309325411445244863531722688671wb)) + __builtin_abort (); + if (bar (-12653567664155974398995022748067044wb, + 7190977642064159111525225823679712940862545424809645152399787447341776579576645887978584020321431wb) + != 7190977642064159111525225823679712940862545424809645152399787434688208915420671488983561272254387wb + || (bar (30518211833575333685611432934770228wb, + 2152360419596992042662178082767272400451689654640037233902067223067458441134717528282349099466966wb) + != 2152360419596992042662178082767272400451689654640037233902067253585670274710051213893782034237194wb)) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-41.c.jj 2023-08-08 16:12:02.345939574 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-41.c 2023-08-08 16:12:02.345939574 +0200 @@ -0,0 +1,34 @@ +/* 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)) _Bool +test256 (_BitInt(256) *q) +{ + return __builtin_sub_overflow ((_BitInt(256)) 0, q[0], q + 1); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 256 + static _BitInt(256) q256[] = { + 45345032714412617256156490782169070529322290545773058110333871537162440472587wb, + 0wb, + -45345032714412617256156490782169070529322290545773058110333871537162440472587wb, + -45345032714412617256156490782169070529322290545773058110333871537162440472587wb, + 0wb, + 45345032714412617256156490782169070529322290545773058110333871537162440472587wb, + -57896044618658097711785492504343953926634992332820282019728792003956564819967wb - 1, + 0wb, + -57896044618658097711785492504343953926634992332820282019728792003956564819967wb - 1 + }; + for (int i = 0; i < 3; ++i) + if (test256 (q256 + 3 * i) != (i == 2) || q256[3 * i + 1] != q256[3 * i + 2]) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/torture/bitint-42.c.jj 2023-08-08 16:15:41.009877752 +0200 +++ gcc/testsuite/gcc.dg/torture/bitint-42.c 2023-08-08 16:15:41.009877752 +0200 @@ -0,0 +1,184 @@ +/* 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__ >= 156 +struct S156 { unsigned _BitInt(156) a : 135; _BitInt(156) b : 2; }; +struct T156 { _BitInt(156) a : 2; unsigned _BitInt(156) b : 135; _BitInt(156) c : 2; }; + +__attribute__((noipa)) _BitInt(156) +test156 (struct S156 *p, struct T156 *q, struct T156 *r, int n) +{ + r[0].b = p[0].a + q[0].b; + r[1].b = p[1].a * q[1].b; + r[2].a = p[2].a == q[2].b; + r[3].a = p[3].a < q[3].b; + r[4].b = p[4].a << n; + return p[5].a + q[5].b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 495 +struct S495 { unsigned _BitInt(495) a : 471; _BitInt(495) b : 2; }; +struct T495 { _BitInt(495) a : 2; unsigned _BitInt(495) b : 471; _BitInt(495) c : 2; }; + +__attribute__((noipa)) _BitInt(495) +test495 (struct S495 *p, struct T495 *q, struct T495 *r, int n) +{ + r[0].b = p[0].a + q[0].b; + r[1].b = p[1].a * q[1].b; + r[2].a = p[2].a == q[2].b; + r[3].a = p[3].a < q[3].b; + r[4].b = p[4].a << n; + return p[5].a + q[5].b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +struct T575 { _BitInt(575) a : 2; _BitInt(575) b : 382; _BitInt(575) c : 2; }; + +__attribute__((noipa)) _BitInt(575) +test575 (struct T575 *q, _BitInt(575) x) +{ + return q->b + x; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 156 + static struct S156 p156[] = { + { 6086908847973295618751425718189955476089uwb, 0wb }, + { 22782605434509677806291360175224474025979uwb, 1wb }, + { 37470702016132547913133822619863997855935uwb, -1wb }, + { 35506973813062189967442086745146532460068uwb, -2wb }, + { 30541197841349399254932135707861871578815uwb, -2wb }, + { 42800615576623455179183425579556615564998uwb, 1wb }, + { 83771790414073692613953222993102430597uwb, 0wb }, + { 36412564746565547536452588666710660799602uwb, 1wb }, + { 33301340481967309644890101787523367044846uwb, -1wb }, + { 12245185680611854260212331160624126801841uwb, -2wb }, + { 35828279900949208432533857460683046288424uwb, -1wb }, + { 4123278359205456806488911776768785478962uwb, 1wb } + }; + static struct T156 q156[] = { + { -2wb, 20935792668463008606182638244678610336415uwb, 0wb }, + { -1wb, 209336580249060835473242979959042853484uwb, -1wb }, + { 0wb, 26553091584512375040647771207085289684805uwb, -2wb }, + { 1wb, 8584102019879028804166913978503267690027uwb, 1wb }, + { -2wb, 3364986457594728242491236670969190237662uwb, 0wb }, + { 1wb, 28487958103578401823549712846248514887291uwb, -1wb }, + { 1wb, 30323438060061607929914857363700386658179uwb, -2wb }, + { -2wb, 38436123658875864126535628489050345446219uwb, 1wb }, + { -1wb, 33301340481967309644890101787523367044846uwb, -1wb }, + { 0wb, 18081372790322879821963779970917788200718uwb, 0wb }, + { 1wb, 35310198378318023568520640435634029391465uwb, -2wb }, + { -2wb, 16532060682830030166332649597929082719904uwb, -1wb } + }; + struct T156 r156[12]; + static unsigned _BitInt(135) e156[] = { + 27022701516436304224934063962868565812504uwb, + 29613894605882195495382184794066465590244uwb, + 0uwb, + 0uwb, + 25008039169844990156837660987808592822272uwb, + 27732430714321733679421188674538799385921uwb, + 30407209850475681622528810586693489088776uwb, + 9125928536800138281422179636318960655206uwb, + 1uwb, + 1uwb, + 27059094310193532424702800326126974533632uwb, + 20655339042035486972821561374697868198866uwb + }; + for (int i = 0; i < 12; ++i) + { + r156[i].a = (i & 1) ? 1wb : -2wb; + r156[i].b = (i & 1) ? 14518714321960041107770649917088777022122uwb : 29037428643920082215541299834177554044245uwb; + r156[i].c = (i & 1) ? -2wb : 1wb; + } + r156[5].b = test156 (&p156[0], &q156[0], &r156[0], 17); + r156[11].b = test156 (&p156[6], &q156[6], &r156[6], 117); + for (int i = 0; i < 12; ++i) + if ((((i % 6) - 2U <= 1U) ? r156[i].a : r156[i].b) != e156[i]) + __builtin_abort (); + else if ((((i % 6) - 2U > 1U) && r156[i].a != ((i & 1) ? 1wb : -2wb)) + || (((i % 6) - 2U <= 1U) && r156[i].b != ((i & 1) ? 14518714321960041107770649917088777022122uwb : 29037428643920082215541299834177554044245uwb)) + || r156[i].c != ((i & 1) ? -2wb : 1wb)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 495 + static struct S495 p495[] = { + { 5900641461698162830220261443910312286116186030711054026202132317287171989449954433727605565187406942318472276126021616097079737645240098454013uwb, 0wb }, + { 5619335266199392590390116416034736345432323405939461237257863293465693217703812518219356211176818397041537700744525965483063880249177661765822uwb, -1wb }, + { 744675643612988167093151199551285556694415176163561012938968935653355128760309622135847398882788196739068398576440472762370028310765535983503uwb, 1wb }, + { 4710120587609940729927891635083547264060530096467790505615232580303577049694742313824211264116793595223025831432779325089965241897060863692416uwb, -2wb }, + { 4700240735957362687308898816111021174982406591648489926246999776223031821022674194534613241738369983608058217658021289655774135981827101958355uwb, -1wb }, + { 1876262100946684033144524627883805711239772124030259629263615724983251183045150901527994496938087455223125779829665212386349414296844947524925uwb, 0wb }, + { 2635441776228543412090459941414006837629084474712903013295503578947861806271451688519107975488661564459243720565422264844084425272156107387136uwb, 1wb }, + { 2630153258749552262848995430888671592867309014306367216498408256861265344131972108995527284590063838830515851856437258905217521364301962720643uwb, -2wb }, + { 2745338434240621337939928605056928843351970485626602387969150293308450866745407501724727739848971206349186529783705440219203189970551219879381uwb, 1wb }, + { 2688974451781009079406742432598239379065348006788221659938456041627730645258351669705421830999330571339577238631004906071154604486839621759962uwb, -1wb }, + { 4974200409958136921019163732486769139044513968318459321751943678326303994594283963911023171617076265195547773578798591476134329493900866070930uwb, -2wb }, + { 5308892348567193242289576342108929297198516978578910066291782408432432101971103786646801744963140659914127252602243854634890888430591500677669uwb, 0wb } + }; + static struct T495 q495[] = { + { 0wb, 4301604554146816407338627211447119428992719156607107928889754501636100741327050147838502142108071735464603549268761292458205988617578325763173uwb, -2wb }, + { -1wb, 2715194601730000102297343743781623149283369741076005412784114057373119142888076403665408178274328506558203084450300859444566357959934633829946uwb, -1wb }, + { -2wb, 744675643612988167093151199551285556694415176163561012938968935653355128760309622135847398882788196739068398576440472762370028310765535983503uwb, 0wb }, + { 1wb, 2905575297593112682176271367301360286079539486548283169761776505152778266677295498111968142984117916873706310434203454796302860902084876845657uwb, 1wb }, + { -2wb, 1837917528781539509450058185492923533367227689379651913582946492506072644598679412452807791857307066254676899775684162126897712525287848351976uwb, -2wb }, + { -1wb, 2319680246150988952074978951387405463389161562155916967834748191217991286707290863021474691040798411643120909475843121856853198824610064919029uwb, -1wb }, + { 0wb, 995091385198857217634636856758679675740255626224651591597840191331701102225958567078470825514618566121501749811346910563358603344922083332530uwb, 0wb }, + { 1wb, 1935767072657166967374130326547364176008146414333487504728787607207566058414790635912675474199093488415105292641061350133643468776770358124726uwb, 1wb }, + { -1wb, 2323578462079768493720340989036535936419394491913499982954052044299468738290318204298367303716254084159730145465632640799602734853085685711959uwb, -1wb }, + { 0wb, 3134743387837581735890167538039234659353143305621277824366534871456819272038615182289564667918939704822338586693965843434870517084569520632192uwb, 1wb }, + { -2wb, 6069214031750054027161180881734548627596253190931156326304738913835931214674310539698411833298960086513572699541120829870803305974299213978797uwb, -2wb }, + { 1wb, 3475118701665891960802877416318617212624733636229950713368672781946851382777667645205965216548373630879140490108440746796343158443948723601215uwb, 0wb } + }; + struct T495 r495[12]; + static unsigned _BitInt(471) e495[] = { + 4105080878509056910641706565917653774193674439925640176070095882154968553394649854768634849749595921611538850548285598212613898764208491978338uwb, + 4272455060900825442658035799123612713461581925816375155025420465351224978751666594799676382302564435552275519560187020810679530912731598360332uwb, + 1uwb, + 0uwb, + 193936707178394586072944129724741337251602515686017126954836162236154016065720970574348980545042390967692432385246117380757295497134607826944uwb, + 4195942347097672985219503579271211174628933686186176597098363916201242469752441764549469187978885866866246689305508334243202613121455012443954uwb, + 3630533161427400629725096798172686513369340100937554604893343770279562908497410255597578801003280130580745470376769175407443028617078190719666uwb, + 3017199903252810774645258484587879229328468140025245420287647204420639096996138928094942159316263828975261069022192893745856107126530044652322uwb, + 0uwb, + 1uwb, + 4881485695834897810379845656011652834144895329454510745024612553531749469753415260371487385803388022234443037087409795804654957238790836453376uwb, + 2686845912897162876175271668987768568908019867416339000638664253610979307366416705055294103965631534621730767864187291088562219375930292040036uwb + }; + for (int i = 0; i < 12; ++i) + { + r495[i].a = (i & 1) ? 1wb : -2wb; + r495[i].b = (i & 1) ? 4064776758223948217944788059626518627276820498261681186014527291178869451588236484531648571697255170781024649897664873561781218332406621492565uwb : 2032388379111974108972394029813259313638410249130840593007263645589434725794118242265824285848627585390512324948832436780890609166203310746282uwb; + r495[i].c = (i & 1) ? -2wb : 1wb; + } + r495[5].b = test495 (&p495[0], &q495[0], &r495[0], 17); + r495[11].b = test495 (&p495[6], &q495[6], &r495[6], 117); + for (int i = 0; i < 12; ++i) + if ((((i % 6) - 2U <= 1U) ? r495[i].a : r495[i].b) != e495[i]) + __builtin_abort (); + else if ((((i % 6) - 2U > 1U) && r495[i].a != ((i & 1) ? 1wb : -2wb)) + || (((i % 6) - 2U <= 1U) && r495[i].b != ((i & 1) ? 4064776758223948217944788059626518627276820498261681186014527291178869451588236484531648571697255170781024649897664873561781218332406621492565uwb : 2032388379111974108972394029813259313638410249130840593007263645589434725794118242265824285848627585390512324948832436780890609166203310746282uwb)) + || r495[i].c != ((i & 1) ? -2wb : 1wb)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + struct T575 q575[] = { + { 0wb, 96684809381001318096256993724350755663760586347837309196134430400012751231961429238828670682891585656560169817843wb, -2wb }, + { -1wb, -2736587102891263842950610428227571747319762162345429601728737031966764668220310874246707348170368842425752759862563wb, 1wb } + }; + if (test575 (&q575[0], -20620110861486347200204305994458440394552720887062830768778333216240622422772611435913937143052282943196256683484434522946545384240670168537704102522242938522404309878852322wb) + != -20620110861486347200204305994458440394552720887062830768778236531431241421454515178920212792296619182609908846175238388516145371489438207108465273851560046936747749709034479wb) + __builtin_abort (); + if (test575 (&q575[1], 42621052848920155042866550876502212956983884683310087431575669593007353224147609487103322505341199223508939436382180596125666953651582557283994756434373621037386194691552808wb) + != 42621052848920155042866550876502212956983884683310087431572933005904461960304658876675094933593879461346594006780451859093700188983362246409748049086203252194960441931690245wb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/atomic/stdatomic-bitint-1.c.jj 2023-08-08 16:22:34.070094908 +0200 +++ gcc/testsuite/gcc.dg/atomic/stdatomic-bitint-1.c 2023-08-08 16:22:34.070094908 +0200 @@ -0,0 +1,442 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +extern void abort (void); + +#if __BITINT_MAXWIDTH__ >= 127 +_Atomic _BitInt(127) v; +_BitInt(127) count, res; +const _BitInt(127) init = ~(_BitInt(127)) 0wb; + +void +test_fetch_add () +{ + atomic_init (&v, 13505789527944801758751150119415226784wb); + count = -64910836855286429164283779649638556795wb; + + if (atomic_fetch_add_explicit (&v, count, memory_order_relaxed) + != 13505789527944801758751150119415226784wb) + abort (); + + if (atomic_fetch_add_explicit (&v, 2227507280963412295355244564739509222wb, + memory_order_consume) + != -51405047327341627405532629530223330011wb) + abort (); + + if (atomic_fetch_add_explicit (&v, count, memory_order_acquire) + != -49177540046378215110177384965483820789wb) + abort (); + + if (atomic_fetch_add_explicit (&v, 42245667388877614520169143618236120405wb, + memory_order_release) + != 56052806558804587457226139100761728144wb) + abort (); + + if (atomic_fetch_add_explicit (&v, count, memory_order_acq_rel) + != -71842709512787029754292020996886257179wb) + abort (); + + if (atomic_fetch_add_explicit (&v, 77995075987640754057679086146674392947wb, + memory_order_seq_cst) + != 33387637092395772813111503069359291754wb) + abort (); + + if (atomic_fetch_add (&v, 11810767284628435493328779846084830297wb) + != -58758470380432704860896714499850421027wb) + abort (); + + if (atomic_load (&v) != -46947703095804269367567934653765590730wb) + abort (); +} + +void +test_fetch_sub () +{ + atomic_store_explicit (&v, 30796781768365552851024605388374299173wb, + memory_order_release); + count = 32457177597484647488149720668185011722wb; + + if (atomic_fetch_sub_explicit (&v, count, memory_order_relaxed) + != 30796781768365552851024605388374299173wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, 54614103079293459991417218347656369566wb, + memory_order_consume) + != -1660395829119094637125115279810712549wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, count, memory_order_acquire) + != -56274498908412554628542333627467082115wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, -44514083923735151931107302009741400482wb, + memory_order_release) + != 81409506954572029614995249420232011891wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, count, memory_order_acq_rel) + != -44217592582162050185584752285910693355wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, 30348078982452392099140613411731040827wb, + memory_order_seq_cst) + != -76674770179646697673734472954095705077wb) + abort (); + + if (atomic_fetch_sub (&v, -82224045897086857020012824788652775087wb) + != 63118334298370141958812217350057359824wb) + abort (); + + if (atomic_load_explicit (&v, memory_order_acquire) + != -24798803265012232752862261577173970817wb) + abort (); +} + +void +test_fetch_and () +{ + atomic_store (&v, init); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_relaxed) != init) + abort (); + + if (atomic_fetch_and_explicit (&v, init, memory_order_consume) != 0) + abort (); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_acquire) != 0) + abort (); + + v = ~v; + if (atomic_fetch_and_explicit (&v, init, memory_order_release) != init) + abort (); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_acq_rel) != init) + abort (); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_seq_cst) != 0) + abort (); + + if (atomic_fetch_and (&v, 0) != 0) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (atomic_fetch_xor_explicit (&v, count, memory_order_relaxed) != init) + abort (); + + if (atomic_fetch_xor_explicit (&v, ~count, memory_order_consume) != init) + abort (); + + if (atomic_fetch_xor_explicit (&v, 0, memory_order_acquire) != 0) + abort (); + + if (atomic_fetch_xor_explicit (&v, ~count, memory_order_release) != 0) + abort (); + + if (atomic_fetch_xor_explicit (&v, 0, memory_order_acq_rel) != init) + abort (); + + if (atomic_fetch_xor_explicit (&v, ~count, memory_order_seq_cst) != init) + abort (); + + if (atomic_fetch_xor (&v, ~count) != 0) + abort (); +} + +void +test_fetch_or () +{ + v = 0; + count = 17592186044416wb; + + if (atomic_fetch_or_explicit (&v, count, memory_order_relaxed) != 0) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, 35184372088832wb, memory_order_consume) + != 17592186044416wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, count, memory_order_acquire) + != 52776558133248wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, 140737488355328wb, memory_order_release) + != 123145302310912wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, count, memory_order_acq_rel) + != 263882790666240wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, count, memory_order_seq_cst) + != 545357767376896wb) + abort (); + + count *= 2; + if (atomic_fetch_or (&v, count) != 1108307720798208wb) + abort (); +} + + +/* Test the OP routines with a result which isn't used. */ + +void +test_add () +{ + v = 0; + count = 4722366482869645213696wb; + + atomic_fetch_add (&v, count); + if (v != 4722366482869645213696wb) + abort (); + + atomic_fetch_add_explicit (&v, count, memory_order_consume); + if (v != 9444732965739290427392wb) + abort (); + + atomic_fetch_add (&v, 4722366482869645213696wb); + if (v != 14167099448608935641088wb) + abort (); + + atomic_fetch_add_explicit (&v, 4722366482869645213696wb, + memory_order_release); + if (v != 18889465931478580854784wb) + abort (); + + atomic_fetch_add (&v, 4722366482869645213696wb); + if (v != 23611832414348226068480wb) + abort (); + + atomic_fetch_add_explicit (&v, count, memory_order_seq_cst); + if (v != 28334198897217871282176wb) + abort (); +} + +void +test_sub () +{ + v = res = -3638804536836293398783417724445294828wb; + count = 0; + + atomic_fetch_sub (&v, count + 1); + if (v != --res) + abort (); + + atomic_fetch_sub_explicit (&v, count + 1, memory_order_consume); + if (v != --res) + abort (); + + atomic_fetch_sub (&v, 1); + if (v != --res) + abort (); + + atomic_fetch_sub_explicit (&v, 1, memory_order_release); + if (v != --res) + abort (); + + atomic_fetch_sub (&v, count + 1); + if (v != --res) + abort (); + + atomic_fetch_sub_explicit (&v, count + 1, memory_order_seq_cst); + if (v != --res) + abort (); +} + +void +test_and () +{ + v = init; + + atomic_fetch_and (&v, 0); + if (v != 0) + abort (); + + v = init; + atomic_fetch_and_explicit (&v, init, memory_order_consume); + if (v != init) + abort (); + + atomic_fetch_and (&v, 0); + if (v != 0) + abort (); + + v = ~v; + atomic_fetch_and_explicit (&v, init, memory_order_release); + if (v != init) + abort (); + + atomic_fetch_and (&v, 0); + if (v != 0) + abort (); + + v = ~v; + atomic_fetch_and_explicit (&v, 0, memory_order_seq_cst); + if (v != 0) + abort (); +} + +void +test_xor () +{ + v = init; + count = 0; + + atomic_fetch_xor (&v, count); + if (v != init) + abort (); + + atomic_fetch_xor_explicit (&v, ~count, memory_order_consume); + if (v != 0) + abort (); + + atomic_fetch_xor (&v, 0); + if (v != 0) + abort (); + + atomic_fetch_xor_explicit (&v, ~count, memory_order_release); + if (v != init) + abort (); + + atomic_fetch_xor_explicit (&v, 0, memory_order_acq_rel); + if (v != init) + abort (); + + atomic_fetch_xor (&v, ~count); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 19342813113834066795298816wb; + + atomic_fetch_or (&v, count); + if (v != 19342813113834066795298816wb) + abort (); + + count *= 2; + atomic_fetch_or_explicit (&v, count, memory_order_consume); + if (v != 58028439341502200385896448wb) + abort (); + + count *= 2; + atomic_fetch_or (&v, 77371252455336267181195264wb); + if (v != 135399691796838467567091712wb) + abort (); + + count *= 2; + atomic_fetch_or_explicit (&v, 154742504910672534362390528wb, + memory_order_release); + if (v != 290142196707511001929482240wb) + abort (); + + count *= 2; + atomic_fetch_or (&v, count); + if (v != 599627206528856070654263296wb) + abort (); + + count *= 2; + atomic_fetch_or_explicit (&v, count, memory_order_seq_cst); + if (v != 1218597226171546208103825408wb) + abort (); +} + +void +test_exchange (void) +{ + atomic_store (&v, 15794812138349191682564933935017390008wb); + if (atomic_exchange (&v, -2166613183393424891717146518563613668wb) + != 15794812138349191682564933935017390008wb + || atomic_load (&v) != -2166613183393424891717146518563613668wb) + abort (); + if (atomic_exchange_explicit (&v, 61251098386268815852902382804483910638wb, + memory_order_relaxed) + != -2166613183393424891717146518563613668wb + || (atomic_load_explicit (&v, memory_order_acquire) + != 61251098386268815852902382804483910638wb)) + abort (); + + count = -2166613183393424891717146518563613668wb; + if (atomic_compare_exchange_strong (&v, &count, + -36677332297536901313774263310237646448wb)) + abort (); + if (count != 61251098386268815852902382804483910638wb + || atomic_load (&v) != 61251098386268815852902382804483910638wb) + abort (); + if (!atomic_compare_exchange_strong (&v, &count, + -36677332297536901313774263310237646448wb)) + abort (); + if (count != 61251098386268815852902382804483910638wb + || atomic_load (&v) != -36677332297536901313774263310237646448wb) + abort (); + + count = -2166613183393424891717146518563613668wb; + if (atomic_compare_exchange_strong_explicit (&v, &count, + 73949932022761409003352953944661689416wb, + memory_order_seq_cst, + memory_order_relaxed)) + abort (); + if (count != -36677332297536901313774263310237646448wb + || atomic_load (&v) != -36677332297536901313774263310237646448wb) + abort (); + if (!atomic_compare_exchange_strong_explicit (&v, &count, + 73949932022761409003352953944661689416wb, + memory_order_seq_cst, + memory_order_seq_cst)) + abort (); + if (count != -36677332297536901313774263310237646448wb + || atomic_load (&v) != 73949932022761409003352953944661689416wb) + abort (); + + count = atomic_load (&v); + do + res = count + -82256758205518164043596305502815392646wb; + while (!atomic_compare_exchange_weak (&v, &count, res)); + if (atomic_load (&v) != -8306826182756755040243351558153703230wb) + abort (); + + count = atomic_load_explicit (&v, memory_order_acquire); + do + res = count + 48855144829609538366772317026461909818wb; + while (!atomic_compare_exchange_weak_explicit (&v, &count, res, + memory_order_relaxed, + memory_order_relaxed)); + if (atomic_load (&v) != 40548318646852783326528965468308206588wb) + abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 127 + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_xor (); + test_fetch_or (); + test_add (); + test_sub (); + test_and (); + test_xor (); + test_or (); + test_exchange (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/atomic/stdatomic-bitint-2.c.jj 2023-08-08 16:22:34.070094908 +0200 +++ gcc/testsuite/gcc.dg/atomic/stdatomic-bitint-2.c 2023-08-08 16:22:34.070094908 +0200 @@ -0,0 +1,450 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +extern void abort (void); + +#if __BITINT_MAXWIDTH__ >= 575 +_Atomic _BitInt(575) v; +_BitInt(575) count, res; +const _BitInt(575) init = ~(_BitInt(575)) 0wb; + +void +test_fetch_add () +{ + atomic_init (&v, 59465222573183779324781274162178653782927579944977967117312772499849358939735575735090252965265846823956223131844773977101864574011188590603103408821590130462520809924774161wb); + count = 21849324526703540909725517290562575722142104889154621021004438836543599493803029317660194646869455042293514095831327249339063542203879269024249546998746919066599380031180974wb; + + if (atomic_fetch_add_explicit (&v, count, memory_order_relaxed) + != 59465222573183779324781274162178653782927579944977967117312772499849358939735575735090252965265846823956223131844773977101864574011188590603103408821590130462520809924774161wb) + abort (); + + if (atomic_fetch_add_explicit (&v, -48324598397571087754171506195219221853271763472221035086980364394554212400270766919963305485900701475788840363160834710492683133292253640988518950921616217692973141455340373wb, + memory_order_consume) + != -42350653636664946795744469057082365512495989716473331818714316710055654119727328532407752918486220628549098485331968443234754400938307745356420121730609534429183196118394433wb) + abort (); + + if (atomic_fetch_add_explicit (&v, count, memory_order_acquire) + != 32989948702316232480335285257522007651797921361911553051336846941838746033267838132787142126234600390460896864515266515948244982922814218638834004898720831836147048500614762wb) + abort (); + + if (atomic_fetch_add_explicit (&v, 6958312589905983216078981134518695082538588883298046610645489916662738759809700053844918067866491080683973037493524864531300139437943661326918145212620326291059845453630984wb, + memory_order_release) + != 54839273229019773390060802548084583373940026251066174072341285778382345527070867450447336773104055432754410960346593765287308525126693487663083551897467750902746428531795736wb) + abort (); + + if (atomic_fetch_add_explicit (&v, count, memory_order_acq_rel) + != 61797585818925756606139783682603278456478615134364220682986775695045084286880567504292254840970546513438383997840118629818608664564637148990001697110088077193806273985426720wb) + abort (); + + if (atomic_fetch_add_explicit (&v, -40070085597220253007443375012839311464160438432662764715171645999337062215395237625623334979615599652975898123428005079853660189572782012739700306191422569739682093304494995wb, + memory_order_seq_cst) + != -40018290390922969514385959536657740838944954527087078253040313514859928772582336763205751042781520939066937619336623790518010310384859186969521833442111587697897732057741874wb) + abort (); + + if (atomic_fetch_add (&v, 7196090098608011755205055682070541953902689411792805630101863619558545582022760829169235622333653743217332966939875542415224317593660770300818700993340012969018217868600175wb) + != 43576824748409044508421925960326542714460281590856076988819568532251621565288359196329114508224401902755999970243440799304012017195734405274550937917412426520723560712112699wb) + abort (); + + if (atomic_load (&v) != 50772914847017056263626981642397084668362971002648882618921432151810167147311120025498350130558055645973332937183316341719236334789395175575369638910752439489741778580712874wb) + abort (); +} + +void +test_fetch_sub () +{ + atomic_store_explicit (&v, -24875491091433158113922205635657739252057730543056417031972993454853665637813018617125143194799847437263037065304695383952916979113678037118532311779822859742705294727822376wb, + memory_order_release); + count = 6813702694653136917886567607003795360731391695538381923575500076220746287948057449348609672603971831069550813465757196210073636056135824219022209113495061317682354090030599wb; + + if (atomic_fetch_sub_explicit (&v, count, memory_order_relaxed) + != -24875491091433158113922205635657739252057730543056417031972993454853665637813018617125143194799847437263037065304695383952916979113678037118532311779822859742705294727822376wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, 8502925336737158389204618905966437550402192530184998378452912098895816391400915282714213521081597588768568861040471642522181200007537708168290327879425612502090295717806034wb, + memory_order_consume) + != -31689193786086295031808773242661534612789122238594798955548493531074411925761076066473752867403819268332587878770452580162990615169813861337554520893317921060387648817852975wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, count, memory_order_acquire) + != -40192119122823453421013392148627972163191314768779797334001405629970228317161991349187966388485416857101156739810924222685171815177351569505844848772743533562477944535659009wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, -14654459030451169455889477114198307761108411115104251375487725308584250511764953921137486025925617622862411621191578047606524662379041353882420330350079004108508600686109553wb, + memory_order_release) + != -47005821817476590338899959755631767523922706464318179257576905706190974605110048798536576061089388688170707553276681418895245451233487393724867057886238594880160298625689608wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, count, memory_order_acq_rel) + != -32351362787025420883010482641433459762814295349213927882089180397606724093345094877399090035163771065308295932085103371288720788854446039842446727536159590771651697939580055wb) + abort (); + + if (atomic_fetch_sub_explicit (&v, 22886836433700729148520267039236396292049781709943309196356241086882444816631218673962641435859436811686812355905147988710440709035301495069683757516099446883747069843672565wb, + memory_order_seq_cst) + != -39165065481678557800897050248437255123545687044752309805664680473827470381293152326747699707767742896377846745550860567498794424910581864061468936649654652089334052029610654wb) + abort (); + + if (atomic_fetch_sub (&v, 49406467535448986167225179068150076098092817730200780462287871488076089290458383699602612866098591282427581289588523598202726797161439183859560135056424525356253246480887928wb) + != 61613298821172980080833943222149943601970205795910300955010606485738697355341562584447859386994342786734176611552061113466447383207492245852620383385192484985222264201066349wb) + abort (); + + if (atomic_load_explicit (&v, memory_order_acquire) + != 12206831285723993913608764153999867503877388065709520492722734997662608064883178884845246520895751504306595321963537515263720586046053061993060248328767959628969017720178421wb) + abort (); +} + +void +test_fetch_and () +{ + atomic_store (&v, init); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_relaxed) != init) + abort (); + + if (atomic_fetch_and_explicit (&v, init, memory_order_consume) != 0) + abort (); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_acquire) != 0) + abort (); + + v = ~v; + if (atomic_fetch_and_explicit (&v, init, memory_order_release) != init) + abort (); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_acq_rel) != init) + abort (); + + if (atomic_fetch_and_explicit (&v, 0, memory_order_seq_cst) != 0) + abort (); + + if (atomic_fetch_and (&v, 0) != 0) + abort (); +} + +void +test_fetch_xor () +{ + v = init; + count = 0; + + if (atomic_fetch_xor_explicit (&v, count, memory_order_relaxed) != init) + abort (); + + if (atomic_fetch_xor_explicit (&v, ~count, memory_order_consume) != init) + abort (); + + if (atomic_fetch_xor_explicit (&v, 0, memory_order_acquire) != 0) + abort (); + + if (atomic_fetch_xor_explicit (&v, ~count, memory_order_release) != 0) + abort (); + + if (atomic_fetch_xor_explicit (&v, 0, memory_order_acq_rel) != init) + abort (); + + if (atomic_fetch_xor_explicit (&v, ~count, memory_order_seq_cst) != init) + abort (); + + if (atomic_fetch_xor (&v, ~count) != 0) + abort (); +} + +void +test_fetch_or () +{ + v = 0wb; + count = 28269553036454149273332760011886696253239742350009903329945699220681916416wb; + + if (atomic_fetch_or_explicit (&v, count, memory_order_relaxed) != 0wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, 56539106072908298546665520023773392506479484700019806659891398441363832832wb, + memory_order_consume) + != 28269553036454149273332760011886696253239742350009903329945699220681916416wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, count, memory_order_acquire) + != 84808659109362447819998280035660088759719227050029709989837097662045749248wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, 226156424291633194186662080095093570025917938800079226639565593765455331328wb, + memory_order_release) + != 197886871255179044913329320083206873772678196450069323309619894544773414912wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, count, memory_order_acq_rel) + != 424043295546812239099991400178300443798596135250148549949185488310228746240wb) + abort (); + + count *= 2; + if (atomic_fetch_or_explicit (&v, count, memory_order_seq_cst) + != 876356144130078627473315560368487583850432012850307003228316675841139408896wb) + abort (); + + count *= 2; + if (atomic_fetch_or (&v, count) != 1780981841296611404219963880748861863954103768050623909786579050902960734208wb) + abort (); +} + + +/* Test the OP routines with a result which isn't used. */ + +void +test_add () +{ + v = 0; + count = 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677wb; + + atomic_fetch_add (&v, count); + if (v != 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677wb) + abort (); + + atomic_fetch_add_explicit (&v, count, memory_order_consume); + if (v != 2973685811219503388667991961246738269772721288963776813759793504178074130510359140173115930589534699106813779098200501348725870508374254508706949645221709435224795354wb) + abort (); + + atomic_fetch_add (&v, 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677wb); + if (v != 4460528716829255083001987941870107404659081933445665220639690256267111195765538710259673895884302048660220668647300752023088805762561381763060424467832564152837193031wb) + abort (); + + atomic_fetch_add_explicit (&v, 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677wb, + memory_order_release); + if (v != 5947371622439006777335983922493476539545442577927553627519587008356148261020718280346231861179069398213627558196401002697451741016748509017413899290443418870449590708wb) + abort (); + + atomic_fetch_add (&v, 1486842905609751694333995980623369134886360644481888406879896752089037065255179570086557965294767349553406889549100250674362935254187127254353474822610854717612397677wb); + if (v != 7434214528048758471669979903116845674431803222409442034399483760445185326275897850432789826473836747767034447745501253371814676270935636271767374113054273588061988385wb) + abort (); + + atomic_fetch_add_explicit (&v, count, memory_order_seq_cst); + if (v != 8921057433658510166003975883740214809318163866891330441279380512534222391531077420519347791768604097320441337294601504046177611525122763526120848935665128305674386062wb) + abort (); +} + +void +test_sub () +{ + v = res = 55339930658115792138308584702507715233391812567721958037499562620485942364609138719919541704955047331226014242859673113345829202990143617633801993282898070230404539826267403wb; + count = 0; + + atomic_fetch_sub (&v, count + 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb); + res -= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb; + if (v != res) + abort (); + + atomic_fetch_sub_explicit (&v, count + 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb, memory_order_consume); + res -= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb; + if (v != res) + abort (); + + atomic_fetch_sub (&v, 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb); + res -= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb; + if (v != res) + abort (); + + atomic_fetch_sub_explicit (&v, 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb, memory_order_release); + res -= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb; + if (v != res) + abort (); + + atomic_fetch_sub (&v, count + 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb); + res -= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb; + if (v != res) + abort (); + + atomic_fetch_sub_explicit (&v, count + 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb, memory_order_seq_cst); + res -= 2266681016524228072657464685355732111725088152428495977635446886262656759828446929716740827028716649170693025791717921736186782036315322643449879013364541057wb; + if (v != res) + abort (); +} + +void +test_and () +{ + v = init; + + atomic_fetch_and (&v, 0); + if (v != 0) + abort (); + + v = init; + atomic_fetch_and_explicit (&v, init, memory_order_consume); + if (v != init) + abort (); + + atomic_fetch_and (&v, 0); + if (v != 0) + abort (); + + v = ~v; + atomic_fetch_and_explicit (&v, init, memory_order_release); + if (v != init) + abort (); + + atomic_fetch_and (&v, 0); + if (v != 0) + abort (); + + v = ~v; + atomic_fetch_and_explicit (&v, 0, memory_order_seq_cst); + if (v != 0) + abort (); +} + +void +test_xor () +{ + v = init; + count = 0; + + atomic_fetch_xor (&v, count); + if (v != init) + abort (); + + atomic_fetch_xor_explicit (&v, ~count, memory_order_consume); + if (v != 0) + abort (); + + atomic_fetch_xor (&v, 0); + if (v != 0) + abort (); + + atomic_fetch_xor_explicit (&v, ~count, memory_order_release); + if (v != init) + abort (); + + atomic_fetch_xor_explicit (&v, 0, memory_order_acq_rel); + if (v != init) + abort (); + + atomic_fetch_xor (&v, ~count); + if (v != 0) + abort (); +} + +void +test_or () +{ + v = 0; + count = 19342813113834066795298816wb; + + atomic_fetch_or (&v, count); + if (v != 19342813113834066795298816wb) + abort (); + + count *= 2; + atomic_fetch_or_explicit (&v, count, memory_order_consume); + if (v != 58028439341502200385896448wb) + abort (); + + count *= 2; + atomic_fetch_or (&v, 77371252455336267181195264wb); + if (v != 135399691796838467567091712wb) + abort (); + + count *= 2; + atomic_fetch_or_explicit (&v, 154742504910672534362390528wb, + memory_order_release); + if (v != 290142196707511001929482240wb) + abort (); + + count *= 2; + atomic_fetch_or (&v, count); + if (v != 599627206528856070654263296wb) + abort (); + + count *= 2; + atomic_fetch_or_explicit (&v, count, memory_order_seq_cst); + if (v != 1218597226171546208103825408wb) + abort (); +} + +void +test_exchange (void) +{ + atomic_store (&v, -285679222948993342888321238830899996788334328454283006589115162661816862491992700267590986826514460282130796141107636816730207482542791159837024986802592659048696136633096wb); + if (atomic_exchange (&v, 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601wb) + != -285679222948993342888321238830899996788334328454283006589115162661816862491992700267590986826514460282130796141107636816730207482542791159837024986802592659048696136633096wb + || atomic_load (&v) != 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601wb) + abort (); + if (atomic_exchange_explicit (&v, -4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649wb, + memory_order_relaxed) + != 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601wb + || (atomic_load_explicit (&v, memory_order_acquire) + != -4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649wb)) + abort (); + + count = 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601wb; + if (atomic_compare_exchange_strong (&v, &count, + 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707wb)) + abort (); + if (count != -4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649wb + || atomic_load (&v) != -4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649wb) + abort (); + if (!atomic_compare_exchange_strong (&v, &count, + 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707wb)) + abort (); + if (count != -4427613371507571222951705350055906255006016685171218855857415580222001757304647519678682295710994407542058879878792272713121656498918585491540313864044915269100507689612649wb + || atomic_load (&v) != 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707wb) + abort (); + + count = 5310030317361876753340683501073244375280341322936688061997080395958520351093955920782059690068348979597317732862920837580508090330213951646930178946470395395144632931547601wb; + if (atomic_compare_exchange_strong_explicit (&v, &count, + -20263258027145541347005514871938569231358927704236809883668741851321168433670480594273940614283839738125120292424689828120954658857299483460682957837178666219043928324493674wb, + memory_order_seq_cst, + memory_order_relaxed)) + abort (); + if (count != 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707wb + || atomic_load (&v) != 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707wb) + abort (); + if (!atomic_compare_exchange_strong_explicit (&v, &count, + -20263258027145541347005514871938569231358927704236809883668741851321168433670480594273940614283839738125120292424689828120954658857299483460682957837178666219043928324493674wb, + memory_order_seq_cst, + memory_order_seq_cst)) + abort (); + if (count != 8894166061872682036448354332319628975793195843703235778626260413018342611721096976767565811189387129127069300488196032026080940074010266394902215699511191435840967345778707wb + || atomic_load (&v) != -20263258027145541347005514871938569231358927704236809883668741851321168433670480594273940614283839738125120292424689828120954658857299483460682957837178666219043928324493674wb) + abort (); + + count = atomic_load (&v); + do + res = count + 3438682542819842029328613486899299339199839206022263296398180581126218550036955367421469273900216774711772362599086182416923053671263751262393559525082445581168420546542404wb; + while (!atomic_compare_exchange_weak (&v, &count, res)); + if (atomic_load (&v) != -16824575484325699317676901385039269892159088498214546587270561270194949883633525226852471340383622963413347929825603645704031605186035732198289398312096220637875507777951270wb) + abort (); + + count = atomic_load_explicit (&v, memory_order_acquire); + do + res = count + 55351299008567209999272942257960316150846002020561006740901388462123844029522178721330031429855007927083338249659817829635668878607777961512926342979905691183772323299904096wb; + while (!atomic_compare_exchange_weak_explicit (&v, &count, res, + memory_order_relaxed, + memory_order_relaxed)); + if (atomic_load (&v) != 38526723524241510681596040872921046258686913522346460153630827191928894145888653494477560089471384963669990319834214183931637273421742229314636944667809470545896815521952826wb) + abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 575 + test_fetch_add (); + test_fetch_sub (); + test_fetch_and (); + test_fetch_xor (); + test_fetch_or (); + test_add (); + test_sub (); + test_and (); + test_xor (); + test_or (); + test_exchange (); +#endif + return 0; +} --- gcc/testsuite/gcc.dg/dfp/bitint-1.c.jj 2023-08-08 16:21:45.952768387 +0200 +++ gcc/testsuite/gcc.dg/dfp/bitint-1.c 2023-08-08 16:21:45.952768387 +0200 @@ -0,0 +1,98 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +tests192 (_Decimal64 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testu192 (_Decimal64 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +tests575 (_Decimal64 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testu575 (_Decimal64 d) +{ + return d; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + if (tests192 (0.DD) != 0wb + || tests192 (0.9999999999999999DD) != 0wb + || tests192 (7.999999999999999DD) != 7wb + || tests192 (-42.5DD) != -42wb + || tests192 (-34242319854.45429e+27DD) != -34242319854454290000000000000000000000wb + || tests192 (-213855087769445.9e+43DD) != -2138550877694459000000000000000000000000000000000000000000wb + || tests192 (313855086769334.0e+43DD) != 3138550867693340000000000000000000000000000000000000000000wb + || tests192 (-313855086769334.0e+43DD) != -3138550867693340000000000000000000000000000000000000000000wb) + __builtin_abort (); + if (tests192 (313855086769334.1e+43DD) != 3138550867693340381917894711603833208051177722232017256447wb + || tests192 (9999999999999999e+369DD) != 3138550867693340381917894711603833208051177722232017256447wb + || tests192 (-313855086769334.1e+43DD) != -3138550867693340381917894711603833208051177722232017256447wb - 1wb + || tests192 (-9999999999999999e+369DD) != -3138550867693340381917894711603833208051177722232017256447wb - 1wb) + __builtin_abort (); + if (testu192 (0.DD) != 0uwb + || testu192 (0.9999999999999999DD) != 0uwb + || testu192 (-0.9999999999999999DD) != 0uwb + || testu192 (-0.5DD) != 0uwb + || testu192 (42.99999999999999DD) != 42uwb + || testu192 (42.e+21DD) != 42000000000000000000000uwb + || testu192 (34272319854.45429e+27DD) != 34272319854454290000000000000000000000uwb + || testu192 (627710173538668.0e+43DD) != 6277101735386680000000000000000000000000000000000000000000uwb) + __builtin_abort (); + if (testu192 (-1.DD) != 0uwb + || testu192 (-42.5e+15DD) != 0uwb + || testu192 (-9999999999999999e+369DD) != 0uwb + || testu192 (627710173538668.1e+43DD) != 6277101735386680763835789423207666416102355444464034512895uwb + || testu192 (9999999999999999e+369DD) != 6277101735386680763835789423207666416102355444464034512895uwb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (tests575 (0.DD) != 0wb + || tests575 (0.999999DD) != 0wb + || tests575 (12.9999999999999DD) != 12wb + || tests575 (-89.5DD) != -89wb + || tests575 (-34242319854.45429e+37DD) != -342423198544542900000000000000000000000000000000wb + || tests575 (-518326003682761.2e+158DD) != -51832600368276120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb + || tests575 (6183260036827613.0e+157DD) != 61832600368276130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb + || tests575 (-6183260036827613.0e+157DD) != -61832600368276130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb) + __builtin_abort (); + if (tests575 (6183260036827614.0e+157DD) != 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb + || tests575 (9999999999999999e+369DD) != 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb + || tests575 (-6183260036827614.0e+157DD) != -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb + || tests575 (-9999999999999999e+369DD) != -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb) + __builtin_abort (); + if (testu575 (0.DD) != 0uwb + || testu575 (0.5555555555555555DD) != 0uwb + || testu575 (-0.7777777777777777DD) != 0uwb + || testu575 (-0.99DD) != 0uwb + || testu575 (42.99999999999999DD) != 42uwb + || testu575 (42.e+21DD) != 42000000000000000000000uwb + || testu575 (94272319854.45429e+27DD) != 94272319854454290000000000000000000000uwb + || testu575 (1236652007365522.0e+158DD) != 123665200736552200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb) + __builtin_abort (); + if (testu575 (-1.DD) != 0uwb + || testu575 (-42.5e+15DD) != 0uwb + || testu575 (-9999999999999999e+369DD) != 0uwb + || testu575 (1236652007365523.0e+158DD) != 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb + || testu575 (9999999999999999e+369DD) != 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/dfp/bitint-2.c.jj 2023-08-08 16:21:45.952768387 +0200 +++ gcc/testsuite/gcc.dg/dfp/bitint-2.c 2023-08-08 16:21:45.952768387 +0200 @@ -0,0 +1,91 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +tests192 (_Decimal32 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testu192 (_Decimal32 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +tests575 (_Decimal32 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testu575 (_Decimal32 d) +{ + return d; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + if (tests192 (0.DF) != 0wb + || tests192 (0.9999999DF) != 0wb + || tests192 (7.999999DF) != 7wb + || tests192 (-42.5DF) != -42wb + || tests192 (-3424.231e+27DF) != -3424231000000000000000000000000wb + || tests192 (-213855.9e+43DF) != -2138559000000000000000000000000000000000000000000wb + || tests192 (313855.0e+52DF) != 3138550000000000000000000000000000000000000000000000000000wb + || tests192 (-3138550.e+51DF) != -3138550000000000000000000000000000000000000000000000000000wb) + __builtin_abort (); + if (tests192 (313855.1e+52DF) != 3138550867693340381917894711603833208051177722232017256447wb + || tests192 (9999999e+90DF) != 3138550867693340381917894711603833208051177722232017256447wb + || tests192 (-3138551e+51DF) != -3138550867693340381917894711603833208051177722232017256447wb - 1wb + || tests192 (-9999999e+90DF) != -3138550867693340381917894711603833208051177722232017256447wb - 1wb) + __builtin_abort (); + if (testu192 (0.DF) != 0uwb + || testu192 (0.9999999DF) != 0uwb + || testu192 (-0.9999999DF) != 0uwb + || testu192 (-0.5DF) != 0uwb + || testu192 (42.99999DF) != 42uwb + || testu192 (42.e+21DF) != 42000000000000000000000uwb + || testu192 (3427.231e+29DF) != 342723100000000000000000000000000uwb + || testu192 (6277101.0e+51DF) != 6277101000000000000000000000000000000000000000000000000000uwb) + __builtin_abort (); + if (testu192 (-1.DF) != 0uwb + || testu192 (-42.5e+15DF) != 0uwb + || testu192 (-9999999e+90DF) != 0uwb + || testu192 (6277102.0e+51DF) != 6277101735386680763835789423207666416102355444464034512895uwb + || testu192 (9999999e+90DF) != 6277101735386680763835789423207666416102355444464034512895uwb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (tests575 (0.DF) != 0wb + || tests575 (0.999999DF) != 0wb + || tests575 (12.9999DF) != 12wb + || tests575 (-89.5DF) != -89wb + || tests575 (-34242.31e+37DF) != -342423100000000000000000000000000000000000wb + || tests575 (-518326.2e+88DF) != -5183262000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb + || tests575 (9999999e+90DF) != 9999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb + || tests575 (-9999999e+90DF) != -9999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb) + __builtin_abort (); + if (testu575 (0.DF) != 0uwb + || testu575 (0.5555555DF) != 0uwb + || testu575 (-0.7777777DF) != 0uwb + || testu575 (-0.99DF) != 0uwb + || testu575 (42.99999DF) != 42uwb + || testu575 (42.e+21DF) != 42000000000000000000000uwb + || testu575 (9427.231e+27DF) != 9427231000000000000000000000000uwb + || testu575 (9999999e+90DF) != 9999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb) + __builtin_abort (); + if (testu575 (-1.DF) != 0uwb + || testu575 (-42.5e+15DF) != 0uwb + || testu575 (-9999999e+90DF) != 0uwb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/dfp/bitint-3.c.jj 2023-08-08 16:21:45.953768373 +0200 +++ gcc/testsuite/gcc.dg/dfp/bitint-3.c 2023-08-08 16:21:45.953768373 +0200 @@ -0,0 +1,98 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _BitInt(192) +tests192 (_Decimal128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(192) +testu192 (_Decimal128 d) +{ + return d; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _BitInt(575) +tests575 (_Decimal128 d) +{ + return d; +} + +__attribute__((noipa)) unsigned _BitInt(575) +testu575 (_Decimal128 d) +{ + return d; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 192 + if (tests192 (0.DL) != 0wb + || tests192 (0.9999999999999999999999999999999999DL) != 0wb + || tests192 (7.999999999999999999999999999999999DL) != 7wb + || tests192 (-42.5DL) != -42wb + || tests192 (-34242319854.45429439857871298745432e+27DL) != -34242319854454294398578712987454320000wb + || tests192 (-213855087769445.9e+43DL) != -2138550877694459000000000000000000000000000000000000000000wb + || tests192 (3138550867693340381917894711603833.0e+24DL) != 3138550867693340381917894711603833000000000000000000000000wb + || tests192 (-3138550867693340381917894711603833.0e+24DL) != -3138550867693340381917894711603833000000000000000000000000wb) + __builtin_abort (); + if (tests192 (3138550867693340381917894711603834.0e+24DL) != 3138550867693340381917894711603833208051177722232017256447wb + || tests192 (9999999999999999999999999999999999e+6111DL) != 3138550867693340381917894711603833208051177722232017256447wb + || tests192 (-3138550867693340381917894711603834.0e+24DL) != -3138550867693340381917894711603833208051177722232017256447wb - 1wb + || tests192 (-9999999999999999999999999999999999e+6111DL) != -3138550867693340381917894711603833208051177722232017256447wb - 1wb) + __builtin_abort (); + if (testu192 (0.DL) != 0uwb + || testu192 (0.9999999999999999999999999999999999DL) != 0uwb + || testu192 (-0.9999999999999999999999999999999999DL) != 0uwb + || testu192 (-0.5DL) != 0uwb + || testu192 (42.99999999999999999999999999999999DL) != 42uwb + || testu192 (42.e+21DL) != 42000000000000000000000uwb + || testu192 (34242319854.45429439857871298745432e+21DL) != 34242319854454294398578712987454uwb + || testu192 (6277101735386680763835789423207666.0e+24DL) != 6277101735386680763835789423207666000000000000000000000000uwb) + __builtin_abort (); + if (testu192 (-1.DL) != 0uwb + || testu192 (-42.5e+15DL) != 0uwb + || testu192 (-9999999999999999999999999999999999e+6111DL) != 0uwb + || testu192 (6277101735386680763835789423207667.0e+24DL) != 6277101735386680763835789423207666416102355444464034512895uwb + || testu192 (9999999999999999999999999999999999e+6111DL) != 6277101735386680763835789423207666416102355444464034512895uwb) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (tests575 (0.DL) != 0wb + || tests575 (0.999999999999999999999DL) != 0wb + || tests575 (12.99999999999999999999999999999DL) != 12wb + || tests575 (-89.5DL) != -89wb + || tests575 (-34242319854.45429986754986758972345e+37DL) != -342423198544542998675498675897234500000000000000wb + || tests575 (-518326003682761.2e+158DL) != -51832600368276120000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb + || tests575 (6183260036827613351512563025491179.0e+139DL) != 61832600368276133515125630254911790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb + || tests575 (-6183260036827613351512563025491179.0e+139DL) != -61832600368276133515125630254911790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb) + __builtin_abort (); + if (tests575 (618326003682761335151256302549118.0e+140DL) != 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb + || tests575 (9999999999999999999999999999999999e+6111DL) != 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb + || tests575 (-6183260036827613351512563025491180.0e+139DL) != -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb + || tests575 (-9999999999999999999999999999999999e+6111DL) != -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb) + __builtin_abort (); + if (testu575 (0.DL) != 0uwb + || testu575 (0.5555555555555555555555555555555555DL) != 0uwb + || testu575 (-0.7777777777777777777777777777777777DL) != 0uwb + || testu575 (-0.99DL) != 0uwb + || testu575 (42.99999999999999999999999999999999DL) != 42uwb + || testu575 (42.e+21DL) != 42000000000000000000000uwb + || testu575 (94272319854.45429e+27DL) != 94272319854454290000000000000000000000uwb + || testu575 (1236652007365522670302512605098235.0e+140DL) != 123665200736552267030251260509823500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb) + __builtin_abort (); + if (testu575 (-1.DL) != 0uwb + || testu575 (-42.5e+15DL) != 0uwb + || testu575 (-9999999999999999999999999999999999e+6111DL) != 0uwb + || testu575 (1236652007365522670302512605098236.0e+140DL) != 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb + || testu575 (9999999999999999999999999999999999e+6111DL) != 123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/dfp/bitint-4.c.jj 2023-08-08 16:22:09.404440148 +0200 +++ gcc/testsuite/gcc.dg/dfp/bitint-4.c 2023-08-08 16:22:09.404440148 +0200 @@ -0,0 +1,156 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _Decimal64 +tests192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) _Decimal64 +testu192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _Decimal64 +tests575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) _Decimal64 +testu575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif + +int +main () +{ + _Decimal64 a, b; +#define CHECK(x, y) (a = (x), b = (y), a != (y) || __builtin_memcmp (&a, &b, sizeof (a))) +#if __BITINT_MAXWIDTH__ >= 192 + if (CHECK (tests192 (0wb), 0.DD) + || CHECK (tests192 (7wb), 7.DD) + || CHECK (tests192 (-42wb), -42.DD) + || CHECK (tests192 (-777777777wb), -777777777.DD) + || CHECK (tests192 (9999999999999000wb), 9999999999999000.DD) + || CHECK (tests192 (-9999999999999999wb), -9999999999999999.DD) + || CHECK (tests192 (-99999999999999994wb), -9999999999999999.e+1DD) + || CHECK (tests192 (99999999999999995wb), 1000000000000000.e+2DD) + || CHECK (tests192 (999999999999999900wb), 9999999999999999.e+2DD) + || CHECK (tests192 (999999999999999949wb), 9999999999999999.e+2DD) + || CHECK (tests192 (-9999999999999999000wb), -9999999999999999.e+3DD) + || CHECK (tests192 (9999999999999999499wb), 9999999999999999.e+3DD) + || CHECK (tests192 (999999999999999900000wb), 9999999999999999.e+5DD) + || CHECK (tests192 (999999999999999949999wb), 9999999999999999.e+5DD) + || CHECK (tests192 (-9999999999999999000000wb), -9999999999999999.e+6DD) + || CHECK (tests192 (-9999999999999999499999wb), -9999999999999999.e+6DD) + || CHECK (tests192 (123456789012345600000000wb), 1234567890123456.e+8DD) + || CHECK (tests192 (34242319854454290000000000000000000000wb), 3424231985445429e+22DD) + || CHECK (tests192 (999999999999999900000000000000000000000000000000wb), 9999999999999999.e+32DD) + || CHECK (tests192 (999999999999999949999999999999999999999999999999wb), 9999999999999999.e+32DD) + || CHECK (tests192 (-999999999999999900000000000000000000000000000000000000000wb), -9999999999999999.e+41DD) + || CHECK (tests192 (-2138550877694459000000000000000000000000000000000000000000wb), -2138550877694459e+42DD) + || CHECK (tests192 (-2138550877694459500000000000000000000000000000000000000000wb), -2138550877694460e+42DD) + || CHECK (tests192 (-2138550877694459499999999999999999999999999999999999999999wb), -2138550877694459e+42DD) + || CHECK (tests192 (-2138550877694459999999999999999999999999999999999999999999wb), -2138550877694460e+42DD) + || CHECK (tests192 (-2138550877694458000000000000000000000000000000000000000000wb), -2138550877694458e+42DD) + || CHECK (tests192 (-2138550877694458500000000000000000000000000000000000000000wb), -2138550877694458e+42DD) + || CHECK (tests192 (-2138550877694458500000000000000000000000000000000000000001wb), -2138550877694459e+42DD) + || CHECK (tests192 (3138550867693340000000000000000000000000000000000000000000wb), 3138550867693340e+42DD) + || CHECK (tests192 (3138550867693340381917894711603833208051177722232017256447wb), 3138550867693340e+42DD) + || CHECK (tests192 (-3138550867693340000000000000000000000000000000000000000000wb), -3138550867693340e+42DD) + || CHECK (tests192 (-3138550867693340381917894711603833208051177722232017256447wb - 1wb), -3138550867693340e+42DD)) + __builtin_abort (); + if (CHECK (testu192 (0uwb), 0.DD) + || CHECK (testu192 (7uwb), 7.DD) + || CHECK (testu192 (42uwb), 42.DD) + || CHECK (testu192 (777777777uwb), 777777777.DD) + || CHECK (testu192 (9999999999999000uwb), 9999999999999000.DD) + || CHECK (testu192 (999999999999999900uwb), 9999999999999999.e+2DD) + || CHECK (testu192 (9999999999999999000uwb), 9999999999999999.e+3DD) + || CHECK (testu192 (99999999999999994999uwb), 9999999999999999.e+4DD) + || CHECK (testu192 (999999999999999900000uwb), 9999999999999999.e+5DD) + || CHECK (testu192 (9999999999999999000000uwb), 9999999999999999.e+6DD) + || CHECK (testu192 (123456789012345600000000uwb), 1234567890123456.e+8DD) + || CHECK (testu192 (34242319854454290000000000000000000000uwb), 3424231985445429e+22DD) + || CHECK (testu192 (9999999999999999000000000000000000000000000000000uwb), 9999999999999999.e+33DD) + || CHECK (testu192 (618935436546517900000000000000000000000000000000000000uwb), 6189354365465179e+38DD) + || CHECK (testu192 (618935436546517950000000000000000000000000000000000000uwb), 6189354365465180e+38DD) + || CHECK (testu192 (618935436546517949999999999999999999999999999999999999uwb), 6189354365465179e+38DD) + || CHECK (testu192 (618935436546517999999999999999999999999999999999999999uwb), 6189354365465180e+38DD) + || CHECK (testu192 (618935436546517800000000000000000000000000000000000000uwb), 6189354365465178e+38DD) + || CHECK (testu192 (618935436546517850000000000000000000000000000000000000uwb), 6189354365465178e+38DD) + || CHECK (testu192 (618935436546517850000000000000000000000000000000000001uwb), 6189354365465179e+38DD) + || CHECK (testu192 (99999999999999990000000000000000000000000000000000000000uwb), 9999999999999999.e+40DD) + || CHECK (testu192 (6277101735386680000000000000000000000000000000000000000000uwb), 6277101735386680e+42DD) + || CHECK (testu192 (6277101735386680499999999999999999999999999999999999999999uwb), 6277101735386680e+42DD) + || CHECK (testu192 (6277101735386680500000000000000000000000000000000000000000uwb), 6277101735386680e+42DD) + || CHECK (testu192 (6277101735386680500000000000000000000000000000000000000001uwb), 6277101735386681e+42DD) + || CHECK (testu192 (6277101735386680500000000000000000000010000000000000000000uwb), 6277101735386681e+42DD) + || CHECK (testu192 (6277101735386680763835789423207666416102355444464034512895uwb), 6277101735386681e+42DD)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (CHECK (tests575 (0wb), 0.DD) + || CHECK (tests575 (7wb), 7.DD) + || CHECK (tests575 (-42wb), -42.DD) + || CHECK (tests575 (-444444444wb), -444444444.DD) + || CHECK (tests575 (9999999999999000wb), 9999999999999000.DD) + || CHECK (tests575 (-9999999999999999wb), -9999999999999999.DD) + || CHECK (tests575 (999999999999999900wb), 9999999999999999.e+2DD) + || CHECK (tests575 (-9999999999999999000wb), -9999999999999999.e+3DD) + || CHECK (tests575 (999999999999999900000wb), 9999999999999999.e+5DD) + || CHECK (tests575 (-99999999999999990000000wb), -9999999999999999.e+7DD) + || CHECK (tests575 (1234567890123456000000000wb), 1234567890123456.e+9DD) + || CHECK (tests575 (3424231985445429000000000000000000000000wb), 3424231985445429e+24DD) + || CHECK (tests575 (99999999999999990000000000000000000000000000000000000000wb), 9999999999999999.e+40DD) + || CHECK (tests575 (-9999999999999999000000000000000000000000000000000000000000000000000000000000000wb), -9999999999999999.e+63DD) + || CHECK (tests575 (-213855087769445900000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694459e+86DD) + || CHECK (tests575 (-213855087769445950000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694460e+86DD) + || CHECK (tests575 (-213855087769445949999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -2138550877694459e+86DD) + || CHECK (tests575 (-213855087769445999999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -2138550877694460e+86DD) + || CHECK (tests575 (-213855087769445800000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694458e+86DD) + || CHECK (tests575 (-213855087769445850000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694458e+86DD) + || CHECK (tests575 (-213855087769445850000000000000000000000000000000000000000000000000000000000000000000000000000000000001wb), -2138550877694459e+86DD) + || CHECK (tests575 (61832600368276130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), 6183260036827613e+157DD) + || CHECK (tests575 (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb), 6183260036827613e+157DD) + || CHECK (tests575 (-61832600368276130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -6183260036827613e+157DD) + || CHECK (tests575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb), -6183260036827613e+157DD)) + __builtin_abort (); + if (CHECK (testu575 (0uwb), 0.DD) + || CHECK (testu575 (17uwb), 17.DD) + || CHECK (testu575 (420uwb), 420.DD) + || CHECK (testu575 (888888888uwb), 888888888.DD) + || CHECK (testu575 (9999999999999000uwb), 9999999999999000.DD) + || CHECK (testu575 (99999999999999990000000uwb), 9999999999999999.e+7DD) + || CHECK (testu575 (9999999999999999000000000uwb), 9999999999999999.e+9DD) + || CHECK (testu575 (99999999999999990000000000000uwb), 9999999999999999.e+13DD) + || CHECK (testu575 (9999999999999999000000000000000uwb), 9999999999999999.e+15DD) + || CHECK (testu575 (1234567890123456000000000000000000uwb), 1234567890123456.e+18DD) + || CHECK (testu575 (34242319854454290000000000000000000000uwb), 3424231985445429e+22DD) + || CHECK (testu575 (9999999999999999000000000000000000000000000000000uwb), 9999999999999999.e+33DD) + || CHECK (testu575 (618935436546517900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465179e+104DD) + || CHECK (testu575 (618935436546517950000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465180e+104DD) + || CHECK (testu575 (618935436546517949999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 6189354365465179e+104DD) + || CHECK (testu575 (618935436546517999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 6189354365465180e+104DD) + || CHECK (testu575 (618935436546517800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465178e+104DD) + || CHECK (testu575 (618935436546517850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465178e+104DD) + || CHECK (testu575 (618935436546517850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001uwb), 6189354365465179e+104DD) + || CHECK (testu575 (99999999999999990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 9999999999999999.e+139DD) + || CHECK (testu575 (123665200736552200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 1236652007365522e+158DD) + || CHECK (testu575 (123665200736552249999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 1236652007365522e+158DD) + || CHECK (testu575 (123665200736552250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 1236652007365522e+158DD) + || CHECK (testu575 (123665200736552250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001uwb), 1236652007365523e+158DD) + || CHECK (testu575 (123665200736552250000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 1236652007365523e+158DD) + || CHECK (testu575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), 1236652007365523e+158DD)) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/dfp/bitint-5.c.jj 2023-08-08 16:22:09.404440148 +0200 +++ gcc/testsuite/gcc.dg/dfp/bitint-5.c 2023-08-08 16:22:09.404440148 +0200 @@ -0,0 +1,159 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _Decimal32 +tests192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) _Decimal32 +testu192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _Decimal32 +tests575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) _Decimal32 +testu575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif + +int +main () +{ + _Decimal32 a, b; +#define CHECK(x, y) (a = (x), b = (y), a != (y) || __builtin_memcmp (&a, &b, sizeof (a))) +#if __BITINT_MAXWIDTH__ >= 192 + if (CHECK (tests192 (0wb), 0.DF) + || CHECK (tests192 (7wb), 7.DF) + || CHECK (tests192 (-42wb), -42.DF) + || CHECK (tests192 (-777777wb), -777777.DF) + || CHECK (tests192 (9999000wb), 9999000.DF) + || CHECK (tests192 (-9999999wb), -9999999.DF) + || CHECK (tests192 (99999994wb), 9999999.e+1DF) + || CHECK (tests192 (99999995wb), 1000000.e+2DF) + || CHECK (tests192 (999999900wb), 9999999.e+2DF) + || CHECK (tests192 (-9999999000wb), -9999999.e+3DF) + || CHECK (tests192 (999999900000wb), 9999999.e+5DF) + || CHECK (tests192 (-9999999000000wb), -9999999.e+6DF) + || CHECK (tests192 (123456700000000000wb), 1234567.e+11DF) + || CHECK (tests192 (34242310000000000000000000000wb), 3424231e+22DF) + || CHECK (tests192 (999999900000000000000000000000000000000wb), 9999999.e+32DF) + || CHECK (tests192 (-999999900000000000000000000000000000000000000000wb), -9999999.e+41DF) + || CHECK (tests192 (-2138551000000000000000000000000000000000000000000000000000wb), -2138551e+51DF) + || CHECK (tests192 (-2138551500000000000000000000000000000000000000000000000000wb), -2138552e+51DF) + || CHECK (tests192 (-2138551499999999999999999999999999999999999999999999999999wb), -2138551e+51DF) + || CHECK (tests192 (-2138551999999999999999999999999999999999999999999999999999wb), -2138552e+51DF) + || CHECK (tests192 (-2138552000000000000000000000000000000000000000000000000000wb), -2138552e+51DF) + || CHECK (tests192 (-2138552500000000000000000000000000000000000000000000000000wb), -2138552e+51DF) + || CHECK (tests192 (-2138552500000000000000000000000000000000000000000000000001wb), -2138553e+51DF) + || CHECK (tests192 (3138550000000000000000000000000000000000000000000000000000wb), 3138550e+51DF) + || CHECK (tests192 (3138550867693340381917894711603833208051177722232017256447wb), 3138551e+51DF) + || CHECK (tests192 (-3138550000000000000000000000000000000000000000000000000000wb), -3138550e+51DF) + || CHECK (tests192 (-3138550867693340381917894711603833208051177722232017256447wb - 1wb), -3138551e+51DF)) + __builtin_abort (); + if (CHECK (testu192 (0uwb), 0.DF) + || CHECK (testu192 (7uwb), 7.DF) + || CHECK (testu192 (42uwb), 42.DF) + || CHECK (testu192 (77777uwb), 77777.DF) + || CHECK (testu192 (9999000uwb), 9999000.DF) + || CHECK (testu192 (999999900uwb), 9999999.e+2DF) + || CHECK (testu192 (999999949uwb), 9999999.e+2DF) + || CHECK (testu192 (9999999000uwb), 9999999.e+3DF) + || CHECK (testu192 (9999999499uwb), 9999999.e+3DF) + || CHECK (testu192 (999999900000uwb), 9999999.e+5DF) + || CHECK (testu192 (9999999000000uwb), 9999999.e+6DF) + || CHECK (testu192 (123456700000000uwb), 1234567.e+8DF) + || CHECK (testu192 (34242310000000000000000000000uwb), 3424231e+22DF) + || CHECK (testu192 (9999999000000000000000000000000000000000uwb), 9999999.e+33DF) + || CHECK (testu192 (61893590000000000000000000000000000000000000000000000uwb), 6189359e+46DF) + || CHECK (testu192 (61893595000000000000000000000000000000000000000000000uwb), 6189360e+46DF) + || CHECK (testu192 (61893594999999999999999999999999999999999999999999999uwb), 6189359e+46DF) + || CHECK (testu192 (61893599999999999999999999999999999999999999999999999uwb), 6189360e+46DF) + || CHECK (testu192 (61893580000000000000000000000000000000000000000000000uwb), 6189358e+46DF) + || CHECK (testu192 (61893585000000000000000000000000000000000000000000000uwb), 6189358e+46DF) + || CHECK (testu192 (61893585000000000000000000000000000000000000000000001uwb), 6189359e+46DF) + || CHECK (testu192 (999999900000000000000000000000000000000000000000000000uwb), 9999999.e+47DF) + || CHECK (testu192 (6277100500000000000000000000000000000000000000000000000000uwb), 6277100e+51DF) + || CHECK (testu192 (6277100500000000000000000000000000000000000000000000000001uwb), 6277101e+51DF) + || CHECK (testu192 (6277100500000000000000000000000000000010000000000000000000uwb), 6277101e+51DF) + || CHECK (testu192 (6277101000000000000000000000000000000000000000000000000000uwb), 6277101e+51DF) + || CHECK (testu192 (6277101499999999999999999999999999999999999999999999999999uwb), 6277101e+51DF) + || CHECK (testu192 (6277101500000000000000000000000000000000000000000000000000uwb), 6277102e+51DF) + || CHECK (testu192 (6277101735386680763835789423207666416102355444464034512895uwb), 6277102e+51DF)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (CHECK (tests575 (0wb), 0.DF) + || CHECK (tests575 (7wb), 7.DF) + || CHECK (tests575 (-42wb), -42.DF) + || CHECK (tests575 (-44444wb), -44444.DF) + || CHECK (tests575 (9999000wb), 9999000.DF) + || CHECK (tests575 (-9999999wb), -9999999.DF) + || CHECK (tests575 (999999900wb), 9999999.e+2DF) + || CHECK (tests575 (-9999999000wb), -9999999.e+3DF) + || CHECK (tests575 (999999900000wb), 9999999.e+5DF) + || CHECK (tests575 (999999949999wb), 9999999.e+5DF) + || CHECK (tests575 (-99999990000000wb), -9999999.e+7DF) + || CHECK (tests575 (1234567000000000000000000wb), 1234567.e+18DF) + || CHECK (tests575 (3424231000000000000000000000000000000000wb), 3424231e+33DF) + || CHECK (tests575 (99999990000000000000000000000000000000000000000wb), 9999999.e+40DF) + || CHECK (tests575 (-9999999000000000000000000000000000000000000000000000000000000000000000wb), -9999999.e+63DF) + || CHECK (tests575 (-2138559000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138559e+90DF) + || CHECK (tests575 (-2138559500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138560e+90DF) + || CHECK (tests575 (-2138559499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -2138559e+90DF) + || CHECK (tests575 (-2138559999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -2138560e+90DF) + || CHECK (tests575 (-2138558000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138558e+90DF) + || CHECK (tests575 (-2138558500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138558e+90DF) + || CHECK (tests575 (-2138558500000000000000000000000000000000000000000000000000000000000000000000000000000000000000001wb), -2138559e+90DF) + || CHECK (tests575 (9999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), 9999999e+90DF) + || CHECK (tests575 (9999999499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), 9999999e+90DF) + || CHECK (tests575 (9999999500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), __builtin_infd32 ()) + || CHECK (tests575 (-9999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -9999999e+90DF) + || CHECK (tests575 (-9999999499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -9999999e+90DF) + || CHECK (tests575 (-9999999500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -__builtin_infd32 ()) + || CHECK (tests575 (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb), __builtin_infd32 ()) + || CHECK (tests575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb), -__builtin_infd32 ())) + __builtin_abort (); + if (CHECK (testu575 (0uwb), 0.DF) + || CHECK (testu575 (17uwb), 17.DF) + || CHECK (testu575 (420uwb), 420.DF) + || CHECK (testu575 (888uwb), 888.DF) + || CHECK (testu575 (9999000uwb), 9999000.DF) + || CHECK (testu575 (99999990000000uwb), 9999999.e+7DF) + || CHECK (testu575 (99999994999999uwb), 9999999.e+7DF) + || CHECK (testu575 (9999999000000000uwb), 9999999.e+9DF) + || CHECK (testu575 (9999999499999999uwb), 9999999.e+9DF) + || CHECK (testu575 (99999990000000000000uwb), 9999999.e+13DF) + || CHECK (testu575 (99999994999999999999uwb), 9999999.e+13DF) + || CHECK (testu575 (9999999000000000000000uwb), 9999999.e+15DF) + || CHECK (testu575 (9999999499999999999999uwb), 9999999.e+15DF) + || CHECK (testu575 (1234567000000000000000000uwb), 1234567.e+18DF) + || CHECK (testu575 (34242310000000000000000000000uwb), 3424231e+22DF) + || CHECK (testu575 (9999999000000000000000000000000000000000uwb), 9999999.e+33DF) + || CHECK (testu575 (61893590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189359e+88DF) + || CHECK (testu575 (61893595000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189360e+88DF) + || CHECK (testu575 (61893594999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 6189359e+88DF) + || CHECK (testu575 (61893599999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 6189360e+88DF) + || CHECK (testu575 (61893580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189358e+88DF) + || CHECK (testu575 (61893585000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189358e+88DF) + || CHECK (testu575 (61893585000000000000000000000000000000000000000000000000000000000000000000000000000000000000001uwb), 6189359e+88DF) + || CHECK (testu575 (9999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 9999999.e+90DF) + || CHECK (tests575 (9999999499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 9999999e+90DF) + || CHECK (tests575 (9999999500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), __builtin_infd32 ()) + || CHECK (testu575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), __builtin_infd32 ())) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/dfp/bitint-6.c.jj 2023-08-08 16:22:09.404440148 +0200 +++ gcc/testsuite/gcc.dg/dfp/bitint-6.c 2023-08-08 16:22:09.404440148 +0200 @@ -0,0 +1,156 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-O2 -std=c2x -pedantic-errors" } */ + +#if __BITINT_MAXWIDTH__ >= 192 +__attribute__((noipa)) _Decimal128 +tests192 (_BitInt(192) b) +{ + return b; +} + +__attribute__((noipa)) _Decimal128 +testu192 (unsigned _BitInt(192) b) +{ + return b; +} +#endif + +#if __BITINT_MAXWIDTH__ >= 575 +__attribute__((noipa)) _Decimal128 +tests575 (_BitInt(575) b) +{ + return b; +} + +__attribute__((noipa)) _Decimal128 +testu575 (unsigned _BitInt(575) b) +{ + return b; +} +#endif + +int +main () +{ + _Decimal128 a, b; +#define CHECK(x, y) (a = (x), b = (y), a != (y) || __builtin_memcmp (&a, &b, sizeof (a))) +#if __BITINT_MAXWIDTH__ >= 192 + if (CHECK (tests192 (0wb), 0.DL) + || CHECK (tests192 (7wb), 7.DL) + || CHECK (tests192 (-42wb), -42.DL) + || CHECK (tests192 (-777777777wb), -777777777.DL) + || CHECK (tests192 (-12345678912345wb), -12345678912345.DL) + || CHECK (tests192 (123456789123456789wb), 123456789123456789.DL) + || CHECK (tests192 (777777777777777777777777777wb), 777777777777777777777777777.DL) + || CHECK (tests192 (9999999999999999999999999900000000wb), 9999999999999999999999999900000000.DL) + || CHECK (tests192 (-9999999999999999999999999999999999wb), -9999999999999999999999999999999999.DL) + || CHECK (tests192 (-99999999999999999999999999999999994wb), -9999999999999999999999999999999999.e+1DL) + || CHECK (tests192 (99999999999999999999999999999999995wb), 1000000000000000000000000000000000.e+2DL) + || CHECK (tests192 (999999999999999999999999999999999900wb), 9999999999999999999999999999999999.e+2DL) + || CHECK (tests192 (999999999999999999999999999999999949wb), 9999999999999999999999999999999999.e+2DL) + || CHECK (tests192 (-9999999999999999999999999999999999000wb), -9999999999999999999999999999999999.e+3DL) + || CHECK (tests192 (9999999999999999999999999999999999499wb), 9999999999999999999999999999999999.e+3DL) + || CHECK (tests192 (34242319854454290000000000000000000000wb), 3424231985445429000000000000000000e+4DL) + || CHECK (tests192 (34242319854454294983573424983275760000wb), 3424231985445429498357342498327576e+4DL) + || CHECK (tests192 (999999999999999999999999999999999900000wb), 9999999999999999999999999999999999.e+5DL) + || CHECK (tests192 (999999999999999999999999999999999949999wb), 9999999999999999999999999999999999.e+5DL) + || CHECK (tests192 (-9999999999999999999999999999999999000000wb), -9999999999999999999999999999999999.e+6DL) + || CHECK (tests192 (-9999999999999999999999999999999999499999wb), -9999999999999999999999999999999999.e+6DL) + || CHECK (tests192 (123456789012345678901234567890123400000000wb), 1234567890123456789012345678901234.e+8DL) + || CHECK (tests192 (999999999999999999999999999999999900000000000000000000000wb), 9999999999999999999999999999999999.e+23DL) + || CHECK (tests192 (999999999999999999999999999999999949999999999999999999999wb), 9999999999999999999999999999999999.e+23DL) + || CHECK (tests192 (-999999999999999999999999999999999900000000000000000000000wb), -9999999999999999999999999999999999.e+23DL) + || CHECK (tests192 (-2138550877694459381917894711603833000000000000000000000000wb), -2138550877694459381917894711603833e+24DL) + || CHECK (tests192 (-2138550877694459381917894711603833500000000000000000000000wb), -2138550877694459381917894711603834e+24DL) + || CHECK (tests192 (-2138550877694459381917894711603833499999999999999999999999wb), -2138550877694459381917894711603833e+24DL) + || CHECK (tests192 (-2138550877694459381917894711603833999999999999999999999999wb), -2138550877694459381917894711603834e+24DL) + || CHECK (tests192 (-2138550877694459381917894711603832000000000000000000000000wb), -2138550877694459381917894711603832e+24DL) + || CHECK (tests192 (-2138550877694459381917894711603832500000000000000000000000wb), -2138550877694459381917894711603832e+24DL) + || CHECK (tests192 (-2138550877694459381917894711603832500000000000000000000001wb), -2138550877694459381917894711603833e+24DL) + || CHECK (tests192 (3138550867693340381917894711603833000000000000000000000000wb), 3138550867693340381917894711603833e+24DL) + || CHECK (tests192 (3138550867693340381917894711603833208051177722232017256447wb), 3138550867693340381917894711603833e+24DL) + || CHECK (tests192 (-3138550867693340381917894711603833000000000000000000000000wb), -3138550867693340381917894711603833e+24DL) + || CHECK (tests192 (-3138550867693340381917894711603833208051177722232017256447wb - 1wb), -3138550867693340381917894711603833e+24DL)) + __builtin_abort (); + if (CHECK (testu192 (0uwb), 0.DL) + || CHECK (testu192 (7uwb), 7.DL) + || CHECK (testu192 (42uwb), 42.DL) + || CHECK (testu192 (777777777uwb), 777777777.DL) + || CHECK (testu192 (99999999999999999999999999000uwb), 99999999999999999999999999000.DL) + || CHECK (testu192 (999999999999999999999999999999999900uwb), 9999999999999999999999999999999999.e+2DL) + || CHECK (testu192 (9999999999999999999999999999999999000uwb), 9999999999999999999999999999999999.e+3DL) + || CHECK (testu192 (99999999999999999999999999999999994999uwb), 9999999999999999999999999999999999.e+4DL) + || CHECK (testu192 (999999999999999999999999999999999900000uwb), 9999999999999999999999999999999999.e+5DL) + || CHECK (testu192 (9999999999999999999999999999999999000000uwb), 9999999999999999999999999999999999.e+6DL) + || CHECK (testu192 (123456789012345600000000uwb), 123456789012345600000000.DL) + || CHECK (testu192 (34242319854454290000000000000000000000uwb), 3424231985445429000000000000000000e+4DL) + || CHECK (testu192 (999999999999999999999999999999999900000000000000000000000uwb), 9999999999999999999999999999999999.e+23DL) + || CHECK (testu192 (6189354365465174593875438957438959000000000000000000000000uwb), 6189354365465174593875438957438959e+24DL) + || CHECK (testu192 (6189354365465174593875438957438959500000000000000000000000uwb), 6189354365465174593875438957438960e+24DL) + || CHECK (testu192 (6189354365465174593875438957438959499999999999999999999999uwb), 6189354365465174593875438957438959e+24DL) + || CHECK (testu192 (6189354365465174593875438957438959999999999999999999999999uwb), 6189354365465174593875438957438960e+24DL) + || CHECK (testu192 (6189354365465174593875438957438958000000000000000000000000uwb), 6189354365465174593875438957438958e+24DL) + || CHECK (testu192 (6189354365465174593875438957438958500000000000000000000000uwb), 6189354365465174593875438957438958e+24DL) + || CHECK (testu192 (6189354365465174593875438957438958500000000000000000000001uwb), 6189354365465174593875438957438959e+24DL) + || CHECK (testu192 (6277101735386680763835789423207666000000000000000000000000uwb), 6277101735386680763835789423207666e+24DL) + || CHECK (testu192 (6277101735386680763835789423207666416102355444464034512895uwb), 6277101735386680763835789423207666e+24DL)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 575 + if (CHECK (tests575 (0wb), 0.DL) + || CHECK (tests575 (7wb), 7.DL) + || CHECK (tests575 (-42wb), -42.DL) + || CHECK (tests575 (-444444444wb), -444444444.DL) + || CHECK (tests575 (-3333333333333333wb), -3333333333333333.DL) + || CHECK (tests575 (99999999999999999999999999000wb), 99999999999999999999999999000.DL) + || CHECK (tests575 (-9999999999999999999999999999999999wb), -9999999999999999999999999999999999.DL) + || CHECK (tests575 (999999999999999999999999999999999900wb), 9999999999999999999999999999999999.e+2DL) + || CHECK (tests575 (-9999999999999999999999999999999999000wb), -9999999999999999999999999999999999.e+3DL) + || CHECK (tests575 (999999999999999999999999999999999900000wb), 9999999999999999999999999999999999.e+5DL) + || CHECK (tests575 (-99999999999999999999999999999999990000000wb), -9999999999999999999999999999999999.e+7DL) + || CHECK (tests575 (1234567890123456000000000wb), 1234567890123456000000000.DL) + || CHECK (tests575 (3424231985445429000000000000000000000000wb), 3424231985445429000000000000000000e+6DL) + || CHECK (tests575 (99999999999999999999999999999999990000000000000000000000000000000000000000wb), 9999999999999999999999999999999999.e+40DL) + || CHECK (tests575 (-9999999999999999999999999999999999000000000000000000000000000000000000000000000000000000000000000wb), -9999999999999999999999999999999999.e+63DL) + || CHECK (tests575 (-213855087769441389758947543987475900000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694413897589475439874759e+86DL) + || CHECK (tests575 (-213855087769441389758947543987475950000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694413897589475439874760e+86DL) + || CHECK (tests575 (-213855087769441389758947543987475949999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -2138550877694413897589475439874759e+86DL) + || CHECK (tests575 (-213855087769441389758947543987475999999999999999999999999999999999999999999999999999999999999999999999999999999999999999wb), -2138550877694413897589475439874760e+86DL) + || CHECK (tests575 (-213855087769441389758947543987475800000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694413897589475439874758e+86DL) + || CHECK (tests575 (-213855087769441389758947543987475850000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -2138550877694413897589475439874758e+86DL) + || CHECK (tests575 (-213855087769441389758947543987475850000000000000000000000000000000000000000000000000000000000000000000000000000000000001wb), -2138550877694413897589475439874759e+86DL) + || CHECK (tests575 (61832600368276133515125630254911790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), 6183260036827613351512563025491179e+139DL) + || CHECK (tests575 (61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb), 6183260036827613351512563025491180e+139DL) + || CHECK (tests575 (-61832600368276133515125630254911790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb), -6183260036827613351512563025491179e+139DL) + || CHECK (tests575 (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb), -6183260036827613351512563025491180e+139DL)) + __builtin_abort (); + if (CHECK (testu575 (0uwb), 0.DL) + || CHECK (testu575 (17uwb), 17.DL) + || CHECK (testu575 (420uwb), 420.DL) + || CHECK (testu575 (888888888uwb), 888888888.DL) + || CHECK (testu575 (9999999999999000uwb), 9999999999999000.DL) + || CHECK (testu575 (99999999999999999999999999999999990000000uwb), 9999999999999999999999999999999999.e+7DL) + || CHECK (testu575 (9999999999999999999999999999999999000000000uwb), 9999999999999999999999999999999999.e+9DL) + || CHECK (testu575 (99999999999999999999999999999999990000000000000uwb), 9999999999999999999999999999999999.e+13DL) + || CHECK (testu575 (9999999999999999999999999999999999000000000000000uwb), 9999999999999999999999999999999999.e+15DL) + || CHECK (testu575 (1234567890123456000000000000000000uwb), 1234567890123456000000000000000000.DL) + || CHECK (testu575 (34242319854454290000000000000000000000uwb), 3424231985445429000000000000000000e+4DL) + || CHECK (testu575 (9999999999999999999999999999999999000000000000000000000000000000000uwb), 9999999999999999999999999999999999.e+33DL) + || CHECK (testu575 (618935436546517949837539847534981700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465179498375398475349817e+104DL) + || CHECK (testu575 (618935436546517949837539847534981750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465179498375398475349818e+104DL) + || CHECK (testu575 (618935436546517949837539847534981749999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 6189354365465179498375398475349817e+104DL) + || CHECK (testu575 (618935436546517949837539847534981799999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 6189354365465179498375398475349818e+104DL) + || CHECK (testu575 (618935436546517949837539847534981800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465179498375398475349818e+104DL) + || CHECK (testu575 (618935436546517949837539847534981850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 6189354365465179498375398475349818e+104DL) + || CHECK (testu575 (618935436546517949837539847534981850000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001uwb), 6189354365465179498375398475349819e+104DL) + || CHECK (testu575 (99999999999999999999999999999999990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 9999999999999999999999999999999999.e+139DL) + || CHECK (testu575 (123665200736552267030251260509823500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 1236652007365522670302512605098235e+140DL) + || CHECK (testu575 (123665200736552267030251260509823549999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999uwb), 1236652007365522670302512605098235e+140DL) + || CHECK (testu575 (123665200736552267030251260509823550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 1236652007365522670302512605098236e+140DL) + || CHECK (testu575 (123665200736552267030251260509823550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001uwb), 1236652007365522670302512605098236e+140DL) + || CHECK (testu575 (123665200736552267030251260509823550000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000uwb), 1236652007365522670302512605098236e+140DL) + || CHECK (testu575 (123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349567uwb), 1236652007365522670302512605098236e+140DL)) + __builtin_abort (); +#endif +} --- gcc/testsuite/gcc.dg/ubsan/bitint-1.c.jj 2023-08-08 16:12:02.346939560 +0200 +++ gcc/testsuite/gcc.dg/ubsan/bitint-1.c 2023-08-08 16:12:02.346939560 +0200 @@ -0,0 +1,49 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */ + +__attribute__((noipa)) int +foo (_BitInt(15) *p, _BitInt(15) *q, int n) +{ + q[0] = p[0] + p[1]; + q[1] = p[2] - p[3]; + q[2] = p[4] * p[5]; + q[3] = p[6] / p[7]; + q[4] = p[8] << n; + q[5] = p[9] >> n; + return n; +} + +int +main () +{ + static _BitInt(15) p[] = { + 16382wb, 1wb, + -16383wb, 1wb, + 127wb, 129wb, + -16383wb - 1, 1wb, + 0wb, 1wb, + 16383wb, 1wb, + -16383wb - 1, 1wb, + 127wb, 130wb, + -16383wb - 1, -1wb, + 0wb, 1wb + }; + _BitInt(15) q[6]; + int n = foo (p, q, 14); + q[4] = p[8] << (n + 2); + q[5] = p[9] >> (n + 2); + foo (p + 10, q, 15); +} + +/* The 16-bit type vs. 15-bit is small inaccuracy. */ +/* { dg-output "shift exponent 16 is too large for 16-bit type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 16 is too large for 16-bit type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: 16383 \\+ 1 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: -16384 - 1 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: 127 \\* 130 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*division of -16384 by -1 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* This isn't accurate, but libubsan right now doesn't know it is 15-bit type rather than 16-bit. */ +/* { dg-output "\[^\n\r]*left shift of 0 by 15 places cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* The wording is totally incorrect, but at least it is diagnosed. */ +/* { dg-output "\[^\n\r]*left shift of 1 by 15 places cannot be represented in type '_BitInt\\\(15\\\)'" } */ --- gcc/testsuite/gcc.dg/ubsan/bitint-2.c.jj 2023-08-08 16:12:02.346939560 +0200 +++ gcc/testsuite/gcc.dg/ubsan/bitint-2.c 2023-08-08 16:12:02.346939560 +0200 @@ -0,0 +1,49 @@ +/* PR c/102989 */ +/* { dg-do run { target { bitint128 && int128 } } } */ +/* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */ + +__attribute__((noipa)) int +foo (_BitInt(125) *p, _BitInt(125) *q, int n) +{ + q[0] = p[0] + p[1]; + q[1] = p[2] - p[3]; + q[2] = p[4] * p[5]; + q[3] = p[6] / p[7]; + q[4] = p[8] << n; + q[5] = p[9] >> n; + return n; +} + +int +main () +{ + static _BitInt(125) p[] = { + 21267647932558653966460912964485513214wb, 1wb, + -21267647932558653966460912964485513215wb, 1wb, + 4611686018427387903wb, 4611686018427387905wb, + -21267647932558653966460912964485513215wb - 1, 1wb, + 0wb, 1wb, + 21267647932558653966460912964485513215wb, 1wb, + -21267647932558653966460912964485513215wb - 1, 1wb, + 4611686018427387903wb, 4611686018427387906wb, + -21267647932558653966460912964485513215wb - 1, -1wb, + 0wb, 1wb + }; + _BitInt(125) q[6]; + int n = foo (p, q, 123); + q[4] = p[8] << (n + 5); + q[5] = p[9] >> (n + 5); + foo (p + 10, q, 125); +} + +/* The 128-bit type vs. 125-bit is small inaccuracy. */ +/* { dg-output "shift exponent 128 is too large for 128-bit type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 128 is too large for 128-bit type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: 0x0fffffffffffffffffffffffffffffff \\+ 1 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: 0xf0000000000000000000000000000000 - 1 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: 4611686018427387903 \\* 4611686018427387906 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*division of 0xf0000000000000000000000000000000 by -1 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* This isn't accurate, but libubsan right now doesn't know it is 125-bit type rather than 128-bit. */ +/* { dg-output "\[^\n\r]*left shift of 0 by 125 places cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* The wording is totally incorrect, but at least it is diagnosed. */ +/* { dg-output "\[^\n\r]*left shift of 1 by 125 places cannot be represented in type '_BitInt\\\(125\\\)'" } */ --- gcc/testsuite/gcc.dg/ubsan/bitint-3.c.jj 2023-08-08 16:12:02.346939560 +0200 +++ gcc/testsuite/gcc.dg/ubsan/bitint-3.c 2023-08-08 16:12:02.346939560 +0200 @@ -0,0 +1,45 @@ +/* PR c/102989 */ +/* { dg-do run { target bitint575 } } */ +/* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */ + +__attribute__((noipa)) int +foo (_BitInt(575) *p, _BitInt(575) *q, int n) +{ + q[0] = p[0] + p[1]; + q[1] = p[2] - p[3]; + q[2] = p[4] * p[5]; + q[3] = p[6] / p[7]; + q[4] = p[8] << n; + q[5] = p[9] >> n; + return n; +} + +int +main () +{ + static _BitInt(575) p[] = { + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174782wb, 1wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1wb, + 248661618204893321077691124073410420050228075398673858720231988446579748506266687766527wb, 248661618204893321077691124073410420050228075398673858720231988446579748506266687766529wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1wb, + 0wb, 1wb, + 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1wb, + 248661618204893321077691124073410420050228075398673858720231988446579748506266687766527wb, 248661618204893321077691124073410420050228075398673858720231988446579748506266687766530wb, + -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, -1wb, + 0wb, 1wb + }; + _BitInt(575) q[6]; + foo (p, q, 574); + foo (p + 10, q, 575); +} + +/* These print unsigned integer overflow even when it is signed. */ +/* { dg-output "signed integer overflow: \\+ cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: - cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*signed integer overflow: \\* cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* Inaccurate. */ +/* { dg-output "\[^\n\r]*division by zero\[^\n\r]*(\n|\r\n|\r)" } */ +/* The wording is totally incorrect, but at least it is diagnosed. */ +/* { dg-output "\[^\n\r]*shift exponent 575 is too large for \[0-9]*-bit type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 575 is too large for \[0-9]*-bit type '_BitInt\\\(575\\\)'" } */