{"id":2222872,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2222872/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260413222006.3862501-3-andrew.pinski@oss.qualcomm.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","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},"msgid":"<20260413222006.3862501-3-andrew.pinski@oss.qualcomm.com>","date":"2026-04-13T22:20:02","name":"[GCC17-PATCH,2/6] phiprop: Factor out the vdef check into new function","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7c13a43b8bbc9f73df34b2f87b990d8f5b3684dc","submitter":{"id":91428,"url":"http://patchwork.ozlabs.org/api/1.1/people/91428/?format=json","name":"Andrew Pinski","email":"andrew.pinski@oss.qualcomm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260413222006.3862501-3-andrew.pinski@oss.qualcomm.com/mbox/","series":[{"id":499758,"url":"http://patchwork.ozlabs.org/api/1.1/series/499758/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499758","date":"2026-04-13T22:20:03","name":"Improve Phiprop slightly","version":1,"mbox":"http://patchwork.ozlabs.org/series/499758/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222872/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222872/checks/","tags":{},"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=BCrYJjiC;\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=FI6MWBzj;\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 (2048-bit key,\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=BCrYJjiC;\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=FI6MWBzj","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.180.131"],"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 4fvhkp2msgz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 08:23:30 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 87EC94BA23C5\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 22:23:28 +0000 (GMT)","from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n [205.220.180.131])\n by sourceware.org (Postfix) with ESMTPS id 701B34BA2E10\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 22:20:16 +0000 (GMT)","from pps.filterd (m0279871.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63DLBTaZ3158091\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 22:20:15 GMT","from mail-pj1-f72.google.com (mail-pj1-f72.google.com\n [209.85.216.72])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dh86b859p-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 22:20:15 +0000 (GMT)","by mail-pj1-f72.google.com with SMTP id\n 98e67ed59e1d1-354c0234c1fso4253691a91.2\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 15:20:15 -0700 (PDT)","from xeond2.wrightpinski.org ([98.97.32.212])\n by smtp.gmail.com with ESMTPSA id\n 41be03b00d2f7-c79219f55c4sm12129600a12.22.2026.04.13.15.20.12\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 13 Apr 2026 15:20:13 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 87EC94BA23C5","OpenDKIM Filter v2.11.0 sourceware.org 701B34BA2E10"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 701B34BA2E10","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 701B34BA2E10","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776118816; cv=none;\n b=MRMgEbVKFt8CWkKcOPXsl9ua0yM49IKZqLi3zUucCoAntoDH/NyT0qHfEEmPBZdqW5N18gQ/qIOTrKYV1LzG0fAOMbKNcaUi0gtoxaqo6q/kmLbihThQpNscqWb3pJJriAySU5TinxtEtUgiXALDoSmxDi6niRg2M4ksVxLYiXw=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776118816; c=relaxed/simple;\n bh=LELcI9HNq26TcS3B1X+mn6srLw9akXiPxWgMkJbLvVs=;\n h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID:\n MIME-Version;\n b=kdBfaBXamXvMl8ky4F/hiYUTsW+azVX+ARk4anyoT7s34EcZzec5j40ixXe6jWzrb1mqT7PwKpeG/lcquatbaYzilk81RK2XkdY4V+upN6lkS/DT9dopepRgead+U5Z0YrilUh8UVXDxANHQwLBKbmqDd5BpnlGbX6qEEuDfAZs=","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:in-reply-to:message-id\n :mime-version:references:subject:to; s=qcppdkim1; bh=e6zKW7qPvER\n D6W5Mkboexmnz2pJBArYgQFyARCqbtd8=; b=BCrYJjiCUFfAb5BpNNTIZDwzYGm\n tvK7I7CpsDW/TYzG2i9to9wC0J/03CRJvNYJGbyIPbm0bi8FVN6hLSvUpx80gnCi\n MfjcmIqOK3SLSByMYoNlyM/+Pcx8yJXy7tU/4LiUHdqWWfPuMTZQqjsFBuMct29k\n oFUS+vNnvqmaT0lduFpwyhbSuMf/DNH/IVBy9hnoYppYbEsl8wQS/j9WdOfBG0Yp\n cSG4ceLrlUpMq7xojnZg3FhNcweqmUjhNC/Pfd/9zXUKNAGLsOmSy5dF4Xq90kbm\n bllF0qq0IXhC9lFQzNFSovQ9MCqALj2kWfQi2q9xTLKLT7kpkhZ6YFzVg7Q==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1776118814; x=1776723614; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=e6zKW7qPvERD6W5Mkboexmnz2pJBArYgQFyARCqbtd8=;\n b=FI6MWBzjn7mEIadGJUUY/Jfp3q4llx1micWmyJsiqSPMMj9ehKZrMBy+Kajg/+TTPe\n +nvEZH9PhygyU2y5rsiUxUiGJx/MV9JmvGIhyPwOJUrmHCIqg1mm/AWVKw2APj/jJ050\n /tuiqStTwN+VZBDzbbn6LronGtmNZmG3pCfhOaeYJEEU7Ur9AVWlG16hQ1MWRk8FQyPc\n CQF4Li1DnxSDBgZ7u+09sw4o3+jDk+LxxIHkE8ZMjfGhmPPPSc2Xq+GxbVD73/fVKIP9\n ZkwKVKwdeY+uboDfMkGc6XS+1zIvg/1p5y2FJ3fJ/p3iZPFR1gjxDE/U5/+fK0hWjbiY\n YKdg=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776118814; x=1776723614;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=e6zKW7qPvERD6W5Mkboexmnz2pJBArYgQFyARCqbtd8=;\n b=OxLW+aZ9FSymjFMGkY0Mhe/xGHgpCkZVZ4y26wV2SPV4lL5TXWSOcmG/4YcC6M6ttK\n 1O/kRVTVPeWnX8H4ykZ1QT+QM4cK9ttCPPQvcoy/DZwyw9D3f809h+1f1QINYL2PTqEu\n PV1PWrKnaIfnsVaZp4d4vyNpDLyWLRrb4ME1mJdyTquhmpqUWUizdcPp+zj+KerpaY0h\n UJ7XzaInbnCoYN2nXRbP0K/UuFvqFFn2GtLi2Wb46btHES5aIMbahQfJL4zoywV8+qja\n 6kMLIIUqlktM2LtrDOaODGpXnBGnvxAWQ3MmoxQPbxiqcDCO4BRRW8P653zDzCt9mrPE\n +ovQ==","X-Gm-Message-State":"AOJu0YwLD9KLWz22tpXWuII3jop6BkiyEFyuKuu1/LMCfwLuRCeGt571\n VPfBrYKfpcCxM7g3x4d7mKAuaO/j6mT9YQw59MWgKUVHosSSiZJBK7rH6FA35D6RHew6CrmcStH\n zFdx8EaF4MvIDTnBnwCDqqu1FYQCe/qx7Zhb9w5yrFNpoaBCVWhrJen4qQie0yVK6bBZ5","X-Gm-Gg":"AeBDiev3Cjzt7ZL4HnkHtXdEYIZZZVfvPT2XBA0poVe8KkfDk0+8bYA47Icpv48koU8\n oLQeLatOrwDaXpScy+iYqDAcboyIEhDITjxjdRWuzhp7JxOy5Dux36fbVqyKIlILwQAw0gl4SGQ\n hB2but4l3G9pEQvrxDSIL5TRQU1yPQAYiMOGgv3cpHaXPdMjnIY3qcdj+9jC94dRXNsJiV1uGO4\n CmEtl/yggUd67jLpTaxdjbE+97HufK6YBW9O1lKN0qsHrIQxb6ygcg1v4Y3dec6fUx2Nd91KWyL\n InCy42B1/cEKRdHfWph7VXsK5Q1I0x5OnEofSl2K57OilqL8nT3U+OigZXH7jhlUPiya/gU45wc\n 3MIxA1r2WirkgU5wfT0VW/mtZ0zPG3jJXywHhVRy+3Llq/OGy","X-Received":["by 2002:a17:90b:53c3:b0:359:8e5e:43de with SMTP id\n 98e67ed59e1d1-35e4281194fmr16912811a91.22.1776118814168;\n Mon, 13 Apr 2026 15:20:14 -0700 (PDT)","by 2002:a17:90b:53c3:b0:359:8e5e:43de with SMTP id\n 98e67ed59e1d1-35e4281194fmr16912771a91.22.1776118813591;\n Mon, 13 Apr 2026 15:20:13 -0700 (PDT)"],"From":"Andrew Pinski <andrew.pinski@oss.qualcomm.com>","To":"gcc-patches@gcc.gnu.org","Cc":"Andrew Pinski <andrew.pinski@oss.qualcomm.com>","Subject":"[GCC17-PATCH 2/6] phiprop: Factor out the vdef check into new\n function","Date":"Mon, 13 Apr 2026 15:20:02 -0700","Message-ID":"<20260413222006.3862501-3-andrew.pinski@oss.qualcomm.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260413222006.3862501-1-andrew.pinski@oss.qualcomm.com>","References":"<20260413222006.3862501-1-andrew.pinski@oss.qualcomm.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDEzMDIxOSBTYWx0ZWRfX7L07KRbFoF0b\n ZLE5DUUZo3xeMpmrMdVgi1Cv6MVZR/k3gxqb2E531TaPKSR+y61DqPPZ6QJVAMT6VunGngwLnWX\n kOaiMUfWSvfZcKym1PGBiOnvXQe/xCkbUHFsnJsci0JxPcCITND25foFSUyEvLmReeqp5eo2AzA\n Rq3XzMY7oLcV9Vr8J2S4UFiPWagqK43ekc5xRB7hCm2UAPbAeUTkTZFhvHvcnptQRf7PYKcVzyJ\n qALtFFc51ZH53x1XSFAmHPvtCH2jgYFaQAPN3x7nrSSAZ5CJZWWG4DIbU9Vli4mpoocZJfQXZO5\n s5DzHj3oTipYg/ODaaqTEVhwm8Z1um8dqLFDRpPHObHZD9UBD+8uEYzHXXm0c/hBVXjiYlVj7Jx\n tQOmhyPG/gBCwc8PQGNzhKyGooGDzad29iXK6v6V8Xxe6lrh7KfBMYmRYzjVvbpJSHfo34VDhq0\n 0313IofKpvuat4K+s7g==","X-Authority-Analysis":"v=2.4 cv=MahcfZ/f c=1 sm=1 tr=0 ts=69dd6c1f cx=c_pps\n a=RP+M6JBNLl+fLTcSJhASfg==:117 a=i7c1TCcCr6Kt3kgLFmYdbA==:17\n a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8\n a=eycAWhLm7xZbe2PtsWcA:9 a=iS9zxrgQBfv6-_F4QbHw:22","X-Proofpoint-ORIG-GUID":"AYXURPGWF6PrY6bwhh0Xf-6ZVrQZN2oW","X-Proofpoint-GUID":"AYXURPGWF6PrY6bwhh0Xf-6ZVrQZN2oW","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-04-13_03,2026-04-13_04,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n bulkscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0\n priorityscore=1501 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0\n clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000\n definitions=main-2604130219","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 is just a small cleanup and should make the code easier\nto understand. And it should make it easier to add/allow\nto skip over some store statements that don't affect the\nvariable being loadded.\n\nBootstrapped and tested on x86_64-linux-gnu.\n\ngcc/ChangeLog:\n\n\t* tree-ssa-phiprop.cc (propagate_with_phi): Factor out\n\tchecking the load for vdef to ....\n\t(can_move_into_conditional): Here.\n\nSigned-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>\n---\n gcc/tree-ssa-phiprop.cc | 59 ++++++++++++++++++++++-------------------\n 1 file changed, 31 insertions(+), 28 deletions(-)","diff":"diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc\nindex 668a302597c..6d369b1bd3f 100644\n--- a/gcc/tree-ssa-phiprop.cc\n+++ b/gcc/tree-ssa-phiprop.cc\n@@ -235,6 +235,34 @@ chk_uses (tree, tree *idx, void *data)\n \t\t\t\t gimple_bb (SSA_NAME_DEF_STMT (*idx)), dom));\n   return true;\n }\n+/* Check if we can move the loads from LOAD_STMT.\n+   This is when the virtual use is the same as the\n+   one active at the start of BB which we know either\n+   from its virtual PHI def (VPHI) or from the common\n+   incoming VUSE (up_vuse).  If neither is present\n+   make sure the def stmt of the virtual use is in a\n+   different basic block dominating BB.  When the def\n+   is an edge-inserted one we know it dominates us.  */\n+static bool\n+can_handle_load (gimple *load_stmt, basic_block bb,\n+\t\t gphi *vphi, tree up_vuse)\n+{\n+  tree vuse = gimple_vuse (load_stmt);\n+  if (vphi)\n+    return vuse == gimple_phi_result (vphi);\n+  if (up_vuse)\n+    return vuse == up_vuse;\n+  gimple *def_stmt = SSA_NAME_DEF_STMT (vuse);\n+  /* If the load does not have a store beforehand,\n+     then we can do the load in conditional. */\n+  if (SSA_NAME_IS_DEFAULT_DEF (vuse))\n+    return true;\n+  if (gimple_bb (def_stmt) != bb\n+      && !dominated_by_p (CDI_DOMINATORS,\n+\t\t\t  bb, gimple_bb (def_stmt)))\n+    return true;\n+  return false;\n+}\n \n /* Propagate between the phi node arguments of PHI in BB and phi result\n    users.  For now this matches\n@@ -335,8 +363,6 @@ propagate_with_phi (basic_block bb, gphi *vphi, gphi *phi,\n   auto_vec<gimple*> delayed_uses;\n   FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr)\n     {\n-      gimple *def_stmt;\n-      tree vuse;\n       bool delay = false;\n \n       /* Check whether this is a load of *ptr.  */\n@@ -385,32 +411,9 @@ propagate_with_phi (basic_block bb, gphi *vphi, gphi *phi,\n \t\t\t\t\t   gimple_bb (use_stmt)->loop_father)))))\n \tdelay = true;\n \n-      /* Check if we can move the loads.  This is when the virtual use\n-\t is the same as the one active at the start of BB which we know\n-\t either from its virtual PHI def or from the common incoming\n-\t VUSE.  If neither is present make sure the def stmt of the virtual\n-\t use is in a different basic block dominating BB.  When the\n-\t def is an edge-inserted one we know it dominates us.  */\n-      vuse = gimple_vuse (use_stmt);\n-      if (vphi)\n-\t{\n-\t  if (vuse != gimple_phi_result (vphi))\n-\t    goto next;\n-\t}\n-      else if (up_vuse)\n-\t{\n-\t  if (vuse != up_vuse)\n-\t    goto next;\n-\t}\n-      else\n-\t{\n-\t  def_stmt = SSA_NAME_DEF_STMT (vuse);\n-\t  if (!SSA_NAME_IS_DEFAULT_DEF (vuse)\n-\t      && (gimple_bb (def_stmt) == bb\n-\t\t  || !dominated_by_p (CDI_DOMINATORS,\n-\t\t\t\t      bb, gimple_bb (def_stmt))))\n-\t    goto next;\n-\t}\n+      tree vuse = gimple_vuse (use_stmt);\n+      if (!can_handle_load (use_stmt, bb, vphi, up_vuse))\n+\tgoto next;\n \n       /* Found a proper dereference with an aggregate copy.  Just\n          insert aggregate copies on the edges instead.  */\n","prefixes":["GCC17-PATCH","2/6"]}