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: 105847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1272150vqr; Fri, 9 Jun 2023 17:37:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5GFZPySfEZMHJ1hXBIWrMx1VS72iIDiK7cKn6+l84oBKBnYHaPnSsbzQf4zkZxnci2pJOa X-Received: by 2002:a05:6402:31f3:b0:514:9eae:b0a7 with SMTP id dy19-20020a05640231f300b005149eaeb0a7mr225000edb.17.1686357437224; Fri, 09 Jun 2023 17:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686357437; cv=none; d=google.com; s=arc-20160816; b=wqqr+dLN8L+o5+Q716ixDQURPlWOENxAYW2C14YNc9RSV/QdPiSN0+GJ+PgwQa42H3 QnO+b04mmG10kIOQNFZGlsEDwXTtR8ezZByes1sMXgn5l3VCW/OA6ASNp71XODK/2tCT AVXe6p/ttVE+6TQ07S5I6qyBtpe4zirSPGKvxybMWE8yt8YYnjOvqTiphUdw/JTa8fMD iCTTHJlFxNAbc0ESFKKiKMySggUN6tve3qHI/JMmNRNynx43pMVzqBSYJdUos/wXPD1N lcgQ7PYSK1SzagqCFSyNnuHwlaOwUrqFobQP9gywjk/ZtgIe4Cx7QbkwvKYni9YnhGAu p9KA== 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 :cc:to:subject:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=lLN+hqGgVUla0ott/p6iP2jkHsPkqy4l1ht6Z2/GwQ0=; b=nhdvwh25CK9q0E5sdhmXKQUN4Jo3OTYes7MMSusssoWWYFwlHZOcK2rSdQMKYnANM+ dMNXuYLcdXGhZWpaqM+iVyq7eITWfJv75FSTa3YEjEWyfnGcOU12Brp9t4XJGsxUJeXf h+ZD6o0Ggo9ZocHDVFyNdHBUEVLvy9MGcOpETeBlp4ajm2nYvBsrG0lJF+tJaCEKzk3r KLDk+PDcdJ6F383zVIw6oCIPmiyOWjrewzNqw87dvjR3GCr463EMIVWPoQPxVCeeElLp XZfIyFdfxSJrGaSSM8rJMOVGX6UJfwSE6yEN1l3tfuKRlaGpXxw77Vazjejv3H4HyTxL VkPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fKmeD3HH; 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 a17-20020aa7cf11000000b00506b37e7d30si2928737edy.417.2023.06.09.17.37.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 17:37:17 -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=fKmeD3HH; 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 2D0933839DCB for ; Sat, 10 Jun 2023 00:35:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D0933839DCB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686357353; 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=fKmeD3HHltAqxpcWSA08wmMdtFOtMerZKrE24bOj5HQeES9ys5maD0xi+gwvGPZ1f 349OWo9hIcvlleFvVe7aOemhufoLeb8JJg73s43riN3ARPvl+55ajc9YLc3JMxtP7I L9ineujLYtlcITbXsdcDG7SYBjPR2pCoisTi2610= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768273936253771834?= X-GMAIL-MSGID: =?utf-8?q?1768273936253771834?= 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