From patchwork Fri Mar 1 22:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Lu X-Patchwork-Id: 209100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp186050dyc; Fri, 1 Mar 2024 14:16:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmqCm9xweDKrb0hlhzPvwOT23u4Bf9DrQ2Mf2Yq7CACh8nQvVsRz+Y91Y6TI7MmzM+/TgiLQ6RuIcaKwGcXD+toEKtFA== X-Google-Smtp-Source: AGHT+IE+c3G38UXMBoXT4p31M7C/j7sXYoSmIE2s+zaoU9qe1cg0QXdGZ1+jDXuctMVI7qIAxb3l X-Received: by 2002:a05:6871:a002:b0:220:d07a:fbc9 with SMTP id vp2-20020a056871a00200b00220d07afbc9mr1397648oab.59.1709331378122; Fri, 01 Mar 2024 14:16:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331378; cv=pass; d=google.com; s=arc-20160816; b=D6P+yxXt/IbKh9Hsisrzh7LidMQUrvrooXBMBEtjrPAEDIyurhAtvh9h69p11N3DFk 4ljAk8NdL5uk0hth6qKVaxcLi9sK7qUyCV6LfJxuV8HiqTv7PhZ+OxBnc2IDl/47Au87 1H4idI+Hagj5/bSVZqP76bmQoxTiNEErCfJUVNrRQkcPyUYkWY+vSClSAAGPrj378Osb qYlU4d1jwfK05U1ZZikhwBT0dm4hFbjdNpjwGBRNuj64JVfkIAKRnJVnJfmuJ41PCbZp xY+hHKM3WPpCGWmNPnDqJfJBMMVwMJimGQlhyq9QersjY/CGDKPSUJgOGeZWtRilXZq5 3r0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=VlAMGFOLmfNJLjq505X6Gzo0ES7q80xebR3zSMJWjo4=; fh=r+SIYcgLopsTG8D0vSkuNNcbfbLGreWBAuINt5YEr6Q=; b=ESDRjlPrs5VB+QizEjp+X/GySeqYyxZDTVV5f7YpKvEmAVKEX5FA3mSb3nKmArFNCW Ngu+vgHiqcCYTSJ/FcypcTs8mBljAXFd5pdlXFOaHzS6f/Wba7X4r4i8Lct0AX0np8Ow Z962K0XiDXDHdoJDO+2xbEOgAKK8n1RpIVVdh4SMo+KaFvETk6QZs4s7fmT2BZRj4rvE ysXIqnCt1q0Dj5XfmxkmWyDQhTvn99opi3iYACVH1Tp2g/fOpvhChyMatkI+pcM/hhNc xIsO+fQEethwlZFeMHnDgVjDs9kwrXAkuf1GBmvfQ2+Z7Hy+5bWl6y3NCpUCGapY2pZz yN6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1817xFpS; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x8-20020a05620a448800b00783577b7501si5160187qkp.357.2024.03.01.14.16.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:16:18 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=1817xFpS; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C88463858421 for ; Fri, 1 Mar 2024 22:16:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 4E3ED3858C66 for ; Fri, 1 Mar 2024 22:15:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E3ED3858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E3ED3858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709331334; cv=none; b=bC9lcen+Ka0sOB3KE49Ec19I75oxVQW6Nnw851ddRIRsz2HtuWeIQr3dIlIb9KQ1n3QAZQJzCZLiEWOH/gw5D9Lj1F46PrBj93GYsOeMM7YwavTmOdr2xbKF3B5Hn19hzGzO2g0mZi5SXffIh3qGJTm+TqTunN5Rj1MEqU/KI/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709331334; c=relaxed/simple; bh=C37vvKylnGzqGCVZmO9ofkb3Af8q0VYX7DELgrkrd4s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=xnPjJsdl1wUKjKeaPCr5m40RbNXf0xfSE2f2Xsykc/V9EonYxm63ew1TzQsitVrO62ruz2gIzfsP76fuhKh569IN3TLsATfSvfoTHS1jwjNpVM4qE7NPo+JVRI3d9/DoZQIlufcHPXGWfpTbQ/eZnmWLViyrUtD4ko6+reNzkNk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3c1a172e46bso1981870b6e.3 for ; Fri, 01 Mar 2024 14:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709331331; x=1709936131; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VlAMGFOLmfNJLjq505X6Gzo0ES7q80xebR3zSMJWjo4=; b=1817xFpS1DP7bQkp/+KQAycC1EiSjKmWhU1+RETC2JlO13vPQJ14wvbhEYD4/MDMGq i2uV6PpQ8cI1eLZvPRfKuqw0EgV4+X0FfCi+dO1TiPBhpSX79DyfkDIDTHUL4zTrld7/ 2ZSbMefQvadxEDNWJSZqe6vcF0StmbIpehfIlo3a7LGF3vsIY9bSX6N+Sc3BcAG/tQUV Y5vFNsCsTBiAoa8MfifJoab4S7zc+o3iUwFTnO6fGXdLUELKz0gurieF2CQOCHe+kh1m IAaKgwTkZQKgPs/yWR/+9HpjUVp+JD7bjlHPbx502coCh2xLUEEuE6CBp4v2cv7CWgDv iNQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331331; x=1709936131; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VlAMGFOLmfNJLjq505X6Gzo0ES7q80xebR3zSMJWjo4=; b=qp0+p8c73nO9qbvx6lYUrmw3cd5zmL5WkB2irQqHsxrcNMoXPHK67eINrTGwJo75n8 5Cdd4H7BxnkiUscxFGLeZNdfLV7ZcIUMEeEsm8POhC6djiVd4QmzPxHiXy5Sb3S1e7E5 wk9liD9DvsjtOhoIAgiVifjq6woYA4b171THmpx0BI+cjrtlmRBjC2p/G2B9XSAR8yg1 dzfmbBdeXKWfVabJ7adWdIWr8SWpaZYqhgpMaLHlNC9CVgW/3dlmF1ekYEmc3sk11uKg 5ShYmJhqs9xxsNl2h3949XZkSiNmn8sZNYuDNWvDqzlJJ42+2/DQpuYvLNUl9AVCCQ8x EhPg== X-Gm-Message-State: AOJu0YyF3Y5EHyWhRrnnFj0mosX1188xmSHk3nORzWoFR10iPPY3m324 zt1paaTg4rDfNdGZPquQdr5wxM6rrXmLf0sHktpWjiPLo6vw9gOXsMKFe4TosgjS6p0fhBxX8BT W X-Received: by 2002:a05:6808:13d1:b0:3c1:c36e:9ed2 with SMTP id d17-20020a05680813d100b003c1c36e9ed2mr3696375oiw.36.1709331331483; Fri, 01 Mar 2024 14:15:31 -0800 (PST) Received: from ewlu.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o74-20020a62cd4d000000b006e58663dd0asm3563457pfg.110.2024.03.01.14.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:15:30 -0800 (PST) From: Edwin Lu To: gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com, Edwin Lu Subject: [PATCH] middle-end: Fix dominator information with loop duplication PR114197 Date: Fri, 1 Mar 2024 14:14:37 -0800 Message-Id: <20240301221437.1981406-1-ewlu@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792363858750326057 X-GMAIL-MSGID: 1792363858750326057 When adding the new_preheader to the cfg, only the new_preheader's dominator information is updated. If one of the new basic block's children was part of the original cfg and adding new_preheader to the cfg introduces another path to that child, the child's dominator information will not be updated. This may cause verify_dominator's assertion to fail. Force recalculating dominators for all duplicated basic blocks and their successors when updating new_preheader's dominator information. PR 114197 gcc/ChangeLog: * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Recalculate dominator info when adding new_preheader to cfg gcc/testsuite/ChangeLog: * gcc.dg/vect/pr114197.c: New test. Signed-off-by: Edwin Lu --- gcc/testsuite/gcc.dg/vect/pr114197.c | 18 ++++++++++++++++++ gcc/tree-vect-loop-manip.cc | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr114197.c diff --git a/gcc/testsuite/gcc.dg/vect/pr114197.c b/gcc/testsuite/gcc.dg/vect/pr114197.c new file mode 100644 index 00000000000..b1fb807729c --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr114197.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ + + +#pragma pack(push) +struct a { + volatile signed b : 8; +}; +#pragma pack(pop) +int c; +static struct a d = {5}; +void e() { +f: + for (c = 8; c < 55; ++c) + if (!d.b) + goto f; +} + diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index f72da915103..0f3a489e78c 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -1840,7 +1840,22 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit, } if (was_imm_dom || duplicate_outer_loop) - set_immediate_dominator (CDI_DOMINATORS, exit_dest, new_exit->src); + { + set_immediate_dominator (CDI_DOMINATORS, exit_dest, new_exit->src); + + /* Update the dominator info for children of duplicated bbs. */ + for (unsigned i = 0; i < scalar_loop->num_nodes; i++) + { + basic_block dom_bb = NULL; + edge e; + edge_iterator ei; + FOR_EACH_EDGE (e, ei, new_bbs[i]->succs) + { + dom_bb = recompute_dominator (CDI_DOMINATORS, e->dest); + set_immediate_dominator (CDI_DOMINATORS, e->dest, dom_bb); + } + } + } /* And remove the non-necessary forwarder again. Keep the other one so we have a proper pre-header for the loop at the exit edge. */