Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2225513/?format=api
{ "id": 2225513, "url": "http://patchwork.ozlabs.org/api/patches/2225513/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/aecVxk86j5b4Wh-L@tucnak/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<aecVxk86j5b4Wh-L@tucnak>", "list_archive_url": null, "date": "2026-04-21T06:14:30", "name": "bitintlower: Padding bit fixes, part 4 [PR123635]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "91e65baf2527268532df908ca8e9047abb49d51b", "submitter": { "id": 671, "url": "http://patchwork.ozlabs.org/api/people/671/?format=api", "name": "Jakub Jelinek", "email": "jakub@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/aecVxk86j5b4Wh-L@tucnak/mbox/", "series": [ { "id": 500738, "url": "http://patchwork.ozlabs.org/api/series/500738/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500738", "date": "2026-04-21T06:14:30", "name": "bitintlower: Padding bit fixes, part 4 [PR123635]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500738/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2225513/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225513/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=VIDO+MuT;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=VIDO+MuT", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com", "sourceware.org; spf=pass smtp.mailfrom=redhat.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.129.124" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0Bsq0Dsrz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 16:15:09 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id A810A4BA23F1\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 06:15:07 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by sourceware.org (Postfix) with ESMTP id 4CBC74BA23CB\n for <gcc-patches@gcc.gnu.org>; Tue, 21 Apr 2026 06:14:39 +0000 (GMT)", "from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-dMmurl0yM0yZV7-bzKs04g-1; Tue,\n 21 Apr 2026 02:14:35 -0400", "from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 2663D1956088; Tue, 21 Apr 2026 06:14:34 +0000 (UTC)", "from tucnak.zalov.cz (unknown [10.44.48.12])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id 7A0F51800446; Tue, 21 Apr 2026 06:14:33 +0000 (UTC)", "from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 63L6EU4P886190\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Tue, 21 Apr 2026 08:14:30 +0200", "(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63L6EUWl886189;\n Tue, 21 Apr 2026 08:14:30 +0200" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org A810A4BA23F1", "OpenDKIM Filter v2.11.0 sourceware.org 4CBC74BA23CB" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 4CBC74BA23CB", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 4CBC74BA23CB", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776752079; cv=none;\n b=Z1JLocb9R9V/Ix8OypdKDXjjVcz1EsBBKQzWGgd5yZAd78K6Isos0NhmL1mYmpcu+pLU6+Ux1hJlXePrZOPq9DjE0CVbWzdmcmUsgJ7oJC7CE1nF5ODDEAfAB5V/5AvogmFLD+Z905FvRllkJq/22v2bjJdyOr2eD47yj++k/7Q=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776752079; c=relaxed/simple;\n bh=wUwm5tAm+Q2RPGUJ9OnJI1X+0+d+ShFmBJkyLCdW+Ok=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=aDPGNgxbKU12qKhXPvMlpMTqShL8OEwodcpZ4+4PYCzKBh85tuDF3secCcGV9YLvl2IdAKnK5FUEt5eKM9b2eXOkofSnnFnrXoSI1KUFzi9yHDtznb4GYDt/KKfwQ+l2eYRpJhQKr/sWcj0gfp1DZVYtI+3UtLyeAaEt8GcTRok=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776752079;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=fm+KtijdAPpmGaf1wA8b83AmeRwTtajYexvewacIhe4=;\n b=VIDO+MuT/OGGXjDlPcu8tb0PGNRdVPSWBp/ahQ21TUeRJzH8fgGSGRQqs6CJXZ7xU7rCbJ\n pFvGr5OIkmojqTRoiB8lNAx28+bN3CLlu+AvqbmHw1qCj4ZxbBuLXg2r7fx0cMKhnvQL3e\n 0wWKsHH87ellvm4QfeFRsldo2GwWffM=", "X-MC-Unique": "dMmurl0yM0yZV7-bzKs04g-1", "X-Mimecast-MFC-AGG-ID": "dMmurl0yM0yZV7-bzKs04g_1776752074", "Date": "Tue, 21 Apr 2026 08:14:30 +0200", "From": "Jakub Jelinek <jakub@redhat.com>", "To": "Richard Biener <rguenther@suse.de>,\n Andrew Pinski <andrew.pinski@oss.qualcomm.com>", "Cc": "gcc-patches@gcc.gnu.org", "Subject": "[PATCH] bitintlower: Padding bit fixes, part 4 [PR123635]", "Message-ID": "<aecVxk86j5b4Wh-L@tucnak>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.111", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "uS99IcCynX9KJudNlCmONn2gTAzdBKMEk2eG892xkno_1776752074", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Reply-To": "Jakub Jelinek <jakub@redhat.com>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "Hi!\n\nAs the following testcase shows, not clearing the padding bits after\nsigned MULT_EXPR (or signed division) is reasonable when overflow actually is\nundefined behavior because then anything can happen. But when it is not\nundefined behavior due to -fwrapv, we need to clear the padding bits\non targets which chose that behavior. It isn't only signed MULT_EXPR,\nbut also division because smallest negative / -1 overflows and in that\ncase the padding bits aren't correct for bitint_extended targets either.\n\nBootstrapped/regtested on x86_64-linux and i686-linux and tested on\nmake -j8 -k check-gcc GCC_TEST_RUN_EXPENSIVE=1 RUNTESTFLAGS=\"GCC_TEST_RUN_EXPENSIVE=1 dg.exp='*bitint* pr112673.c builtin-stdc-bit-*.c pr112566-2.c pr112511.c pr116588.c pr116003.c pr113693.c pr113602.c flex-array-counted-by-7.c' dg-torture.exp='*bitint* pr116480-2.c pr114312.c pr114121.c' dfp.exp=*bitint* vect.exp='vect-early-break_99-pr113287.c' tree-ssa.exp=pr113735.c\"\non riscv64-linux, ok for trunk?\n\n2026-04-21 Jakub Jelinek <jakub@redhat.com>\n\n\tPR middle-end/123635\n\t* gimple-lower-bitint.cc (bitint_large_huge::lower_muldiv_stmt):\n\tExtend the padding bits not just for unsigned MULT_EXPR but for any\n\tTYPE_OVERFLOW_WRAPS MULT_EXPR and signed TYPE_OVERFLOW_WRAPS division.\n\n\t* gcc.dg/torture/bitint-90.c: New test.\n\n\n\tJakub", "diff": "--- gcc/gimple-lower-bitint.cc.jj\t2026-04-20 09:11:19.132955449 +0200\n+++ gcc/gimple-lower-bitint.cc\t2026-04-20 18:29:23.419243836 +0200\n@@ -4085,7 +4085,8 @@ bitint_large_huge::lower_muldiv_stmt (tr\n gcc_assert (TREE_CODE (type) == BITINT_TYPE\n \t && bitint_precision_kind (type) >= bitint_prec_large);\n int prec = TYPE_PRECISION (type), prec1, prec2;\n- bool zero_ms_limb = false;\n+ bool ext_ms_limb = false;\n+ bool do_ext = false;\n rhs1 = handle_operand_addr (rhs1, stmt, NULL, &prec1);\n rhs2 = handle_operand_addr (rhs2, stmt, NULL, &prec2);\n if (obj == NULL_TREE)\n@@ -4101,15 +4102,26 @@ bitint_large_huge::lower_muldiv_stmt (tr\n lhs = force_gimple_operand_gsi (&m_gsi, lhs, true,\n \t\t\t\t NULL_TREE, true, GSI_SAME_STMT);\n }\n+ if (bitint_extended && TYPE_OVERFLOW_WRAPS (type))\n+ {\n+ if (rhs_code == MULT_EXPR)\n+\tdo_ext = true;\n+ /* For signed division with -fwrapv, minimum negative / -1 needs\n+\t is minimum negative and the padding bits above it should be all\n+\t set. */\n+ else if (!TYPE_UNSIGNED (type)\n+\t && (rhs_code == TRUNC_DIV_EXPR || rhs_code == EXACT_DIV_EXPR))\n+\tdo_ext = true;\n+ }\n if (bitint_extended == bitint_ext_full\n && abi_limb_prec > limb_prec\n && (CEIL (prec, abi_limb_prec) * abi_limb_prec\n \t > CEIL (prec, limb_prec) * limb_prec))\n {\n /* unsigned multiplication needs to wrap around, so we can't\n-\t increase prec. */\n- if (rhs_code == MULT_EXPR && TYPE_UNSIGNED (type))\n-\tzero_ms_limb = true;\n+\t increase prec. Similarly for -fwrapv. */\n+ if (do_ext)\n+\text_ms_limb = true;\n else\n \tprec = CEIL (prec, abi_limb_prec) * abi_limb_prec;\n }\n@@ -4166,10 +4178,8 @@ bitint_large_huge::lower_muldiv_stmt (tr\n \t add_eh_edge (e2->src, e1);\n \t}\n }\n- if (bitint_extended\n- && rhs_code == MULT_EXPR\n- && TYPE_UNSIGNED (type)\n- && (prec % limb_prec) != 0)\n+ if (do_ext\n+ && ((prec % limb_prec) != 0 || (ext_ms_limb && !TYPE_UNSIGNED (type))))\n {\n /* Unsigned multiplication wraps, but libgcc function will return the\n \t bits beyond prec within the top limb as another limb of the full\n@@ -4180,13 +4190,33 @@ bitint_large_huge::lower_muldiv_stmt (tr\n tree v = make_ssa_name (m_limb_type);\n g = gimple_build_assign (v, l);\n insert_before (g);\n- v = add_cast (ctype, v);\n- l = limb_access (type, obj, idx, true);\n- v = add_cast (m_limb_type, v);\n- g = gimple_build_assign (l, v);\n- insert_before (g);\n+ tree v2 = v;\n+ if ((prec % limb_prec) != 0)\n+\t{\n+\t v = add_cast (ctype, v);\n+\t l = limb_access (type, obj, idx, true);\n+\t v = add_cast (m_limb_type, v);\n+\t v2 = v;\n+\t g = gimple_build_assign (l, v);\n+\t insert_before (g);\n+\t}\n+ if (ext_ms_limb && !TYPE_UNSIGNED (type))\n+\t{\n+\t v2 = add_cast (signed_type_for (m_limb_type), v2);\n+\t tree lpm1 = build_int_cst (unsigned_type_node, limb_prec - 1);\n+\t v = make_ssa_name (TREE_TYPE (v2));\n+\t g = gimple_build_assign (v, RSHIFT_EXPR, v2, lpm1);\n+\t insert_before (g);\n+\t unsigned int i\n+\t = CEIL (prec, abi_limb_prec) * abi_limb_prec / limb_prec;\n+\t v = add_cast (m_limb_type, v);\n+\t g = gimple_build_assign (limb_access (type, obj, size_int (i - 1),\n+\t\t\t\t\t\ttrue), v);\n+\t insert_before (g);\n+\t ext_ms_limb = false;\n+\t}\n }\n- if (zero_ms_limb)\n+ if (ext_ms_limb)\n {\n unsigned int i = CEIL (prec, abi_limb_prec) * abi_limb_prec / limb_prec;\n g = gimple_build_assign (limb_access (type, obj, size_int (i - 1), true),\n--- gcc/testsuite/gcc.dg/torture/bitint-90.c.jj\t2026-04-20 14:55:37.538638849 +0200\n+++ gcc/testsuite/gcc.dg/torture/bitint-90.c\t2026-04-20 15:05:46.279391694 +0200\n@@ -0,0 +1,57 @@\n+/* PR middle-end/123635 */\n+/* { dg-do run { target bitint } } */\n+/* { dg-options \"-std=c23 -pedantic-errors -fwrapv\" } */\n+/* { dg-skip-if \"\" { ! run_expensive_tests } { \"*\" } { \"-O0\" \"-O2\" } } */\n+/* { dg-skip-if \"\" { ! run_expensive_tests } { \"-flto\" } { \"\" } } */\n+\n+#if __BITINT_MAXWIDTH__ >= 513\n+_BitInt(513) a, b, c, d, e, f;\n+#endif\n+\n+#include \"../bitintext.h\"\n+\n+#if __BITINT_MAXWIDTH__ >= 513\n+[[gnu::noipa]] void\n+f1 (_BitInt(513) q, _BitInt(513) r, _BitInt(513) s, _BitInt(513) t)\n+{\n+ a = q * r;\n+ BEXTC (a);\n+ b = s * t;\n+ BEXTC (b);\n+ c = q / r;\n+ BEXTC (c);\n+ d = s / t;\n+ BEXTC (d);\n+ e = q % r;\n+ BEXTC (e);\n+ f = s % t;\n+ BEXTC (f);\n+}\n+#endif\n+\n+int\n+main ()\n+{\n+#if __BITINT_MAXWIDTH__ >= 513\n+ __builtin_memset (&a, 0x55, sizeof (a));\n+ __builtin_memset (&b, 0xaa, sizeof (b));\n+ __builtin_memset (&c, 0x55, sizeof (c));\n+ __builtin_memset (&d, 0xaa, sizeof (d));\n+ __builtin_memset (&e, 0x55, sizeof (e));\n+ __builtin_memset (&f, 0xaa, sizeof (f));\n+ f1 (-2569442167708526883032321549154973033917914038435073849581606377835896531300464410672941576709766056731856560073179286923714310748484353548564505224275735wb,\n+ 2168258207301112123000422415459500116718298091852207369853333917415269374034197937707930701823104675221367858731870896332002496458560727651061447629500290wb,\n+ -13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084095wb - 1,\n+ -1wb);\n+ __builtin_memset (&a, 0x55, sizeof (a));\n+ __builtin_memset (&b, 0xaa, sizeof (b));\n+ __builtin_memset (&c, 0x55, sizeof (c));\n+ __builtin_memset (&d, 0xaa, sizeof (d));\n+ __builtin_memset (&e, 0x55, sizeof (e));\n+ __builtin_memset (&f, 0xaa, sizeof (f));\n+ f1 (11182751058163266900062523691585082292935101550776465927580156147436400116827277563246395892657460272253702154027346376026845302222986890807879025959971622wb,\n+ 8164167338045748506210025483965624248110931799582481638963258497469488589147418794642910866480254020122096903001279978332046522756597851796198650349835611wb,\n+ -10069248634646183494877194696541551363329286638973022393951487924262590826071711445633243661699089159257055025645295791432791410100972241125609033584314602wb,\n+ -8066635266964063729231989957397398910332013431298049172762795336443651271867788598667551930170370590334905534762032999936946715583168838873523754981312676wb);\n+#endif\n+}\n", "prefixes": [] }