Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2224935/?format=api
{ "id": 2224935, "url": "http://patchwork.ozlabs.org/api/patches/2224935/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/008301dcd02b$1253b880$36fb2980$@nextmovesoftware.com/", "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": "<008301dcd02b$1253b880$36fb2980$@nextmovesoftware.com>", "list_archive_url": null, "date": "2026-04-19T18:33:50", "name": "PR tree-optimization/124715: pow(0, -1) sets errno with -fmath-errno", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c1a68d0f7762637a88cd5a24d2f7904973c26efc", "submitter": { "id": 68376, "url": "http://patchwork.ozlabs.org/api/people/68376/?format=api", "name": "Roger Sayle", "email": "roger@nextmovesoftware.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/008301dcd02b$1253b880$36fb2980$@nextmovesoftware.com/mbox/", "series": [ { "id": 500523, "url": "http://patchwork.ozlabs.org/api/series/500523/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=500523", "date": "2026-04-19T18:33:50", "name": "PR tree-optimization/124715: pow(0, -1) sets errno with -fmath-errno", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/500523/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2224935/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2224935/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=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com\n header.a=rsa-sha256 header.s=default header.b=OIShXfij;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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=fail reason=\"signature verification failed\" (2048-bit key,\n unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com\n header.a=rsa-sha256 header.s=default header.b=OIShXfij", "sourceware.org; dmarc=pass (p=none dis=none)\n header.from=nextmovesoftware.com", "sourceware.org;\n spf=pass smtp.mailfrom=nextmovesoftware.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=69.48.154.134" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 4fzHMh5tp2z1yD4\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 20 Apr 2026 04:34:23 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 4F1BE4AADCC6\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 19 Apr 2026 18:34:21 +0000 (GMT)", "from server.nextmovesoftware.com (server.nextmovesoftware.com\n [69.48.154.134])\n by sourceware.org (Postfix) with ESMTPS id DB68A4BA23E7\n for <gcc-patches@gcc.gnu.org>; Sun, 19 Apr 2026 18:33:52 +0000 (GMT)", "from [168.86.198.7] (port=64906 helo=Dell)\n by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls\n TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.99.1)\n (envelope-from <roger@nextmovesoftware.com>)\n id 1wEWxr-0000000BXoM-1van for gcc-patches@gcc.gnu.org;\n Sun, 19 Apr 2026 14:33:52 -0400" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 4F1BE4AADCC6", "OpenDKIM Filter v2.11.0 sourceware.org DB68A4BA23E7" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org DB68A4BA23E7", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org DB68A4BA23E7", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776623633; cv=none;\n b=XnAVH+uE773L9nEqdlVtFgOeZpeV0QZJvf5PMLllpkuOVpEftTM2XC3Juqaa1Ic+uQZreFylk7Yltg003dvUoEJE+/2a7gAKfKywFJvAK52FALD644DwqUcihayuDMUCyAE21QQ0vIyk7Aho8PzSf9s8ZxhyeevQC0a1uYWiK3k=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776623633; c=relaxed/simple;\n bh=8hkbNq0FOkbsbzs2sUie+suzNbVbDO3O3ExwvavrFKM=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=FfXshLcUCTAboUbR3i7rEKmPXqSGP6qXTmYREARXHOtAIi8JwgqHA8Z1ZMGyXBZNIvyh6wjCYbA4jdb2sDArlAoNDySO5M0Tckdnw42+WiPMjXyGTs3D+Su0IMcdDlt1h4OjFFbwjN+hO0sl7vd1Vt3USOQ0bdWRh8M45mpruIU=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID:\n Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:\n Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:\n List-Subscribe:List-Post:List-Owner:List-Archive;\n bh=x6a4wwQHcVpc/L54jaEwmooVKs7/svpaaAieE4MbuyA=; b=OIShXfij7B7Ku1JfqTgErU86lw\n 42fUnZ98nUGcqX0NXVVQ2H1RAkTTJQBJaqSaF8GgdKADf9Z0KEbpI4wC3ogF7jV/Q4FsyqUfRhgni\n bar9HLsCAMGAq7s4eu5y+UJpohS+f+FXLICGKZMXi6GSerNdCWu0dCr0LRaVj4T7XTsmpw9n4t9lH\n Vxact53cuFBK8G469AlzTGXKhNtX+Wr0No68wBGR4SRZ7n362hLCbkzlZgCXNf0rBmY9x4j3XVEN1\n GIiOlJ4mae07yeI42mW0sJe+9nEG88B5Ff46Zrtng2lXcd0ZjNA1umN64df4pm3n/8Nx8x3CARbXV\n 2fje4NVQ==;", "From": "\"Roger Sayle\" <roger@nextmovesoftware.com>", "To": "\"'GCC Patches'\" <gcc-patches@gcc.gnu.org>", "Subject": "[PATCH] PR tree-optimization/124715: pow(0,\n -1) sets errno with -fmath-errno", "Date": "Sun, 19 Apr 2026 19:33:50 +0100", "Message-ID": "<008301dcd02b$1253b880$36fb2980$@nextmovesoftware.com>", "MIME-Version": "1.0", "Content-Type": "multipart/mixed;\n boundary=\"----=_NextPart_000_0084_01DCD033.74184790\"", "X-Mailer": "Microsoft Outlook 16.0", "Thread-Index": "AdzQKrR6LNRbevsoTFSb8cLJAFfHaw==", "Content-Language": "en-gb", "X-AntiAbuse": [ "This header was added to track abuse,\n please include it with any abuse report", "Primary Hostname - server.nextmovesoftware.com", "Original Domain - gcc.gnu.org", "Originator/Caller UID/GID - [47 12] / [47 12]", "Sender Address Domain - nextmovesoftware.com" ], "X-Get-Message-Sender-Via": "server.nextmovesoftware.com: authenticated_id:\n roger@nextmovesoftware.com", "X-Authenticated-Sender": "server.nextmovesoftware.com:\n roger@nextmovesoftware.com", "X-Source": "", "X-Source-Args": "", "X-Source-Dir": "", "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>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "This patch addresses PR tree-optimization/124715, where it is unsafe for\nGCC (specifically match.pd) to transform pow(x,-1) into 1.0/x if x may be\nzero, which sets errno, unless -fno-math-errno (included in -ffast-math)\nis specified.\n\nThis patch has been tested on x86_64-pc-linux-gnu with make bootstrap\nand make -k check, with no new failures. Ok for mainline or stage 1?\n\n\n2026-04-19 Roger Sayle <roger@nextmovesoftware.com>\n\ngcc/ChangeLog\n PR tree-optimization/124715\n * match.pd (simpify pows): Check flag_errno_math before simplifying\n pow(x,-1) -> 1/x when x could be zero.\n\ngcc/testsuite/ChangeLog\n PR tree-optimization/124715\n * gcc.dg/no-math-errno-5.c: New test case.\n * gcc.dg/no-math-errno-6.c: Likewise.\n\nRoger\n--", "diff": "diff --git a/gcc/match.pd b/gcc/match.pd\nindex 7b652afb43d..9fa0f7d2191 100644\n--- a/gcc/match.pd\n+++ b/gcc/match.pd\n@@ -9642,7 +9642,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)\n (if (real_equal (value, &dconst1))\n @0)\n /* pow(x,-1) -> 1/x. */\n- (if (real_equal (value, &dconstm1))\n+ (if (real_equal (value, &dconstm1)\n+\t && (!flag_errno_math || !real_maybe_zerop (@0)))\n (rdiv { build_real (type, dconst1); } @0))\n /* pow(x,0.5) -> sqrt(x). */\n (if (flag_unsafe_math_optimizations\ndiff --git a/gcc/testsuite/gcc.dg/no-math-errno-5.c b/gcc/testsuite/gcc.dg/no-math-errno-5.c\nnew file mode 100644\nindex 00000000000..9a64a9a7227\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/no-math-errno-5.c\n@@ -0,0 +1,14 @@\n+/* PR tree-optimization/124715 */\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fno-math-errno -fdump-tree-optimized\" } */\n+/* { dg-require-effective-target c99_runtime } */\n+\n+extern double pow(double, double);\n+\n+double foo(double x)\n+{\n+ return pow(x,-1.0);\n+}\n+\n+/* { dg-final { scan-tree-dump-not \"pow \" \"optimized\" } } */\n+/* { dg-final { scan-tree-dump \" / \" \"optimized\" } } */\ndiff --git a/gcc/testsuite/gcc.dg/no-math-errno-6.c b/gcc/testsuite/gcc.dg/no-math-errno-6.c\nnew file mode 100644\nindex 00000000000..2b3ce04c51d\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/no-math-errno-6.c\n@@ -0,0 +1,14 @@\n+/* PR tree-optimization/124715 */\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fmath-errno -fdump-tree-optimized\" } */\n+/* { dg-require-effective-target c99_runtime } */\n+\n+extern double pow(double, double);\n+\n+double foo(double x)\n+{\n+ return pow(x,-1.0);\n+}\n+\n+/* { dg-final { scan-tree-dump-not \" / \" \"optimized\" } } */\n+/* { dg-final { scan-tree-dump \"pow \" \"optimized\" } } */\n", "prefixes": [] }