From patchwork Mon Oct 18 22:05:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1542894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=tx8i8V/i; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HY9vL15Kmz9sPB for ; Tue, 19 Oct 2021 09:06:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9A1CF385841B for ; Mon, 18 Oct 2021 22:06:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A1CF385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634594793; bh=H/pJsAR2ilRl8yf4xegwycKqTiDxreWIO8+h+NVBTL0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tx8i8V/iqNXGV6R+qH66tn0GK0nh0OrfkKtgPa261lsHg5rVfAEZNG6R7EYVw1Ow2 Ss9bDvT9FY4EWxmOd1FC2yBvD1prk340U7LJrQaw4a8XzVCX6z1xwHR+1S2yWZ37Ch qh9Ud+Mgp9U+NnIpsW1Kw9grV3mSBHj+G0m9BuH4= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 4CACF385840D for ; Mon, 18 Oct 2021 22:05:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CACF385840D Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-25J4as5XNWOxVDrYndMG1A-1; Mon, 18 Oct 2021 18:05:38 -0400 X-MC-Unique: 25J4as5XNWOxVDrYndMG1A-1 Received: by mail-qk1-f197.google.com with SMTP id w2-20020a3794020000b02903b54f40b442so13390087qkd.0 for ; Mon, 18 Oct 2021 15:05:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=H/pJsAR2ilRl8yf4xegwycKqTiDxreWIO8+h+NVBTL0=; b=mQ2oRi2IrRt1IkFnRAcNizLnn/G8jspGr+P++ukDTIF4fM2+if5L/FR677/E2CWCA0 D7z6PcPGUWnUmVrKZgA3BtUZz6/3p/+/YmVOVC7HnrxPcs93ARIwJCE9zdeGFGeYDp18 XCxLg8pcZnvdGkBPezogYy4s0XiEBvmgxXoyB/dMET9iR4MdJfe22XtUr2sUGxRUGyvG fejUC0gsZklH0aNjuJAAjCNGUJIEfdK0D62jIvoUJ8ejrEnIa/X+NTAvNloPJA+sWPTS n9lfB+OfMCG7l0JUlvbkej423TZ9OLBGqrW0SvdZL5f3boRyEJjfRtVAg/BVNdhg7JR2 qDFg== X-Gm-Message-State: AOAM531rtnEAozZ1L7LWWRt4ZXW5H+0MITLz17LiG8hzoV0mr5K+MlRo wci56XudNaOhxAb0d8FkvHw4SH6Nb2rRcv3Ce2MJq0wEch/c2J5v0O5cNUcCBUg8UsCU4QI5rDP NiVHIGM1S6jn5qPca4w== X-Received: by 2002:a37:4553:: with SMTP id s80mr24939763qka.489.1634594737669; Mon, 18 Oct 2021 15:05:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywTawoEIomM3AdQAbt19Ad5N4mGysfrJ4tknGlaRamXx74fLhv5ms01s8JtYVm2bmESY9J2w== X-Received: by 2002:a37:4553:: with SMTP id s80mr24939742qka.489.1634594737464; Mon, 18 Oct 2021 15:05:37 -0700 (PDT) Received: from ?IPv6:2607:fea8:a262:5f00::38cf? ([2607:fea8:a262:5f00::38cf]) by smtp.gmail.com with ESMTPSA id m11sm7642662qkp.0.2021.10.18.15.05.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Oct 2021 15:05:36 -0700 (PDT) Subject: [COMMITTED] tree-optimization/102796 - Process EH edges again. To: Richard Biener References: <65efdb72-260a-e5a3-5b28-f536f86bd5e6@redhat.com> Message-ID: <803718e3-dd35-0c6b-05f5-96af9897bf02@redhat.com> Date: Mon, 18 Oct 2021 18:05:35 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-11.9 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_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 Cc: Jakub Jelinek , gcc-patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Sorry for the breakage, we need to continue processing EH edges.. Bootstrapped on x86_64-pc-linux-gnu (including Go :-)  with no regressions as of the original checkin.   I hope this catches all the other ripple PRs too.  Pushed. > Returning NULL in gimple_range_ssa_p is probably not a good idea. The > name does carry a range it just has to be considered VARYING. > > The issue with abnormal edges is that they do not have a jump > associated with them and thus we cannot insert code on the edge > because we cannot split it. That has implications for coalescing > since we cannot even insert copies there so the PHI argument > and the PHI result have to be the same register for the arguments > on abnormal edges. > > Otherwise they do carry a value and a range but forcing that to be > VARYING makes sense to avoid propagating constants to where > it is not allowed (though the substitution phase should be the one > checking). gimple_range_ssa_p is mean to be more of a gateway into processing.  If its false, we wont try to find any additional range for it.  This keeps it out of the tables and caches, reducing processing time as well as the memory footprint. We can find ranges for anything with supports_type_p() set to true,and it is likely to be VARYING if gimple_range_ssa_p is false now. That said, this is the first time is been super heavily exercised in this regard, and there are a couple of places where we were returning FALSE which was less than ideal.   I should have been calling get_tree_range, which would then return false for non-supported types, or the global/varying value if they are. And we could probably do better for at least calculating a range for such SSA_NAMES under these circumstances.. there is no reason we can't fold the stmt an get a range.  I'll tweak/audit  that in a follow up so there is better consistency between when we check gimple_range_ssa_p and irange::type_support_p() Andrew commit 4d92a69fc5882c86aab63d52382b393d4f20b3ed Author: Andrew MacLeod Date: Mon Oct 18 13:52:18 2021 -0400 Process EH edges again and call get_tree_range on non gimple_range_ssa_p names. PR tree-optimization/102796 gcc/ * gimple-range.cc (gimple_ranger::range_on_edge): Process EH edges normally. Return get_tree_range for non gimple_range_ssa_p names. (gimple_ranger::range_of_stmt): Use get_tree_range for non gimple_range_ssa_p names. gcc/testsuite/ * g++.dg/pr102796.C: New. diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 85ef9745593..93d6da66ccb 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -180,9 +180,9 @@ gimple_ranger::range_on_edge (irange &r, edge e, tree name) int_range_max edge_range; gcc_checking_assert (irange::supports_type_p (TREE_TYPE (name))); - // Do not process values along abnormal or EH edges. - if (e->flags & (EDGE_ABNORMAL|EDGE_EH)) - return false; + // Do not process values along abnormal edges. + if (e->flags & EDGE_ABNORMAL) + return get_tree_range (r, name, NULL); unsigned idx; if ((idx = tracer.header ("range_on_edge ("))) @@ -203,7 +203,7 @@ gimple_ranger::range_on_edge (irange &r, edge e, tree name) bool res = true; if (!gimple_range_ssa_p (name)) - res = range_of_expr (r, name); + return get_tree_range (r, name, NULL); else { range_on_exit (r, e->src, name); @@ -258,7 +258,7 @@ gimple_ranger::range_of_stmt (irange &r, gimple *s, tree name) if (!name) res = fold_range_internal (r, s, NULL_TREE); else if (!gimple_range_ssa_p (name)) - res = false; + res = get_tree_range (r, name, NULL); // Check if the stmt has already been processed, and is not stale. else if (m_cache.get_non_stale_global_range (r, name)) { diff --git a/gcc/testsuite/g++.dg/pr102796.C b/gcc/testsuite/g++.dg/pr102796.C new file mode 100644 index 00000000000..6ad1008922f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr102796.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-O3 -fno-tree-ccp -fno-tree-fre -fno-tree-forwprop -std=c++17" } + +namespace std { +template +struct initializer_list { + const int* __begin_; + decltype(sizeof(int)) __size_; +}; +} // namespace std +struct destroyme1 {}; +struct witharg1 { + witharg1(const destroyme1&); + ~witharg1(); +}; +std::initializer_list globalInitList2 = {witharg1(destroyme1()), + witharg1(destroyme1())}; +