From patchwork Tue Jun 11 10:27:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1113625 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502742-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="e9pgyXFO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45NR5r0YdJz9s5c for ; Tue, 11 Jun 2019 20:27:42 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=ubaIaW/E6opAW97nY20tw10rDcFE9ZtB7KEGFB3jdtW8IfXGRz PqoTW9RXKkv8PqGKgKi646XOwW9Y9XFILOKqEfXbLe9a4DEPYdiJMFT9bQfMSWyn ZmsPI74bnXC5ccd+Drvgjy1zIZhpjbyp3MYYrDG+I/DLCbVL/iG0mB734= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=bBRTelgOFpRvfTUqnZqN7pIGGI0=; b=e9pgyXFO1KQpR4Y6kma+ aadUE6NMTP3U/tPoUzkoM+dqmjNILjp1iaQMI6Z1CaSmR/DbZt2XyiHz2owtoiEj CT5Q/B/0m0DoWRLIM1Xcu91Azg4UlibNgTs1uTCJFWKJUWp6yaVvg8OalyGB96YK QEthixBNpScCGbESlV5GgMo= Received: (qmail 116464 invoked by alias); 11 Jun 2019 10:27:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 116455 invoked by uid 89); 11 Jun 2019 10:27:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=treevrph, vr-values.c, tree-vrp.h, treevrpc X-HELO: mail-qt1-f178.google.com Received: from mail-qt1-f178.google.com (HELO mail-qt1-f178.google.com) (209.85.160.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Jun 2019 10:27:33 +0000 Received: by mail-qt1-f178.google.com with SMTP id m29so13845693qtu.1 for ; Tue, 11 Jun 2019 03:27:33 -0700 (PDT) Received: from abulafia.quesejoda.com ([148.101.34.1]) by smtp.gmail.com with ESMTPSA id q36sm8616661qtc.12.2019.06.11.03.27.30 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 03:27:31 -0700 (PDT) To: gcc-patches From: Aldy Hernandez Subject: Remove value_range_constant_singleton Message-ID: Date: Tue, 11 Jun 2019 06:27:30 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 X-IsSubscribed: yes We already have value_range::singleton_p. No need for a separate external function with the same functionality. OK? commit 42981b54247461fcaa43d14315efa6fd3abbf949 Author: Aldy Hernandez Date: Tue Jun 4 18:42:33 2019 +0200 Remove value_range_constant_singleton in favor of value_range::singleton_p. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 815e7546b89..bee0a75a000 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2019-06-11 Aldy Hernandez + + * gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Use + value_range::singleton_p. + * tree-vrp.c (value_range_constant_singleton): Remove. + * tree-vrp.h (value_range_constant_singleton): Remove. + * vr-values.c (vr_values::singleton): Use + value_range::singleton_p. + 2019-06-07 Aldy Hernandez * tree-vrp.h (value_range_base::intersect): New. diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c index ca6ec1354fd..b7b006abf6c 100644 --- a/gcc/gimple-ssa-evrp.c +++ b/gcc/gimple-ssa-evrp.c @@ -109,8 +109,8 @@ evrp_dom_walker::before_dom_children (basic_block bb) value_range *vr = evrp_range_analyzer.get_value_range (lhs); /* Mark PHIs whose lhs we fully propagate for removal. */ - tree val = value_range_constant_singleton (vr); - if (val && may_propagate_copy (lhs, val)) + tree val; + if (vr->singleton_p (&val) && may_propagate_copy (lhs, val)) { stmts_to_remove.safe_push (phi); continue; @@ -158,7 +158,7 @@ evrp_dom_walker::before_dom_children (basic_block bb) value_range *vr = evrp_range_analyzer.get_value_range (output); /* Mark stmts whose output we fully propagate for removal. */ - if ((val = value_range_constant_singleton (vr)) + if (vr->singleton_p (&val) && may_propagate_copy (output, val) && !stmt_could_throw_p (cfun, stmt) && !gimple_has_side_effects (stmt)) @@ -204,8 +204,8 @@ evrp_dom_walker::before_dom_children (basic_block bb) || virtual_operand_p (arg)) continue; value_range *vr = evrp_range_analyzer.get_value_range (arg); - tree val = value_range_constant_singleton (vr); - if (val && may_propagate_copy (arg, val)) + tree val; + if (vr->singleton_p (&val) && may_propagate_copy (arg, val)) propagate_value (use_p, val); } } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 99c93f8f93b..08e6c6b6111 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1188,21 +1188,6 @@ range_includes_p (const value_range_base *vr, HOST_WIDE_INT x) return vr->may_contain_p (build_int_cst (vr->type (), x)); } -/* If *VR has a value range that is a single constant value return that, - otherwise return NULL_TREE. - - ?? This actually returns TRUE for [&x, &x], so perhaps "constant" - is not the best name. */ - -tree -value_range_constant_singleton (const value_range_base *vr) -{ - tree result = NULL; - if (vr->singleton_p (&result)) - return result; - return NULL; -} - /* Value range wrapper for wide_int_range_set_zero_nonzero_bits. Compute MAY_BE_NONZERO and MUST_BE_NONZERO bit masks for range in VR. diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 255f549a03d..e48cc37bafc 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -259,7 +259,6 @@ extern bool infer_value_range (gimple *, tree, tree_code *, tree *); extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap); -extern tree value_range_constant_singleton (const value_range_base *); extern bool range_int_cst_p (const value_range_base *); extern bool range_int_cst_singleton_p (const value_range_base *); diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 27c463b633f..1c05ffb7f17 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -414,7 +414,10 @@ vr_values::singleton (tree op, gimple *stmt ATTRIBUTE_UNUSED) if (TREE_CODE (op) != SSA_NAME) return NULL_TREE; - return value_range_constant_singleton (get_value_range (op)); + tree t; + if (get_value_range (op)->singleton_p (&t)) + return t; + return NULL; } /* Return true if op is in a boolean [0, 1] value-range. */