From patchwork Tue Apr 11 23:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 82213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2932235vqo; Tue, 11 Apr 2023 16:53:21 -0700 (PDT) X-Google-Smtp-Source: AKy350abPoxZ5Hyj7LuefIMMYujvWPT7bi5NomnMmN8DpTj8sFFcdHCXESSLpyFoNOVPOI09MC+W X-Received: by 2002:a17:906:4406:b0:933:4dc8:972d with SMTP id x6-20020a170906440600b009334dc8972dmr12125345ejo.20.1681257200992; Tue, 11 Apr 2023 16:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681257200; cv=none; d=google.com; s=arc-20160816; b=nwtcwxeNmJQMjhGDP76VeK32hTNZ2DoWPpRKQd0ZaxekomqRSVexgkbtF/BEQDn3KA QPjDWx8it8Ku/aDSG4pKbbXGhFogCWQoRBlG+lqM+X9OnEPuxdNQnyhC3g7bEYJ+tvTP 5daDshLqGgdvcSy2p0YCe6ANt6bOBBlFcZrE/vATf2VrjhJP8LeAb8jR4/s7JIfNdNUc CrfObjuNC0uhiUsRo+E64G1bpA0r7vnd+Y0htlhP25vTQIi+bg3UkFIJwCsxsmAaldIq H/VMlWLGLBXUuTT0qQ2a/9k+AuP/vfoyKXHXbcle6Tc6E1bhpNt5hYuFs1JyPFkIh1KH iSmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=UhVO3Bm1qxwqNqDHf0ERRy5UqFiYJD32RSOx+U9bYxg=; b=kDYdJq20KcZhaX5PJCAqLoNGFEMF6jSR5XYcx9Zt0mic7dXWHajKRVkU81E8am3BwL PkSKj5UDIjvk/g8BZwLDdDIPqkmiU8rltgGBkiC/WLTJqewNTbxe/831BjZxHaj4P3d6 OebL7HMcY6nPfmC6VMqAJTKscJ4Y7giqN6+vzWC7rFocXiFcNE7gEsz8LHBj+wzAsNSo tIsEZCvMMhplZtwP36eo9ARC/mrjt/X9fKdj1dnuu5/aGPJlj5T5q2BZcJxxdh8as6CO G3lwfeyLftAg89IU3tid6VSSjI0Kz8H8rkq7WlbTtd67u/M9Qvk5xTZVAFZVtghNFXnu hDCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GTilHsrG; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hs23-20020a1709073e9700b009334a4e66f0si866571ejc.171.2023.04.11.16.53.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 16:53:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GTilHsrG; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E18D6385840D for ; Tue, 11 Apr 2023 23:53:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E18D6385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681257199; bh=UhVO3Bm1qxwqNqDHf0ERRy5UqFiYJD32RSOx+U9bYxg=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=GTilHsrGMkeCA2nHRrjzMcUwKqrQOXdEpHV6OttoEhjLvEAyyQ3CU8jgiGxFjH6WH 9NsdtrWK9Sn7UnM55fQzWWKPjxzn0CGrZcQaaBFLj0+bBAfzZxJoY6wEu0jWYD4Qhm cXGM+XsS79pc2Hzd9tVADZBY35BlMaqTX2i5q/h0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CACB23858D28 for ; Tue, 11 Apr 2023 23:52:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CACB23858D28 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-qFcANUgHO0qaV3uPxazr8g-1; Tue, 11 Apr 2023 19:52:33 -0400 X-MC-Unique: qFcANUgHO0qaV3uPxazr8g-1 Received: by mail-qk1-f199.google.com with SMTP id a62-20020ae9e841000000b0074abdff4ccdso808228qkg.13 for ; Tue, 11 Apr 2023 16:52:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681257152; x=1683849152; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=huJYu2cm4h0QkK/krvJEs9+lFygNyafPM+eavNWKwfI=; b=1DJL3sCIje5DPgBXAI5ZgPWpnLOCHRLF4SQcO/1xki8TvbrJ8rKXJAISf36m/ik3c0 xhoDZ3duqjkxesGmzhJDEeT8UeuzVveKubZp+2UI2bH6nB4e4zcIYpSuW002zi09KQKh +fqGA9QvEMN/n8tC7j/jirnZh+DxkhXONeQ1EOhOL3aqSs6GFPR2e4KrKHmEMCCJsH+c EgIU/r2DHrrBxj9HnMLtcMvHnagq2jFTPLxSsz1fcq0QRUCIzT/TSZNlLpOwXFhmwjPP nOR9pr1jVOBk0iCONY3Fs/1kAJiWZ6PcFMwMHKMjsmJp+x4Pu8TzaP/RldVRQusxHJwd SN+A== X-Gm-Message-State: AAQBX9e75xLe+v3STzty9iCIeuKTd18DP4gSeSHubTv0s1Z51AL7uFNJ ofBw5DAuyojnGpr2nNsVwLcavpnXgdZpUoOuKBHCr+oT7JPL6x36YacqdhGk9MayVYbuazK5n8b 1v8Q12VVYTlDHM92SVqgurU8C10WDl1KLZxwKio7SJPN5b0C4K9wBtWxzheOF/6OaAC14KrvFNp k5kg== X-Received: by 2002:a05:6214:2526:b0:5ad:2a05:ddd1 with SMTP id gg6-20020a056214252600b005ad2a05ddd1mr29455874qvb.34.1681257152065; Tue, 11 Apr 2023 16:52:32 -0700 (PDT) X-Received: by 2002:a05:6214:2526:b0:5ad:2a05:ddd1 with SMTP id gg6-20020a056214252600b005ad2a05ddd1mr29455858qvb.34.1681257151709; Tue, 11 Apr 2023 16:52:31 -0700 (PDT) Received: from ?IPV6:2607:fea8:51dd:1100::345b? ([2607:fea8:51dd:1100::345b]) by smtp.gmail.com with ESMTPSA id kl5-20020a056214518500b005dd8b934595sm4496483qvb.45.2023.04.11.16.52.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 16:52:31 -0700 (PDT) Message-ID: <951d67a7-5eb7-35e5-5e68-ddd6e3d05e3f@redhat.com> Date: Tue, 11 Apr 2023 19:52:29 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 To: gcc-patches Cc: Jakub Jelinek , Richard Biener , "hernandez, aldy" Subject: [PATCH] PR tree-optimization/109462 - Don't use ANY PHI equivalences in range-on-entry. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762925950737280769?= X-GMAIL-MSGID: =?utf-8?q?1762925950737280769?= This is a carry over from PR 108139. When we have a PHI node which has 2 arguments and one is undefined, we create an equivalence between the LHS and the non-undefined PHI argument.  THis allows us to perform certain optimizations. The problem is, when we are evaluating range-on-entry in the cache, its depends on where that equivalence is made, from where we have no context. a_3 = if c_3 is undefined,  then a_3 is equivalent to b_2... but b_2 is not equivalence to a_3 everywhere..   its a one way thing. 108139 fixed this by not evaluating any equivalences if the equivalence was the LHS. What it missed, was it possible we are calculating the range of a_3.   b_2 is not defined in a phi node, so it happily used the equivalence.  This PR demonstrates that we can't always use that equivlence either without more context.  There can be places in the IL where a_3 is used, but b_2 has moved to a new value within a loop. So we can't do this if either NAME or the equivalence is equal via a PHI node with an undefined argument. Unfortunately, this unsafe assumption is why PR 101912 is fixed.   Fixing this issue properly is going to cause that to reopen as it is unsafe. (That PR is  a false uninitialized warning issue, rather than an wrong-code issue) This bootstraps on x86_64-pc-linux-gnu  with that single regression, which I have XFAILed for now.  OK for trunk?   Once Jakub verifies it actually fixes the execution problem.   we have no executable test . yet. Andrew commit 90848fb75cf91a45edd355d2b1485ef835099609 Author: Andrew MacLeod Date: Tue Apr 11 17:29:03 2023 -0400 Don't use ANY PHI equivalences in range-on-entry. PR 108139 dissallows PHI equivalencies in the on-entry calculator, but it was only checking if the equivlaence was a PHI. In this case, NAME itself is a PHI with an equivlaence caused by an undefined value, so we also need to check that case. Unfortunately this un-fixes 101912. PR tree-optimization/109462 gcc/ * gimple-range-cache.cc (ranger_cache::fill_block_cache): Don't check for equivalences if NAME is a phi node. gcc/testsuite/ * gcc.dg/uninit-pr101912.c: XFAIL the warning. diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 6a098d8ec28..3b52f1e734c 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -1218,7 +1218,9 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb) fprintf (dump_file, "\n"); } // See if any equivalences can refine it. - if (m_oracle) + // PR 109462, like 108139 below, a one way equivalence introduced + // by a PHI node can also be through the definition side. Disallow it. + if (m_oracle && !is_a (SSA_NAME_DEF_STMT (name))) { tree equiv_name; relation_kind rel; diff --git a/gcc/testsuite/gcc.dg/uninit-pr101912.c b/gcc/testsuite/gcc.dg/uninit-pr101912.c index 1550c03436d..62cd2a0c73e 100644 --- a/gcc/testsuite/gcc.dg/uninit-pr101912.c +++ b/gcc/testsuite/gcc.dg/uninit-pr101912.c @@ -11,7 +11,7 @@ tzloadbody (void) for (int i = 0; i < n; i++) { int corr = getint (); - if (corr < 1 || (corr == 1 && !(leapcnt == 0 || (prevcorr < corr ? corr == prevcorr + 1 : (corr == prevcorr || corr == prevcorr - 1))))) /* { dg-bogus "uninitialized" } */ + if (corr < 1 || (corr == 1 && !(leapcnt == 0 || (prevcorr < corr ? corr == prevcorr + 1 : (corr == prevcorr || corr == prevcorr - 1))))) /* { dg-bogus "uninitialized" "pr101912" { xfail *-*-* } } */ return -1; prevcorr = corr;