Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218079/?format=api
{ "id": 2218079, "url": "http://patchwork.ozlabs.org/api/patches/2218079/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260331112100.3944800-1-eikansh.gupta@oss.qualcomm.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": "<20260331112100.3944800-1-eikansh.gupta@oss.qualcomm.com>", "list_archive_url": null, "date": "2026-03-31T11:21:00", "name": "[v2] tree-ssa-dce: eliminate dead relaxed atomic loads with no LHS [PR123966]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "101dbff981945384420efca24e4523fd9d59480e", "submitter": { "id": 92956, "url": "http://patchwork.ozlabs.org/api/people/92956/?format=api", "name": "Eikansh Gupta", "email": "eikansh.gupta@oss.qualcomm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260331112100.3944800-1-eikansh.gupta@oss.qualcomm.com/mbox/", "series": [ { "id": 498179, "url": "http://patchwork.ozlabs.org/api/series/498179/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498179", "date": "2026-03-31T11:21:00", "name": "[v2] tree-ssa-dce: eliminate dead relaxed atomic loads with no LHS [PR123966]", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/498179/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218079/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218079/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 (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=UX05bggT;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=Xw/bSM25;\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=pass (2048-bit key,\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=UX05bggT;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=Xw/bSM25", "sourceware.org; dmarc=none (p=none dis=none)\n header.from=oss.qualcomm.com", "sourceware.org;\n spf=pass smtp.mailfrom=oss.qualcomm.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=205.220.168.131" ], "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 4flQgG2BHzz1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 22:21:45 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id BAD9C4BA2E3E\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 11:21:42 +0000 (GMT)", "from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com\n [205.220.168.131])\n by sourceware.org (Postfix) with ESMTPS id DB4794BA23EA\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 11:21:09 +0000 (GMT)", "from pps.filterd (m0279866.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 62VB2Cps2391788\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 11:21:09 GMT", "from mail-pl1-f199.google.com (mail-pl1-f199.google.com\n [209.85.214.199])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d7ue7m9e5-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 11:21:08 +0000 (GMT)", "by mail-pl1-f199.google.com with SMTP id\n d9443c01a7336-2b249975139so87168405ad.0\n for <gcc-patches@gcc.gnu.org>; Tue, 31 Mar 2026 04:21:08 -0700 (PDT)", "from hu-eikagupt-hyd.qualcomm.com ([202.46.22.19])\n by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b25f2016a0sm35666205ad.29.2026.03.31.04.21.05\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 31 Mar 2026 04:21:06 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org BAD9C4BA2E3E", "OpenDKIM Filter v2.11.0 sourceware.org DB4794BA23EA" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org DB4794BA23EA", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org DB4794BA23EA", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774956070; cv=none;\n b=kxFEcladBWBnPkp3nXdxBp3Ccg0nd+h8/Ma4gjJvdGDh03FhdyH69nNBTreMuP2yrE5nysf/4PJWcvPQyZI1qYEq/TZJRfc7ZMABFXoVy4uu9zhuLfcO+uURr7FEP9r9RefozRjMAHjQt04+jED7+jfHJF37bf/PNwtrZ4pV3Ak=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774956070; c=relaxed/simple;\n bh=np16cZMg9sYxIezDEUUTrT1FAazcHN5qwjqpFkSBCyc=;\n h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id:\n MIME-Version;\n b=FPEhu9pObvcCTC29jfDFwvRtqyAWrUFKFIw6T/H7fSQiuXocUlZXKeFvP7+XI1O23sAxUzOsLqOGhOJ6RXae+XeVbM0YIv0saUJLiexMCUoOfH61OlgRvRSVgL/2qO5KdCF1xo4IVBmUGljAH43j/M9vAisjrOGrggW8ZYy7WLc=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:date:from:message-id:mime-version\n :subject:to; s=qcppdkim1; bh=JnUTeyzLaLT14DTu2h2bqTo2ouWoi+QGWAA\n kFI5SbDE=; b=UX05bggTwDzPlB8AUHdXkzrH4LCLMCpaMetwlt1x+YN2f3EBr96\n zNp04flYMTSnqageE5dJlYX6mUXVPM5wZu3sZf2UxpxYVW4hjS192dSQmgLCoQm6\n ptiwAaQ6QX5EWzaOhtAg4m0bIWyUQlciX5CWOuyPgcHhW+i/Gmgk6MUgyYfS6teU\n 7Wqlqa+OQ0PzBMUyuOv7frT/Fm+MtVMvML+ELmrD570bQX7vEacJJkcutdoVVfpd\n hSwQhDX6xlcIAGkiCXZKkqWaJYnMW6pZ24sGrHxOm/fsPo2u96WIVMxqAxzXino7\n FkZiN0SAuwCykaTi4q5LfdhOUUUMB0L/ptw==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1774956068; x=1775560868; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=JnUTeyzLaLT14DTu2h2bqTo2ouWoi+QGWAAkFI5SbDE=;\n b=Xw/bSM25sOC0WC0TyNF4c0xAfsgbc4X2Q10PBseZ+n+eV0gQGk7Oy2urNPQYq33iJV\n JXRWB8pUWA1HFBn08P987W5lir4RlRB8JPmyg31/r6n47XHxxQIuicXxonvNBSKkM4D0\n lXYjbMZ44aqux+TE7OV2Su3+H2zUZ6GxsYwDLTz4/8MjFsbYaRrMSvRS7C9QG3BZ0Ajs\n p9CIDzOa7IIHAl7Z6nOew/E7UXjtf/DEGu/QlhiTIXXs8VsO+RgwLsATuWPq/w1FsWsm\n I2OnLSZrlcRF9zbUBwQjC5JFob5JXJNJMAZfi8l3+EbxnExiJVBocQkLpWvHrg9knR9H\n HKLw==" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774956068; x=1775560868;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=JnUTeyzLaLT14DTu2h2bqTo2ouWoi+QGWAAkFI5SbDE=;\n b=d+4U9d7Hp3T6sfB+UWDqbbng8EgGfKyZCuxYlFg06IB/ae6iLqcSwlEyrQT7h2vv8C\n 3/U5rhwiNQ74EPk1/+BRZunhb3Bs28P/FpaP49ZhfybjG2uQJZbtpVp8dKBtoM+DO3mq\n 5+ul9U9lzAhky6k3PYpXA2lDLvkLBT+mvMMqkPDCWEgby07OEIHK7/MFaohjrehQadST\n MctQOfxQCqqAQs1QuFactfPYkqobol8+I6z/X/7i9NvaTMu126rtEp75Mx6ODezjRhZ9\n EG/ix0mtqHsJLlhHPu/s73hbCzSrYDvIvAFpcnUDiE8luMbJ0ABtYvqY6voWh7yiwEXp\n Lxkg==", "X-Gm-Message-State": "AOJu0YyZoAlLZrrCBDcDSHyG9MWKpx2iPrClY0AUlHC8QuErVfBVJJo5\n 0jdDtfl8UbFN9QixU24I5C3vEJZH0AiexgVFE7l1ISk8cdDrWgLArDVdZEagqXOPNVByQVlt929\n jWmXap6fKwVnNyBUCpWuZ3738s9EslqbKYnqObfA2t7WXEf8ZyPh1x4DKwfwtIc2KB1ht", "X-Gm-Gg": "ATEYQzx694euwXVVrvksKC8e4PRLNyFhRdcs94HKZ619Q9MuTU9FbYyIXW8eK+35pNo\n hZ4lP5m/yizqNKBTcX5R8RAYPsiWpRlG0kEJdXuGsbla/XN/6sQEl2S3UB4B/i3SU0CJs746zSz\n 2oAA6vK/MqUDXvsMLSHykAi1oAzIbwXCGOU+xbNANnauxVbummFzy4qdQsJU/G8CL7QqYXzlZr+\n VPlQ1HXGCOalKzm2+FY0DJjc9tgZA5THewTSz8V2hTQVfw8Ft5HVq00KtFm9XuVVR5lK+YEiote\n RTeaucwXJl+zqp7MbLzCZhPopJIjefYsnQbqLXldhonNPpRzygjS1wPlFcQJ/htjP7PMQaedcY5\n PdA5hgw7mXFGlJ3pEYlAKRZdFA22LuolDn4QgC+4n5j71de8rFl4Gaec=", "X-Received": [ "by 2002:a17:902:d550:b0:2b2:4728:aa26 with SMTP id\n d9443c01a7336-2b24728b236mr121564685ad.35.1774956067769;\n Tue, 31 Mar 2026 04:21:07 -0700 (PDT)", "by 2002:a17:902:d550:b0:2b2:4728:aa26 with SMTP id\n d9443c01a7336-2b24728b236mr121564385ad.35.1774956067219;\n Tue, 31 Mar 2026 04:21:07 -0700 (PDT)" ], "From": "Eikansh Gupta <eikansh.gupta@oss.qualcomm.com>", "To": "gcc-patches@gcc.gnu.org", "Cc": "Eikansh Gupta <eikansh.gupta@oss.qualcomm.com>", "Subject": "[PATCH v2] tree-ssa-dce: eliminate dead relaxed atomic loads with no\n LHS [PR123966]", "Date": "Tue, 31 Mar 2026 16:51:00 +0530", "Message-Id": "<20260331112100.3944800-1-eikansh.gupta@oss.qualcomm.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMzMxMDExMCBTYWx0ZWRfX1hN/sfPPDVZV\n JXzsIAnJqM998/axS/5NOBMROvT/INxGKkiPxf3BRCkC5yvSGjiPcfzwWglRqtYDeq9ifGISdqe\n O/F+oEHb00wXYSoaP9SdZIHjnlM5bKvy+t94l2CNISrD/j2DOYzy96ZQJk9rtXE2aPr6Mhyzz9d\n Q6TGR6AhLzX6LyXdYL1iZiyNWI2MXrCrRwMUgMZ+La2uz7cUvNILNzbNWAs+HNcmMg044HdIw+M\n gNOvLQvj4O/W8wTaEgP6BroTUFcnHH/dsQoef3ygijp8FaDsVyyhMUgmgHp5pZIrXL1IaQpzL0R\n 78N/TGHEiAuGqfRCEsVpUtkIBNWPuBeMmnvcdPE58FZ4S5SjlBfjcjp3+KldAD2GxeaavJ2joan\n ecScza+vCBp9DH1oHLxw0MdfgSliv03ZFtgEhH1s6KZc7xrQRqCfVsYVX4UE9hDj4Wv/x7FDFoO\n 6bU8SF963088meeqhpQ==", "X-Proofpoint-GUID": "Gu57thaViKvsI9hZwiKhPiwGRzh3FRTm", "X-Authority-Analysis": "v=2.4 cv=G7sR0tk5 c=1 sm=1 tr=0 ts=69cbae24 cx=c_pps\n a=JL+w9abYAAE89/QcEU+0QA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17\n a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8\n a=0HEUfKhkY0tIicNJuRcA:9 a=324X-CrmTo6CU4MGRt3R:22", "X-Proofpoint-ORIG-GUID": "Gu57thaViKvsI9hZwiKhPiwGRzh3FRTm", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-03-31_02,2026-03-31_01,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n clxscore=1015 phishscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0\n priorityscore=1501 spamscore=0 adultscore=0 impostorscore=0 suspectscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603310110", "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": "A relaxed atomic load whose result is never used has no observable\neffect: the value is discarded and __ATOMIC_RELAXED provides no\ninter-thread synchronisation guarantee.\n\nFix this by adding an early-return check for\nBUILT_IN_ATOMIC_LOAD_1/2/4/8/16 calls that have no LHS and a\ncompile-time-constant relaxed memory order.\n\n PR tree-optimization/123966\n\ngcc/ChangeLog:\n\t* tree-ssa-dce.cc (mark_stmt_if_obviously_necessary):\n Don't mark a relaxed atomic load with no LHS as necessary.\n\ngcc/testsuite/ChangeLog:\n\t* gcc.dg/tree-ssa/pr123966.c: New test.\n\nSigned-off-by: Eikansh Gupta <eikansh.gupta@oss.qualcomm.com>\n---\n gcc/testsuite/gcc.dg/tree-ssa/pr123966.c | 71 ++++++++++++++++++++++++\n gcc/tree-ssa-dce.cc | 24 ++++++++\n 2 files changed, 95 insertions(+)\n create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr123966.c", "diff": "diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr123966.c b/gcc/testsuite/gcc.dg/tree-ssa/pr123966.c\nnew file mode 100644\nindex 00000000000..7658f1d1945\n--- /dev/null\n+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr123966.c\n@@ -0,0 +1,71 @@\n+/* { dg-do compile } */\n+/* { dg-options \"-O2 -fdump-tree-cddce1\" } */\n+\n+unsigned char g1;\n+unsigned short g2;\n+unsigned int g4;\n+unsigned long long g8;\n+\n+/* Relaxed loads, result unused -- must be eliminated. */\n+void test_relaxed_1 (void)\n+{\n+ unsigned char r;\n+ __atomic_load (&g1, &r, 0);\n+}\n+\n+void test_relaxed_2 (void)\n+{\n+ unsigned short r;\n+ __atomic_load (&g2, &r, 0);\n+}\n+\n+void test_relaxed_4 (void)\n+{\n+ unsigned int r;\n+ __atomic_load (&g4, &r, 0);\n+}\n+\n+void test_relaxed_8 (void)\n+{\n+ unsigned long long r;\n+ __atomic_load (&g8, &r, 0);\n+}\n+\n+/* Non-relaxed orders, result unused -- must be preserved. */\n+void test_acquire (void)\n+{\n+ unsigned int r;\n+ __atomic_load (&g4, &r, 2);\n+}\n+\n+void test_seqcst (void)\n+{\n+ unsigned int r;\n+ __atomic_load (&g4, &r, 5);\n+}\n+\n+void test_consume (void)\n+{\n+ unsigned int r;\n+ __atomic_load (&g4, &r, 1);\n+}\n+\n+/* Runtime order -- must be preserved (order unknown at compile time). */\n+void test_runtime (int order)\n+{\n+ unsigned int r;\n+ __atomic_load (&g4, &r, order);\n+}\n+\n+/* Relaxed load but result is used -- must be preserved. */\n+unsigned int test_used (void)\n+{\n+ unsigned int r;\n+ __atomic_load (&g4, &r, 0);\n+ return r;\n+}\n+\n+/* { dg-final { scan-tree-dump-times \"__atomic_load_1\" 0 \"cddce1\" } } */\n+/* { dg-final { scan-tree-dump-times \"__atomic_load_2\" 0 \"cddce1\" } } */\n+/* { dg-final { scan-tree-dump-times \"__atomic_load_8\" 0 \"cddce1\" } } */\n+/* { dg-final { scan-tree-dump-times \"__atomic_load_4\" 5 \"cddce1\" } } */\ndiff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc\nindex 7932607e889..bc8ae6d10f9 100644\n--- a/gcc/tree-ssa-dce.cc\n+++ b/gcc/tree-ssa-dce.cc\n@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3. If not see\n #include \"tree-ssa.h\"\n #include \"ipa-modref-tree.h\"\n #include \"ipa-modref.h\"\n+#include \"memmodel.h\"\n \n static struct stmt_stats\n {\n@@ -408,6 +409,29 @@ mark_stmt_if_obviously_necessary (gimple *stmt, bool aggressive)\n \tif (is_removable_cxa_atexit_call (call))\n \t return;\n \n+\t/* A relaxed atomic load with no LHS has no observable effect:\n+\t the value is discarded and relaxed ordering provides no\n+\t inter-thread synchronisation guarantee. Don't mark it\n+\t necessary so DCE can remove it. */\n+\tif (gimple_call_builtin_p (call, BUILT_IN_NORMAL))\n+\t switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))\n+\t {\n+\t case BUILT_IN_ATOMIC_LOAD_1:\n+\t case BUILT_IN_ATOMIC_LOAD_2:\n+\t case BUILT_IN_ATOMIC_LOAD_4:\n+\t case BUILT_IN_ATOMIC_LOAD_8:\n+\t case BUILT_IN_ATOMIC_LOAD_16:\n+\t {\n+\t tree model_arg = gimple_call_arg (call, 1);\n+\t if (TREE_CODE (model_arg) == INTEGER_CST\n+\t\t && is_mm_relaxed (memmodel_from_int (tree_to_uhwi (model_arg))))\n+\t\treturn;\n+\t break;\n+\t }\n+\t default:\n+\t break;\n+\t }\n+\n \t/* IFN_GOACC_LOOP calls are necessary in that they are used to\n \t represent parameter (i.e. step, bound) of a lowered OpenACC\n \t partitioned loop. But this kind of partitioned loop might not\n", "prefixes": [ "v2" ] }