From patchwork Fri May 7 19:03:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1475652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@gcc.gnu.org; receiver=) Authentication-Results: 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=hUMEOJ0S; dkim-atps=neutral Received: from sourceware.org (server2.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 ozlabs.org (Postfix) with ESMTPS id 4FcKbS2Lxbz9sVb for ; Sat, 8 May 2021 05:03:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 176F53A3E006; Fri, 7 May 2021 19:03:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 176F53A3E006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620414194; bh=YKOKbZ24l1S7uw9aZSq9EEP0Tbm1H25SuyCcrM2fkN4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hUMEOJ0S/sZVsId3lq1sc9Olc4EgE3e6j2ijeS1q2BRqdnM9s4C8ZZxcCBjifgFIR 5hOT8IVbL+93TBr7Ixy68Dv/wKIzcNvT85fwqQtIxqW4nOT2tmnTS6vTMGxr64658m ixCaxEl8j+9LD3KkSHyZG3qX7DK5RYnEeNaIlovw= 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 ESMTP id B06D03896827 for ; Fri, 7 May 2021 19:03:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B06D03896827 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-yW4o-0uxNDeeUuF8GXamKg-1; Fri, 07 May 2021 15:03:09 -0400 X-MC-Unique: yW4o-0uxNDeeUuF8GXamKg-1 Received: by mail-qt1-f200.google.com with SMTP id d16-20020ac811900000b02901bbebf64663so6343972qtj.14 for ; Fri, 07 May 2021 12:03:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:cc:message-id:date:user-agent :mime-version:content-language; bh=YKOKbZ24l1S7uw9aZSq9EEP0Tbm1H25SuyCcrM2fkN4=; b=KlIYzUymqoJVem8zSopJmzZoB7U2RlUEWQn8cofL7cBe3fchtwzyAzGGUChkG5keyC AKRNtKTaaFUVXWLnQXAyCgU2vVx/9C20+1CSXx18HULvfqhpEiPWRBm3BaH8Yp/tQNZl SSEJX9Ec57cLaZ92hPLkeOmEJeXp+N+7J9rO2/QC5wgQchlKL6uR1Zf82MCZNCVDU+F3 nkfd3WzQO3r1zJZJq3oGA5frc0GWdeJpahyJwXqXrDGfniqdYePydZ9eQEW/Cp8ymvK/ NbgntNlaS+U9WRLBlLVujoqNsHOiwRgNyjOTTL0cOroS3Fsv+joWrevstIJvm6WIUr7e y2gg== X-Gm-Message-State: AOAM532PCrUgGAhSXZ+Q3y/uzV6r22g+LaT/SV8n85413y80I3pAoYVC Oy+IVqe3+V3dWXl9tB6OHhBvN830x9ZhIuyPCVtLaQb8NI2LogS1q/1r0hLBID6m5IqpYZHlZfi FBhPFBM0GK7LNIbsblw== X-Received: by 2002:a0c:c18c:: with SMTP id n12mr11135513qvh.43.1620414188781; Fri, 07 May 2021 12:03:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0SN4Hulp/bxOqn8oqvz0XWDAvnz6Zd/bXiigFDyX/sHt7eNFwGUh1owZI6vXpc07K24FHYg== X-Received: by 2002:a0c:c18c:: with SMTP id n12mr11135499qvh.43.1620414188636; Fri, 07 May 2021 12:03:08 -0700 (PDT) Received: from ?IPv6:2607:fea8:a25f:fa00:6ae8:97ac:cf69:b86d? ([2607:fea8:a25f:fa00:6ae8:97ac:cf69:b86d]) by smtp.gmail.com with ESMTPSA id 189sm5492211qkd.51.2021.05.07.12.03.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 May 2021 12:03:08 -0700 (PDT) To: gcc-patches Subject: [PATCH] Export gcond edge range routine. Message-ID: <7614c3bf-da08-148d-6435-55e34b2ff7a2@redhat.com> Date: Fri, 7 May 2021 15:03:07 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.7 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@gcc.gnu.org Sender: "Gcc-patches" Rename the outgoing_edge class to gimple_outgoing_edge, and provide an extern entry point for convenience to return a range for the TRUE and FALSE edges of a gcond. Bootstraps onĀ  x86_64-pc-linux-gnu with no testsuite regressions. Pushed. Andrew commit 42a146ac12f48422f5a26b5ab9a804639cbdeea3 Author: Andrew MacLeod Date: Mon Apr 26 18:14:15 2021 -0400 Make TRUE/FALSE edge calculation available without the outgoing edge class. Rename class to gimple_outoging_edge and provide a non-class routine for the outgoing edge of a gcond. * gimple-range-edge.h (gimple_outgoing_range): Rename from outgoing_range. (gcond_edge_range): Export prototype. * gimple-range-edge.cc (gcond_edge_range): New. (gimple_outgoing_range::edge_range_p): Use gcond_edge_range. * gimple-range-gori.h (gori_compute): Use gimple_outgoing_range. diff --git a/gcc/gimple-range-edge.cc b/gcc/gimple-range-edge.cc index 4d4cb97bbec..d11153e677e 100644 --- a/gcc/gimple-range-edge.cc +++ b/gcc/gimple-range-edge.cc @@ -52,12 +52,26 @@ gimple_outgoing_range_stmt_p (basic_block bb) } -outgoing_range::outgoing_range () +// Return a TRUE or FALSE range representing the edge value of a GCOND. + +void +gcond_edge_range (irange &r, edge e) +{ + gcc_checking_assert (e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)); + if (e->flags & EDGE_TRUE_VALUE) + r = int_range<2> (boolean_true_node, boolean_true_node); + else + r = int_range<2> (boolean_false_node, boolean_false_node); +} + + +gimple_outgoing_range::gimple_outgoing_range () { m_edge_table = NULL; } -outgoing_range::~outgoing_range () + +gimple_outgoing_range::~gimple_outgoing_range () { if (m_edge_table) delete m_edge_table; @@ -68,7 +82,7 @@ outgoing_range::~outgoing_range () // Use a cached value if it exists, or calculate it if not. bool -outgoing_range::get_edge_range (irange &r, gimple *s, edge e) +gimple_outgoing_range::get_edge_range (irange &r, gimple *s, edge e) { gcc_checking_assert (is_a (s)); gswitch *sw = as_a (s); @@ -100,7 +114,7 @@ outgoing_range::get_edge_range (irange &r, gimple *s, edge e) // Calculate all switch edges from SW and cache them in the hash table. void -outgoing_range::calc_switch_ranges (gswitch *sw) +gimple_outgoing_range::calc_switch_ranges (gswitch *sw) { bool existed; unsigned x, lim; @@ -165,7 +179,7 @@ outgoing_range::calc_switch_ranges (gswitch *sw) // return NULL gimple * -outgoing_range::edge_range_p (irange &r, edge e) +gimple_outgoing_range::edge_range_p (irange &r, edge e) { // Determine if there is an outgoing edge. gimple *s = gimple_outgoing_range_stmt_p (e->src); @@ -174,12 +188,7 @@ outgoing_range::edge_range_p (irange &r, edge e) if (is_a (s)) { - if (e->flags & EDGE_TRUE_VALUE) - r = int_range<2> (boolean_true_node, boolean_true_node); - else if (e->flags & EDGE_FALSE_VALUE) - r = int_range<2> (boolean_false_node, boolean_false_node); - else - gcc_unreachable (); + gcond_edge_range (r, e); return s; } diff --git a/gcc/gimple-range-edge.h b/gcc/gimple-range-edge.h index 8970c9e14d6..87b4124d01d 100644 --- a/gcc/gimple-range-edge.h +++ b/gcc/gimple-range-edge.h @@ -35,11 +35,11 @@ along with GCC; see the file COPYING3. If not see // The return value is NULL for no range, or the branch statement which the // edge gets the range from, along with the range. -class outgoing_range +class gimple_outgoing_range { public: - outgoing_range (); - ~outgoing_range (); + gimple_outgoing_range (); + ~gimple_outgoing_range (); gimple *edge_range_p (irange &r, edge e); private: void calc_switch_ranges (gswitch *sw); @@ -47,9 +47,11 @@ private: hash_map *m_edge_table; irange_allocator m_range_allocator; -}; +}; -// If there is a range control statment at the end of block BB, return it. +// If there is a range control statement at the end of block BB, return it. gimple *gimple_outgoing_range_stmt_p (basic_block bb); +// Return the range on edge E if it is from a GCOND. Either TRUE or FALSE. +void gcond_edge_range (irange &r, edge e); #endif // GIMPLE_RANGE_EDGE_H diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h index 48c746d1f37..7bb18a9baf1 100644 --- a/gcc/gimple-range-gori.h +++ b/gcc/gimple-range-gori.h @@ -108,7 +108,7 @@ private: const irange &lhs, tree name); class gori_map *m_gori_map; - outgoing_range outgoing; // Edge values for COND_EXPR & SWITCH_EXPR. + gimple_outgoing_range outgoing; // Edge values for COND_EXPR & SWITCH_EXPR. };