From patchwork Sat Jun 10 00:33:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793254 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=DaKxaf9f; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJqG5lBJz20Wg for ; Sat, 10 Jun 2023 10:34:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E0073856975 for ; Sat, 10 Jun 2023 00:34:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E0073856975 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357254; bh=v38H3J7A87xRbH4zMkvyi2P/w/oFG5Wc2n6rXs1EpOU=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=DaKxaf9fukV3o08MK11GS4Bn6eamUJDMcr6SkFvr9ar45ZXbSPetY60G3n/DlAtIk dPRrbJZLcITF81I6P2d8x869+lqdRMgt/BwjKpIkIM5rIBtQLz/H3xZ2g6DPV0Dq91 mK2OsTxlT/W1S1lL+2awW2q6AgGNjkb5ii26rftY= 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 5747C3858D35 for ; Sat, 10 Jun 2023 00:33:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5747C3858D35 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-543-Wn-CqTqxP7iIu0UzJaoAYw-1; Fri, 09 Jun 2023 20:33:47 -0400 X-MC-Unique: Wn-CqTqxP7iIu0UzJaoAYw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-75d556224e7so298845285a.1 for ; Fri, 09 Jun 2023 17:33:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357226; x=1688949226; 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=eFxsMJ+NbC8jhc7qO6vP5HbZX+Ly0qgJJoyxBSanjVE=; b=FCzu74eIsSrloVEcr4ZncK7IiZD012o9A0ZpVDwogzAsZCR+eBmaxR0WnNXgWXV/uN ZTBV0PsejKDwnpFNu+zsH9Qt2MnghJwQ4va4IDILbdsEdbG0kK1FGboReJb7lLRIog5e ambaIHdTGspJ0vGL1nmT98k1hoep1tr1val7oSSekEMhgBBUUnmKlk1a6mR8DAGgY3cU mT0J+r7/aUFTtaDXWKZBrKr+aSSK3kQkhRQtukpQQoWokrugaXGJmrb1ss+bfRDaOYNd gBynUokOemvsDNDE0U+XXiWagtGenH9FyXENka24JM3SqdwfI4vjjJo3kf4yxOocGK18 q5sQ== X-Gm-Message-State: AC+VfDxQQgOc22VcLDxcHhZI4hgVkwNUHLGQs9sj0Tl4zGShg/H8/JJt iGY1CpXPqwlxc7FfgeyP7pbpqR/aq+oytHP21ao3bd8jBznWiRzGDAeDnQyboaHI97YssrqiGee fFF72eAOjz8jLJOH8C42xYNK+A2rjj1jJuQeL1uxDFf7SYBWdvZpm1vsw6Nd5p7Qve99Bgrrje1 ZnWw== X-Received: by 2002:a05:620a:2b95:b0:75e:bb5e:3e6a with SMTP id dz21-20020a05620a2b9500b0075ebb5e3e6amr3132206qkb.26.1686357226481; Fri, 09 Jun 2023 17:33:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4OCUH2aMkleQ5cxHXTPnC5+KndVop+Me5RK/41k6bVmEK0reCsgZN5Ak/maDxebGeSBvwk6g== X-Received: by 2002:a05:620a:2b95:b0:75e:bb5e:3e6a with SMTP id dz21-20020a05620a2b9500b0075ebb5e3e6amr3132191qkb.26.1686357226103; Fri, 09 Jun 2023 17:33:46 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id n13-20020a05620a152d00b0075ebbd60771sm1367980qkk.84.2023.06.09.17.33.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:33:45 -0700 (PDT) Message-ID: Date: Fri, 9 Jun 2023 20:33:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 1/15] - Provide a unified range-op table. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" With all the operators unified under range_operator, I can now start moving them into a unified table rather than have them spread around in various type tables. This patch creates a range_table for the unified operations, and has checks to ensure that if the operator comes from the unified table, it does not exist in any other table.  This is a sanity check for the duration of the transition. This patch also moves all the low hanging fruit opcodes which exist ion only one table directly into the unified table. It also introduced range-op-mixed.h which will contain the class declarations for any "shared" operators so that each implementation file can see the decl.   It also contains the common routines from range-op.h that some of the operators need. With the next patch , I will begin the transition, one opcode at a time, to the unified table.   By doing this in separate commits, we can easily isolate any potential problems that show up... not that I expect any, its fairly mechanical..but just in case. This first set will move all the integer/float shared opcodes into the header file and into the unified table.  The foperator_* classes will be removed and the methods themselves will simply be renamed to implement the unified range_operator method.  The code will remain in range-op-float.cc for those implementations, and the integral versions will remain in range-op.cc. All the patches bootstrap on x86_64-pc-linux-gnu and pass all regressions.  I wont add much more comment for most of them when they are equivalent in functionality.   Pushed. Andrew From df392fbd5d13c944479ed00fcb805e6f26d3fd4b Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 12:58:57 -0400 Subject: [PATCH 01/31] Provide a unified range-op table. Create a table to prepare for unifying all operations into a single table. Move any operators which only occur in one table to the approriate initialization routine. Provide a mixed header file for range-ops with multiple categories. * range-op-float.cc (class float_table): Move to header. (float_table::float_table): Move float only operators to... (range_op_table::initialize_float_ops): Here. * range-op-mixed.h: New. * range-op.cc (integral_tree_table, pointer_tree_table): Moved to top of file. (float_tree_table): Moved from range-op-float.cc. (unified_tree_table): New. (unified_table::unified_table): New. Call initialize routines. (get_op_handler): Check unified table first. (range_op_handler::range_op_handler): Handle no type constructor. (integral_table::integral_table): Move integral only operators to... (range_op_table::initialize_integral_ops): Here. (pointer_table::pointer_table): Move pointer only operators to... (range_op_table::initialize_pointer_ops): Here. * range-op.h (enum bool_range_state): Move to range-op-mixed.h. (get_bool_state): Ditto. (empty_range_varying): Ditto. (relop_early_resolve): Ditto. (class range_op_table): Add new init methods for range types. (class integral_table): Move declaration to here. (class pointer_table): Move declaration to here. (class float_table): Move declaration to here. --- gcc/range-op-float.cc | 29 +++++++------- gcc/range-op-mixed.h | 78 +++++++++++++++++++++++++++++++++++++ gcc/range-op.cc | 89 +++++++++++++++++++++++++++++-------------- gcc/range-op.h | 89 ++++++++++++++++--------------------------- 4 files changed, 185 insertions(+), 100 deletions(-) create mode 100644 gcc/range-op-mixed.h diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index bb10accd78f..8659217659c 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see #include "wide-int.h" #include "value-relation.h" #include "range-op.h" +#include "range-op-mixed.h" // Default definitions for floating point operators. @@ -2807,15 +2808,6 @@ private: } } fop_div; -// Instantiate a range_op_table for floating point operations. -class float_table : public range_op_table -{ - public: - float_table (); -} global_floating_table; - -// Pointer to the float table so the dispatch code can access it. -range_op_table *floating_tree_table = &global_floating_table; float_table::float_table () { @@ -2833,6 +2825,19 @@ float_table::float_table () set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); + + set (ABS_EXPR, fop_abs); + set (NEGATE_EXPR, fop_negate); + set (PLUS_EXPR, fop_plus); + set (MINUS_EXPR, fop_minus); + set (MULT_EXPR, fop_mult); +} + +// Initialize any pointer operators to the primary table + +void +range_op_table::initialize_float_ops () +{ set (UNLE_EXPR, fop_unordered_le); set (UNLT_EXPR, fop_unordered_lt); set (UNGE_EXPR, fop_unordered_ge); @@ -2841,12 +2846,6 @@ float_table::float_table () set (ORDERED_EXPR, fop_ordered); set (UNORDERED_EXPR, fop_unordered); set (LTGT_EXPR, fop_ltgt); - - set (ABS_EXPR, fop_abs); - set (NEGATE_EXPR, fop_negate); - set (PLUS_EXPR, fop_plus); - set (MINUS_EXPR, fop_minus); - set (MULT_EXPR, fop_mult); set (RDIV_EXPR, fop_div); } diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h new file mode 100644 index 00000000000..a78bc2ba59c --- /dev/null +++ b/gcc/range-op-mixed.h @@ -0,0 +1,78 @@ +/* Header file for mixed range operator class. + Copyright (C) 2017-2023 Free Software Foundation, Inc. + Contributed by Andrew MacLeod + and Aldy Hernandez . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_RANGE_OP_MIXED_H +#define GCC_RANGE_OP_MIXED_H + +enum bool_range_state { BRS_FALSE, BRS_TRUE, BRS_EMPTY, BRS_FULL }; +bool_range_state get_bool_state (vrange &r, const vrange &lhs, tree val_type); + +// If the range of either op1 or op2 is undefined, set the result to +// varying and return TRUE. If the caller truly cares about a result, +// they should pass in a varying if it has an undefined that it wants +// treated as a varying. + +inline bool +empty_range_varying (vrange &r, tree type, + const vrange &op1, const vrange & op2) +{ + if (op1.undefined_p () || op2.undefined_p ()) + { + r.set_varying (type); + return true; + } + else + return false; +} + +// For relation opcodes, first try to see if the supplied relation +// forces a true or false result, and return that. +// Then check for undefined operands. If none of this applies, +// return false. + +inline bool +relop_early_resolve (irange &r, tree type, const vrange &op1, + const vrange &op2, relation_trio trio, + relation_kind my_rel) +{ + relation_kind rel = trio.op1_op2 (); + // If known relation is a complete subset of this relation, always true. + if (relation_union (rel, my_rel) == my_rel) + { + r = range_true (type); + return true; + } + + // If known relation has no subset of this relation, always false. + if (relation_intersect (rel, my_rel) == VREL_UNDEFINED) + { + r = range_false (type); + return true; + } + + // If either operand is undefined, return VARYING. + if (empty_range_varying (r, type, op1, op2)) + return true; + + return false; +} + +#endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 44a95b20ffa..4e00c9f439e 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -47,36 +47,48 @@ along with GCC; see the file COPYING3. If not see #include "value-relation.h" #include "range-op.h" #include "tree-ssa-ccp.h" +#include "range-op-mixed.h" -// Instantiate a range op table for integral operations. +integral_table integral_tree_table; +pointer_table pointer_tree_table; +float_table float_tree_table; -class integral_table : public range_op_table +// Instantiate a range_op_table for unified operations. +class unified_table : public range_op_table { -public: - integral_table (); -} integral_tree_table; + public: + unified_table (); +} unified_tree_table; -// Instantiate a range op table for pointer operations. +// Invoke the initialization routines for each class of range. -class pointer_table : public range_op_table +unified_table::unified_table () { -public: - pointer_table (); -} pointer_tree_table; - + initialize_integral_ops (); + initialize_pointer_ops (); + initialize_float_ops (); +} // The tables are hidden and accessed via a simple extern function. range_operator * get_op_handler (enum tree_code code, tree type) { - // First check if there is a pointer specialization. + if (unified_tree_table[code]) + { + // Should not be in any other table if it is in the unified table. + gcc_checking_assert (!pointer_tree_table[code]); + gcc_checking_assert (!integral_tree_table[code]); + gcc_checking_assert (!float_tree_table[code]); + return unified_tree_table[code]; + } + if (POINTER_TYPE_P (type)) return pointer_tree_table[code]; if (INTEGRAL_TYPE_P (type)) return integral_tree_table[code]; if (frange::supports_p (type)) - return (*floating_tree_table)[code]; + return float_tree_table[code]; return NULL; } @@ -96,6 +108,13 @@ range_op_handler::range_op_handler (tree_code code, tree type) set_op_handler (code, type); } +// Constructing without a type must come from the unified table. + +range_op_handler::range_op_handler (tree_code code) +{ + m_operator = unified_tree_table[code]; +} + // Create a dispatch pattern for value range discriminators LHS, OP1, and OP2. // This is used to produce a unique value for each dispatch pattern. Shift // values are based on the size of the m_discriminator field in value_range.h. @@ -4875,6 +4894,26 @@ integral_table::integral_table () set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); set (MULT_EXPR, op_mult); + set (NOP_EXPR, op_cast); + set (CONVERT_EXPR, op_cast); + set (BIT_AND_EXPR, op_bitwise_and); + set (BIT_IOR_EXPR, op_bitwise_or); + set (BIT_XOR_EXPR, op_bitwise_xor); + set (BIT_NOT_EXPR, op_bitwise_not); + set (INTEGER_CST, op_integer_cst); + set (SSA_NAME, op_ident); + set (PAREN_EXPR, op_ident); + set (OBJ_TYPE_REF, op_ident); + set (ABS_EXPR, op_abs); + set (NEGATE_EXPR, op_negate); + set (ADDR_EXPR, op_addr); +} + +// Initialize any integral operators to the primary table + +void +range_op_table::initialize_integral_ops () +{ set (TRUNC_DIV_EXPR, op_trunc_div); set (FLOOR_DIV_EXPR, op_floor_div); set (ROUND_DIV_EXPR, op_round_div); @@ -4882,27 +4921,13 @@ integral_table::integral_table () set (EXACT_DIV_EXPR, op_exact_div); set (LSHIFT_EXPR, op_lshift); set (RSHIFT_EXPR, op_rshift); - set (NOP_EXPR, op_cast); - set (CONVERT_EXPR, op_cast); set (TRUTH_AND_EXPR, op_logical_and); - set (BIT_AND_EXPR, op_bitwise_and); set (TRUTH_OR_EXPR, op_logical_or); - set (BIT_IOR_EXPR, op_bitwise_or); - set (BIT_XOR_EXPR, op_bitwise_xor); set (TRUNC_MOD_EXPR, op_trunc_mod); set (TRUTH_NOT_EXPR, op_logical_not); - set (BIT_NOT_EXPR, op_bitwise_not); - set (INTEGER_CST, op_integer_cst); - set (SSA_NAME, op_ident); - set (PAREN_EXPR, op_ident); - set (OBJ_TYPE_REF, op_ident); set (IMAGPART_EXPR, op_unknown); set (REALPART_EXPR, op_unknown); - set (POINTER_DIFF_EXPR, op_pointer_diff); - set (ABS_EXPR, op_abs); set (ABSU_EXPR, op_absu); - set (NEGATE_EXPR, op_negate); - set (ADDR_EXPR, op_addr); } pointer_table::pointer_table () @@ -4911,7 +4936,6 @@ pointer_table::pointer_table () set (BIT_IOR_EXPR, op_pointer_or); set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (POINTER_PLUS_EXPR, op_pointer_plus); set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); @@ -4929,6 +4953,15 @@ pointer_table::pointer_table () set (BIT_XOR_EXPR, op_bitwise_xor); } +// Initialize any pointer operators to the primary table + +void +range_op_table::initialize_pointer_ops () +{ + set (POINTER_PLUS_EXPR, op_pointer_plus); + set (POINTER_DIFF_EXPR, op_pointer_diff); +} + #if CHECKING_P #include "selftest.h" diff --git a/gcc/range-op.h b/gcc/range-op.h index 2abec3299ef..0721d4a302d 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -186,6 +186,7 @@ class range_op_handler public: range_op_handler (); range_op_handler (enum tree_code code, tree type); + range_op_handler (enum tree_code code); inline operator bool () const { return m_operator != NULL; } bool fold_range (vrange &r, tree type, @@ -272,69 +273,18 @@ relation_kind le_op1_op2_relation (const irange &lhs); relation_kind gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs); -enum bool_range_state { BRS_FALSE, BRS_TRUE, BRS_EMPTY, BRS_FULL }; -bool_range_state get_bool_state (vrange &r, const vrange &lhs, tree val_type); - -// If the range of either op1 or op2 is undefined, set the result to -// varying and return TRUE. If the caller truly cares about a result, -// they should pass in a varying if it has an undefined that it wants -// treated as a varying. - -inline bool -empty_range_varying (vrange &r, tree type, - const vrange &op1, const vrange & op2) -{ - if (op1.undefined_p () || op2.undefined_p ()) - { - r.set_varying (type); - return true; - } - else - return false; -} - -// For relation opcodes, first try to see if the supplied relation -// forces a true or false result, and return that. -// Then check for undefined operands. If none of this applies, -// return false. - -inline bool -relop_early_resolve (irange &r, tree type, const vrange &op1, - const vrange &op2, relation_trio trio, - relation_kind my_rel) -{ - relation_kind rel = trio.op1_op2 (); - // If known relation is a complete subset of this relation, always true. - if (relation_union (rel, my_rel) == my_rel) - { - r = range_true (type); - return true; - } - - // If known relation has no subset of this relation, always false. - if (relation_intersect (rel, my_rel) == VREL_UNDEFINED) - { - r = range_false (type); - return true; - } - - // If either operand is undefined, return VARYING. - if (empty_range_varying (r, type, op1, op2)) - return true; - - return false; -} - // This implements the range operator tables as local objects. class range_op_table { public: range_operator *operator[] (enum tree_code code); -protected: void set (enum tree_code code, range_operator &op); -private: +protected: range_operator *m_range_tree[MAX_TREE_CODES]; + void initialize_integral_ops (); + void initialize_pointer_ops (); + void initialize_float_ops (); }; @@ -357,8 +307,33 @@ range_op_table::set (enum tree_code code, range_operator &op) m_range_tree[code] = &op; } -// This holds the range op table for floating point operations. -extern range_op_table *floating_tree_table; +// This holds the range op tables + +class integral_table : public range_op_table +{ +public: + integral_table (); +}; +extern integral_table integral_tree_table; + +// Instantiate a range op table for pointer operations. + +class pointer_table : public range_op_table +{ +public: + pointer_table (); +}; +extern pointer_table pointer_tree_table; + +// Instantiate a range_op_table for floating point operations. +class float_table : public range_op_table +{ + public: + float_table (); +}; +extern float_table float_tree_table; + + extern range_operator *ptr_op_widen_mult_signed; extern range_operator *ptr_op_widen_mult_unsigned; -- 2.40.1 From patchwork Sat Jun 10 00:34:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=LAGiFZzb; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJrZ45tyz20Vx for ; Sat, 10 Jun 2023 10:35:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 729BA3856626 for ; Sat, 10 Jun 2023 00:35:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 729BA3856626 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357324; bh=lLN+hqGgVUla0ott/p6iP2jkHsPkqy4l1ht6Z2/GwQ0=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LAGiFZzbeg7/67KpL9UtxTMgjnYxlj3hV1Ywcs0x+So3FGCUyCeYpvsLWLuFhSk7O OVZrHHBFOOXCrb1vpCSULq5YGh4PDbo84Zl3W8he3uMtnjG9bwJtKZJZKclRjamCl8 VogUPn/gfTevDz57sbT/RIPKwUZaTd40S9bxpJeQ= 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 5DBDF385B513 for ; Sat, 10 Jun 2023 00:34:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DBDF385B513 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-479-FSD9KvjlMdKhczigDvG18Q-1; Fri, 09 Jun 2023 20:34:05 -0400 X-MC-Unique: FSD9KvjlMdKhczigDvG18Q-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-62606d7739cso29640876d6.1 for ; Fri, 09 Jun 2023 17:34:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357244; x=1688949244; h=cc:to:subject:from:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qoUU9heIl8EEW0/Spm+M8VWpk+0Xl6S4JKp0/J9zC0g=; b=iTBhJUjYNKWny1LIXMAcWnqdRwF6uySWXvhsJARRkmP3YULNwFLiD2zKijgYXDrwaq fLACIhDmaKJ6A8pJK+dITxmwgVQhHvpltnp3+nVqkHsRP13GCzIOOl5mf2m/P45ORPQb 1lh7+AsxSzUJAEPUk4voPQzOeboXZ2K8AiuMhHOfVJlPi5rmYr5xPE/LpdT6QAlGqryu P/KvJ0z896fVlhpzlr/adY8fNA5wUSSgZcWDOG0CH/bgkMxyfZ3cXog2DqCcLSskrjKz vvAhCnDUTEH4jusFAXteZTyeG0JUA/nMT6PEQ4c6nabjlaC4+85WNRew0TNEfQ1BToXX tPag== X-Gm-Message-State: AC+VfDzVIP7GfkzGZ83OIWnbExoyzkcmI/ea27OwLLPSypxtq3EFSDVy r/oNTWhtyy41Y3mf33EoMCVWS566Tlc8B5Mt0tZMFkfhLQpO1qgbBpGKn03f3BUp+uayc3hAZMU qj0ilWCPOG2sx1xqfVUOrO/ITQc7WsAuDbiatNBY3R9T/k5VsUG8EZVLt0DUTJsyfcR7L0YWlJk xlKA== X-Received: by 2002:a05:6214:230c:b0:61f:ace6:e94e with SMTP id gc12-20020a056214230c00b0061face6e94emr3453603qvb.0.1686357244319; Fri, 09 Jun 2023 17:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6v4dMtCxjhvoD7VrBJEiotFlk4opjA3hmTiCKWrqvlE1B5l4e+GnFhufZ0qQq+5pZt9UnyCQ== X-Received: by 2002:a05:6214:230c:b0:61f:ace6:e94e with SMTP id gc12-20020a056214230c00b0061face6e94emr3453588qvb.0.1686357243952; Fri, 09 Jun 2023 17:34:03 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id o11-20020a0ccb0b000000b006262725bc89sm1501765qvk.73.2023.06.09.17.34.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:03 -0700 (PDT) Message-ID: <567ecdbc-5607-82a4-e547-3d46367785f2@redhat.com> Date: Fri, 9 Jun 2023 20:34:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: [PATCH 2/15] Unify EQ_EXPR range operator. To: gcc-patches Cc: "hernandez, aldy" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify the EQ_EXPR opcode Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From 684959c5c058c2368e65c4c308a2cb3e3912782e Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:18:39 -0400 Subject: [PATCH 02/31] Unify EQ_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_equal): Remove. Move prototypes to range-op-mixed.h (operator_equal::fold_range): Rename from foperator_equal. (operator_equal::op1_range): Ditto. (float_table::float_table): Remove EQ_EXPR. * range-op-mixed.h (class operator_equal): Combined from integer and float files. * range-op.cc (op_equal): New object. (unified_table::unified_table): Add EQ_EXPR. (class operator_equal): Move to range-op-mixed.h. (equal_op1_op2_relation): Fold into operator_equal::op1_op2_relation. (integral_table::integral_table): Remove EQ_EXPR. (pointer_table::pointer_table): Remove EQ_EXPR. * range-op.h (equal_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 41 ++++++++++++--------------------------- gcc/range-op-mixed.h | 37 +++++++++++++++++++++++++++++++++++ gcc/range-op.cc | 45 +++++++++++++------------------------------ gcc/range-op.h | 1 - 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 8659217659c..98636cec8cf 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -563,35 +563,18 @@ public: public: } fop_identity; -class foperator_equal : public range_operator +bool +operator_equal::op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio rel) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return equal_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio rel = TRIO_VARYING) const final override - { - return op1_range (r, type, lhs, op1, rel.swap_op1_op2 ()); - } -} fop_equal; + return op1_range (r, type, lhs, op1, rel.swap_op1_op2 ()); +} bool -foperator_equal::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_equal::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_EQ)) return true; @@ -644,7 +627,7 @@ foperator_equal::fold_range (irange &r, tree type, } bool -foperator_equal::op1_range (frange &r, tree type, +operator_equal::op1_range (frange &r, tree type, const irange &lhs, const frange &op2, relation_trio trio) const @@ -2021,7 +2004,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_equal.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (EQ_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2819,7 +2803,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (EQ_EXPR, fop_equal); set (NE_EXPR, fop_not_equal); set (LT_EXPR, fop_lt); set (LE_EXPR, fop_le); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index a78bc2ba59c..79e2cbd8532 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -75,4 +75,41 @@ relop_early_resolve (irange &r, tree type, const vrange &op1, return false; } +// ---------------------------------------------------------------------- +// Mixed Mode Operators. +// ---------------------------------------------------------------------- + +class operator_equal : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &val, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &val, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio rel = TRIO_VARYING) const final override; + + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 4e00c9f439e..e85560a6ab5 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -60,6 +60,10 @@ class unified_table : public range_op_table unified_table (); } unified_tree_table; +// Instantiate the operators which apply to multiple types here. + +operator_equal op_equal; + // Invoke the initialization routines for each class of range. unified_table::unified_table () @@ -67,6 +71,8 @@ unified_table::unified_table () initialize_integral_ops (); initialize_pointer_ops (); initialize_float_ops (); + + set (EQ_EXPR, op_equal); } // The tables are hidden and accessed via a simple extern function. @@ -819,35 +825,19 @@ get_bool_state (vrange &r, const vrange &lhs, tree val_type) return BRS_TRUE; } +// ------------------------------------------------------------------------ -class operator_equal : public range_operator +void +operator_equal::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &val, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &val, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, EQ_EXPR, lh, rh); } -} op_equal; + update_known_bitmask (r, EQ_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -equal_op1_op2_relation (const irange &lhs) +operator_equal::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -862,13 +852,6 @@ equal_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_equal::op1_op2_relation (const irange &lhs) const -{ - return equal_op1_op2_relation (lhs); -} - - bool operator_equal::fold_range (irange &r, tree type, const irange &op1, @@ -4883,7 +4866,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); @@ -4937,7 +4919,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); diff --git a/gcc/range-op.h b/gcc/range-op.h index 0721d4a302d..61f2ac16643 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind equal_op1_op2_relation (const irange &lhs); relation_kind not_equal_op1_op2_relation (const irange &lhs); relation_kind lt_op1_op2_relation (const irange &lhs); relation_kind le_op1_op2_relation (const irange &lhs); -- 2.40.1 From patchwork Sat Jun 10 00:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=ikD3kT6f; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJqp5plnz20Wg for ; Sat, 10 Jun 2023 10:34:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1D35385662F for ; Sat, 10 Jun 2023 00:34:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1D35385662F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357284; bh=uosxOQ7wsaSmMTqxFEhOniLNXnsp/QptQIfeb2p0syY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ikD3kT6fblLxIEwxEzQ2DXKWZLMaxDLNgZ15qFSt2v6EhjpmMwJoingX2TbNLpW+G Wr5H35pJz3bAzXcTz4FdKFBgXgyQTSgGSQG+Bdol94M5ZMBfcUiZHR3mHV7+bJCI7l Iu11zO3fEXEJf3kO4r9Je30rCoTHmkR9YhimT/QM= 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 851F83856611 for ; Sat, 10 Jun 2023 00:34:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 851F83856611 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-9IBmnS1lMY2xhbBF-C_P3w-1; Fri, 09 Jun 2023 20:34:12 -0400 X-MC-Unique: 9IBmnS1lMY2xhbBF-C_P3w-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6262e6c3b44so29529386d6.0 for ; Fri, 09 Jun 2023 17:34:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357252; x=1688949252; 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=hEpFMjo1k/avH0qlDpaSMpgFJ8ME7udrRKJmHwzfFFk=; b=EUXVZ8egCwllW89kAou1AkpBmm2GD0XSXYOVVX3xaZJias4xLpu7LFvvXymqlmERrj ylrrPzaEWtwg6lTmGxunTKajNUgeTLeb9a/a5hSVDeU1w9Ms6TxdezAz5JJiT1hAD7Dl CYhbLG7bTr6Gq8IH7wiauKQgVwSXvYWANTAOXOKBnPpYjv3hSajIVbZuLa+PTYzqmEzc k2MWWl1AyNhMJ2ZghmFy0kSsb1CN4euZrr/5nFnSaKfQRQ8VQlelMYKhiD/FgV/1ImME ceFAw5T1Cg1v41V1fkEeBfy+UzV4Cxsz7EMML/PULQz36wC/Fy2l1RL1ikvcY+zpP1d0 RxyQ== X-Gm-Message-State: AC+VfDyyGdA96mnodxi915ZA6bx9zfYC5StV216xhzAmn4+AZCWOW9ZI JJ5zEnv6yvDwNsLlWD4JSbWtbNX1EN0BIf15/DtE525vnhzwN88FN5wHsj5V89uJLYihxHe1Km0 wZhqd7nVer1a8+gDVH6oIvWmOGm0Td1TQysZs7e2jN94pfnNQaApktjhHwJqNY2+YS+DQR95S1l ODOQ== X-Received: by 2002:a05:6214:500b:b0:626:2668:8b9f with SMTP id jo11-20020a056214500b00b0062626688b9fmr3905217qvb.41.1686357252023; Fri, 09 Jun 2023 17:34:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Jh241zOlIJZ6y8bZSoOuAOciXeOrmnqmd258TjTgYuAtG2EkvBIK5JqlswfwW/ehuA3qX6w== X-Received: by 2002:a05:6214:500b:b0:626:2668:8b9f with SMTP id jo11-20020a056214500b00b0062626688b9fmr3905204qvb.41.1686357251710; Fri, 09 Jun 2023 17:34:11 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id n13-20020a05620a152d00b0075ebbd60771sm1368161qkk.84.2023.06.09.17.34.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:11 -0700 (PDT) Message-ID: Date: Fri, 9 Jun 2023 20:34:10 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 3/15] Unify NE_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US 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, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify the NE_EXPR opcode Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From cb409a3b3367109944ff332899ec401dc60f678c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:25:49 -0400 Subject: [PATCH 03/31] Unify NE_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_not_equal): Remove. Move prototypes to range-op-mixed.h (operator_equal::fold_range): Rename from foperator_not_equal. (operator_equal::op1_range): Ditto. (float_table::float_table): Remove NE_EXPR. * range-op-mixed.h (class operator_not_equal): Combined from integer and float files. * range-op.cc (op_equal): New object. (unified_table::unified_table): Add NE_EXPR. (class operator_not_equal): Move to range-op-mixed.h. (not_equal_op1_op2_relation): Fold into operator_not_equal::op1_op2_relation. (integral_table::integral_table): Remove NE_EXPR. (pointer_table::pointer_table): Remove NE_EXPR. * range-op.h (not_equal_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 36 +++++++++--------------------------- gcc/range-op-mixed.h | 29 +++++++++++++++++++++++++++++ gcc/range-op.cc | 41 ++++++++++------------------------------- gcc/range-op.h | 1 - 4 files changed, 48 insertions(+), 59 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 98636cec8cf..ec24167a8c5 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -675,28 +675,10 @@ operator_equal::op1_range (frange &r, tree type, return true; } -class foperator_not_equal : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return not_equal_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; -} fop_not_equal; - bool -foperator_not_equal::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_not_equal::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_NE)) return true; @@ -750,10 +732,10 @@ foperator_not_equal::fold_range (irange &r, tree type, } bool -foperator_not_equal::op1_range (frange &r, tree type, - const irange &lhs, - const frange &op2, - relation_trio trio) const +operator_not_equal::op1_range (frange &r, tree type, + const irange &lhs, + const frange &op2, + relation_trio trio) const { relation_kind rel = trio.op1_op2 (); switch (get_bool_state (r, lhs, type)) @@ -2086,7 +2068,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_not_equal.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (NE_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2803,7 +2786,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (NE_EXPR, fop_not_equal); set (LT_EXPR, fop_lt); set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 79e2cbd8532..03a988d9c8a 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -112,4 +112,33 @@ public: const irange &rh) const final override; }; +class operator_not_equal : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel = TRIO_VARYING) const final override; + + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const final override; + + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index e85560a6ab5..1bea4af101d 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -63,6 +63,7 @@ class unified_table : public range_op_table // Instantiate the operators which apply to multiple types here. operator_equal op_equal; +operator_not_equal op_not_equal; // Invoke the initialization routines for each class of range. @@ -73,6 +74,7 @@ unified_table::unified_table () initialize_float_ops (); set (EQ_EXPR, op_equal); + set (NE_EXPR, op_not_equal); } // The tables are hidden and accessed via a simple extern function. @@ -926,34 +928,19 @@ operator_equal::op2_range (irange &r, tree type, return operator_equal::op1_range (r, type, lhs, op1, rel.swap_op1_op2 ()); } -class operator_not_equal : public range_operator +// ------------------------------------------------------------------------- + +void +operator_not_equal::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, NE_EXPR, lh, rh); } -} op_not_equal; + update_known_bitmask (r, NE_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -not_equal_op1_op2_relation (const irange &lhs) +operator_not_equal::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -968,12 +955,6 @@ not_equal_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_not_equal::op1_op2_relation (const irange &lhs) const -{ - return not_equal_op1_op2_relation (lhs); -} - bool operator_not_equal::fold_range (irange &r, tree type, const irange &op1, @@ -4866,7 +4847,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); @@ -4919,7 +4899,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); diff --git a/gcc/range-op.h b/gcc/range-op.h index 61f2ac16643..8ab5f414147 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind not_equal_op1_op2_relation (const irange &lhs); relation_kind lt_op1_op2_relation (const irange &lhs); relation_kind le_op1_op2_relation (const irange &lhs); relation_kind gt_op1_op2_relation (const irange &lhs); -- 2.40.1 From patchwork Sat Jun 10 00:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=qJjNl5Cg; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJr02l8Bz20Wg for ; Sat, 10 Jun 2023 10:34:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E0953856092 for ; Sat, 10 Jun 2023 00:34:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E0953856092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357294; bh=ymRJ2Q8lL6s1fr/qKcVWwadx9usvrPqPVMq7c5GlK/I=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qJjNl5CgzjAprmY2rCLNVOI7BB7Il3qdCLIIDrESY4cgu8EmiaKGUHTcA57/dfY+/ +T3mNQsEerwSdwjBovovasUF0F+1JPmfXIJ026Hrq+fD2zzmEIBvHOhkULNhxNa0o3 wxFUxOshuf0KdX5rA4UXr2cTSnKuguEAKDC2iG+M= 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 9082E3858D3C for ; Sat, 10 Jun 2023 00:34:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9082E3858D3C Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-cxJKWqhPPvOtYHUSHZN7Hg-1; Fri, 09 Jun 2023 20:34:23 -0400 X-MC-Unique: cxJKWqhPPvOtYHUSHZN7Hg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-75d0a182bdfso329440485a.3 for ; Fri, 09 Jun 2023 17:34:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357262; x=1688949262; 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=HIo0vJUA8jbjFL9E6R+uJ7gn/dh7YOykOyKlDQPbZGo=; b=adRLoKYvd9epg0mBAc5QvsdeuLPzKD/fnyLTogoG5hydYb1BuBVeAfh5LwFpd0mmO3 ucbZuAC1S8K4gbcX1aweCzljY2UQ9WXX9iS/gUdwqtstet5Bub43aVF9lSzU5BY/8pqc hX2XgT9eCDNd29h5Y60zQL4xoZVUloy1cx3liGS+ygSdlqYhZCmNZd3gXINYG9IUshj8 MmjxcjA1TPidVT8B44UTxZTW5GdqZYhChBd7dyfzxFPyKKzjBv2jfTNv6vBsS7FXlylb zkc8evehfpLAgl5agD8VnrgFnMyMRUD6ukY51+R2hz4+yn0/ZnVYtGzHKDrYNtL2chcq IAPg== X-Gm-Message-State: AC+VfDxgo6oTBPhY0+Uc2IGeBEfN4qZZ0ZvLtnvGHG1S1Gz8gPQi5xLR 4xAxWO91AOzshKdUF2rSCsB3wiCFmzozL3rjtaC4E/PSxeU1V3GHyqGUDtivYjXuCcnKXz/9p1c Bs0mi/mGLapCBHpgYZmooOQ+1IlGBoveNKd+ZTQx33suPVJRP/o4Hei4uVBzIkDpyVF8R8lKghu fAvQ== X-Received: by 2002:a05:620a:2454:b0:75b:23a0:de9b with SMTP id h20-20020a05620a245400b0075b23a0de9bmr3693120qkn.25.1686357262790; Fri, 09 Jun 2023 17:34:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7StHytCOJwym/vhnO95v4TykHwjzeVtg77pWcmitVIPBcWHYDcQB2c3oTwLJyTAucHNvzvbA== X-Received: by 2002:a05:620a:2454:b0:75b:23a0:de9b with SMTP id h20-20020a05620a245400b0075b23a0de9bmr3693106qkn.25.1686357262451; Fri, 09 Jun 2023 17:34:22 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id s27-20020a05620a031b00b007592f2016f4sm1367473qkm.110.2023.06.09.17.34.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:22 -0700 (PDT) Message-ID: <84ed3426-9b27-e0e1-d20a-ad9ce8224e03@redhat.com> Date: Fri, 9 Jun 2023 20:34:21 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 4/15] Unify LT_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify the LT_EXPR opcode Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From f7c1366a89edf1ffdd9c495cff544358f2ff395e Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:29:15 -0400 Subject: [PATCH 04/31] Unify LT_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_lt): Remove. Move prototypes to range-op-mixed.h (operator_lt::fold_range): Rename from foperator_lt. (operator_lt::op1_range): Ditto. (float_table::float_table): Remove LT_EXPR. * range-op-mixed.h (class operator_lt): Combined from integer and float files. * range-op.cc (op_lt): New object. (unified_table::unified_table): Add LT_EXPR. (class operator_lt): Move to range-op-mixed.h. (lt_op1_op2_relation): Fold into operator_lt::op1_op2_relation. (integral_table::integral_table): Remove LT_EXPR. (pointer_table::pointer_table): Remove LT_EXPR. * range-op.h (lt_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 52 +++++++++++++------------------------------ gcc/range-op-mixed.h | 30 +++++++++++++++++++++++++ gcc/range-op.cc | 39 +++++++------------------------- gcc/range-op.h | 1 - 4 files changed, 53 insertions(+), 69 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index ec24167a8c5..1b0ac9a7fc2 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -779,32 +779,10 @@ operator_not_equal::op1_range (frange &r, tree type, return true; } -class foperator_lt : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return lt_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio = TRIO_VARYING) const final override; -} fop_lt; - bool -foperator_lt::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_lt::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_LT)) return true; @@ -822,11 +800,11 @@ foperator_lt::fold_range (irange &r, tree type, } bool -foperator_lt::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_lt::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -859,11 +837,11 @@ foperator_lt::op1_range (frange &r, } bool -foperator_lt::op2_range (frange &r, - tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_lt::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1547,7 +1525,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_lt.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (LT_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2786,7 +2765,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (LT_EXPR, fop_lt); set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 03a988d9c8a..bc93ab5be06 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -141,4 +141,34 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_lt : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio = TRIO_VARYING) const final override; + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 1bea4af101d..13877999847 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -64,6 +64,7 @@ class unified_table : public range_op_table operator_equal op_equal; operator_not_equal op_not_equal; +operator_lt op_lt; // Invoke the initialization routines for each class of range. @@ -75,6 +76,7 @@ unified_table::unified_table () set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); + set (LT_EXPR, op_lt); } // The tables are hidden and accessed via a simple extern function. @@ -1090,34 +1092,17 @@ build_ge (irange &r, tree type, const wide_int &val) } -class operator_lt : public range_operator +void +operator_lt::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, LT_EXPR, lh, rh); } -} op_lt; + update_known_bitmask (r, LT_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -lt_op1_op2_relation (const irange &lhs) +operator_lt::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1132,12 +1117,6 @@ lt_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_lt::op1_op2_relation (const irange &lhs) const -{ - return lt_op1_op2_relation (lhs); -} - bool operator_lt::fold_range (irange &r, tree type, const irange &op1, @@ -4847,7 +4826,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); @@ -4899,7 +4877,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); diff --git a/gcc/range-op.h b/gcc/range-op.h index 8ab5f414147..df1d8871b53 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind lt_op1_op2_relation (const irange &lhs); relation_kind le_op1_op2_relation (const irange &lhs); relation_kind gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs); -- 2.40.1 From patchwork Sat Jun 10 00:34:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=A/Y2lN7w; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJtY4L92z20Vx for ; Sat, 10 Jun 2023 10:37:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F74D3839DD8 for ; Sat, 10 Jun 2023 00:37:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F74D3839DD8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357427; bh=Q/50PpMlLhgDX1FRjSFJBk8aI5MCIzGeQwDqgzj5ENg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=A/Y2lN7w4rkEuAmqrL7jna6HOSH1+zWCxjrS34jDFgr+MqvScw/ttZVzQMRvdXYby VXNhJ4o0GlWjxijTA5ZMpJLPqqhWG+/imTcdE/7gsuuPL0g9exysjczPCpR2KdwqRW /YZJ0I6SRlKcE7HzkHak++NeJhj7u7/ieWXZmd44= 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 807C43858408 for ; Sat, 10 Jun 2023 00:34:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 807C43858408 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-675-SRxOgyqGP2qiKg0f-Wg3YA-1; Fri, 09 Jun 2023 20:34:35 -0400 X-MC-Unique: SRxOgyqGP2qiKg0f-Wg3YA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-75d5588d7e9so327808085a.1 for ; Fri, 09 Jun 2023 17:34:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357275; x=1688949275; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=99e7jgKYAzbnZ1Wwfvhwm8FpsbGOHWHrT0xeq+mjHps=; b=Ss7NuXObVrXIg4G3gnF6ZWyJpSExJg/2ccGXHhMPPDG4pgIFGK9/FB7DpL1kCXImfQ ZBRCsxI1HRfidCFMm32hhqy8XDgdMR78jmJOAUFYV11osRZRT7XpaHzy0A5bbr6UZZo0 G3q5T/3eHIMW+woc85kDf1XdtOSKlGxpGfOMIOKbQsModDNFfoYvc5TiFhjzwUAKcEqn trkQhYopX3H62c9RsQRZuxiK2onaHdw5jGxqotJtuslJPUyosB8gSbLbHMpDFpnknBsx MTt3GwGCh768cxnUqoN/Tas5pnP8wChiYmJHn+TsjhbvLGz57ZqtBHlL7nGtDBdHSLzQ iTgw== X-Gm-Message-State: AC+VfDz5GVuoq4WupcjuG8c+/8Se/f+lDGCXygWRhhQSUNSn4WxRtJE6 JDbZQdZ/Rl6890K/jqlZ/fWlou/RGU6lvAQTkJoFF3sMkcvSGoG26/R3yvWHoMj7Ao8Y2Ryo7xR 4nZH4egoHTQvSjJvYW/UdPoPbabF6rn7Du4xFZJdA+kxYvAWA/dZMaABoRu+/jjfm+tqzCk7c+1 N7ig== X-Received: by 2002:a05:620a:2a16:b0:75e:b9e1:876d with SMTP id o22-20020a05620a2a1600b0075eb9e1876dmr3531984qkp.75.1686357274994; Fri, 09 Jun 2023 17:34:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WlEbS3FYNkMfLZcW6rFD9N/NDShiRrWhbNXrC+JeM279tpCTpRBunBf39zRbLosAOT1Jhfw== X-Received: by 2002:a05:620a:2a16:b0:75e:b9e1:876d with SMTP id o22-20020a05620a2a1600b0075eb9e1876dmr3531971qkp.75.1686357274623; Fri, 09 Jun 2023 17:34:34 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id m14-20020a05620a13ae00b0075da00ef114sm1377241qki.46.2023.06.09.17.34.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:34 -0700 (PDT) Message-ID: <2078a799-12da-356b-3802-4e8fdd09614e@redhat.com> Date: Fri, 9 Jun 2023 20:34:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Subject: [COMMITTED 5/15] Unify LE_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify the LE_EXPR opcode. Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From 9de70a61ca83d50c35f73eafaaa7276d8f0ad211 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:30:56 -0400 Subject: [PATCH 05/31] Unify LE_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_le): Remove. Move prototypes to range-op-mixed.h (operator_le::fold_range): Rename from foperator_le. (operator_le::op1_range): Ditto. (float_table::float_table): Remove LE_EXPR. * range-op-mixed.h (class operator_le): Combined from integer and float files. * range-op.cc (op_le): New object. (unified_table::unified_table): Add LE_EXPR. (class operator_le): Move to range-op-mixed.h. (le_op1_op2_relation): Fold into operator_le::op1_op2_relation. (integral_table::integral_table): Remove LE_EXPR. (pointer_table::pointer_table): Remove LE_EXPR. * range-op.h (le_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 52 +++++++++++++------------------------------ gcc/range-op-mixed.h | 33 +++++++++++++++++++++++++++ gcc/range-op.cc | 39 +++++++------------------------- gcc/range-op.h | 1 - 4 files changed, 56 insertions(+), 69 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 1b0ac9a7fc2..a480f1641d2 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -873,32 +873,10 @@ operator_lt::op2_range (frange &r, return true; } -class foperator_le : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return le_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio rel = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio rel = TRIO_VARYING) const final override; -} fop_le; - bool -foperator_le::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_le::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_LE)) return true; @@ -916,11 +894,11 @@ foperator_le::fold_range (irange &r, tree type, } bool -foperator_le::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_le::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -949,11 +927,11 @@ foperator_le::op1_range (frange &r, } bool -foperator_le::op2_range (frange &r, - tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_le::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1637,7 +1615,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_le.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (LE_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2765,7 +2744,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (LE_EXPR, fop_le); set (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index bc93ab5be06..dd42d98ca49 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -171,4 +171,37 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_le : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel = TRIO_VARYING) const final override; + + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio rel = TRIO_VARYING) const final override; + + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio rel = TRIO_VARYING) const final override; + + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 13877999847..c2e9927e774 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -65,6 +65,7 @@ class unified_table : public range_op_table operator_equal op_equal; operator_not_equal op_not_equal; operator_lt op_lt; +operator_le op_le; // Invoke the initialization routines for each class of range. @@ -77,6 +78,7 @@ unified_table::unified_table () set (EQ_EXPR, op_equal); set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); + set (LE_EXPR, op_le); } // The tables are hidden and accessed via a simple extern function. @@ -1192,34 +1194,17 @@ operator_lt::op2_range (irange &r, tree type, } -class operator_le : public range_operator +void +operator_le::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, LE_EXPR, lh, rh); } -} op_le; + update_known_bitmask (r, LE_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -le_op1_op2_relation (const irange &lhs) +operator_le::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1234,12 +1219,6 @@ le_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_le::op1_op2_relation (const irange &lhs) const -{ - return le_op1_op2_relation (lhs); -} - bool operator_le::fold_range (irange &r, tree type, const irange &op1, @@ -4826,7 +4805,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); set (PLUS_EXPR, op_plus); @@ -4877,7 +4855,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); set (SSA_NAME, op_ident); diff --git a/gcc/range-op.h b/gcc/range-op.h index df1d8871b53..7d24b43a80e 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind le_op1_op2_relation (const irange &lhs); relation_kind gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs); -- 2.40.1 From patchwork Sat Jun 10 00:34:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=lYJlgEQy; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJvr2l3Gz20Vx for ; Sat, 10 Jun 2023 10:38:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 487A8382798A for ; Sat, 10 Jun 2023 00:38:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 487A8382798A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357494; bh=yv7SsJSYN/j0UCqTfwnp14bhkMmdDmtMyTgrOCWxpMY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lYJlgEQyyAVBGa/UmoRy5XyTNvcKLLEy7Gm3Pe4J3Uo3PJfg/5KMA7oartFg7C69c IzK1zVOp/i2OcQRR6m96/ldE/rZfanhYTWOWLOOOk6ps1x8IOW45VZdZPKvVNV75Fo vV0a5/AmTMjAfnw8HspQuWbgAyc+8S2Fm766GfsM= 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 0B42C3854E5F for ; Sat, 10 Jun 2023 00:34:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B42C3854E5F Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-oyLeZoHaMvmSXliO3FXgpg-1; Fri, 09 Jun 2023 20:34:50 -0400 X-MC-Unique: oyLeZoHaMvmSXliO3FXgpg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-3f9a53add26so19595231cf.0 for ; Fri, 09 Jun 2023 17:34:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357289; x=1688949289; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u1D3qLB9iMen2OSCPUekgtnxMFOFomuGkeNxOcMJYWY=; b=dMfkLv8tuQbkjuFrqDgTFpkkAEy/Mxfkaxuet9PkWmPk/BULbfIF/OmLELecW8H+pe 0cp3d66o84gbWbaNLp4Tm4BArymv8RKOGzYZxqC/lpMcPFtXAhTsL2o8ZuPNi+H1KaJP jvKToqmXo03FU681ayTzbWWFCwPlbHDWZTefDZE34XHHpmTtK4PAlK9yn9K2xpGJh6Mu xneMu6jHYQIXxVewuO079cazn8NX8lb+g1h4Kp8ndfSBTLVJsG/lyet0A5275U/yO7Oh T1zEeJ3n2s5MjIOx/bWDdZLxrZyy0bQEI3IXLos8xZsRrN0hq0NcksDw92H3N7q3u29R mr2Q== X-Gm-Message-State: AC+VfDy9eWfpNonBlgtdNcpic9LXpAIasybrx3U2ncdsbUn5vzXyAKAh jgcCbUvxME7/zj+M81C+souvL3NCmOydRwyAF1siadNVG9+/yNlRiSawLqCUD0TVDfcbx+NPxGR iK1ZSV12wDVI3COBs0IKvfuI2kUYgoSbwSMMq3RIjo5WfHd2qpVlCgPi6bQNgH/eo4xHDzpjRhh HHBg== X-Received: by 2002:a05:622a:508:b0:3f5:713:adb4 with SMTP id l8-20020a05622a050800b003f50713adb4mr4220493qtx.18.1686357289336; Fri, 09 Jun 2023 17:34:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7vqsYBm8jyiSPOMDY3rp14XxJkW1ZdcuPKif0D/Wj4//2N6HFcyKskEAiT2NJCC1BPDEP4Nw== X-Received: by 2002:a05:622a:508:b0:3f5:713:adb4 with SMTP id l8-20020a05622a050800b003f50713adb4mr4220484qtx.18.1686357289012; Fri, 09 Jun 2023 17:34:49 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id i6-20020ac84886000000b003f6bbd7863csm1545227qtq.86.2023.06.09.17.34.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:34:48 -0700 (PDT) Message-ID: <2d656c9e-010c-53c3-874e-5a409f7681a8@redhat.com> Date: Fri, 9 Jun 2023 20:34:47 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches , "hernandez, aldy" Subject: [COMMITTED 6/15] Unify GT_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify GT_EXPR the  range operator Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From e5a4bb7c12d00926e0c7bbf0c77dd1be8f23a39a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:32:25 -0400 Subject: [PATCH 06/31] Unify GT_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_gt): Remove. Move prototypes to range-op-mixed.h (operator_gt::fold_range): Rename from foperator_gt. (operator_gt::op1_range): Ditto. (float_table::float_table): Remove GT_EXPR. * range-op-mixed.h (class operator_gt): Combined from integer and float files. * range-op.cc (op_gt): New object. (unified_table::unified_table): Add GT_EXPR. (class operator_gt): Move to range-op-mixed.h. (gt_op1_op2_relation): Fold into operator_gt::op1_op2_relation. (integral_table::integral_table): Remove GT_EXPR. (pointer_table::pointer_table): Remove GT_EXPR. * range-op.h (gt_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 52 +++++++++++++------------------------------ gcc/range-op-mixed.h | 31 ++++++++++++++++++++++++++ gcc/range-op.cc | 40 +++++++-------------------------- gcc/range-op.h | 1 - 4 files changed, 54 insertions(+), 70 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index a480f1641d2..2f090e75245 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -961,32 +961,10 @@ operator_le::op2_range (frange &r, return true; } -class foperator_gt : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return gt_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio = TRIO_VARYING) const final override; -} fop_gt; - bool -foperator_gt::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_gt::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_GT)) return true; @@ -1004,11 +982,11 @@ foperator_gt::fold_range (irange &r, tree type, } bool -foperator_gt::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_gt::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1043,11 +1021,11 @@ foperator_gt::op1_range (frange &r, } bool -foperator_gt::op2_range (frange &r, - tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_gt::op2_range (frange &r, + tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1723,7 +1701,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_gt.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (GT_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2744,7 +2723,6 @@ float_table::float_table () // All the relational operators are expected to work, because the // calculation of ranges on outgoing edges expect the handlers to be // present. - set (GT_EXPR, fop_gt); set (GE_EXPR, fop_ge); set (ABS_EXPR, fop_abs); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index dd42d98ca49..1c68d54b085 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -204,4 +204,35 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_gt : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio = TRIO_VARYING) const final override; + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, const irange &rh) const; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index c2e9927e774..e971bf4cd33 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -66,6 +66,7 @@ operator_equal op_equal; operator_not_equal op_not_equal; operator_lt op_lt; operator_le op_le; +operator_gt op_gt; // Invoke the initialization routines for each class of range. @@ -79,6 +80,7 @@ unified_table::unified_table () set (NE_EXPR, op_not_equal); set (LT_EXPR, op_lt); set (LE_EXPR, op_le); + set (GT_EXPR, op_gt); } // The tables are hidden and accessed via a simple extern function. @@ -1291,34 +1293,17 @@ operator_le::op2_range (irange &r, tree type, } -class operator_gt : public range_operator +void +operator_gt::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, GT_EXPR, lh, rh); } -} op_gt; + update_known_bitmask (r, GT_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -gt_op1_op2_relation (const irange &lhs) +operator_gt::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1333,13 +1318,6 @@ gt_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_gt::op1_op2_relation (const irange &lhs) const -{ - return gt_op1_op2_relation (lhs); -} - - bool operator_gt::fold_range (irange &r, tree type, const irange &op1, const irange &op2, @@ -4805,7 +4783,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); set (PLUS_EXPR, op_plus); set (MINUS_EXPR, op_minus); @@ -4855,7 +4832,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); set (SSA_NAME, op_ident); set (INTEGER_CST, op_integer_cst); diff --git a/gcc/range-op.h b/gcc/range-op.h index 7d24b43a80e..411ab5e4a0a 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,7 +266,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &mustbe_nonzero); // op1_op2_relation methods that are the same across irange and frange. -relation_kind gt_op1_op2_relation (const irange &lhs); relation_kind ge_op1_op2_relation (const irange &lhs); // This implements the range operator tables as local objects. -- 2.40.1 From patchwork Sat Jun 10 00:35:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=rbPE3iCL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJsW1Bxkz20Vx for ; Sat, 10 Jun 2023 10:36:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CFC3385C6CD for ; Sat, 10 Jun 2023 00:36:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CFC3385C6CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357373; bh=z30wSZIXjci25pP/33Yryu3Zyhda91n754yHA10pwws=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rbPE3iCLj3larHzOwL+QitFToKzOPqyFxtWw4n+JLUY+UkpjleDwQ/UigZWrZJrGB q4wt0LQ4YUJx322bcaB7kMC9ihNSoCtlHedIht88TXFqK9FH/IioBaguEQBb5KTQSr WxtZDDMJvteLQaaeOoZ+IYPEVpkgK1yOk9XxWfHw= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 22D7A3853D2E for ; Sat, 10 Jun 2023 00:35:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22D7A3853D2E Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-FPeJDyWqPQ6aBHjvHu0SSg-1; Fri, 09 Jun 2023 20:35:04 -0400 X-MC-Unique: FPeJDyWqPQ6aBHjvHu0SSg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f9e2f5a2b4so5309121cf.1 for ; Fri, 09 Jun 2023 17:35:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357303; x=1688949303; 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=IaSMTR0kccsFCwr/zasK1Dx7v36PhqAPEwo84nu5ugg=; b=g3ktvrtsBRVxE4X8VK0TjcBz1MD2lFhMbvMSaoqcNdw99ek3vWcrusAnunbEm4HyhZ C2Vupbt0fFddlzu3tTyRXlctI5sE+qfVyLdC2ARxuANKjRe5owOVQvcWfiF1FTK+/EEh bvSrgDdRDI2QXWb3NXQKS3vIZmea9HxelksOy/66y+nvC0JFSr6SukS7ZwkZ516J0+eY W53n58bjYW8IwyZ9t9fQqd6zbllGryWBLUO+cVtslHLajZ5sZ4aYlW1iAoelS847y1rX +L8wC6faW1fvuocT5+p6pzdEkZulqi1EtpmY9/84ISGjN3ch00lJDjri1VR+MJxGCYUd ijWg== X-Gm-Message-State: AC+VfDyp80Cs2DE3AKoRlIou1LnPU6h2GnM3mLabmeE0XgDlRSYnukz6 H27rPwJq5L932m3LrWbSpbRV47Y6LY6DyMCDKeAorlcu74jnx3FeQ9whSh2KP/FC3+rsrtGV6wk /X089GA5gFX6A3pN1L/v2qBbKPV1uTgMstoTlDn03T+Alc9rQ+W7pt8DQCwIbN1BT92zFOgKfiV M9Zg== X-Received: by 2002:a05:622a:448:b0:3f2:31e:e783 with SMTP id o8-20020a05622a044800b003f2031ee783mr3254647qtx.50.1686357302960; Fri, 09 Jun 2023 17:35:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7M3PC5rHXE0HXtHvhYSb6MD8rhW64Iwnerz6Mcn39I+79qrte7izCa1LzRiWYBExTjYPjkJA== X-Received: by 2002:a05:622a:448:b0:3f2:31e:e783 with SMTP id o8-20020a05622a044800b003f2031ee783mr3254636qtx.50.1686357302694; Fri, 09 Jun 2023 17:35:02 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id cb5-20020a05622a1f8500b003e388264753sm1564008qtb.65.2023.06.09.17.35.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:35:02 -0700 (PDT) Message-ID: <08fec1b6-91e9-e7bc-3122-9529ebf1f862@redhat.com> Date: Fri, 9 Jun 2023 20:35:01 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 7/15] Unify GE_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Unify GE_EXPR the range operator Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From 364b936b8d82e86c73b2b964d4c8a2c16dcbedf8 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:33:33 -0400 Subject: [PATCH 07/31] Unify GE_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_ge): Remove. Move prototypes to range-op-mixed.h (operator_ge::fold_range): Rename from foperator_ge. (operator_ge::op1_range): Ditto. (float_table::float_table): Remove GE_EXPR. * range-op-mixed.h (class operator_ge): Combined from integer and float files. * range-op.cc (op_ge): New object. (unified_table::unified_table): Add GE_EXPR. (class operator_ge): Move to range-op-mixed.h. (ge_op1_op2_relation): Fold into operator_ge::op1_op2_relation. (integral_table::integral_table): Remove GE_EXPR. (pointer_table::pointer_table): Remove GE_EXPR. * range-op.h (ge_op1_op2_relation): Delete. --- gcc/range-op-float.cc | 54 +++++++++++-------------------------------- gcc/range-op-mixed.h | 33 ++++++++++++++++++++++++++ gcc/range-op.cc | 39 +++++++------------------------ gcc/range-op.h | 3 --- 4 files changed, 55 insertions(+), 74 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 2f090e75245..4faca62c48f 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -1059,32 +1059,10 @@ operator_gt::op2_range (frange &r, return true; } -class foperator_ge : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - bool fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - relation_kind op1_op2_relation (const irange &lhs) const final override - { - return ge_op1_op2_relation (lhs); - } - bool op1_range (frange &r, tree type, - const irange &lhs, const frange &op2, - relation_trio = TRIO_VARYING) const final override; - bool op2_range (frange &r, tree type, - const irange &lhs, const frange &op1, - relation_trio = TRIO_VARYING) const final override; -} fop_ge; - bool -foperator_ge::fold_range (irange &r, tree type, - const frange &op1, const frange &op2, - relation_trio rel) const +operator_ge::fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio rel) const { if (frelop_early_resolve (r, type, op1, op2, rel, VREL_GE)) return true; @@ -1102,11 +1080,11 @@ foperator_ge::fold_range (irange &r, tree type, } bool -foperator_ge::op1_range (frange &r, - tree type, - const irange &lhs, - const frange &op2, - relation_trio) const +operator_ge::op1_range (frange &r, + tree type, + const irange &lhs, + const frange &op2, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1137,10 +1115,10 @@ foperator_ge::op1_range (frange &r, } bool -foperator_ge::op2_range (frange &r, tree type, - const irange &lhs, - const frange &op1, - relation_trio) const +operator_ge::op2_range (frange &r, tree type, + const irange &lhs, + const frange &op1, + relation_trio) const { switch (get_bool_state (r, lhs, type)) { @@ -1813,7 +1791,8 @@ public: op1_no_nan.clear_nan (); if (op2.maybe_isnan ()) op2_no_nan.clear_nan (); - if (!fop_ge.fold_range (r, type, op1_no_nan, op2_no_nan, rel)) + if (!range_op_handler (GE_EXPR).fold_range (r, type, op1_no_nan, + op2_no_nan, rel)) return false; // The result is the same as the ordered version when the // comparison is true or when the operands cannot be NANs. @@ -2720,11 +2699,6 @@ float_table::float_table () set (OBJ_TYPE_REF, fop_identity); set (REAL_CST, fop_identity); - // All the relational operators are expected to work, because the - // calculation of ranges on outgoing edges expect the handlers to be - // present. - set (GE_EXPR, fop_ge); - set (ABS_EXPR, fop_abs); set (NEGATE_EXPR, fop_negate); set (PLUS_EXPR, fop_plus); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 1c68d54b085..d6cd3683932 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -235,4 +235,37 @@ public: relation_kind op1_op2_relation (const irange &lhs) const final override; void update_bitmask (irange &r, const irange &lh, const irange &rh) const; }; + +class operator_ge : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::op1_op2_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool fold_range (irange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type, + const irange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio = TRIO_VARYING) const final override; + bool op2_range (frange &r, tree type, + const irange &lhs, const frange &op1, + relation_trio = TRIO_VARYING) const final override; + + relation_kind op1_op2_relation (const irange &lhs) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index e971bf4cd33..a127da22006 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -67,6 +67,7 @@ operator_not_equal op_not_equal; operator_lt op_lt; operator_le op_le; operator_gt op_gt; +operator_ge op_ge; // Invoke the initialization routines for each class of range. @@ -81,6 +82,7 @@ unified_table::unified_table () set (LT_EXPR, op_lt); set (LE_EXPR, op_le); set (GT_EXPR, op_gt); + set (GE_EXPR, op_ge); } // The tables are hidden and accessed via a simple extern function. @@ -1388,34 +1390,17 @@ operator_gt::op2_range (irange &r, tree type, } -class operator_ge : public range_operator +void +operator_ge::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::op1_op2_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - virtual relation_kind op1_op2_relation (const irange &lhs) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, GE_EXPR, lh, rh); } -} op_ge; + update_known_bitmask (r, GE_EXPR, lh, rh); +} // Check if the LHS range indicates a relation between OP1 and OP2. relation_kind -ge_op1_op2_relation (const irange &lhs) +operator_ge::op1_op2_relation (const irange &lhs) const { if (lhs.undefined_p ()) return VREL_UNDEFINED; @@ -1430,12 +1415,6 @@ ge_op1_op2_relation (const irange &lhs) return VREL_VARYING; } -relation_kind -operator_ge::op1_op2_relation (const irange &lhs) const -{ - return ge_op1_op2_relation (lhs); -} - bool operator_ge::fold_range (irange &r, tree type, const irange &op1, @@ -4783,7 +4762,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (GE_EXPR, op_ge); set (PLUS_EXPR, op_plus); set (MINUS_EXPR, op_minus); set (MIN_EXPR, op_min); @@ -4832,7 +4810,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (GE_EXPR, op_ge); set (SSA_NAME, op_ident); set (INTEGER_CST, op_integer_cst); set (ADDR_EXPR, op_addr); diff --git a/gcc/range-op.h b/gcc/range-op.h index 411ab5e4a0a..20a77e1165e 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -265,9 +265,6 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &maybe_nonzero, wide_int &mustbe_nonzero); -// op1_op2_relation methods that are the same across irange and frange. -relation_kind ge_op1_op2_relation (const irange &lhs); - // This implements the range operator tables as local objects. class range_op_table -- 2.40.1 From patchwork Sat Jun 10 00:35:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=Np2wLbpS; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJs817qvz20Vx for ; Sat, 10 Jun 2023 10:35:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0421F3836E93 for ; Sat, 10 Jun 2023 00:35:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0421F3836E93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357354; bh=j7qKylV8uaPOXIGCvFbEOpmjz2iQUEymRsGXziVtqY8=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Np2wLbpSrwYV26ZoqDA1FBImWoVT4vZQprcFbR4VUNK9L4onVFNXuSfzQiSDHFRTp hHQTP2GKx6zMQ2LSKWBL2bP/A9XnZ2NNBgNlTbPZxsWeoizKja4iXuRVr8ZIyArQb8 5jL9JkXids9o9IqbUkD8ELWl6LRQfaEFFwpepoiU= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 78AEE385C6EF for ; Sat, 10 Jun 2023 00:35:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78AEE385C6EF Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-ccF0Hng4PJ2Hu6ddbenGTQ-1; Fri, 09 Jun 2023 20:35:28 -0400 X-MC-Unique: ccF0Hng4PJ2Hu6ddbenGTQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-75d59ed75e2so305476485a.2 for ; Fri, 09 Jun 2023 17:35:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357327; x=1688949327; 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=4ULmkmjkMWa0MKjfAHDixxrjMcOHPh0caPDg+IHqrsY=; b=VNLfNlOYyG8/5AtAKyn/A67nsBdS4g4q7RZit/xCjJC895smQsDRnulnjpaVNblHdb usF4ZQzpjjvnqg1T2QqydBgtug44Xa0fUbhJLS6I1ERJTj3LpscRYdmFNkqfzoNdHZi6 C/zpo/WbJWe8WcDrx4XIY5oIzmw8XfAH1NmpmMiro4G+XhO1LBsydl46jTEhpLfPvb21 HolnA3EkGj4r/PDjPcIFOEP6JW45fpvTdFPhbj8wpMG2khdd3cIbj+ZND0Dmo8wYFhu/ U2pVI45H9IEQCLoR+dDOVgDAaPrt6N+lKeHGZ4cQUws4U/Gshrj05kVEbQ+rTj553S1l vZqA== X-Gm-Message-State: AC+VfDzLnbaYecgdH9QlWQllEKga1/8CKIcnjtqwyqaSgWRfrs6d+qbH khibAnuWNYN15jEmc0rZzCV5lfmFKCLRYM4NaOIOBzSGiPr5eReVNhwfsVd0gAradcFoO1PTien vNLtNO+M7rTAF9DkrZy52e1Pe7DWd3ie+ynvmi00eUHjcF0Lk30RcNn5fR43U1yT/k+btcMyCjd sF/g== X-Received: by 2002:a05:620a:488d:b0:75b:23a0:e7a6 with SMTP id ea13-20020a05620a488d00b0075b23a0e7a6mr3266915qkb.7.1686357327711; Fri, 09 Jun 2023 17:35:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zkKw9BIom/hl1WWcrf9N7kB4P0Oqai2BDrZWZIbjTwnDFw7ZPcR0aTWeBuaBrIvYQ4q7uCA== X-Received: by 2002:a05:620a:488d:b0:75b:23a0:e7a6 with SMTP id ea13-20020a05620a488d00b0075b23a0e7a6mr3266899qkb.7.1686357327346; Fri, 09 Jun 2023 17:35:27 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id b14-20020a05620a126e00b0075c5e32593fsm1366500qkl.40.2023.06.09.17.35.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:35:26 -0700 (PDT) Message-ID: <15aa449a-aa1f-10cd-783f-23295f77d4e2@redhat.com> Date: Fri, 9 Jun 2023 20:35:26 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 8/15] Unify Identity range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This unifies the identity operation, which is used by SSA_NAME, PAREN_EXPR, OBJ_TYPE_REF and REAL_CST. REAL_CST is using it incorrectly, but preserves current functionality.  There will not be an SSA_NAME in the op1 position, so there is no point in having an op1_range routine.  That will be corrected in the next patch. Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From 60b00c6f187450e1f3ffac1b64986ae74b8b948b Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:35:24 -0400 Subject: [PATCH 08/31] Unify Identity range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_identity): Remove. Move prototypes to range-op-mixed.h (operator_identity::fold_range): Rename from foperator_identity. (operator_identity::op1_range): Ditto. (float_table::float_table): Remove fop_identity. * range-op-mixed.h (class operator_identity): Combined from integer and float files. * range-op.cc (op_identity): New object. (unified_table::unified_table): Add op_identity. (class operator_identity): Move to range-op-mixed.h. (integral_table::integral_table): Remove identity. (pointer_table::pointer_table): Remove identity. --- gcc/range-op-float.cc | 40 +++++++++++++++------------------------- gcc/range-op-mixed.h | 24 ++++++++++++++++++++++++ gcc/range-op.cc | 29 +++++------------------------ 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 4faca62c48f..bc8ecc61bce 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -541,27 +541,22 @@ build_gt (frange &r, tree type, const frange &val) } -class foperator_identity : public range_operator +bool +operator_identity::fold_range (frange &r, tree, const frange &op1, + const frange &, relation_trio) const { - using range_operator::fold_range; - using range_operator::op1_range; -public: - bool fold_range (frange &r, tree type ATTRIBUTE_UNUSED, - const frange &op1, const frange &op2 ATTRIBUTE_UNUSED, - relation_trio = TRIO_VARYING) const final override - { - r = op1; - return true; - } - bool op1_range (frange &r, tree type ATTRIBUTE_UNUSED, - const frange &lhs, const frange &op2 ATTRIBUTE_UNUSED, - relation_trio = TRIO_VARYING) const final override - { - r = lhs; - return true; - } -public: -} fop_identity; + r = op1; + return true; +} + +bool +operator_identity::op1_range (frange &r, tree, const frange &lhs, + const frange &, relation_trio) const +{ + r = lhs; + return true; +} + bool operator_equal::op2_range (frange &r, tree type, @@ -2694,11 +2689,6 @@ private: float_table::float_table () { - set (SSA_NAME, fop_identity); - set (PAREN_EXPR, fop_identity); - set (OBJ_TYPE_REF, fop_identity); - set (REAL_CST, fop_identity); - set (ABS_EXPR, fop_abs); set (NEGATE_EXPR, fop_negate); set (PLUS_EXPR, fop_plus); diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index d6cd3683932..f30f7d019ee 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -268,4 +268,28 @@ public: void update_bitmask (irange &r, const irange &lh, const irange &rh) const final override; }; + +class operator_identity : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::lhs_op1_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool fold_range (frange &r, tree type ATTRIBUTE_UNUSED, + const frange &op1, const frange &op2 ATTRIBUTE_UNUSED, + relation_trio = TRIO_VARYING) const final override; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool op1_range (frange &r, tree type ATTRIBUTE_UNUSED, + const frange &lhs, const frange &op2 ATTRIBUTE_UNUSED, + relation_trio = TRIO_VARYING) const final override; + relation_kind lhs_op1_relation (const irange &lhs, + const irange &op1, const irange &op2, + relation_kind rel) const final override; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index a127da22006..70684b4c7f7 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -68,6 +68,7 @@ operator_lt op_lt; operator_le op_le; operator_gt op_gt; operator_ge op_ge; +operator_identity op_ident; // Invoke the initialization routines for each class of range. @@ -83,6 +84,10 @@ unified_table::unified_table () set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); + set (SSA_NAME, op_ident); + set (PAREN_EXPR, op_ident); + set (OBJ_TYPE_REF, op_ident); + set (REAL_CST, op_ident); } // The tables are hidden and accessed via a simple extern function. @@ -4240,26 +4245,6 @@ operator_cst::fold_range (irange &r, tree type ATTRIBUTE_UNUSED, } -class operator_identity : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::lhs_op1_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual relation_kind lhs_op1_relation (const irange &lhs, - const irange &op1, - const irange &op2, - relation_kind rel) const; -} op_ident; - // Determine if there is a relationship between LHS and OP1. relation_kind @@ -4774,9 +4759,6 @@ integral_table::integral_table () set (BIT_XOR_EXPR, op_bitwise_xor); set (BIT_NOT_EXPR, op_bitwise_not); set (INTEGER_CST, op_integer_cst); - set (SSA_NAME, op_ident); - set (PAREN_EXPR, op_ident); - set (OBJ_TYPE_REF, op_ident); set (ABS_EXPR, op_abs); set (NEGATE_EXPR, op_negate); set (ADDR_EXPR, op_addr); @@ -4810,7 +4792,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (SSA_NAME, op_ident); set (INTEGER_CST, op_integer_cst); set (ADDR_EXPR, op_addr); set (NOP_EXPR, op_cast); -- 2.40.1 From patchwork Sat Jun 10 00:35:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=h5ayyyUN; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJsP5Ld8z20Vx for ; Sat, 10 Jun 2023 10:36:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C052B3856968 for ; Sat, 10 Jun 2023 00:36:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C052B3856968 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357367; bh=aCzL1MBwAPwMlqBfjcrbJZR9++PpPfQqLKn5gGMna58=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=h5ayyyUNQW1fVCn9xvd5vE48YUA5kUzR+MbribDtkRKa387acroiDpHGdxsOoRmlj nc/dd4qXX9Rm3tctzrd92qH+4/zd0qhL46AvqES+FYZuWwx0s7f0MGElyG0Lh4rlET N5ngNAiAdVsz7K9rsfUf6STdP6ajjt0r31xwquwc= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 50D083854E48 for ; Sat, 10 Jun 2023 00:35:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50D083854E48 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-IChLDsqPNOabLVUNUpXfKg-1; Fri, 09 Jun 2023 20:35:40 -0400 X-MC-Unique: IChLDsqPNOabLVUNUpXfKg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-75caeec5545so366816885a.0 for ; Fri, 09 Jun 2023 17:35:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357339; x=1688949339; 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=prxKxENhqRYiPlQnO31iuhk9RPyzEebY5jVEus5j8HA=; b=KIzTSDw7GLcne2XNjDCi+kM9JRN+X7MeJgS21j3PbyvpdaIw03JTDtjFu5QiaM1G0/ l0bBw+9UaIqD+9l2wmlRhnisku5uCIJVQc5R4lqxUozHBphdfyjkO63LJIczZGMY7Dex ih7seda9pUBoUwx/sWt/OMS4EA3jZWnKC5frHnwL5sRHknmpKFDcDrGNG3PM1oadxJOV 4BPTqJq0qhe4Nw5Ovi7z8RLkodz9FhEqcnmmP3ZM0IiLOdZUutQ8wuYdEpHrvEEH7lFD zRiaaJziS0lEspSz6z7Je+ef8hYs9nEjaMVf/oMNIFDTx8Yr3I1by5Kq2JF5y71vVGl1 0TCw== X-Gm-Message-State: AC+VfDx2nE2pz4fk/wmEuIuAx0v0AwOlycxmRLOgeWSygS1X+PVL/VVZ adMoRTfBwc3Ec3D9B+XaiJw91gRAu3XCICfmQInAkkOaq8DTi9bpT6tUb57EBBMwm9oFAYeeyA2 7khzUXkA/qjAPhTynO4GiGEfBj4ZSCec/2JftiJZG6b2YldFIqZB0M4RNHJ7zyDp9rGg8YV2AWc YL3A== X-Received: by 2002:a05:620a:2591:b0:75e:b9c7:46d7 with SMTP id x17-20020a05620a259100b0075eb9c746d7mr3827147qko.21.1686357339547; Fri, 09 Jun 2023 17:35:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ymy1SPSNkOT5htJMLZKYXuM9WP3VVm69Nd0zPD+1EJevIDsmKX+yWHY6n3tbrNC65fZsX/Q== X-Received: by 2002:a05:620a:2591:b0:75e:b9c7:46d7 with SMTP id x17-20020a05620a259100b0075eb9c746d7mr3827132qko.21.1686357339238; Fri, 09 Jun 2023 17:35:39 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id g7-20020a05620a108700b0075b327a2988sm1354495qkk.133.2023.06.09.17.35.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:35:38 -0700 (PDT) Message-ID: <4bd184ed-98b9-9c61-6a31-e7ae721b18ce@redhat.com> Date: Fri, 9 Jun 2023 20:35:37 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 9/15] Unify operator_cst range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" THis patch move the CONST operator into the mixed header.  It also sets REAL_CST to use this instead, as it has no op1_range routines. Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From 35a580f09eaceda5b0dd370b1e39fe05ba0a154f Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:37:11 -0400 Subject: [PATCH 09/31] Unify operator_cst range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (operator_cst::fold_range): New. * range-op-mixed.h (class operator_cst): Move from integer file. * range-op.cc (op_cst): New object. (unified_table::unified_table): Add op_cst. Also use for REAL_CST. (class operator_cst): Move to range-op-mixed.h. (integral_table::integral_table): Remove op_cst. (pointer_table::pointer_table): Remove op_cst. --- gcc/range-op-float.cc | 7 +++++++ gcc/range-op-mixed.h | 12 ++++++++++++ gcc/range-op.cc | 16 +++------------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index bc8ecc61bce..11d76f2ef25 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -557,6 +557,13 @@ operator_identity::op1_range (frange &r, tree, const frange &lhs, return true; } +bool +operator_cst::fold_range (frange &r, tree, const frange &op1, + const frange &, relation_trio) const +{ + r = op1; + return true; +} bool operator_equal::op2_range (frange &r, tree type, diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index f30f7d019ee..5b7fbe89856 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -292,4 +292,16 @@ public: relation_kind rel) const final override; }; +class operator_cst : public range_operator +{ +public: + using range_operator::fold_range; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool fold_range (frange &r, tree type, + const frange &op1, const frange &op2, + relation_trio = TRIO_VARYING) const final override; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 70684b4c7f7..31d4e1a1739 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -69,6 +69,7 @@ operator_le op_le; operator_gt op_gt; operator_ge op_ge; operator_identity op_ident; +operator_cst op_cst; // Invoke the initialization routines for each class of range. @@ -87,7 +88,8 @@ unified_table::unified_table () set (SSA_NAME, op_ident); set (PAREN_EXPR, op_ident); set (OBJ_TYPE_REF, op_ident); - set (REAL_CST, op_ident); + set (REAL_CST, op_cst); + set (INTEGER_CST, op_cst); } // The tables are hidden and accessed via a simple extern function. @@ -4224,16 +4226,6 @@ operator_bitwise_not::op1_range (irange &r, tree type, } -class operator_cst : public range_operator -{ - using range_operator::fold_range; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; -} op_integer_cst; - bool operator_cst::fold_range (irange &r, tree type ATTRIBUTE_UNUSED, const irange &lh, @@ -4758,7 +4750,6 @@ integral_table::integral_table () set (BIT_IOR_EXPR, op_bitwise_or); set (BIT_XOR_EXPR, op_bitwise_xor); set (BIT_NOT_EXPR, op_bitwise_not); - set (INTEGER_CST, op_integer_cst); set (ABS_EXPR, op_abs); set (NEGATE_EXPR, op_negate); set (ADDR_EXPR, op_addr); @@ -4792,7 +4783,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (INTEGER_CST, op_integer_cst); set (ADDR_EXPR, op_addr); set (NOP_EXPR, op_cast); set (CONVERT_EXPR, op_cast); -- 2.40.1 From patchwork Sat Jun 10 00:35:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=VxsUsq0A; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJtd59z0z20Vx for ; Sat, 10 Jun 2023 10:37:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AEDEA3882654 for ; Sat, 10 Jun 2023 00:37:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEDEA3882654 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357431; bh=B9wTWXnKuxfEF6SNKbPAwK7MBG+4ph5esyBJRFTmIeA=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=VxsUsq0AwgMwpz08zIqah91FIH2UFFBFqozjsA+pX/2NQHPxJzpmC8NX3iPDtKXdF QDN2yAl/6FscAR7kNK+EmMs2FIamj1ovRtv9SIQURAwODS2KjXHoeS4Z0UrQy+htGc aZS92zUaqEymP2kjMYvsHoMFUcZjvCZPSbOOkduA= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id BFC0438323C3 for ; Sat, 10 Jun 2023 00:35:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFC0438323C3 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-YpLPPowXM-ytwA213HGjFw-1; Fri, 09 Jun 2023 20:35:53 -0400 X-MC-Unique: YpLPPowXM-ytwA213HGjFw-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-3f9a6c18c34so33641051cf.3 for ; Fri, 09 Jun 2023 17:35:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357353; x=1688949353; 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=Zvvt1VHEu+xxgKDkNqn3f1mU35EBniZWE0QcZrQnYDY=; b=aInkTczfEOFMO+RFpQ4DEdMgnUKoDmG9QAjJuD8h2bvwm2mxNM+EKw8Qv7Ilb77YGl k7n8AWGpuyASXcVcD9w8hI/IEV3YoSPDAe3OqjnDWmnMB5lLtbMBWwvwZkA8OUXec5gA ZQofUkW9HVOXGmPJ1LiW4nd5Rp2//xrBWoLBokyJAxVp6wuzi6+lfbRKKj5v7jWRjDUB 2HK6DHc5UK1uPjpDU2agPwQgVFam78vzoq7klx6O+rBHUREqbXyxT9S/0JDqSznASZiW eKcQZzLNH1XWxsK0FPFfyg2Auz9sn0w94wQvGLnYfWy/mcYtvbTFxt22JhzcsI3SGOS6 uM0g== X-Gm-Message-State: AC+VfDyZ6q5IXMFzjGn3MGDjw9bciYDUOVo7//JewuGWDfZdayL3Pw8j /e/gC77n6GKH/PdTkOfb5zkoR0RA52bDSzwYGjhEQJYjy2AF+LpBgZHgfp2pSuacMHN4iDnAito NyQ9eCjAASsyEt9Gn2MQwIuzOepgsX222S2nQkui4dXL1AATSc0Wad1RJazMjoKiX9Ii74rdb9A cWHg== X-Received: by 2002:ac8:57cc:0:b0:3f9:7251:30f4 with SMTP id w12-20020ac857cc000000b003f9725130f4mr3407664qta.4.1686357353100; Fri, 09 Jun 2023 17:35:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ttzf8OC8fH2hm8+2R/DQDDYBXs40wu0Jn9pvQjjAcZ42ZZsVtakIOjNsdyG2/tugzeryLfQ== X-Received: by 2002:ac8:57cc:0:b0:3f9:7251:30f4 with SMTP id w12-20020ac857cc000000b003f9725130f4mr3407649qta.4.1686357352849; Fri, 09 Jun 2023 17:35:52 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id z2-20020ac875c2000000b003f9a77d1ba9sm1563629qtq.43.2023.06.09.17.35.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:35:52 -0700 (PDT) Message-ID: <2afdd19f-b5a3-a7c5-b753-4a340c59ce32@redhat.com> Date: Fri, 9 Jun 2023 20:35:51 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 10/15] Unify operator_cast range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From ee46a15733524103a9eda433df5dc44cdc055d73 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:39:54 -0400 Subject: [PATCH 10/31] Unify operator_cast range operator Move the declaration of the class to the range-op-mixed header, and use it in the new unified table. * range-op-mixed.h (class operator_cast): Combined from integer and float files. * range-op.cc (op_cast): New object. (unified_table::unified_table): Add op_cast (class operator_cast): Move to range-op-mixed.h. (integral_table::integral_table): Remove op_cast (pointer_table::pointer_table): Remove op_cast. --- gcc/range-op-mixed.h | 24 ++++++++++++++++++++++++ gcc/range-op.cc | 34 ++++------------------------------ 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 5b7fbe89856..9de8479cd24 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -304,4 +304,28 @@ public: relation_trio = TRIO_VARYING) const final override; }; + +class operator_cast: public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + using range_operator::lhs_op1_relation; + bool fold_range (irange &r, tree type, + const irange &op1, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + relation_kind lhs_op1_relation (const irange &lhs, + const irange &op1, const irange &op2, + relation_kind) const final override; +private: + bool truncating_cast_p (const irange &inner, const irange &outer) const; + bool inside_domain_p (const wide_int &min, const wide_int &max, + const irange &outer) const; + void fold_pair (irange &r, unsigned index, const irange &inner, + const irange &outer) const; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 31d4e1a1739..7d89b633da3 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -70,6 +70,7 @@ operator_gt op_gt; operator_ge op_ge; operator_identity op_ident; operator_cst op_cst; +operator_cast op_cast; // Invoke the initialization routines for each class of range. @@ -90,6 +91,9 @@ unified_table::unified_table () set (OBJ_TYPE_REF, op_ident); set (REAL_CST, op_cst); set (INTEGER_CST, op_cst); + set (NOP_EXPR, op_cast); + set (CONVERT_EXPR, op_cast); + } // The tables are hidden and accessed via a simple extern function. @@ -2868,32 +2872,6 @@ operator_rshift::wi_fold (irange &r, tree type, } -class operator_cast: public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; - using range_operator::lhs_op1_relation; -public: - virtual bool fold_range (irange &r, tree type, - const irange &op1, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual relation_kind lhs_op1_relation (const irange &lhs, - const irange &op1, - const irange &op2, - relation_kind) const; -private: - bool truncating_cast_p (const irange &inner, const irange &outer) const; - bool inside_domain_p (const wide_int &min, const wide_int &max, - const irange &outer) const; - void fold_pair (irange &r, unsigned index, const irange &inner, - const irange &outer) const; -} op_cast; - // Add a partial equivalence between the LHS and op1 for casts. relation_kind @@ -4744,8 +4722,6 @@ integral_table::integral_table () set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); set (MULT_EXPR, op_mult); - set (NOP_EXPR, op_cast); - set (CONVERT_EXPR, op_cast); set (BIT_AND_EXPR, op_bitwise_and); set (BIT_IOR_EXPR, op_bitwise_or); set (BIT_XOR_EXPR, op_bitwise_xor); @@ -4784,8 +4760,6 @@ pointer_table::pointer_table () set (MAX_EXPR, op_ptr_min_max); set (ADDR_EXPR, op_addr); - set (NOP_EXPR, op_cast); - set (CONVERT_EXPR, op_cast); set (BIT_NOT_EXPR, op_bitwise_not); set (BIT_XOR_EXPR, op_bitwise_xor); -- 2.40.1 From patchwork Sat Jun 10 00:36:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=RQTnUaxy; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QdJx46M9pz20Vx for ; Sat, 10 Jun 2023 10:39:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA21138983A9 for ; Sat, 10 Jun 2023 00:39:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA21138983A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357558; bh=cRadtxGzEz45BR1HV29dA8LJ24SVuIsmkUNOzOnKY9Y=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=RQTnUaxyLSXQ8XNp+IDXD/y0NnWWpXygw/JcTv9ygOO8igdKKPqoUiOdggwH3OuxW S+hyC0QnKtxclxhXTo5ay8F+CCM8GvaaVmmF3T3bopO3SZiokfuTS//BKJb42oLsOq 5adYCzIXC0uE5VMkpy+7wdgyOt5Xj+NHumIzKBxY= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 7480E38319C7 for ; Sat, 10 Jun 2023 00:36:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7480E38319C7 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-n5Tf_lnRMsCHhKY-v7pTOQ-1; Fri, 09 Jun 2023 20:36:05 -0400 X-MC-Unique: n5Tf_lnRMsCHhKY-v7pTOQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6260cd5068cso27976846d6.2 for ; Fri, 09 Jun 2023 17:36:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686357364; x=1688949364; 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=yRumLaWvCEcsUlcRfsA7UREiNGXJ3CyCeAhlOn7swzs=; b=dxWEOC+7dy1qxvmOjAByFFCDhldwyDV+4X0lcdih0LocFSoMthBsVYFP21emtsdu27 FRLxldUU9v5jQ+yhl6Za+nYmO7sJggPUvuyAEg55aSR6lcg9Dd+2m5KhYxT0aXtab5XF ODNP6xnnts3W4Y9YgKk01nTP2LtHnXFRF1u1LeZh0V8nKkQqvPwnoT4OIRGIl5Kq66zr XT5b7po83VuIRMwl2hD2wW8cqW4UfrgH4FeJYAveUKGxAhIaYX286Ke480oZ6dnCujgq c1I6LxU+vkwSV1uE75kTWORUgx56V/KEwFyc2RL8JzsyZ8J53Pym8cGFVvIFY0PDanXD t7tA== X-Gm-Message-State: AC+VfDwzl3qhJaDlny9i6y6U3b3FjxFOTHbJ1KicJkUkqG98H7IjFsev o4Fg9Sp9AtmohcnVl9JeiLAHHJIgDeI8qYnEO6iG8bAX6TpCQjnRnY4Dnia5kZbiWWrtD+q44sA kAhXCdbzg85YBTZiEe0xFKVJsXvQQw+1SrmMK3GG5HXnrNd7mm1aC7STvIZ0kjrILy/AAeHe56u u8eA== X-Received: by 2002:ad4:5caf:0:b0:626:1be5:177b with SMTP id q15-20020ad45caf000000b006261be5177bmr2911128qvh.65.1686357364384; Fri, 09 Jun 2023 17:36:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7rm2siojpTBjXuxisSLjrzwpdYvZZdg2Os7OOWmL6xf5nT3pxYDVVeRV5gu2n6nRKIL42wqQ== X-Received: by 2002:ad4:5caf:0:b0:626:1be5:177b with SMTP id q15-20020ad45caf000000b006261be5177bmr2911115qvh.65.1686357364111; Fri, 09 Jun 2023 17:36:04 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id x15-20020a05620a12af00b0075cda118f83sm1373917qki.73.2023.06.09.17.36.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jun 2023 17:36:03 -0700 (PDT) Message-ID: <37091c54-e7b5-9f84-8b21-b4507f2723bb@redhat.com> Date: Fri, 9 Jun 2023 20:36:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: gcc-patches Cc: "hernandez, aldy" Subject: [COMMITTED 11/15] Unify PLUS_EXPR range operator X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.4 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed. Andrew From cc4eaf6f1e1958f920007d4cc7cafb635b5dda64 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 9 Jun 2023 13:41:28 -0400 Subject: [PATCH 11/31] Unify PLUS_EXPR range operator Move the declaration of the class to the range-op-mixed header, add the floating point prototypes as well, and use it in the new unified table. * range-op-float.cc (foperator_plus): Remove. Move prototypes to range-op-mixed.h (operator_plus::fold_range): Rename from foperator_plus. (operator_plus::op1_range): Ditto. (operator_plus::op2_range): Ditto. (operator_plus::rv_fold): Ditto. (float_table::float_table): Remove PLUS_EXPR. * range-op-mixed.h (class operator_plus): Combined from integer and float files. * range-op.cc (op_plus): New object. (unified_table::unified_table): Add PLUS_EXPR. (class operator_plus): Move to range-op-mixed.h. (integral_table::integral_table): Remove PLUS_EXPR. (pointer_table::pointer_table): Remove PLUS_EXPR. --- gcc/range-op-float.cc | 94 ++++++++++++++++++++----------------------- gcc/range-op-mixed.h | 39 ++++++++++++++++++ gcc/range-op.cc | 37 ++++------------- 3 files changed, 90 insertions(+), 80 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 11d76f2ef25..bd1b79281d0 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -2254,54 +2254,49 @@ float_widen_lhs_range (tree type, const frange &lhs) return ret; } -class foperator_plus : public range_operator +bool +operator_plus::op1_range (frange &r, tree type, const frange &lhs, + const frange &op2, relation_trio) const { - using range_operator::op1_range; - using range_operator::op2_range; -public: - virtual bool op1_range (frange &r, tree type, - const frange &lhs, - const frange &op2, - relation_trio = TRIO_VARYING) const final override - { - if (lhs.undefined_p ()) - return false; - range_op_handler minus (MINUS_EXPR, type); - if (!minus) - return false; - frange wlhs = float_widen_lhs_range (type, lhs); - return float_binary_op_range_finish (minus.fold_range (r, type, wlhs, op2), - r, type, wlhs); - } - virtual bool op2_range (frange &r, tree type, - const frange &lhs, - const frange &op1, - relation_trio = TRIO_VARYING) const final override - { - return op1_range (r, type, lhs, op1); - } -private: - void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, bool &maybe_nan, - tree type, - const REAL_VALUE_TYPE &lh_lb, - const REAL_VALUE_TYPE &lh_ub, - const REAL_VALUE_TYPE &rh_lb, - const REAL_VALUE_TYPE &rh_ub, - relation_kind) const final override - { - frange_arithmetic (PLUS_EXPR, type, lb, lh_lb, rh_lb, dconstninf); - frange_arithmetic (PLUS_EXPR, type, ub, lh_ub, rh_ub, dconstinf); + if (lhs.undefined_p ()) + return false; + range_op_handler minus (MINUS_EXPR, type); + if (!minus) + return false; + frange wlhs = float_widen_lhs_range (type, lhs); + return float_binary_op_range_finish (minus.fold_range (r, type, wlhs, op2), + r, type, wlhs); +} - // [-INF] + [+INF] = NAN - if (real_isinf (&lh_lb, true) && real_isinf (&rh_ub, false)) - maybe_nan = true; - // [+INF] + [-INF] = NAN - else if (real_isinf (&lh_ub, false) && real_isinf (&rh_lb, true)) - maybe_nan = true; - else - maybe_nan = false; - } -} fop_plus; +bool +operator_plus::op2_range (frange &r, tree type, + const frange &lhs, const frange &op1, + relation_trio) const +{ + return op1_range (r, type, lhs, op1); +} + +void +operator_plus::rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, + bool &maybe_nan, tree type, + const REAL_VALUE_TYPE &lh_lb, + const REAL_VALUE_TYPE &lh_ub, + const REAL_VALUE_TYPE &rh_lb, + const REAL_VALUE_TYPE &rh_ub, + relation_kind) const +{ + frange_arithmetic (PLUS_EXPR, type, lb, lh_lb, rh_lb, dconstninf); + frange_arithmetic (PLUS_EXPR, type, ub, lh_ub, rh_ub, dconstinf); + + // [-INF] + [+INF] = NAN + if (real_isinf (&lh_lb, true) && real_isinf (&rh_ub, false)) + maybe_nan = true; + // [+INF] + [-INF] = NAN + else if (real_isinf (&lh_ub, false) && real_isinf (&rh_lb, true)) + maybe_nan = true; + else + maybe_nan = false; +} class foperator_minus : public range_operator @@ -2317,9 +2312,9 @@ public: if (lhs.undefined_p ()) return false; frange wlhs = float_widen_lhs_range (type, lhs); - return float_binary_op_range_finish (fop_plus.fold_range (r, type, wlhs, - op2), - r, type, wlhs); + return float_binary_op_range_finish ( + range_op_handler (PLUS_EXPR).fold_range (r, type, wlhs, op2), + r, type, wlhs); } virtual bool op2_range (frange &r, tree type, const frange &lhs, @@ -2698,7 +2693,6 @@ float_table::float_table () { set (ABS_EXPR, fop_abs); set (NEGATE_EXPR, fop_negate); - set (PLUS_EXPR, fop_plus); set (MINUS_EXPR, fop_minus); set (MULT_EXPR, fop_mult); } diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 9de8479cd24..fbfe3f825a3 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -328,4 +328,43 @@ private: const irange &outer) const; }; +class operator_plus : public range_operator +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::lhs_op1_relation; + using range_operator::lhs_op2_relation; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio) const final override; + bool op1_range (frange &r, tree type, + const frange &lhs, const frange &op2, + relation_trio = TRIO_VARYING) const final override; + + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio) const final override; + bool op2_range (frange &r, tree type, + const frange &lhs, const frange &op1, + relation_trio = TRIO_VARYING) const final override; + + relation_kind lhs_op1_relation (const irange &lhs, const irange &op1, + const irange &op2, + relation_kind rel) const final override; + relation_kind lhs_op2_relation (const irange &lhs, const irange &op1, + const irange &op2, + relation_kind rel) const final override; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; +private: + void wi_fold (irange &r, tree type, const wide_int &lh_lb, + const wide_int &lh_ub, const wide_int &rh_lb, + const wide_int &rh_ub) const final override; + void rv_fold (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, + bool &maybe_nan, tree type, + const REAL_VALUE_TYPE &lh_lb, const REAL_VALUE_TYPE &lh_ub, + const REAL_VALUE_TYPE &rh_lb, const REAL_VALUE_TYPE &rh_ub, + relation_kind) const final override; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 7d89b633da3..1dc5c38ef63 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -71,6 +71,7 @@ operator_ge op_ge; operator_identity op_ident; operator_cst op_cst; operator_cast op_cast; +operator_plus op_plus; // Invoke the initialization routines for each class of range. @@ -93,7 +94,7 @@ unified_table::unified_table () set (INTEGER_CST, op_cst); set (NOP_EXPR, op_cast); set (CONVERT_EXPR, op_cast); - + set (PLUS_EXPR, op_plus); } // The tables are hidden and accessed via a simple extern function. @@ -1498,35 +1499,12 @@ operator_ge::op2_range (irange &r, tree type, } -class operator_plus : public range_operator +void +operator_plus::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::op1_range; - using range_operator::op2_range; - using range_operator::lhs_op1_relation; - using range_operator::lhs_op2_relation; -public: - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio) const; - virtual void wi_fold (irange &r, tree type, - const wide_int &lh_lb, - const wide_int &lh_ub, - const wide_int &rh_lb, - const wide_int &rh_ub) const; - virtual relation_kind lhs_op1_relation (const irange &lhs, const irange &op1, - const irange &op2, - relation_kind rel) const; - virtual relation_kind lhs_op2_relation (const irange &lhs, const irange &op1, - const irange &op2, - relation_kind rel) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, PLUS_EXPR, lh, rh); } -} op_plus; + update_known_bitmask (r, PLUS_EXPR, lh, rh); +} // Check to see if the range of OP2 indicates anything about the relation // between LHS and OP1. @@ -4717,7 +4695,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (PLUS_EXPR, op_plus); set (MINUS_EXPR, op_minus); set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); -- 2.40.1