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: 105845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1271752vqr; Fri, 9 Jun 2023 17:36:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LMKkpvf/M+aJxVx4tuXXHDvAAVvcz7NBbf6112bbZO6isIn9/LGv8ZdFTn9ZxAZ1C3B8F X-Received: by 2002:a05:6402:3cb:b0:514:a4cd:85d7 with SMTP id t11-20020a05640203cb00b00514a4cd85d7mr376101edw.26.1686357365564; Fri, 09 Jun 2023 17:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686357365; cv=none; d=google.com; s=arc-20160816; b=Ajc7rQBc/Pdou2WAtAOCc5hIUSYuw5SYXOmgAJMgY6SWJoJNWw+fpPFuGugBfGvG6a ezI8UCDyQKe4R9IOczJ1VbMtXW/pgp2gcKF6uxdLjdS+R7MAif7OwchiWHfNj6BfdhqE QXQysIclbOIUDmPlh9UiUSz5LMVyI94RjOlyBOD/X8EsCNdkt9PLO7XQ7HD9YlaZd4gf RwDuoHi01Es+kVlbXkjHObulJkA0sjDjmQ53GMPN3wjIAuSLFE60CyXZ10lnHQFV8GVW oYBxWAOhjbfCGRiVM6oX+5vhGMkysWoDWCs4y1bm2fwV2vD/pQWdtvwrxH73rECjkzAA WxaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=uosxOQ7wsaSmMTqxFEhOniLNXnsp/QptQIfeb2p0syY=; b=xdzltzOdol2RsFiTp56SjHmEtGlFH9pxfn3xoBl54hV0odD+mdka4+8zr6jejf6ser oX3oehNaUlInqIdWD1xzxCGabG3jxsDKm2lJ97lx8fpCV0RFOl7/0EKhDC/+Z9F54HNB XtYdcyeZp918gzKUTxvqSw2B/KixY+XsN8MHFrTmrZ+DNM9Dfo5LrIpgP1O2l/7kaq8L RrnVcI3G8M1dVIskqHl2vUjTObM19I4dUYdGKr4Sbjef9DvQEOb7IVmf7to8ICc0U17P 7gHs3wvfpGJ/PjnRraumHv63DhkzpSSb0KjE36+BEGoV1fvl0FB7MB20fC/kviT3a2rl nx2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oYvzscTr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b2-20020aa7c902000000b005149dba2986si2977157edt.665.2023.06.09.17.36.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 17:36:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oYvzscTr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3057385354A for ; Sat, 10 Jun 2023 00:35:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3057385354A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357314; 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=oYvzscTrY/nZIBmL/7ANbnRr2D7LOhh/wWJDHKkYzwZFh23OQ5qVGD0jXMl3G++NK 1FgVtHEoqr7MAbe31nVXcDiu/jjnoLsUvpzOLtZGyNztZHTYHEi2prmoSkZb0YNxfw XGiIDnv3YK7vZWu460vDS+8RXhXNCqB85BTl2iQ4= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768273860891175727?= X-GMAIL-MSGID: =?utf-8?q?1768273860891175727?= 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