From patchwork Thu Nov 14 17:12:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1194981 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513442-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="LC1ziXnv"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="AIOcVV1P"; 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 47DSjH029sz9s7T for ; Fri, 15 Nov 2019 04:12:50 +1100 (AEDT) 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=aUIcLToqrqKBJIcAizaq15eYFPAY4SzPUB1CyvkEw9TaERW0gg mUhtMsNhm35o0Un6xH5EoAHkTXbKsSFxD+C8SlulFSgZfgDdhLabr6wZGnarczMl 5/da7yucJV2ws75ye2NJ2NWk91/5EOWkhtPYVOkL0KTBdFnp5/hKSZcQU= 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=xFBp9dKBVYb0xPZGlBp0l7UYIBI=; b=LC1ziXnvic5aLxhHZQjZ K+ilK10b2fL38DcqZjzb8NdpcPpRKduRRL/0hdWPspG9FVebOR1cMAwrEWNrqxZJ SJA8nmRhxMLYJcoRGp4foXmx5shrFw1wNi4oeUwZkklgrIs5CSvgQtqIlrIESYHE 0btbN+Y6UW2WZ4QZUqW6b3M= Received: (qmail 710 invoked by alias); 14 Nov 2019 17:12:43 -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 701 invoked by uid 89); 14 Nov 2019 17:12:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=UD:varying_p, UD:undefined_p X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Nov 2019 17:12:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573751559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=gZXio7ongSW4xUATpN50/PeX6e+f5ZfesWDnwIl7M6o=; b=AIOcVV1PHb3Jm4yiwxyjaAYuuzVV1XO3CcjYUwGTNdE06fqmSl3VyqEd5bf+UMFUIZCQgK Npz4b85RlPbcr3eqsLn7Q92wXubqDwN1FZSdsxCHKo4OWdYZr10akCZjSCn4MDeV+Xajoq Un9QlDADtPd0DKWu/smtLVrpo1HF144= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-hTI-2HHEOpeGKGhwBCoKzw-1; Thu, 14 Nov 2019 12:12:37 -0500 Received: by mail-wm1-f72.google.com with SMTP id h191so4282289wme.5 for ; Thu, 14 Nov 2019 09:12:37 -0800 (PST) Received: from abulafia.quesejoda.com (149.red-81-32-135.dynamicip.rima-tde.net. [81.32.135.149]) by smtp.gmail.com with ESMTPSA id p25sm6362618wma.20.2019.11.14.09.12.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2019 09:12:34 -0800 (PST) To: Andrew MacLeod , gcc-patches From: Aldy Hernandez Subject: [COMMITTED] Remove range_intersect, range_invert, and range_union. Message-ID: Date: Thu, 14 Nov 2019 18:12:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes range_intersect, range_union, and range_intersect are currently returning their results by value. After Andrew's change, these should also return their results in an argument. However, if we do this, the functions become superfluous since we have corresponding API methods with the same functionality: - r = range_intersect (op1, op2); + r = op1; + r.intersect (op2); I have removed all 3 functions and have adjusted the code throughout. Committed as mostly obvious, after having consulted with Andrew that it was these and not the range_true* ones as well that needed adjusting. Aldy commit e0f55e7de91f779fe12ab65fc9479e4df0fe2614 Author: Aldy Hernandez Date: Thu Nov 14 17:55:32 2019 +0100 Remove range_intersect, range_invert, and range_union. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 051b10ed953..4266f6b1655 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2019-11-14 Aldy Hernandez + + * range-op.cc (*operator*::*range): Remove calls to + range_intersect, range_invert, and range_union in favor of calling + the in-place API methods. + (range_tests): Same. + * range.cc (range_intersect): Remove. + (range_union): Remove. + (range_invert): Remove. + * range.h (range_intersect): Remove. + (range_union): Remove. + (range_intersect): Remove. + 2019-11-14 Ilya Leoshkevich PR rtl-optimization/92430 diff --git a/gcc/range-op.cc b/gcc/range-op.cc index ae3025c6eea..4a23cca3dbb 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -396,7 +396,8 @@ operator_equal::fold_range (value_range &r, tree type, { // If ranges do not intersect, we know the range is not equal, // otherwise we don't know anything for sure. - r = range_intersect (op1, op2); + r = op1; + r.intersect (op2); if (r.undefined_p ()) r = range_false (type); else @@ -415,7 +416,10 @@ operator_equal::op1_range (value_range &r, tree type, // If the result is false, the only time we know anything is // if OP2 is a constant. if (wi::eq_p (op2.lower_bound(), op2.upper_bound())) - r = range_invert (op2); + { + r = op2; + r.invert (); + } else r.set_varying (type); break; @@ -476,7 +480,8 @@ operator_not_equal::fold_range (value_range &r, tree type, { // If ranges do not intersect, we know the range is not equal, // otherwise we don't know anything for sure. - r = range_intersect (op1, op2); + r = op1; + r.intersect (op2); if (r.undefined_p ()) r = range_true (type); else @@ -495,7 +500,10 @@ operator_not_equal::op1_range (value_range &r, tree type, // If the result is true, the only time we know anything is if // OP2 is a constant. if (wi::eq_p (op2.lower_bound(), op2.upper_bound())) - r = range_invert (op2); + { + r = op2; + r.invert (); + } else r.set_varying (type); break; @@ -1974,7 +1982,8 @@ operator_logical_or::fold_range (value_range &r, tree type ATTRIBUTE_UNUSED, if (empty_range_check (r, lh, rh)) return; - r = range_union (lh, rh); + r = lh; + r.union_ (rh); } bool @@ -2221,7 +2230,10 @@ operator_logical_not::fold_range (value_range &r, tree type, if (lh.varying_p () || lh.undefined_p ()) r = lh; else - r = range_invert (lh); + { + r = lh; + r.invert (); + } gcc_checking_assert (lh.type() == type); return; } @@ -2232,10 +2244,9 @@ operator_logical_not::op1_range (value_range &r, const value_range &lhs, const value_range &op2 ATTRIBUTE_UNUSED) const { - if (lhs.varying_p () || lhs.undefined_p ()) - r = lhs; - else - r = range_invert (lhs); + r = lhs; + if (!lhs.varying_p () && !lhs.undefined_p ()) + r.invert (); return true; } @@ -3033,13 +3044,6 @@ range_tests () r1.union_ (r2); ASSERT_TRUE (r0 == r1); - // [10,20] U [30,40] ==> [10,20][30,40]. - r0 = value_range (INT (10), INT (20)); - r1 = value_range (INT (30), INT (40)); - r0.union_ (r1); - ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)), - value_range (INT (30), INT (40)))); - // Make sure NULL and non-NULL of pointer types work, and that // inverses of them are consistent. tree voidp = build_pointer_type (void_type_node); @@ -3049,27 +3053,12 @@ range_tests () r0.invert (); ASSERT_TRUE (r0 == r1); - // [10,20][30,40] U [25,70] => [10,70]. - r0 = range_union (value_range (INT (10), INT (20)), - value_range (INT (30), INT (40))); - r1 = value_range (INT (25), INT (70)); - r0.union_ (r1); - ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)), - value_range (INT (25), INT (70)))); - // [10,20] U [15, 30] => [10, 30]. r0 = value_range (INT (10), INT (20)); r1 = value_range (INT (15), INT (30)); r0.union_ (r1); ASSERT_TRUE (r0 == value_range (INT (10), INT (30))); - // [10,20] U [25,25] => [10,20][25,25]. - r0 = value_range (INT (10), INT (20)); - r1 = value_range (INT (25), INT (25)); - r0.union_ (r1); - ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)), - value_range (INT (25), INT (25)))); - // [15,40] U [] => [15,40]. r0 = value_range (INT (15), INT (40)); r1.set_undefined (); @@ -3094,19 +3083,6 @@ range_tests () r0.intersect (r1); ASSERT_TRUE (r0 == value_range (INT (15), INT (20))); - // [10,20][30,40] ^ [40,50] => [40,40]. - r0 = range_union (value_range (INT (10), INT (20)), - value_range (INT (30), INT (40))); - r1 = value_range (INT (40), INT (50)); - r0.intersect (r1); - ASSERT_TRUE (r0 == value_range (INT (40), INT (40))); - - // Test non-destructive intersection. - r0 = rold = value_range (INT (10), INT (20)); - ASSERT_FALSE (range_intersect (r0, value_range (INT (15), - INT (30))).undefined_p ()); - ASSERT_TRUE (r0 == rold); - // Test the internal sanity of wide_int's wrt HWIs. ASSERT_TRUE (wi::max_value (TYPE_PRECISION (boolean_type_node), TYPE_SIGN (boolean_type_node)) diff --git a/gcc/range.cc b/gcc/range.cc index e592d05738e..6eff6c0a38f 100644 --- a/gcc/range.cc +++ b/gcc/range.cc @@ -29,30 +29,6 @@ along with GCC; see the file COPYING3. If not see #include "ssa.h" #include "range.h" -value_range -range_intersect (const value_range &r1, const value_range &r2) -{ - value_range tmp (r1); - tmp.intersect (r2); - return tmp; -} - -value_range -range_invert (const value_range &r1) -{ - value_range tmp (r1); - tmp.invert (); - return tmp; -} - -value_range -range_union (const value_range &r1, const value_range &r2) -{ - value_range tmp (r1); - tmp.union_ (r2); - return tmp; -} - value_range range_zero (tree type) { diff --git a/gcc/range.h b/gcc/range.h index b4806e64bbb..6efec1699e3 100644 --- a/gcc/range.h +++ b/gcc/range.h @@ -23,9 +23,6 @@ along with GCC; see the file COPYING3. If not see value_range range_zero (tree type); value_range range_nonzero (tree type); -value_range range_intersect (const value_range &, const value_range &); -value_range range_union (const value_range &, const value_range &); -value_range range_invert (const value_range &); value_range range_positives (tree type); value_range range_negatives (tree type); #endif // GCC_RANGE_H