From patchwork Mon Jun 12 15:32:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793966 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=nmIpXJJ9; 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 4Qfwfq5CMvz20QH for ; Tue, 13 Jun 2023 01:32:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B04003856DDF for ; Mon, 12 Jun 2023 15:32:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B04003856DDF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686583953; bh=qJ9oX0STGaAfc1m5nRcggMnAM480j+70PdgfC4z+mR0=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nmIpXJJ9+P2SOrAO7St8VbzDYYph8lpqEm9B9B15v6nf5QzjNTNjn/odh6LyJ57qU mF6pithkqEVvudalhISE0N26wcsA1EnD/4iqQ+65RA+qb/kZJFHgcXQmXYePO4mhxY dmBBweLfflpZp8hBxWdzbghUcwjufIuZnu9qa6kg= 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 94FA93858288 for ; Mon, 12 Jun 2023 15:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94FA93858288 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-kNfyVPF1PFiQD_t4Ag8J8Q-1; Mon, 12 Jun 2023 11:32:10 -0400 X-MC-Unique: kNfyVPF1PFiQD_t4Ag8J8Q-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-39cdf9f9d10so516784b6e.3 for ; Mon, 12 Jun 2023 08:32:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583929; x=1689175929; 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=MDWQ7/DdjiYJo5enCJUccmp37Fw0gNe6fgvt13jfeSU=; b=Og3dAxKhPutUAajOzXhDJUPCv2pzLVN9NmULDFcEKKa6MADV4tzdObt48dmMJmisKb 3LyPx6FUpQOlLgeq7v23xOzG4GVlt+beCO9nHTMznWJicJFZnumO70N4FVemQRbWZsAy mCW+W1njCH8ArWeSirGgR2fvBcz2+cwG/nA8BrdLMVaPiuEW045dEz6gBfEFPmiAsJIf ofdqSL0ldCFC3T1TF5SiVN4oph23ac+4PqmL3nkbl1kutWKjpqhavd3BVRIsKMomXfqK mAMFyC3iJSLYU7wyOOs9TXltYN/IQ6HQLQZuWY0IwG13ITtlgZeZIghXpWqy0PSscB8t V7Vg== X-Gm-Message-State: AC+VfDxUk+dhEJQ3cXv9GfTQHRguIwvoVkXLQWq1k7+VjhGmiGqTfiaT UEU7iAD3Q4HfhGVWn4eKDXVZZ2nRUpfFYBQuViGyFSyO/A8dZMbp8Bc3jGnsqb/1eF8i5nFCZRC wqVhGdzp474QQx2DsEHR81M881pOjewreAP0xy7oApFTToVq6aPe+F8VhGwOGfPhksNXHXKx+89 nhuw== X-Received: by 2002:a05:6808:1902:b0:39a:b7a3:7d61 with SMTP id bf2-20020a056808190200b0039ab7a37d61mr5166437oib.28.1686583928975; Mon, 12 Jun 2023 08:32:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ518peS0LZRU1GP/imAsoe67dQHS09V2ofwQ841NajdeN7cT9FedQnbTQCiAHvUWjvpuuc3hg== X-Received: by 2002:a05:6808:1902:b0:39a:b7a3:7d61 with SMTP id bf2-20020a056808190200b0039ab7a37d61mr5166409oib.28.1686583928554; Mon, 12 Jun 2023 08:32:08 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id q14-20020a0cf5ce000000b005dd8b9345b9sm3296719qvm.81.2023.06.12.08.32.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:08 -0700 (PDT) Message-ID: <0994e73e-bd28-2542-df1e-dd285931bbf7@redhat.com> Date: Mon, 12 Jun 2023 11:32:07 -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/17] Move operator_addr_expr to the unified range-op table. 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, 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" Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 438f8281ad2d821e09eaf5691d1b76b6f2f39b4c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 15:56:15 -0400 Subject: [PATCH 01/17] Move operator_addr_expr to the unified range-op table. * range-op-mixed.h (class operator_addr_expr): Move from... * range-op.cc (unified_table::unified_table): Add ADDR_EXPR. (class operator_addr_expr): Move from here. (integral_table::integral_table): Remove ADDR_EXPR. (pointer_table::pointer_table): Remove ADDR_EXPR. --- gcc/range-op-mixed.h | 13 +++++++++++++ gcc/range-op.cc | 23 +++++------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 52b8570cb2a..d31b144169d 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -501,4 +501,17 @@ public: relation_kind kind) const final override; }; +class operator_addr_expr : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + 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; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 028631c6851..20cc9b0dc9c 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -75,6 +75,7 @@ operator_abs op_abs; operator_minus op_minus; operator_negate op_negate; operator_mult op_mult; +operator_addr_expr op_addr; // Invoke the initialization routines for each class of range. @@ -102,6 +103,10 @@ unified_table::unified_table () set (MINUS_EXPR, op_minus); set (NEGATE_EXPR, op_negate); set (MULT_EXPR, op_mult); + + // Occur in both integer and pointer tables, but currently share + // integral implelmentation. + set (ADDR_EXPR, op_addr); } // The tables are hidden and accessed via a simple extern function. @@ -4366,21 +4371,6 @@ operator_negate::op1_range (irange &r, tree type, } -class operator_addr_expr : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; -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; -} op_addr; - bool operator_addr_expr::fold_range (irange &r, tree type, const irange &lh, @@ -4613,7 +4603,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 (ADDR_EXPR, op_addr); } // Initialize any integral operators to the primary table @@ -4644,8 +4633,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (ADDR_EXPR, op_addr); - set (BIT_NOT_EXPR, op_bitwise_not); set (BIT_XOR_EXPR, op_bitwise_xor); } -- 2.40.1 From patchwork Mon Jun 12 15:32:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793967 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=HHpPFery; 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 4Qfwg65CG8z20QH for ; Tue, 13 Jun 2023 01:32:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 227F338560AA for ; Mon, 12 Jun 2023 15:32:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 227F338560AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686583968; bh=doOXsoIKz93AKkEz7X7uGRcTASL7dfkx6UR5SNI5iC0=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=HHpPFery3YgPA3fr29s88hnpuenW85Ev1+78aBejITKZB096e0gn2DYT8vyn9HDeQ Ra9U2ePMyZJ944mXcirA5pBWzoabwTe1vt3YtzKx3eBAd1d9KeLDPbmzsimTEE2N2D TtfrkbOlgW3r2WuucLbO/PrbecW+HtlZOi/Hr2kI= 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 8128B3858D32 for ; Mon, 12 Jun 2023 15:32:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8128B3858D32 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-424-kShsDkwpMjmMfZuGdppZOQ-1; Mon, 12 Jun 2023 11:32:18 -0400 X-MC-Unique: kShsDkwpMjmMfZuGdppZOQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-75d4fb030a8so486058085a.2 for ; Mon, 12 Jun 2023 08:32:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583934; x=1689175934; 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=IkBKFE/ixOMkby1LT6nmmo4oENywO+G+dqcrlKKsGHc=; b=hBpDB4r6rONe478pStB8Sf6XCAkdF+oQncVTpjmB6nkSxTzXe4N+5vOjL/bjm77sOB t+Jj6lspJpmfor4VhFw8vtOfFUJHTF2IFuyYWfAXhWd/G+MzEA8bA4d9V14/inJblTcO r4D3A0AOxVi4CHLAyfgnEfy9/7XCkCZwOGoi/dKHNNmdI09wZAtTvwNTWzBYyUXiIDLU S61K1/a77ERIRy+MLx4e5yH/gR8k8AqQrqQieL43paLjwFMGr5+A41BSXHkY+KsRUjzi uIpuPlIIXHCSroKRpGKRC1HdyNjogOwRCK3gMp2mxcHkaGLBRSTrc9WsRDCfVlFGQKxU YxvQ== X-Gm-Message-State: AC+VfDyGf8dyvsDhiWWeTFD+CoGARKCuKYQn15dFyRCHfCKjZ8nYwYVb BXEzmLmOEvSBYvjc+8nfO/+eRUdud9cQVjUsYpC0x1A1uqe+ghY0d03JL1/yvUmDFXg+YDHkWdh 7FTX+/w1VPs8jMCqrlQBPL4dgOKKHDUV/sanl9GHLqIz2rrAYBaLzPMCaRAqcMNAeMXYo6HHr0c tZcQ== X-Received: by 2002:a05:620a:a58:b0:760:73be:be92 with SMTP id j24-20020a05620a0a5800b0076073bebe92mr4047606qka.28.1686583934084; Mon, 12 Jun 2023 08:32:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TCds0iFtorPyltDIIbN9Q/s9Rc3SKH2nNh3qaOP2+IJ1dGifDFMYrcHVcOvCrsE33q3J4yQ== X-Received: by 2002:a05:620a:a58:b0:760:73be:be92 with SMTP id j24-20020a05620a0a5800b0076073bebe92mr4047588qka.28.1686583933711; Mon, 12 Jun 2023 08:32:13 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id i2-20020a05620a074200b0075f2c1afb7fsm1575159qki.57.2023.06.12.08.32.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:13 -0700 (PDT) Message-ID: <8e5fb19b-9df3-6acb-4f18-08514ee9ef96@redhat.com> Date: Mon, 12 Jun 2023 11:32:12 -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 2/17] - Move operator_bitwise_not to the unified range-op table. 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, 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" Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 5bb4c53870db1331592a89119f41beee2b17d832 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 15:59:43 -0400 Subject: [PATCH 02/17] Move operator_bitwise_not to the unified range-op table. * range-op-mixed.h (class operator_bitwise_not): Move from... * range-op.cc (unified_table::unified_table): Add BIT_NOT_EXPR. (class operator_bitwise_not): Move from here. (integral_table::integral_table): Remove BIT_NOT_EXPR. (pointer_table::pointer_table): Remove BIT_NOT_EXPR. --- gcc/range-op-mixed.h | 13 +++++++++++++ gcc/range-op.cc | 21 +++------------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index d31b144169d..ba04c51a2d8 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -514,4 +514,17 @@ public: relation_trio rel = TRIO_VARYING) const final override; }; +class operator_bitwise_not : public range_operator +{ +public: + using range_operator::fold_range; + using range_operator::op1_range; + bool fold_range (irange &r, tree type, + const irange &lh, const irange &rh, + 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; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 20cc9b0dc9c..107582a9571 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -76,6 +76,7 @@ operator_minus op_minus; operator_negate op_negate; operator_mult op_mult; operator_addr_expr op_addr; +operator_bitwise_not op_bitwise_not; // Invoke the initialization routines for each class of range. @@ -105,8 +106,9 @@ unified_table::unified_table () set (MULT_EXPR, op_mult); // Occur in both integer and pointer tables, but currently share - // integral implelmentation. + // integral implementation. set (ADDR_EXPR, op_addr); + set (BIT_NOT_EXPR, op_bitwise_not); } // The tables are hidden and accessed via a simple extern function. @@ -4080,21 +4082,6 @@ operator_logical_not::op1_range (irange &r, } -class operator_bitwise_not : public range_operator -{ - using range_operator::fold_range; - using range_operator::op1_range; -public: - virtual bool fold_range (irange &r, tree type, - const irange &lh, - const irange &rh, - 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; -} op_bitwise_not; - bool operator_bitwise_not::fold_range (irange &r, tree type, const irange &lh, @@ -4602,7 +4589,6 @@ integral_table::integral_table () 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); } // Initialize any integral operators to the primary table @@ -4633,7 +4619,6 @@ pointer_table::pointer_table () set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); - set (BIT_NOT_EXPR, op_bitwise_not); set (BIT_XOR_EXPR, op_bitwise_xor); } -- 2.40.1 From patchwork Mon Jun 12 15:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793968 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=xnC5oxhx; 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 4QfwgH1Dnkz20QH for ; Tue, 13 Jun 2023 01:32:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 264113855898 for ; Mon, 12 Jun 2023 15:32:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 264113855898 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686583977; bh=vpNWyOiMyW3+E18vfWZNM9bRVbU1ymVupBpkB2FFirg=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xnC5oxhxo/GD66SCH3m8SccOB5+9oJd8J9x7oKbAiaeoOok2u9EqfaY7OYMwibgGz tOCOepJMu4Lf6Q2z3c6U8H4h2WkoV6ZjJwrc0+0MjoZ2qIbSb4u22JA7VBwuPqIt72 foTmLom4FROG8NX0261nW8A4DVCYGvUCpPpzk1Yw= 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 B98073857723 for ; Mon, 12 Jun 2023 15:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B98073857723 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-540-WQx0iabLN9-XIl5OzbkWqA-1; Mon, 12 Jun 2023 11:32:23 -0400 X-MC-Unique: WQx0iabLN9-XIl5OzbkWqA-1 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-39c7f777049so3036471b6e.0 for ; Mon, 12 Jun 2023 08:32:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583939; x=1689175939; 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=isiJkMjWZ/DUG8PC332AUCr/BHzk2rOPYNvllcaOq4A=; b=RjUFsfURaKQfsvL7eoED2QbARPzYaDnTJX2qbpEeVpHQ/T+n9FnBiV0G4x+Td426hm N4JGQJeeY3Yyz5mAI14YFlmwlALYCXK58711zc6+fKS0+6WXll4c6EAEL1pK3g+cwo49 5TcWYVjvhOjrM1Apu1EXf7FOXbSuMT2V0/KZml4VNZOwW9/iu7a2qULtbpLU3atqBXTK yxcrCI0KzAga8QSwtxDZ7u/zAkc3EkB5RRUFJcNhZM4sSfUxk5/tP+Dz/B/direRBOIb M30eKRimZYAKaFd0tmt1ibpLvIFen5M9qCWtjO/1+RLb0l6x2I5jnGBfFc4X9cS2Prm1 tw5A== X-Gm-Message-State: AC+VfDwm6SQee4l/uxdhSlDIqZSUdENoVNlzdeUPktAcDz56oisLwwBO qsP8bIilHgvnBK0zGhIN6LLb8qtXbTqaINieqyr+Nq3tu2K665YVmTS5MmI9+dp/jd7y0ZfOwfN aOALnvkaHiLtKDxmUGQRwhquWgWATpx7hjH5+Yj1wsaRE0RHz3qlgoEw5NtWfJ7qR59WS2gvRE4 lKlw== X-Received: by 2002:a05:6808:213:b0:397:fa4e:6107 with SMTP id l19-20020a056808021300b00397fa4e6107mr4386616oie.18.1686583939190; Mon, 12 Jun 2023 08:32:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Fx8gJyk+1OEBtUYCrBOECSBMrrS048AmvpK4zJwPEwRgbHS+RSJcvqa1EojEcM0pkcDEZ4A== X-Received: by 2002:a05:6808:213:b0:397:fa4e:6107 with SMTP id l19-20020a056808021300b00397fa4e6107mr4386600oie.18.1686583938890; Mon, 12 Jun 2023 08:32:18 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id o8-20020a05620a130800b0075caf18008bsm2913051qkj.116.2023.06.12.08.32.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:18 -0700 (PDT) Message-ID: <0b9acc83-57b2-ad2a-efa4-c4744f593348@redhat.com> Date: Mon, 12 Jun 2023 11:32:17 -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/17] - Move operator_bitwise_xor to the unified range-op table. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From cc18db2826c5449e84366644fa461816fa5f3f99 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:01:05 -0400 Subject: [PATCH 03/17] Move operator_bitwise_xor to the unified range-op table. * range-op-mixed.h (class operator_bitwise_xor): Move from... * range-op.cc (unified_table::unified_table): Add BIT_XOR_EXPR. (class operator_bitwise_xor): Move from here. (integral_table::integral_table): Remove BIT_XOR_EXPR. (pointer_table::pointer_table): Remove BIT_XOR_EXPR. --- gcc/range-op-mixed.h | 23 +++++++++++++++++++++++ gcc/range-op.cc | 36 +++++++----------------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index ba04c51a2d8..644473053e0 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -527,4 +527,27 @@ public: relation_trio rel = TRIO_VARYING) const final override; }; +class operator_bitwise_xor : public range_operator +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio rel = TRIO_VARYING) const final override; + bool op1_op2_relation_effect (irange &lhs_range, + tree type, + const irange &op1_range, + const irange &op2_range, + relation_kind rel) const; + 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; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 107582a9571..11f576c55c5 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -77,6 +77,7 @@ operator_negate op_negate; operator_mult op_mult; operator_addr_expr op_addr; operator_bitwise_not op_bitwise_not; +operator_bitwise_xor op_bitwise_xor; // Invoke the initialization routines for each class of range. @@ -109,6 +110,7 @@ unified_table::unified_table () // integral implementation. set (ADDR_EXPR, op_addr); set (BIT_NOT_EXPR, op_bitwise_not); + set (BIT_XOR_EXPR, op_bitwise_xor); } // The tables are hidden and accessed via a simple extern function. @@ -3732,33 +3734,12 @@ operator_bitwise_or::op2_range (irange &r, tree type, return operator_bitwise_or::op1_range (r, type, lhs, op1); } - -class operator_bitwise_xor : public range_operator +void +operator_bitwise_xor::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::op1_range; - using range_operator::op2_range; -public: - 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 bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio rel = TRIO_VARYING) const; - virtual bool op1_op2_relation_effect (irange &lhs_range, - tree type, - const irange &op1_range, - const irange &op2_range, - relation_kind rel) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, BIT_XOR_EXPR, lh, rh); } -} op_bitwise_xor; + update_known_bitmask (r, BIT_XOR_EXPR, lh, rh); +} void operator_bitwise_xor::wi_fold (irange &r, tree type, @@ -4588,7 +4569,6 @@ integral_table::integral_table () set (MAX_EXPR, op_max); set (BIT_AND_EXPR, op_bitwise_and); set (BIT_IOR_EXPR, op_bitwise_or); - set (BIT_XOR_EXPR, op_bitwise_xor); } // Initialize any integral operators to the primary table @@ -4618,8 +4598,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 (BIT_XOR_EXPR, op_bitwise_xor); } // Initialize any pointer operators to the primary table -- 2.40.1 From patchwork Mon Jun 12 15:32:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793969 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=Pjz6We+7; 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 4QfwhJ42x1z20QH for ; Tue, 13 Jun 2023 01:33:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8E100383906C for ; Mon, 12 Jun 2023 15:33:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E100383906C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584030; bh=40qPu3jeHFLKggS5K31LPiY/2Ni7JYd6kioJ2GTm7+k=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Pjz6We+7CTuq2x7l+pavVPcr3wrRdO8PlZRn4iD1SyvfKHMugeOzYnc2JIplOjWqY 29giE4pzOhK8IYa8A01O7rwSc6Lan0CLrthn4N/QsKPlXaH8W6ArMU4kXbBLO/4Lqo YpMjdhQdMNpMP66rK/GHRp6dsvwoI66ebS902mok= 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 51E2F3856DFB for ; Mon, 12 Jun 2023 15:32:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 51E2F3856DFB Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-30-a0h-ABBvPDO1d-3ISs6S_g-1; Mon, 12 Jun 2023 11:32:24 -0400 X-MC-Unique: a0h-ABBvPDO1d-3ISs6S_g-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-3f9e556c7d8so95281cf.0 for ; Mon, 12 Jun 2023 08:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583944; x=1689175944; 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=2MNmnFDSFz5LlRGE6E6KNtMNBwaxwX/abT60BRpoE4g=; b=S/CgsZbu2DEumfQzzw2X8vr7+Fx3ss4mVcK8vLv/xBoO7FUUK6HM4Vja6GvDiQXqMe UtWWrDdJE18mrz3bW1FCl/9pnIjB6/z9WyK04ISs0P/MpHOPKL6n2Bd4YoR4R51q6zjE +LvgjfyIBcxlmIJWR2ndKH17z4knVODMV7ou9Qn7e4uri2Qi4VwcjtNvy1x6o7VlNC5f cStOmMuKsS3+wwnfqkua7VR9YkLTw70fHeP13JQsO416dPA1mJOdhe27wYr6E0Ar09ug O8m1eJZfTrBg91fPj4iS3cBGZ05WJBhm2d60Zt8/OI0J3w7k88yuRpmpcVv2nxTxejEa 8OMQ== X-Gm-Message-State: AC+VfDxXl3XQfwL0Vb5SFjJ8F7bDJN3nJu0AWIPkSefjxkuUk7Hov8Ee 481Lvg+5EfW38VYRFbIAFQpwSinkCNeanX7H4Hs/lRA4LMhd0l4T5LYcUEmbVozpv8N8rMu3ihy F/FjxOC1FBujgqa8NMG0zLO+Qz4PmnlhEShy0VPdTey27hCpPZorpjR0uYdYXYlpPmJIa8vb//G NXSw== X-Received: by 2002:ac8:5d93:0:b0:3dc:ac3b:ca6c with SMTP id d19-20020ac85d93000000b003dcac3bca6cmr16678552qtx.6.1686583944007; Mon, 12 Jun 2023 08:32:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4sLLEKwnJJBX3CoawAXOcfDyXUzoHJzmT35pk7ox3tXDAa2kP8YVUXtNFd2v+7NoNyCyxDbQ== X-Received: by 2002:ac8:5d93:0:b0:3dc:ac3b:ca6c with SMTP id d19-20020ac85d93000000b003dcac3bca6cmr16678517qtx.6.1686583943588; Mon, 12 Jun 2023 08:32:23 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id bw18-20020a05622a099200b003f9aecb599fsm3501858qtb.35.2023.06.12.08.32.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:23 -0700 (PDT) Message-ID: <15991394-cf27-d4b9-e305-8a79fd2dac85@redhat.com> Date: Mon, 12 Jun 2023 11:32:22 -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/17] - Move operator_bitwise_and to the unified range-op table. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From f2166fc81194a3e4e9ef185a7404551b410bb752 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:02:09 -0400 Subject: [PATCH 04/17] Move operator_bitwise_and to the unified range-op table. At this point, the remaining 4 integral operation have different impllementations than pointers, so we now check for a pointer table entry first, then if there is nothing, look at the Unified table. * range-op-mixed.h (class operator_bitwise_and): Move from... * range-op.cc (unified_table::unified_table): Add BIT_AND_EXPR. (get_op_handler): Check for a pointer table entry first. (class operator_bitwise_and): Move from here. (integral_table::integral_table): Remove BIT_AND_EXPR. --- gcc/range-op-mixed.h | 27 ++++++++++++++++++++++++ gcc/range-op.cc | 49 ++++++++++++++------------------------------ 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 644473053e0..b3d51f8a54e 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -550,4 +550,31 @@ private: const wide_int &lh_ub, const wide_int &rh_lb, const wide_int &rh_ub) const final override; }; + +class operator_bitwise_and : public range_operator +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::lhs_op1_relation; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + 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; + 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 simple_op1_range_solver (irange &r, tree type, + const irange &lhs, + const irange &op2) const; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 11f576c55c5..57bd95a1151 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -78,6 +78,7 @@ operator_mult op_mult; operator_addr_expr op_addr; operator_bitwise_not op_bitwise_not; operator_bitwise_xor op_bitwise_xor; +operator_bitwise_and op_bitwise_and; // Invoke the initialization routines for each class of range. @@ -111,6 +112,11 @@ unified_table::unified_table () set (ADDR_EXPR, op_addr); set (BIT_NOT_EXPR, op_bitwise_not); set (BIT_XOR_EXPR, op_bitwise_xor); + + // These are in both integer and pointer tables, but pointer has a different + // implementation. These also remain in the pointer table until a pointer + // speifc version is provided. + set (BIT_AND_EXPR, op_bitwise_and); } // The tables are hidden and accessed via a simple extern function. @@ -118,16 +124,17 @@ unified_table::unified_table () range_operator * get_op_handler (enum tree_code code, tree type) { + // If this is pointer type and there is pointer specifc routine, use it. + if (POINTER_TYPE_P (type) && pointer_tree_table[code]) + return pointer_tree_table[code]; + 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]); 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]; return NULL; @@ -3121,37 +3128,12 @@ operator_logical_and::op2_range (irange &r, tree type, } -class operator_bitwise_and : public range_operator +void +operator_bitwise_and::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; -public: - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio rel = TRIO_VARYING) 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) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, BIT_AND_EXPR, lh, rh); } -private: - void simple_op1_range_solver (irange &r, tree type, - const irange &lhs, - const irange &op2) const; -} op_bitwise_and; - + update_known_bitmask (r, BIT_AND_EXPR, lh, rh); +} // Optimize BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR of signed types // by considering the number of leading redundant sign bit copies. @@ -4567,7 +4549,6 @@ integral_table::integral_table () { set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); - set (BIT_AND_EXPR, op_bitwise_and); set (BIT_IOR_EXPR, op_bitwise_or); } -- 2.40.1 From patchwork Mon Jun 12 15:32:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793972 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=SFzb9eKl; 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 4Qfwhj2g5nz20QH for ; Tue, 13 Jun 2023 01:34:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4FC0F38319FF for ; Mon, 12 Jun 2023 15:34:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FC0F38319FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584051; bh=zJBrDKGmYkii7BC1HyA/nYY7oMknsfKAuOQTVherBPA=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=SFzb9eKl4OcGMQe0j3UqB/oSvGrER74IYyxsz9HF4C3sK10Fg2j3wCo5qrY+Yl/Rp KaQMY5ndO9CadaxJa/mFf0fJeUSixfzZg8KcljyLvtR00XQPZM7CDqUwwD7RWoPZgA 2buvX+wDg+jlNvRXGtP6Rxdd46uKcOD8928FOrEQ= 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 C01E7385771E for ; Mon, 12 Jun 2023 15:32:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C01E7385771E 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-442-2_UNyWOPNviFtd9ZLBlceQ-1; Mon, 12 Jun 2023 11:32:34 -0400 X-MC-Unique: 2_UNyWOPNviFtd9ZLBlceQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-62dec818268so165066d6.0 for ; Mon, 12 Jun 2023 08:32:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583949; x=1689175949; 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=WZoCXT1yDrKdKBDEIpk9z2vgJ/hQoDz6i8KWY2wEfHE=; b=XMlinZKyFv0EFwv5K8cgqbOjen7hce9lDH/Fi06INbVwEoXmWPF0BQCFW181WBQEZ2 C0bRpiszgWnGMlM7U7UE8QD/wJ2tkRRop3Wl7Ja1FLw6RJgZl7aibpIusYoV4FvoX2+d 4vDINrlVfVDhdTrScyYN2Q82plMtU9jLoQHdFasj4FyW5EcIxDBdE5pse80c6HVXhv0E cRspM+WJEWl4JOFaC6wvSirtyDXKJ9Pcw5qmDUkEUABlkTaG8bPeXvRwfhnolWCX8NQ3 n0f6pF/d4wDqcKoUWpmwqqTVamnGHWRkz/HXpycKpUBS7evwhsTzYyG0RnRXgFpw3Fi2 6f3A== X-Gm-Message-State: AC+VfDz6KixQTadrHKUF3gJ/Q0+w6HVSIG+pNCcHwaFDvFEOodqR1MD7 GzhOkStrtsDrJeKI/BGDNm/9C4GdYTmUd1UKtuOMdCJ1NXAIAPXKejJwbI1BmgdmOyqLO/ONN7/ RwKUR8YbvDb1aDDCdhJ4I8klvcZ9yvWcx6/1zWqVY8HmVP96kGxEclMvN6FPRNr0Hz25zpbdOE8 hk9A== X-Received: by 2002:a05:6214:21ec:b0:62b:5aef:ee66 with SMTP id p12-20020a05621421ec00b0062b5aefee66mr9818989qvj.19.1686583948950; Mon, 12 Jun 2023 08:32:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ569y0Lahu1a5BlfxCL+qEwrh0qpBJPlg5rKQSlsnWPUOVQr3ddViZPfyCGJCBIXuC7yQjQdw== X-Received: by 2002:a05:6214:21ec:b0:62b:5aef:ee66 with SMTP id p12-20020a05621421ec00b0062b5aefee66mr9818961qvj.19.1686583948513; Mon, 12 Jun 2023 08:32:28 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id u5-20020a0c8dc5000000b006261d4ae7a5sm3261140qvb.68.2023.06.12.08.32.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:28 -0700 (PDT) Message-ID: <158c083d-028a-56b4-8fa8-5c2df0e9af5f@redhat.com> Date: Mon, 12 Jun 2023 11:32:27 -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 5/17] - Move operator_bitwise_or to the unified range-op table. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From a71ee5c2d48691280f76a90e2838d968f45de0c8 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:05:33 -0400 Subject: [PATCH 05/17] Move operator_bitwise_or to the unified range-op table. * range-op-mixed.h (class operator_bitwise_or): Move from... * range-op.cc (unified_table::unified_table): Add BIT_IOR_EXPR. (class operator_bitwise_or): Move from here. (integral_table::integral_table): Remove BIT_IOR_EXPR. --- gcc/range-op-mixed.h | 19 +++++++++++++++++++ gcc/range-op.cc | 28 +++++++--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index b3d51f8a54e..8a11d61220c 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -577,4 +577,23 @@ private: const irange &op2) const; }; +class operator_bitwise_or : public range_operator +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override; + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio rel = TRIO_VARYING) 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; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 57bd95a1151..07e0c88e209 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -79,6 +79,7 @@ operator_addr_expr op_addr; operator_bitwise_not op_bitwise_not; operator_bitwise_xor op_bitwise_xor; operator_bitwise_and op_bitwise_and; +operator_bitwise_or op_bitwise_or; // Invoke the initialization routines for each class of range. @@ -117,6 +118,7 @@ unified_table::unified_table () // implementation. These also remain in the pointer table until a pointer // speifc version is provided. set (BIT_AND_EXPR, op_bitwise_and); + set (BIT_IOR_EXPR, op_bitwise_or); } // The tables are hidden and accessed via a simple extern function. @@ -3608,27 +3610,12 @@ operator_logical_or::op2_range (irange &r, tree type, } -class operator_bitwise_or : public range_operator +void +operator_bitwise_or::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { - using range_operator::op1_range; - using range_operator::op2_range; -public: - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio rel = TRIO_VARYING) 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; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, BIT_IOR_EXPR, lh, rh); } -} op_bitwise_or; + update_known_bitmask (r, BIT_IOR_EXPR, lh, rh); +} void operator_bitwise_or::wi_fold (irange &r, tree type, @@ -4549,7 +4536,6 @@ integral_table::integral_table () { set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); - set (BIT_IOR_EXPR, op_bitwise_or); } // Initialize any integral operators to the primary table -- 2.40.1 From patchwork Mon Jun 12 15:32:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793975 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=op4qCsF+; 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 4Qfwjy2Ysjz20Vx for ; Tue, 13 Jun 2023 01:35:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BF0C385558A for ; Mon, 12 Jun 2023 15:35:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BF0C385558A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584116; bh=UbbGRRCaeQLL7L7unOxH5SgZujwelow7IXWw0BOyCko=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=op4qCsF+b7slfhFZOWJH4H89Zyz6sBLxop+Nc+JpR/J+N+JGnzcbiajOa0aB6OlLT jfUFajf/om6ngHCOtnItqiIXKNjKMzUAaAXCZ7BmcE8m1bYDxZBLFThakr2FdqEKgO e1yORUdNKq4FdrtRAlQUxcKdbIx4rbNjGHlv9JQI= 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 43E0B3856DDF for ; Mon, 12 Jun 2023 15:32:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 43E0B3856DDF Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-Lj9qzBcxMGek4z2oclQRqg-1; Mon, 12 Jun 2023 11:32:34 -0400 X-MC-Unique: Lj9qzBcxMGek4z2oclQRqg-1 Received: by mail-vk1-f200.google.com with SMTP id 71dfb90a1353d-461791658deso884149e0c.3 for ; Mon, 12 Jun 2023 08:32:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583953; x=1689175953; 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=lNP0FMrY0CBFM3Wm3SKjkBepnwbyDyl7rvicwthNVus=; b=Wu8ONlkbmK3q2yCi0MINbUjSOhcoa0sKKmzKmQztAImfrxQhQiNXzCLeeZZWPwfQhm Y6cdQkWMsm5QNGVY/s22rGt756g12QCbYqQzOJVeA9U/cnlqre628Bnmp0L+W6vMcz5D P37OQma2PKOfW/ZLRzFsuTzLNKHL1GLC/ncePikXTeW+E41+BBVnlmt4m2Ci6dnffnEE Ylm7p5J6vAKcQuXa+ZCp1j9ykw4sJGjBd/lcf3M2r6JAUrg+RNHTmRqvgU5YFUUXvQFH 1ls2xC+luqIDIk7Tmm8HchUPkkORbk2GPMpbjZp5YXBrdAl7/OACexch7jaGzKyCShWd 6Gxg== X-Gm-Message-State: AC+VfDxpwSlgPvBmBr4i3uVruPg+hQtoiByUoUMN8V7rXVkCpiCHxCiF 2y6UuiH77UIFrZktm9ipjtFtxCME+Cbh0lUn5ncDtqb+p1peewDyC8EJ4OsWcF/LraQ4dJNHxfD 9AfrxhJemjDXVdm+xJ4/9dMM2siPJ2sUZaTkPDscCObYFpmESbnPq0OrP8jJnBiuvcKmP7YabgL ra0A== X-Received: by 2002:a1f:5fc8:0:b0:466:1a69:2928 with SMTP id t191-20020a1f5fc8000000b004661a692928mr2654177vkb.7.1686583953445; Mon, 12 Jun 2023 08:32:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cbxFG6k6phO+nz6A+Brm5vWAJn5QCGD6uNNPA4ez9Spu4f5MenhMdHjvXF25gx/9URD702Q== X-Received: by 2002:a1f:5fc8:0:b0:466:1a69:2928 with SMTP id t191-20020a1f5fc8000000b004661a692928mr2654157vkb.7.1686583953091; Mon, 12 Jun 2023 08:32:33 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id i13-20020a0cf38d000000b0062df1a5e8c4sm247321qvk.27.2023.06.12.08.32.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:32 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:32:31 -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 6/17] - Move operator_min to the unified range-op table. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 508645fd461ceb8b743837e24411df2e17bd3950 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:09:58 -0400 Subject: [PATCH 06/17] Move operator_min to the unified range-op table. * range-op-mixed.h (class operator_min): Move from... * range-op.cc (unified_table::unified_table): Add MIN_EXPR. (class operator_min): Move from here. (integral_table::integral_table): Remove MIN_EXPR. --- gcc/range-op-mixed.h | 11 +++++++++++ gcc/range-op.cc | 18 +++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 8a11d61220c..7bd9b5e1129 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -596,4 +596,15 @@ private: const wide_int &rh_ub) const final override; }; +class operator_min : public range_operator +{ +public: + 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; +}; + #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 07e0c88e209..a777fb0d8a3 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -80,6 +80,7 @@ operator_bitwise_not op_bitwise_not; operator_bitwise_xor op_bitwise_xor; operator_bitwise_and op_bitwise_and; operator_bitwise_or op_bitwise_or; +operator_min op_min; // Invoke the initialization routines for each class of range. @@ -119,6 +120,7 @@ unified_table::unified_table () // speifc version is provided. set (BIT_AND_EXPR, op_bitwise_and); set (BIT_IOR_EXPR, op_bitwise_or); + set (MIN_EXPR, op_min); } // The tables are hidden and accessed via a simple extern function. @@ -1980,17 +1982,12 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, } -class operator_min : public range_operator +void +operator_min::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { -public: - 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; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, MIN_EXPR, lh, rh); } -} op_min; + update_known_bitmask (r, MIN_EXPR, lh, rh); +} void operator_min::wi_fold (irange &r, tree type, @@ -4534,7 +4531,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, integral_table::integral_table () { - set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); } -- 2.40.1 From patchwork Mon Jun 12 15:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793970 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=MKvj987r; 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 4QfwhK1n8bz20XR for ; Tue, 13 Jun 2023 01:33:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2D1F13836E84 for ; Mon, 12 Jun 2023 15:33:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D1F13836E84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584031; bh=KjjAi8c6o+m2sRfxeHyDy+pBcVV+mPX9/F0oJG/OFGA=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=MKvj987rxA0gKlNyzkZDx++3uGSH06qLz+lvDQjTMxCFj+//knzvj5alqJjZ1RIMy wLVBCu2oFUY+ihVJO02SROdrHClG4Z1TgjfZ+s69MB5I6t9r3tjHRHzKFuyk0nAt8K Nxxqg/nuFsbW4B4EWEPdAWT4NC8EonH3jHtTOT0M= 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 B0BFC385772B for ; Mon, 12 Jun 2023 15:32:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0BFC385772B Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-99h-83TCNg--oFpM2VdB3g-1; Mon, 12 Jun 2023 11:32:39 -0400 X-MC-Unique: 99h-83TCNg--oFpM2VdB3g-1 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-39ce91ab7ccso464270b6e.3 for ; Mon, 12 Jun 2023 08:32:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583958; x=1689175958; 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=TN+lHoDLwg1GDBMWj1rUkLsMWNUQNmGEyxDIDPy0tI8=; b=XSe27aWvr0KsjuVZtLMIllpEExnULxeLjb088bmvgRLvNnt8xod6x5L4RbIIZfp0z8 JOZa5HO9On5kBHA1aNlAkiUfsNuvgIDGc7NSXEisUSMV75DEZdmweFwq1cEl+Sw/QLd/ EM5mNUE+UkLfPWIt65RxZHNAB/R9hGQr1N7eE6eLDNtW+F7/QedvG7B1TCkzmrsE+lWV DbHy6sPHBcp536x+wWZdjQeC51QvOD43WkbzEgAbKx53Q0VeYvQyUQ12jPuK5abNJFi6 B7Iy4+nhWW9xF6EpgJlGEJSltZySBSJ1ukZU9cs9y6zwb2TA1csZqWFP0b57Dw+z350u D+Pg== X-Gm-Message-State: AC+VfDx//mC2kf6jLxT0FRAVHMOpnRH3r6my9frqSIrEXKGKslnidWFf JEVY2uOs8ZMZZBCGjYHphQLmYb95DfZpzcjWCeMDxChG7yaWBgE+BWE5B+a05Icit7u1W/GnKy4 hxvK21BYQjk/DVGAPFzeZ3HCxLOeO4/soC3iLjQ+22r+vTv7w/ck+oko41jLxUURJ34klAhtfVg c5iw== X-Received: by 2002:a05:6808:180a:b0:398:2b18:9aa8 with SMTP id bh10-20020a056808180a00b003982b189aa8mr5118527oib.20.1686583957836; Mon, 12 Jun 2023 08:32:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GbzAOGHP3HTI/vqMZk1z7reuarjMX9OXEKDazk62zOy9XcvOoEPUeN81OgLWYxPNB6AThQw== X-Received: by 2002:a05:6808:180a:b0:398:2b18:9aa8 with SMTP id bh10-20020a056808180a00b003982b189aa8mr5118509oib.20.1686583957531; Mon, 12 Jun 2023 08:32:37 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id u15-20020a05620a120f00b0075b2af4a076sm2947105qkj.16.2023.06.12.08.32.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:37 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:32:36 -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/17] - Move operator_max to the unified range-op table. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" This is the last of the integral operators, so also remove the integral table. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 6585fa54e0f2a54f1a398b49b5b4b6a9cd6da4ea Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:10:54 -0400 Subject: [PATCH 07/17] Move operator_max to the unified range-op table. Also remove the integral table. * range-op-mixed.h (class operator_max): Move from... * range-op.cc (unified_table::unified_table): Add MAX_EXPR. (get_op_handler): Remove the integral table. (class operator_max): Move from here. (integral_table::integral_table): Delete. * range-op.h (class integral_table): Delete. --- gcc/range-op-mixed.h | 10 ++++++++++ gcc/range-op.cc | 34 ++++++++-------------------------- gcc/range-op.h | 9 --------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 7bd9b5e1129..cd137acd0e6 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -607,4 +607,14 @@ private: const wide_int &rh_ub) const final override; }; +class operator_max : public range_operator +{ +public: + 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; +}; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op.cc b/gcc/range-op.cc index a777fb0d8a3..e83f627a722 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -49,7 +49,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-ccp.h" #include "range-op-mixed.h" -integral_table integral_tree_table; pointer_table pointer_tree_table; // Instantiate a range_op_table for unified operations. @@ -81,6 +80,7 @@ operator_bitwise_xor op_bitwise_xor; operator_bitwise_and op_bitwise_and; operator_bitwise_or op_bitwise_or; operator_min op_min; +operator_max op_max; // Invoke the initialization routines for each class of range. @@ -121,6 +121,7 @@ unified_table::unified_table () set (BIT_AND_EXPR, op_bitwise_and); set (BIT_IOR_EXPR, op_bitwise_or); set (MIN_EXPR, op_min); + set (MAX_EXPR, op_max); } // The tables are hidden and accessed via a simple extern function. @@ -132,16 +133,7 @@ get_op_handler (enum tree_code code, tree type) if (POINTER_TYPE_P (type) && pointer_tree_table[code]) return pointer_tree_table[code]; - if (unified_tree_table[code]) - { - // Should not be in any other table if it is in the unified table. - gcc_checking_assert (!integral_tree_table[code]); - return unified_tree_table[code]; - } - - if (INTEGRAL_TYPE_P (type)) - return integral_tree_table[code]; - return NULL; + return unified_tree_table[code]; } range_op_handler::range_op_handler () @@ -2001,17 +1993,12 @@ operator_min::wi_fold (irange &r, tree type, } -class operator_max : public range_operator +void +operator_max::update_bitmask (irange &r, const irange &lh, + const irange &rh) const { -public: - 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; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, MAX_EXPR, lh, rh); } -} op_max; + update_known_bitmask (r, MAX_EXPR, lh, rh); +} void operator_max::wi_fold (irange &r, tree type, @@ -4529,11 +4516,6 @@ pointer_or_operator::wi_fold (irange &r, tree type, r.set_varying (type); } -integral_table::integral_table () -{ - set (MAX_EXPR, op_max); -} - // Initialize any integral operators to the primary table void diff --git a/gcc/range-op.h b/gcc/range-op.h index 0f5ee41f96c..08c51bace40 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -299,15 +299,6 @@ range_op_table::set (enum tree_code code, range_operator &op) m_range_tree[code] = &op; } -// 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 -- 2.40.1 From patchwork Mon Jun 12 15:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793973 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=fL3ZF8cN; 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 4QfwjZ0jGBz20QH for ; Tue, 13 Jun 2023 01:34:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED9E43888C4E for ; Mon, 12 Jun 2023 15:34:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED9E43888C4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584095; bh=F3ATWGyffw4IRA5oSYxTLPiS1RHKB9suGtYGpzVHQ/o=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fL3ZF8cNSKekyWZW2356kOe75Hndnp3P/rE19qqQc4+1MJvPjnjQCZp8WsfPI8tPJ An8QRFNUc1QqzCZ1VN+26y6UygVSylb586Rqq3OjcGNXKLXb83cjSXIab/YGqg3tdU NQezsInPmppQiKCYsBcrmpim0a3O8oh58MCkZVH4= 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 31EFD3858020 for ; Mon, 12 Jun 2023 15:32:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31EFD3858020 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-606-66iFGxoaM6-poibUyuzkDw-1; Mon, 12 Jun 2023 11:32:43 -0400 X-MC-Unique: 66iFGxoaM6-poibUyuzkDw-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f9a7a41baeso45001791cf.1 for ; Mon, 12 Jun 2023 08:32:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583962; x=1689175962; 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=q0umecH9tKHgRkeEvRIEznQIrI/LlYxiRc4wxX63K7k=; b=Yo3YPZ3L4Tk7DRwTuiHLlOCgpEMq+wdjWp2XsKd7vHNGYIU6QqLIMbRxCPl5XPTTXL 6T/FwFu3/WQUBLxccn6FJM5JZzG6dKzRiYdVNP6c1zjIlLeInkqhfAaDTT6BlDHmE0bV fo1zPcbz7gRpDb+DSyS0rr2qd+fgBEj0U6T9UNxWaFEjJf+TJ5ELI7g0i0IsP21UDlFh ItmMpWxSJBGxhPHf6V0aQyTdASjNOu0bYK1OT3eWs2hWxNZOoapKWPThunkGoEEBUySQ tQSsCUV0+f6zO/xnm5TOJ0P/pDmmi0eyIREulk8SdtH+NKvVQYb6MW3/tWZcpdzOmXAi YXeA== X-Gm-Message-State: AC+VfDz7uFqlnvYnPCI7ngxHQIIo49XZ8u2F68WevhDOlPmQMzw6v4cV +QO1itNmIFe3pZH5f+vN4H4rzXtIwJTie4mceKrLBqHvcsKBWQQjMEHwqWU2nk1uKJWulgcYzYE Gte62OctmLkIRW+pEGCE3A5Zmr9PIwYMhAKOHZzQX6531PmyGwE1v5fIDtu9TVXRz4xmZcj6yzV I8Eg== X-Received: by 2002:ac8:7fc8:0:b0:3f3:845f:122c with SMTP id b8-20020ac87fc8000000b003f3845f122cmr11007393qtk.34.1686583962559; Mon, 12 Jun 2023 08:32:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51ruHhXALpNFLnck75XrvEFfVYmInFfaukVbT0W9S2kLpiVcit0FRziWLIa5ZR4Fg6WOmbwg== X-Received: by 2002:ac8:7fc8:0:b0:3f3:845f:122c with SMTP id b8-20020ac87fc8000000b003f3845f122cmr11007363qtk.34.1686583962143; Mon, 12 Jun 2023 08:32:42 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id fy26-20020a05622a5a1a00b003f86bc1753bsm3475201qtb.80.2023.06.12.08.32.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:41 -0700 (PDT) Message-ID: <419f4280-d0c5-7fbe-2dae-4c198b69186e@redhat.com> Date: Mon, 12 Jun 2023 11:32:40 -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/17] - Split pointer based range operators to range-op-ptr.cc X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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, 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 moves all the pointer specific code into a new file range-op-ptr.cc Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From cb511d2209fa3a05801983a6965656734c1592c6 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:17:51 -0400 Subject: [PATCH 08/17] Split pointer ibased range operators to range-op-ptr.cc MOve the pointer table and all pointer specific operators into a new file for pointers. * Makefile.in (OBJS): Add range-op-ptr.o. * range-op-mixed.h (update_known_bitmask): Move prototype here. (minus_op1_op2_relation_effect): Move prototype here. (wi_includes_zero_p): Move function to here. (wi_zero_p): Ditto. * range-op.cc (update_known_bitmask): Remove static. (wi_includes_zero_p): Move to header. (wi_zero_p): Move to header. (minus_op1_op2_relation_effect): Remove static. (operator_pointer_diff): Move class and routines to range-op-ptr.cc. (pointer_plus_operator): Ditto. (pointer_min_max_operator): Ditto. (pointer_and_operator): Ditto. (pointer_or_operator): Ditto. (pointer_table): Ditto. (range_op_table::initialize_pointer_ops): Ditto. * range-op-ptr.cc: New. --- gcc/Makefile.in | 1 + gcc/range-op-mixed.h | 25 ++++ gcc/range-op-ptr.cc | 286 +++++++++++++++++++++++++++++++++++++++++++ gcc/range-op.cc | 258 +------------------------------------- 4 files changed, 314 insertions(+), 256 deletions(-) create mode 100644 gcc/range-op-ptr.cc diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 0c02f312985..4be82e83b9e 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1588,6 +1588,7 @@ OBJS = \ range.o \ range-op.o \ range-op-float.o \ + range-op-ptr.o \ read-md.o \ read-rtl.o \ read-rtl-function.o \ diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index cd137acd0e6..b188f5a516e 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -22,6 +22,31 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_RANGE_OP_MIXED_H #define GCC_RANGE_OP_MIXED_H +void update_known_bitmask (irange &, tree_code, const irange &, const irange &); +bool minus_op1_op2_relation_effect (irange &lhs_range, tree type, + const irange &, const irange &, + relation_kind rel); + + +// Return TRUE if 0 is within [WMIN, WMAX]. + +inline bool +wi_includes_zero_p (tree type, const wide_int &wmin, const wide_int &wmax) +{ + signop sign = TYPE_SIGN (type); + return wi::le_p (wmin, 0, sign) && wi::ge_p (wmax, 0, sign); +} + +// Return TRUE if [WMIN, WMAX] is the singleton 0. + +inline bool +wi_zero_p (tree type, const wide_int &wmin, const wide_int &wmax) +{ + unsigned prec = TYPE_PRECISION (type); + return wmin == wmax && wi::eq_p (wmin, wi::zero (prec)); +} + + 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); diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc new file mode 100644 index 00000000000..55c37cc8c86 --- /dev/null +++ b/gcc/range-op-ptr.cc @@ -0,0 +1,286 @@ +/* Code for range operators. + 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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "insn-codes.h" +#include "rtl.h" +#include "tree.h" +#include "gimple.h" +#include "cfghooks.h" +#include "tree-pass.h" +#include "ssa.h" +#include "optabs-tree.h" +#include "gimple-pretty-print.h" +#include "diagnostic-core.h" +#include "flags.h" +#include "fold-const.h" +#include "stor-layout.h" +#include "calls.h" +#include "cfganal.h" +#include "gimple-iterator.h" +#include "gimple-fold.h" +#include "tree-eh.h" +#include "gimple-walk.h" +#include "tree-cfg.h" +#include "wide-int.h" +#include "value-relation.h" +#include "range-op.h" +#include "tree-ssa-ccp.h" +#include "range-op-mixed.h" + +class pointer_plus_operator : public range_operator +{ + using range_operator::op2_range; +public: + 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 bool op2_range (irange &r, tree type, + const irange &lhs, + const irange &op1, + relation_trio = TRIO_VARYING) const; + void update_bitmask (irange &r, const irange &lh, const irange &rh) const + { update_known_bitmask (r, POINTER_PLUS_EXPR, lh, rh); } +} op_pointer_plus; + +void +pointer_plus_operator::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 +{ + // Check for [0,0] + const, and simply return the const. + if (lh_lb == 0 && lh_ub == 0 && rh_lb == rh_ub) + { + r.set (type, rh_lb, rh_lb); + return; + } + + // For pointer types, we are really only interested in asserting + // whether the expression evaluates to non-NULL. + // + // With -fno-delete-null-pointer-checks we need to be more + // conservative. As some object might reside at address 0, + // then some offset could be added to it and the same offset + // subtracted again and the result would be NULL. + // E.g. + // static int a[12]; where &a[0] is NULL and + // ptr = &a[6]; + // ptr -= 6; + // ptr will be NULL here, even when there is POINTER_PLUS_EXPR + // where the first range doesn't include zero and the second one + // doesn't either. As the second operand is sizetype (unsigned), + // consider all ranges where the MSB could be set as possible + // subtractions where the result might be NULL. + if ((!wi_includes_zero_p (type, lh_lb, lh_ub) + || !wi_includes_zero_p (type, rh_lb, rh_ub)) + && !TYPE_OVERFLOW_WRAPS (type) + && (flag_delete_null_pointer_checks + || !wi::sign_mask (rh_ub))) + r = range_nonzero (type); + else if (lh_lb == lh_ub && lh_lb == 0 + && rh_lb == rh_ub && rh_lb == 0) + r = range_zero (type); + else + r.set_varying (type); +} + +bool +pointer_plus_operator::op2_range (irange &r, tree type, + const irange &lhs ATTRIBUTE_UNUSED, + const irange &op1 ATTRIBUTE_UNUSED, + relation_trio trio) const +{ + relation_kind rel = trio.lhs_op1 (); + r.set_varying (type); + + // If the LHS and OP1 are equal, the op2 must be zero. + if (rel == VREL_EQ) + r.set_zero (type); + // If the LHS and OP1 are not equal, the offset must be non-zero. + else if (rel == VREL_NE) + r.set_nonzero (type); + else + return false; + return true; +} + +class pointer_min_max_operator : public range_operator +{ +public: + 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; +} op_ptr_min_max; + +void +pointer_min_max_operator::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 +{ + // For MIN/MAX expressions with pointers, we only care about + // nullness. If both are non null, then the result is nonnull. + // If both are null, then the result is null. Otherwise they + // are varying. + if (!wi_includes_zero_p (type, lh_lb, lh_ub) + && !wi_includes_zero_p (type, rh_lb, rh_ub)) + r = range_nonzero (type); + else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub)) + r = range_zero (type); + else + r.set_varying (type); +} + + +class pointer_and_operator : public range_operator +{ +public: + 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; +} op_pointer_and; + +void +pointer_and_operator::wi_fold (irange &r, tree type, + const wide_int &lh_lb, + const wide_int &lh_ub, + const wide_int &rh_lb ATTRIBUTE_UNUSED, + const wide_int &rh_ub ATTRIBUTE_UNUSED) const +{ + // For pointer types, we are really only interested in asserting + // whether the expression evaluates to non-NULL. + if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub)) + r = range_zero (type); + else + r.set_varying (type); +} + + +class pointer_or_operator : public range_operator +{ + using range_operator::op1_range; + using range_operator::op2_range; +public: + virtual bool op1_range (irange &r, tree type, + const irange &lhs, + const irange &op2, + relation_trio rel = TRIO_VARYING) const; + virtual bool op2_range (irange &r, tree type, + const irange &lhs, + const irange &op1, + relation_trio rel = TRIO_VARYING) 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; +} op_pointer_or; + +bool +pointer_or_operator::op1_range (irange &r, tree type, + const irange &lhs, + const irange &op2 ATTRIBUTE_UNUSED, + relation_trio) const +{ + if (lhs.undefined_p ()) + return false; + if (lhs.zero_p ()) + { + r.set_zero (type); + return true; + } + r.set_varying (type); + return true; +} + +bool +pointer_or_operator::op2_range (irange &r, tree type, + const irange &lhs, + const irange &op1, + relation_trio) const +{ + return pointer_or_operator::op1_range (r, type, lhs, op1); +} + +void +pointer_or_operator::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 +{ + // For pointer types, we are really only interested in asserting + // whether the expression evaluates to non-NULL. + if (!wi_includes_zero_p (type, lh_lb, lh_ub) + && !wi_includes_zero_p (type, rh_lb, rh_ub)) + r = range_nonzero (type); + else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub)) + r = range_zero (type); + else + r.set_varying (type); +} + +class operator_pointer_diff : public range_operator +{ + virtual bool op1_op2_relation_effect (irange &lhs_range, + tree type, + const irange &op1_range, + const irange &op2_range, + relation_kind rel) const; + void update_bitmask (irange &r, const irange &lh, const irange &rh) const + { update_known_bitmask (r, POINTER_DIFF_EXPR, lh, rh); } +} op_pointer_diff; + +bool +operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, + const irange &op1_range, + const irange &op2_range, + relation_kind rel) const +{ + return minus_op1_op2_relation_effect (lhs_range, type, op1_range, op2_range, + rel); +} + +// When PRANGE is implemented, these are all the opcodes which are currently +// expecting routines with PRANGE signatures. + +pointer_table::pointer_table () +{ + set (BIT_AND_EXPR, op_pointer_and); + set (BIT_IOR_EXPR, op_pointer_or); + set (MIN_EXPR, op_ptr_min_max); + set (MAX_EXPR, op_ptr_min_max); +} + +// 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); +} diff --git a/gcc/range-op.cc b/gcc/range-op.cc index e83f627a722..e0cd1b10790 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -381,7 +381,7 @@ irange_to_masked_value (const irange &r, widest_int &value, widest_int &mask) // Update the known bitmasks in R when applying the operation CODE to // LH and RH. -static void +void update_known_bitmask (irange &r, tree_code code, const irange &lh, const irange &rh) { @@ -444,24 +444,6 @@ get_shift_range (irange &r, tree type, const irange &op) return true; } -// Return TRUE if 0 is within [WMIN, WMAX]. - -static inline bool -wi_includes_zero_p (tree type, const wide_int &wmin, const wide_int &wmax) -{ - signop sign = TYPE_SIGN (type); - return wi::le_p (wmin, 0, sign) && wi::ge_p (wmax, 0, sign); -} - -// Return TRUE if [WMIN, WMAX] is the singleton 0. - -static inline bool -wi_zero_p (tree type, const wide_int &wmin, const wide_int &wmax) -{ - unsigned prec = TYPE_PRECISION (type); - return wmin == wmax && wi::eq_p (wmin, wi::zero (prec)); -} - // Default wide_int fold operation returns [MIN, MAX]. void @@ -1844,7 +1826,7 @@ operator_minus::lhs_op1_relation (const irange &, const irange &op1, // LHS of the expression. If so, apply it to LHS_RANGE. This is a helper // function for both MINUS_EXPR and POINTER_DIFF_EXPR. -static bool +bool minus_op1_op2_relation_effect (irange &lhs_range, tree type, const irange &op1_range ATTRIBUTE_UNUSED, const irange &op2_range ATTRIBUTE_UNUSED, @@ -1951,29 +1933,6 @@ operator_minus::op2_range (irange &r, tree type, return fold_range (r, type, op1, lhs); } - -class operator_pointer_diff : public range_operator -{ - virtual bool op1_op2_relation_effect (irange &lhs_range, - tree type, - const irange &op1_range, - const irange &op2_range, - relation_kind rel) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, POINTER_DIFF_EXPR, lh, rh); } -} op_pointer_diff; - -bool -operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, - const irange &op1_range, - const irange &op2_range, - relation_kind rel) const -{ - return minus_op1_op2_relation_effect (lhs_range, type, op1_range, op2_range, - rel); -} - - void operator_min::update_bitmask (irange &r, const irange &lh, const irange &rh) const @@ -4319,202 +4278,6 @@ operator_addr_expr::op1_range (irange &r, tree type, { return operator_addr_expr::fold_range (r, type, lhs, op2); } - - -class pointer_plus_operator : public range_operator -{ - using range_operator::op2_range; -public: - 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 bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio = TRIO_VARYING) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const - { update_known_bitmask (r, POINTER_PLUS_EXPR, lh, rh); } -} op_pointer_plus; - -void -pointer_plus_operator::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 -{ - // Check for [0,0] + const, and simply return the const. - if (lh_lb == 0 && lh_ub == 0 && rh_lb == rh_ub) - { - r.set (type, rh_lb, rh_lb); - return; - } - - // For pointer types, we are really only interested in asserting - // whether the expression evaluates to non-NULL. - // - // With -fno-delete-null-pointer-checks we need to be more - // conservative. As some object might reside at address 0, - // then some offset could be added to it and the same offset - // subtracted again and the result would be NULL. - // E.g. - // static int a[12]; where &a[0] is NULL and - // ptr = &a[6]; - // ptr -= 6; - // ptr will be NULL here, even when there is POINTER_PLUS_EXPR - // where the first range doesn't include zero and the second one - // doesn't either. As the second operand is sizetype (unsigned), - // consider all ranges where the MSB could be set as possible - // subtractions where the result might be NULL. - if ((!wi_includes_zero_p (type, lh_lb, lh_ub) - || !wi_includes_zero_p (type, rh_lb, rh_ub)) - && !TYPE_OVERFLOW_WRAPS (type) - && (flag_delete_null_pointer_checks - || !wi::sign_mask (rh_ub))) - r = range_nonzero (type); - else if (lh_lb == lh_ub && lh_lb == 0 - && rh_lb == rh_ub && rh_lb == 0) - r = range_zero (type); - else - r.set_varying (type); -} - -bool -pointer_plus_operator::op2_range (irange &r, tree type, - const irange &lhs ATTRIBUTE_UNUSED, - const irange &op1 ATTRIBUTE_UNUSED, - relation_trio trio) const -{ - relation_kind rel = trio.lhs_op1 (); - r.set_varying (type); - - // If the LHS and OP1 are equal, the op2 must be zero. - if (rel == VREL_EQ) - r.set_zero (type); - // If the LHS and OP1 are not equal, the offset must be non-zero. - else if (rel == VREL_NE) - r.set_nonzero (type); - else - return false; - return true; -} - -class pointer_min_max_operator : public range_operator -{ -public: - 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; -} op_ptr_min_max; - -void -pointer_min_max_operator::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 -{ - // For MIN/MAX expressions with pointers, we only care about - // nullness. If both are non null, then the result is nonnull. - // If both are null, then the result is null. Otherwise they - // are varying. - if (!wi_includes_zero_p (type, lh_lb, lh_ub) - && !wi_includes_zero_p (type, rh_lb, rh_ub)) - r = range_nonzero (type); - else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub)) - r = range_zero (type); - else - r.set_varying (type); -} - - -class pointer_and_operator : public range_operator -{ -public: - 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; -} op_pointer_and; - -void -pointer_and_operator::wi_fold (irange &r, tree type, - const wide_int &lh_lb, - const wide_int &lh_ub, - const wide_int &rh_lb ATTRIBUTE_UNUSED, - const wide_int &rh_ub ATTRIBUTE_UNUSED) const -{ - // For pointer types, we are really only interested in asserting - // whether the expression evaluates to non-NULL. - if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub)) - r = range_zero (type); - else - r.set_varying (type); -} - - -class pointer_or_operator : public range_operator -{ - using range_operator::op1_range; - using range_operator::op2_range; -public: - virtual bool op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2, - relation_trio rel = TRIO_VARYING) const; - virtual bool op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio rel = TRIO_VARYING) 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; -} op_pointer_or; - -bool -pointer_or_operator::op1_range (irange &r, tree type, - const irange &lhs, - const irange &op2 ATTRIBUTE_UNUSED, - relation_trio) const -{ - if (lhs.undefined_p ()) - return false; - if (lhs.zero_p ()) - { - r.set_zero (type); - return true; - } - r.set_varying (type); - return true; -} - -bool -pointer_or_operator::op2_range (irange &r, tree type, - const irange &lhs, - const irange &op1, - relation_trio) const -{ - return pointer_or_operator::op1_range (r, type, lhs, op1); -} - -void -pointer_or_operator::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 -{ - // For pointer types, we are really only interested in asserting - // whether the expression evaluates to non-NULL. - if (!wi_includes_zero_p (type, lh_lb, lh_ub) - && !wi_includes_zero_p (type, rh_lb, rh_ub)) - r = range_nonzero (type); - else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub)) - r = range_zero (type); - else - r.set_varying (type); -} // Initialize any integral operators to the primary table @@ -4537,23 +4300,6 @@ range_op_table::initialize_integral_ops () set (ABSU_EXPR, op_absu); } -pointer_table::pointer_table () -{ - set (BIT_AND_EXPR, op_pointer_and); - set (BIT_IOR_EXPR, op_pointer_or); - set (MIN_EXPR, op_ptr_min_max); - set (MAX_EXPR, op_ptr_min_max); -} - -// 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" -- 2.40.1 From patchwork Mon Jun 12 15:32:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793979 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=dODpI3bU; 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 4QfwlH1Gb2z20Vx for ; Tue, 13 Jun 2023 01:36:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 360A5389A103 for ; Mon, 12 Jun 2023 15:36:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 360A5389A103 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584185; bh=Noqm5QhwhY28z4Q0yCwBiaMOcKjHBNnCTsZDqlOX8M8=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=dODpI3bUhhOgT/Q1Ul52eXRxF9HYEZpPLyRiKh42FPI4XbvVkZqmMUxqHV4K2QpqK fLj2lwpPjWoH8Z1HqbwR6p9LKngMbWch73rrxMIl/iBw00hdxeGMcoUZrawEe9K0y5 WxLkpBXIFDEf8x+Q164+GL6XNuS0B16Gxm0ulELM= 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 EE19E3858298 for ; Mon, 12 Jun 2023 15:32:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE19E3858298 Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-Ej-IoP4RPOqc7RhIQTa5Cw-1; Mon, 12 Jun 2023 11:32:49 -0400 X-MC-Unique: Ej-IoP4RPOqc7RhIQTa5Cw-1 Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-460a63d4923so1304568e0c.0 for ; Mon, 12 Jun 2023 08:32:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583968; x=1689175968; 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=1r17L22mAT9y6S4p1OKlDKftadkeB1PejGHw7H77818=; b=CYPSqK6qv3V8uPXmMANQN2sohh+nVwA3f02MbloM9XA0lwordkOp0h4M1RhbYt+K/F X12Wtz8jyh4pP8IqQ5aBtbZRAjJGS1LVI0GL9Bk041w+AFBZIbKaV5+Dk0pzVmQR9AQR l9loeUqbPvTk37wb+jnmODU86BZaQWBPpoSUl6u9XbDEOhjbnU0wUn3RPRmXC6JKS9XB sk+7xsNr8FPax8m85x4r0zrr61GumOUmNcavBxcHiM7cdV5nC/0oC4vC+3LSd8rcfkbo QLQuCEZ3e7jJEmHNVvgKEwdWt4LwYtvVf44OCOGSGjIVhgqqBw3sFKE5LlNl8rzWGU0T Xe5w== X-Gm-Message-State: AC+VfDzFmPZAwHtqzNjMOfOi0+nPM9YyQVqqzKoCiDR1oZ20vm/iyM4J 9+vWoKm9l8y8NUthWt5rKckgaNShe5zBz0of786mfseI671jAJnUWVJ+lCAk93YJ8bNWNxdfmL5 8FwSz0GWUd4VVOGCAJ3FMVdDjSQqApg2vq6akhq/7bbmh5pX/019yOmwuvJrq4ERZnhgc8BCTFR G4dg== X-Received: by 2002:a1f:4c81:0:b0:457:4515:bdf2 with SMTP id z123-20020a1f4c81000000b004574515bdf2mr3329239vka.1.1686583968524; Mon, 12 Jun 2023 08:32:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4D50AuO/0ycuoZB6zG2fhbGL5qhKNvfjHClUFgByEp4Bm0DnORUR4EIRCqfvq8gCmw1UOkJA== X-Received: by 2002:a1f:4c81:0:b0:457:4515:bdf2 with SMTP id z123-20020a1f4c81000000b004574515bdf2mr3329224vka.1.1686583968062; Mon, 12 Jun 2023 08:32:48 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id i13-20020a0cf38d000000b0062df1a5e8c4sm247469qvk.27.2023.06.12.08.32.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:47 -0700 (PDT) Message-ID: <690d98ed-2389-d664-dff6-00617dd596c0@redhat.com> Date: Mon, 12 Jun 2023 11:32:46 -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/17] - Add a hybrid BIT_AND_EXPR operator for integer and pointer. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" Add a hybrid operator to choose between integer and pointer versions at runtime. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 8adb8b2fd5797706e9fbb353d52fda123545431d Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:28:40 -0400 Subject: [PATCH 09/17] Add a hybrid BIT_AND_EXPR operator for integer and pointer. This adds an operator to the unified table for BIT_AND_EXPR which will select either the pointer or integer version based on the type passed to the method. This is for use until we have a seperate PRANGE class. * range-op-mixed.h (operator_bitwise_and): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove BIT_AND_EXPR. (class hybrid_and_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_and_operator. * range-op.cc (unified_table::unified_table): Comment out BIT_AND_EXPR. --- gcc/range-op-mixed.h | 12 ++++----- gcc/range-op-ptr.cc | 62 +++++++++++++++++++++++++++++++++++++++++++- gcc/range-op.cc | 9 ++++--- 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index b188f5a516e..4177818e4b9 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -584,19 +584,19 @@ public: using range_operator::lhs_op1_relation; bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, - relation_trio rel = TRIO_VARYING) const final override; + relation_trio rel = TRIO_VARYING) const override; bool op2_range (irange &r, tree type, const irange &lhs, const irange &op1, - relation_trio rel = TRIO_VARYING) const final override; + relation_trio rel = TRIO_VARYING) const override; relation_kind lhs_op1_relation (const irange &lhs, const irange &op1, const irange &op2, - relation_kind) const final override; + relation_kind) const override; void update_bitmask (irange &r, const irange &lh, - const irange &rh) const final override; -private: + const irange &rh) const override; +protected: 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; + const wide_int &rh_ub) const override; void simple_op1_range_solver (irange &r, tree type, const irange &lhs, const irange &op2) const; diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 55c37cc8c86..941026994ed 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -270,12 +270,71 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, pointer_table::pointer_table () { - set (BIT_AND_EXPR, op_pointer_and); set (BIT_IOR_EXPR, op_pointer_or); set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); } +// ---------------------------------------------------------------------- +// Hybrid operators for the 4 operations which integer and pointers share, +// but which have different implementations. Simply check the type in +// the call and choose the appropriate method. +// Once there is a PRANGE signature, simply add the appropriate +// prototypes in the rmixed range class, and remove these hybrid classes. + +class hybrid_and_operator : public operator_bitwise_and +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::lhs_op1_relation; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_and::op1_range (r, type, lhs, op2, rel); + else + return false; + } + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio rel = TRIO_VARYING) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_and::op2_range (r, type, lhs, op1, rel); + else + return false; + } + relation_kind lhs_op1_relation (const irange &lhs, + const irange &op1, const irange &op2, + relation_kind rel) const final override + { + if (!lhs.undefined_p () && INTEGRAL_TYPE_P (lhs.type ())) + return operator_bitwise_and::lhs_op1_relation (lhs, op1, op2, rel); + else + return VREL_VARYING; + } + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_bitwise_and::update_bitmask (r, lh, rh); + } + + 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 + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_and::wi_fold (r, type, lh_lb, lh_ub, + rh_lb, rh_ub); + else + return op_pointer_and.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_and; + + // Initialize any pointer operators to the primary table void @@ -283,4 +342,5 @@ range_op_table::initialize_pointer_ops () { set (POINTER_PLUS_EXPR, op_pointer_plus); set (POINTER_DIFF_EXPR, op_pointer_diff); + set (BIT_AND_EXPR, op_hybrid_and); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index e0cd1b10790..dcb922143ce 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -116,9 +116,12 @@ unified_table::unified_table () set (BIT_XOR_EXPR, op_bitwise_xor); // These are in both integer and pointer tables, but pointer has a different - // implementation. These also remain in the pointer table until a pointer - // speifc version is provided. - set (BIT_AND_EXPR, op_bitwise_and); + // implementation. + // If commented out, there is a hybrid version in range-op-ptr.cc which + // is used until there is a pointer range class. Then we can simply + // uncomment the operator here and use the unified version. + + //set (BIT_AND_EXPR, op_bitwise_and); set (BIT_IOR_EXPR, op_bitwise_or); set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); -- 2.40.1 From patchwork Mon Jun 12 15:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793982 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=VEtVm9F0; 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 4QfwmP3jY1z20Vx for ; Tue, 13 Jun 2023 01:37:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E3C9392AC36 for ; Mon, 12 Jun 2023 15:37:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E3C9392AC36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584243; bh=AeM/9ZEjMz/7TxGw4FKU+IRjnExPbrIpcl3MFkAFHVE=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=VEtVm9F0NAPRlTdI9opn8WGrIiumnY68p52OPniMsU+NGHMM14H8PoAp6Z/az6v2I gRxrbzNqrlrMChA5lK+TB3uT3dEeHoysm6lhI8poi4x/M5UbbW6l6qRyinUPQ9WRn+ AX2gJ7sy64HD4AF88NB1qeTi1Nazn7WLq8ZUKOKA= 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 04CA7385558F for ; Mon, 12 Jun 2023 15:32:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04CA7385558F Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-MEmgIM4nNY6fNqyebs261g-1; Mon, 12 Jun 2023 11:32:54 -0400 X-MC-Unique: MEmgIM4nNY6fNqyebs261g-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-7834ce87f84so1633635241.2 for ; Mon, 12 Jun 2023 08:32:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583973; x=1689175973; 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=/k+N6diUEunezkrG/lOY5kJP5kRCTF22w3nKi0tbo9k=; b=BJSM0+CvjHvNJtY12SvYTNEBColYwV7G9mIx/zgRWXQiQ0TTC3zfIe7Az+AAmRVJkj W8myDJ83IGNOHgLxnwziuBQt7DwSr3kR2IsIlUKx/GPYnB/SABo0/wdjm26YUuGaXEHx agTuBz1kfLhT+UrKLDW7MFPrEz+Zk+3lnD7jWZrqIXe+FKa36du82acYB6fz6ayhuLVh gTmLkf6G1406Za71SwXdfjt2O81+NuognTNoU5n3pMWGfl7Erj38gYoo9sl+H1d//Aqm wNshrqZfvzV1hQGqJEXuKX255X3sFlR8X+3y3WyPyYQ9BojSQZYDwkcx8CpqPdzutxlJ Vk3Q== X-Gm-Message-State: AC+VfDyn8c2DcMJGYU76NxT10old2cYIkYx7C/r/DNrKbEPQq1OYjPW3 33Q82NDXgWjc58lZOzmKqnGeT5n/+WW9tSsY8Fdvd4icdXNTGzJp0QfsYRXQUsvfW2Mkzbvfazd EiccU0knc/Tot6j7yL8GbXLn/fYL9Si64VLzvs2nwQ2RXCOEwbGCNbQ1O5xsxZAdHmHzB3iKJbs vCMA== X-Received: by 2002:a67:e3a2:0:b0:43b:19f4:88d9 with SMTP id j2-20020a67e3a2000000b0043b19f488d9mr3574253vsm.21.1686583973464; Mon, 12 Jun 2023 08:32:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SVw/HTd18RLFAqBRCvjymqjkrdhV4Ul1SwWXIMUOo9qz08whevJcNSKcn2x8lGLC4cGVMrg== X-Received: by 2002:a67:e3a2:0:b0:43b:19f4:88d9 with SMTP id j2-20020a67e3a2000000b0043b19f488d9mr3574244vsm.21.1686583973052; Mon, 12 Jun 2023 08:32:53 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id mg9-20020a056214560900b006238b6bd191sm3233172qvb.145.2023.06.12.08.32.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:52 -0700 (PDT) Message-ID: <1d685c80-95a7-e640-c3d7-5fa909dd9de8@redhat.com> Date: Mon, 12 Jun 2023 11:32: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/17] - Add a hybrid BIT_IOR_EXPR operator for integer and pointer. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.1 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" Add a hybrid operator to choose between integer and pointer versions at runtime. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 80f402e832a2ce402ee1562030d5c67ebc276f7c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:33:17 -0400 Subject: [PATCH 10/17] Add a hybrid BIT_IOR_EXPR operator for integer and pointer. This adds an operator to the unified table for BIT_IOR_EXPR which will select either the pointer or integer version based on the type passed to the method. This is for use until we have a seperate PRANGE class. * range-op-mixed.h (operator_bitwise_or): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove BIT_IOR_EXPR. (class hybrid_or_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_or_operator. * range-op.cc (unified_table::unified_table): Comment out BIT_IOR_EXPR. --- gcc/range-op-mixed.h | 10 ++++----- gcc/range-op-ptr.cc | 52 ++++++++++++++++++++++++++++++++++++++++++-- gcc/range-op.cc | 4 ++-- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index 4177818e4b9..e4852e974c4 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -609,16 +609,16 @@ public: using range_operator::op2_range; bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, - relation_trio rel = TRIO_VARYING) const final override; + relation_trio rel = TRIO_VARYING) const override; bool op2_range (irange &r, tree type, const irange &lhs, const irange &op1, - relation_trio rel = TRIO_VARYING) const final override; + relation_trio rel = TRIO_VARYING) const override; void update_bitmask (irange &r, const irange &lh, - const irange &rh) const final override; -private: + const irange &rh) const override; +protected: 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; + const wide_int &rh_ub) const override; }; class operator_min : public range_operator diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 941026994ed..7b22d0bf05b 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -184,9 +184,9 @@ pointer_and_operator::wi_fold (irange &r, tree type, class pointer_or_operator : public range_operator { +public: using range_operator::op1_range; using range_operator::op2_range; -public: virtual bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, @@ -270,7 +270,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, 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); } @@ -334,6 +333,54 @@ public: } } op_hybrid_and; +// Temporary class which dispatches routines to either the INT version or +// the pointer version depending on the type. Once PRANGE is a range +// class, we can remove the hybrid. + +class hybrid_or_operator : public operator_bitwise_or +{ +public: + using range_operator::op1_range; + using range_operator::op2_range; + using range_operator::lhs_op1_relation; + bool op1_range (irange &r, tree type, + const irange &lhs, const irange &op2, + relation_trio rel = TRIO_VARYING) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_or::op1_range (r, type, lhs, op2, rel); + else + return op_pointer_or.op1_range (r, type, lhs, op2, rel); + } + bool op2_range (irange &r, tree type, + const irange &lhs, const irange &op1, + relation_trio rel = TRIO_VARYING) const final override + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_or::op2_range (r, type, lhs, op1, rel); + else + return op_pointer_or.op2_range (r, type, lhs, op1, rel); + } + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_bitwise_or::update_bitmask (r, lh, rh); + } + + 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 + { + if (INTEGRAL_TYPE_P (type)) + return operator_bitwise_or::wi_fold (r, type, lh_lb, lh_ub, + rh_lb, rh_ub); + else + return op_pointer_or.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_or; + + // Initialize any pointer operators to the primary table @@ -343,4 +390,5 @@ range_op_table::initialize_pointer_ops () set (POINTER_PLUS_EXPR, op_pointer_plus); set (POINTER_DIFF_EXPR, op_pointer_diff); set (BIT_AND_EXPR, op_hybrid_and); + set (BIT_IOR_EXPR, op_hybrid_or); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index dcb922143ce..0a9a3297de7 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -121,8 +121,8 @@ unified_table::unified_table () // is used until there is a pointer range class. Then we can simply // uncomment the operator here and use the unified version. - //set (BIT_AND_EXPR, op_bitwise_and); - set (BIT_IOR_EXPR, op_bitwise_or); + // set (BIT_AND_EXPR, op_bitwise_and); + // set (BIT_IOR_EXPR, op_bitwise_or); set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); } -- 2.40.1 From patchwork Mon Jun 12 15:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793971 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=QL7VTEBi; 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 4QfwhW1Fybz20QH for ; Tue, 13 Jun 2023 01:34:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09A7538323D2 for ; Mon, 12 Jun 2023 15:34:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09A7538323D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584041; bh=efQ7i0+XsYgSXa9VnMx07t3rMo9zrsUI5oKOVbWu+fc=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=QL7VTEBi6eEYqEmaFI22oOUIforLQ/nTj3F5YLTah+ho4KqFDyu0t7BUF7wFSytBS s3iahJr7xZyjOy/eY7TqVRqGB7Jskq1GbVtc+X0tZsRLiu/8vtFset6ozwC9kBv5mc ImhnKRIZuOIIGowOi+UrzUEMR+XCkbO+UqoGdziA= 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 0ADE13857735 for ; Mon, 12 Jun 2023 15:33:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0ADE13857735 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-eZAiYGk7N3yKl0A8WrrTQQ-1; Mon, 12 Jun 2023 11:33:01 -0400 X-MC-Unique: eZAiYGk7N3yKl0A8WrrTQQ-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6b29f1f2febso2066218a34.3 for ; Mon, 12 Jun 2023 08:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583980; x=1689175980; 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=VdTri3ihE1BCtTCFtwiyfIfUJCYl0Enu1w/2iGZctsE=; b=lK0biYlJVsvcDallBEosvfjsGEuRTOFPPpXHDZRypRST0Tz4ESJprpRPtt9iSnPM3S 0FzmhHIi373JbpPHPAJZY0wFkmwtMst/Y0MAc9A8axDQQnJEdBBuD4BTzmvUJcBC7UkP slPSBSoYgyT4f4PLQZuS/CvGyVFoQdOFboZu7GPDhhFwiaG9aXEpnVrE7bU0w2X+N2L+ lH3cx/QLMqSXOXjTqOLQCiTgTDC+roxqFUnjsxTPf7pxV1QWDFLNSsxPl/LSb1L5Q//i rUhfTfpasJoOddvFp/3LWPR5fglhUxmb3QdKGd8bmnGYZ0d6IaTYDkswQgTnwthl224h SsdA== X-Gm-Message-State: AC+VfDyaPl7Cik0A87yz4OKVJePyVLTS40jPBIhqqqhosfIG3q0ai24o hltmFr/HUBE6v+FjB5cA4s5rP4jcnDKCRwNsk070diWAy/RKa3Tm62PgF9lq96Qbnl0nL/SLPO+ 7mHjfAyXpEILy7T64tOMF1HEqmAFqknItz0V6OnptUNAzlLAhM+wwuit8B7A3rNn++iIC9VSql7 u3RQ== X-Received: by 2002:a9d:7842:0:b0:6b0:c963:6cba with SMTP id c2-20020a9d7842000000b006b0c9636cbamr7477087otm.13.1686583979819; Mon, 12 Jun 2023 08:32:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cz91dZSgz8VLi5oDa5ano50tOx0CfpEjIWdaEAbJLs4+vGHVzWN5iQMjYFeSwAlDUoSicxg== X-Received: by 2002:a9d:7842:0:b0:6b0:c963:6cba with SMTP id c2-20020a9d7842000000b006b0c9636cbamr7477067otm.13.1686583979525; Mon, 12 Jun 2023 08:32:59 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id fx6-20020a05622a4ac600b003f9efa2ddb4sm1264269qtb.66.2023.06.12.08.32.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:32:59 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:32:58 -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/17] - Add a hybrid MIN_EXPR operator for integer and pointer. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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" Add a hybrid operator to choose between integer and pointer versions at runtime. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 08f2e419b1e29f114857b3d817904abf3b4891be Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:34:26 -0400 Subject: [PATCH 11/17] Add a hybrid MIN_EXPR operator for integer and pointer. This adds an operator to the unified table for MIN_EXPR which will select either the pointer or integer version based on the type passed to the method. This is for use until we have a seperate PRANGE class. * range-op-mixed.h (operator_min): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove MIN_EXPR. (class hybrid_min_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_min_operator. * range-op.cc (unified_table::unified_table): Comment out MIN_EXPR. --- gcc/range-op-mixed.h | 6 +++--- gcc/range-op-ptr.cc | 28 +++++++++++++++++++++++++++- gcc/range-op.cc | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index e4852e974c4..a65935435c2 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -625,11 +625,11 @@ class operator_min : public range_operator { public: void update_bitmask (irange &r, const irange &lh, - const irange &rh) const final override; -private: + const irange &rh) const override; +protected: 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; + const wide_int &rh_ub) const override; }; class operator_max : public range_operator diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 7b22d0bf05b..483e43ca994 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -270,7 +270,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, pointer_table::pointer_table () { - set (MIN_EXPR, op_ptr_min_max); set (MAX_EXPR, op_ptr_min_max); } @@ -380,6 +379,32 @@ public: } } op_hybrid_or; +// Temporary class which dispatches routines to either the INT version or +// the pointer version depending on the type. Once PRANGE is a range +// class, we can remove the hybrid. + +class hybrid_min_operator : public operator_min +{ +public: + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_min::update_bitmask (r, lh, rh); + } + + 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 + { + if (INTEGRAL_TYPE_P (type)) + return operator_min::wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + else + return op_ptr_min_max.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_min; + + // Initialize any pointer operators to the primary table @@ -391,4 +416,5 @@ range_op_table::initialize_pointer_ops () set (POINTER_DIFF_EXPR, op_pointer_diff); set (BIT_AND_EXPR, op_hybrid_and); set (BIT_IOR_EXPR, op_hybrid_or); + set (MIN_EXPR, op_hybrid_min); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 0a9a3297de7..481f3b1324d 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -123,7 +123,7 @@ unified_table::unified_table () // set (BIT_AND_EXPR, op_bitwise_and); // set (BIT_IOR_EXPR, op_bitwise_or); - set (MIN_EXPR, op_min); + // set (MIN_EXPR, op_min); set (MAX_EXPR, op_max); } -- 2.40.1 From patchwork Mon Jun 12 15:33:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793983 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=RbIKn54H; 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 4Qfwnb1FPHz20Vx for ; Tue, 13 Jun 2023 01:38:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 236F23885C11 for ; Mon, 12 Jun 2023 15:38:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 236F23885C11 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584305; bh=8OH7Vk3JdxFUwWY3S1IMh8qV5Id7NXYIFRDIj75FDVo=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=RbIKn54HcGa1q8Rp0kujZoPwZt3+tyXWzJeuhfga0zQxtE7H/UtcQrm14o/lpvuP4 IBoWTsyBKAbT6I4XBl9A01oUppYlyzYJe1gSVjdlAoPQaAiVSsGmSJdQ7o7wvTCZ3d aHnjZaHDcuz4tAH7csJYlwAn9OT1cgNsZdvDes38= 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 F07563856636 for ; Mon, 12 Jun 2023 15:33:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F07563856636 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-80-JH7NYplEPO2p1LWxbppGzw-1; Mon, 12 Jun 2023 11:33:06 -0400 X-MC-Unique: JH7NYplEPO2p1LWxbppGzw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-62dec6b082bso123546d6.0 for ; Mon, 12 Jun 2023 08:33:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583984; x=1689175984; 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=rYVRfkErd6/iNmdpN8G0vZ9M5DwvKHQfpwWFhAhqUno=; b=PtWwf4eUiCvx6Foh7KCpNxUe4kFT97LI6NnaJN836oHlFKxb+JbEtluGr9Xa3n4sEF R4zp+O/1W709WV776otSvi8j5xVR0bgdPLU/wbsSXGi/FDQZ0t+5i/7mszYobf+i4YVF kodrdIPanYaWJeNprpQWYwHdz0GqQXhy84+nrizZlPIpkfgMyvQnW+kokn1d653ZOEpH GiWCCToBJgd48cFysEX+L3r5Bd9PNkhoRwVVzhL6tYzetwFMKdVGvyuT5qt79EPnzjdh TIRCGiEzzJdK7rmX54QYv+aovWW6WId+i3P+TGvwfC7m+RjAimMyLX0NOculQ2O1HwuY m8Zg== X-Gm-Message-State: AC+VfDzG+UAKTjLDaVvAnqcPkXd0ZtqRU4lkutXhDONjZOKniaFFpt3J KkKcCMf1dcfUPgI6Ebrc6MkCmR0VbWtABcVKKxnJS+obkUJVNRZ8CcaXAGj519SyFVDGQwaUOdr IqAF0nc03qy9DaPRqibFh7Rwm/Ky1s6VRKqjYN8cbRehAQMPcGdA1CTOYq0LQbzTH0AF0iwLX1O uZRA== X-Received: by 2002:a05:6214:c22:b0:626:299b:68ee with SMTP id a2-20020a0562140c2200b00626299b68eemr12611272qvd.55.1686583984184; Mon, 12 Jun 2023 08:33:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NMb8VnpbCkQjZzF6ylftu/TNh9xrZoVQWncF4t0Xu3qgU+nCq0eHU/ymjkVk6zVWpz/0B2Q== X-Received: by 2002:a05:6214:c22:b0:626:299b:68ee with SMTP id a2-20020a0562140c2200b00626299b68eemr12611244qvd.55.1686583983829; Mon, 12 Jun 2023 08:33:03 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id x16-20020a0ce0d0000000b0062627f71b07sm1303885qvk.125.2023.06.12.08.33.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:03 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:33: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 12/17] - Add a hybrid MAX_EXPR operator for integer and pointer. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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" Add a hybrid operator to choose between integer and pointer versions at runtime. This is the last use of the pointer table, so it is also removed. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From cd194f582c5be3cc91e025e304e2769f61ceb6b6 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:35:18 -0400 Subject: [PATCH 12/17] Add a hybrid MAX_EXPR operator for integer and pointer. This adds an operator to the unified table for MAX_EXPR which will select either the pointer or integer version based on the type passed to the method. This is for use until we have a seperate PRANGE class. THIs also removes the pointer table which is no longer needed. * range-op-mixed.h (operator_max): Remove final. * range-op-ptr.cc (pointer_table::pointer_table): Remove MAX_EXPR. (pointer_table::pointer_table): Remove. (class hybrid_max_operator): New. (range_op_table::initialize_pointer_ops): Add hybrid_max_operator. * range-op.cc (pointer_tree_table): Remove. (unified_table::unified_table): Comment out MAX_EXPR. (get_op_handler): Remove check of pointer table. * range-op.h (class pointer_table): Remove. --- gcc/range-op-mixed.h | 6 +++--- gcc/range-op-ptr.cc | 30 ++++++++++++++++++++---------- gcc/range-op.cc | 10 ++-------- gcc/range-op.h | 9 --------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index a65935435c2..bdc488b8754 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -636,10 +636,10 @@ class operator_max : public range_operator { public: void update_bitmask (irange &r, const irange &lh, - const irange &rh) const final override; -private: + const irange &rh) const override; +protected: 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; + const wide_int &rh_ub) const override; }; #endif // GCC_RANGE_OP_MIXED_H diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index 483e43ca994..ea66fe9056b 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -157,7 +157,6 @@ pointer_min_max_operator::wi_fold (irange &r, tree type, r.set_varying (type); } - class pointer_and_operator : public range_operator { public: @@ -265,14 +264,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type, rel); } -// When PRANGE is implemented, these are all the opcodes which are currently -// expecting routines with PRANGE signatures. - -pointer_table::pointer_table () -{ - set (MAX_EXPR, op_ptr_min_max); -} - // ---------------------------------------------------------------------- // Hybrid operators for the 4 operations which integer and pointers share, // but which have different implementations. Simply check the type in @@ -404,8 +395,26 @@ public: } } op_hybrid_min; +class hybrid_max_operator : public operator_max +{ +public: + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override + { + if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ())) + operator_max::update_bitmask (r, lh, rh); + } - + 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 + { + if (INTEGRAL_TYPE_P (type)) + return operator_max::wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + else + return op_ptr_min_max.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub); + } +} op_hybrid_max; // Initialize any pointer operators to the primary table @@ -417,4 +426,5 @@ range_op_table::initialize_pointer_ops () set (BIT_AND_EXPR, op_hybrid_and); set (BIT_IOR_EXPR, op_hybrid_or); set (MIN_EXPR, op_hybrid_min); + set (MAX_EXPR, op_hybrid_max); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 481f3b1324d..046b7691bb6 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -49,8 +49,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-ccp.h" #include "range-op-mixed.h" -pointer_table pointer_tree_table; - // Instantiate a range_op_table for unified operations. class unified_table : public range_op_table { @@ -124,18 +122,14 @@ unified_table::unified_table () // set (BIT_AND_EXPR, op_bitwise_and); // set (BIT_IOR_EXPR, op_bitwise_or); // set (MIN_EXPR, op_min); - set (MAX_EXPR, op_max); + // set (MAX_EXPR, op_max); } // The tables are hidden and accessed via a simple extern function. range_operator * -get_op_handler (enum tree_code code, tree type) +get_op_handler (enum tree_code code, tree) { - // If this is pointer type and there is pointer specifc routine, use it. - if (POINTER_TYPE_P (type) && pointer_tree_table[code]) - return pointer_tree_table[code]; - return unified_tree_table[code]; } diff --git a/gcc/range-op.h b/gcc/range-op.h index 08c51bace40..15c45137af2 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -299,15 +299,6 @@ range_op_table::set (enum tree_code code, range_operator &op) m_range_tree[code] = &op; } -// Instantiate a range op table for pointer operations. - -class pointer_table : public range_op_table -{ -public: - pointer_table (); -}; -extern pointer_table pointer_tree_table; - extern range_operator *ptr_op_widen_mult_signed; extern range_operator *ptr_op_widen_mult_unsigned; extern range_operator *ptr_op_widen_plus_signed; -- 2.40.1 From patchwork Mon Jun 12 15:33:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793974 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=jK6Ty4Ms; 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 4Qfwjd0v5Bz20QH for ; Tue, 13 Jun 2023 01:35:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 272A53889822 for ; Mon, 12 Jun 2023 15:34:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 272A53889822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584099; bh=x3OaFfB0OPOuhKgnrwPMY9ss8qcCNevDApfnXjdGnlQ=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=jK6Ty4MsSRqrhB95AZck7Zmy4XF4emZPi5elT6eztnJwvIdaWVJ9ppMlva6dDNePU V59nMMI4/nEtWaaQTmPo6Ul/bN96Wcpj8t3ZAJI/sDXLWyBoDEWM8Gvu0XwtARfmyn ISGOQKslWiclxnSX0Z2Ve1oX/t/lHlv3XD3Nn3F8= 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 C320F3854160 for ; Mon, 12 Jun 2023 15:33:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C320F3854160 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-0TtMpCQpPyK3mcYT13Ls4Q-1; Mon, 12 Jun 2023 11:33:09 -0400 X-MC-Unique: 0TtMpCQpPyK3mcYT13Ls4Q-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-75d5588d7e9so534479685a.1 for ; Mon, 12 Jun 2023 08:33:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583989; x=1689175989; 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=gzpF9h3wH9CBkv0Qsp8Am7S9P7jMBSsmTy7WmQ4Jrk4=; b=gPMeBN15r3DZDPqgaxqI7s/a+WZCDSBYIrLDDUefhY+ExbiWISJqU2b3ljKjlJVDPy Eu+LeWwUt5xkizl36WVrNpSWZWiuOT6BRDf4B92PKOE4BmbTZvixnul7BCvgqeZcmqxd YCakCwVJfpqVK03pbev8btfeLTYwNvdXRm7ko4FmOHcZvQ3Al1sdw1vB86/niAdSEGQ/ KoZuupImUjNdIjCGmHhJG0bHoyw/Zv7+xM6GCop/PWUvi/+7fJmHww22dmCvinlKwn7x GVIctdJZ7bn3+voWYqIkOVTlVLWIRomaJnoNbaHQfDRFyb6Dn1w+3QTW2KarRdXOmxK1 h+BQ== X-Gm-Message-State: AC+VfDw9ClEcq9N3BRP585X49MhxK45+nSuscECkY+cfRCSxsNGZi2Kw HB6RcB8adUQ4UrAOTMiDwKkhvkibiNOsbBjLCXqJ4pP+OBHR20VBY1UQg/TLg8ynSlsKxLlDZMF es0WIp0e7MOsyIyUGoEcISNM4iyYVmCe3Kg+JiImPM0Ad6D9tNtWA/Lwj+r5nzAL26+9FPXmRWE WAyw== X-Received: by 2002:a05:620a:688e:b0:75e:c36c:e3e8 with SMTP id rv14-20020a05620a688e00b0075ec36ce3e8mr10813696qkn.37.1686583988851; Mon, 12 Jun 2023 08:33:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ESFg+kKv+vzLDJVEnzhampFYbvzIoyukGZ3rdSMQ+ihs7IglEBEgivUha5jW3sppEGlkvZg== X-Received: by 2002:a05:620a:688e:b0:75e:c36c:e3e8 with SMTP id rv14-20020a05620a688e00b0075ec36ce3e8mr10813679qkn.37.1686583988531; Mon, 12 Jun 2023 08:33:08 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id v11-20020ae9e30b000000b0074fb15e2319sm2922118qkf.122.2023.06.12.08.33.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:08 -0700 (PDT) Message-ID: <8989b7ec-874e-dc64-7f2c-0aaf9924ba78@redhat.com> Date: Mon, 12 Jun 2023 11:33:07 -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 13/17] - Remove type from range_op_handler table selection X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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" Lucky 13.  WIth the unified table complete, it is no longer necessary to specify a type when constructing a range_op_handler. This patch removes that requirement. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 8934830333933349d41e62f9fd6a3d21ab71150c Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:41:20 -0400 Subject: [PATCH 13/17] Remove type from range_op_handler table selection With the unified table complete, we no loonger need to specify a type to choose a table when setting a range_op_handler. * gimple-range-gori.cc (gori_compute::condexpr_adjust): Do not pass type. * gimple-range-op.cc (get_code): Rename from get_code_and_type and simplify. (gimple_range_op_handler::supported_p): No need for type. (gimple_range_op_handler::gimple_range_op_handler): Ditto. (cfn_copysign::fold_range): Ditto. (cfn_ubsan::fold_range): Ditto. * ipa-cp.cc (ipa_vr_operation_and_type_effects): Ditto. * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Ditto. * range-op-float.cc (operator_plus::op1_range): Ditto. (operator_mult::op1_range): Ditto. (range_op_float_tests): Ditto. * range-op.cc (get_op_handler): Remove. (range_op_handler::set_op_handler): Remove. (operator_plus::op1_range): No need for type. (operator_minus::op1_range): Ditto. (operator_mult::op1_range): Ditto. (operator_exact_divide::op1_range): Ditto. (operator_cast::op1_range): Ditto. (perator_bitwise_not::fold_range): Ditto. (operator_negate::fold_range): Ditto. * range-op.h (range_op_handler::range_op_handler): Remove type param. (range_cast): No need for type. (range_op_table::operator[]): Check for enum_code >= 0. * tree-data-ref.cc (compute_distributive_range): No need for type. * tree-ssa-loop-unswitch.cc (unswitch_predicate): Ditto. * value-query.cc (range_query::get_tree_range): Ditto. * value-relation.cc (relation_oracle::validate_relation): Ditto. * vr-values.cc (range_of_var_in_loop): Ditto. (simplify_using_ranges::fold_cond_with_ops): Ditto. --- gcc/gimple-range-gori.cc | 2 +- gcc/gimple-range-op.cc | 42 ++++++++++------------------------- gcc/ipa-cp.cc | 6 ++--- gcc/ipa-fnsummary.cc | 6 ++--- gcc/range-op-float.cc | 6 ++--- gcc/range-op.cc | 39 ++++++++------------------------ gcc/range-op.h | 10 +++------ gcc/tree-data-ref.cc | 4 ++-- gcc/tree-ssa-loop-unswitch.cc | 2 +- gcc/value-query.cc | 5 ++--- gcc/value-relation.cc | 2 +- gcc/vr-values.cc | 6 ++--- 12 files changed, 43 insertions(+), 87 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index a1c8d51e484..abc70cd54ee 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -1478,7 +1478,7 @@ gori_compute::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, tree type = TREE_TYPE (gimple_assign_rhs1 (cond_def)); if (!range_compatible_p (type, TREE_TYPE (gimple_assign_rhs2 (cond_def)))) return false; - range_op_handler hand (gimple_assign_rhs_code (cond_def), type); + range_op_handler hand (gimple_assign_rhs_code (cond_def)); if (!hand) return false; diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index b6b10e47b78..4cbc981ee04 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -94,28 +94,14 @@ gimple_range_base_of_assignment (const gimple *stmt) // If statement is supported by range-ops, set the CODE and return the TYPE. -static tree -get_code_and_type (gimple *s, enum tree_code &code) +static inline enum tree_code +get_code (gimple *s) { - tree type = NULL_TREE; - code = NOP_EXPR; - if (const gassign *ass = dyn_cast (s)) - { - code = gimple_assign_rhs_code (ass); - // The LHS of a comparison is always an int, so we must look at - // the operands. - if (TREE_CODE_CLASS (code) == tcc_comparison) - type = TREE_TYPE (gimple_assign_rhs1 (ass)); - else - type = TREE_TYPE (gimple_assign_lhs (ass)); - } - else if (const gcond *cond = dyn_cast (s)) - { - code = gimple_cond_code (cond); - type = TREE_TYPE (gimple_cond_lhs (cond)); - } - return type; + return gimple_assign_rhs_code (ass); + if (const gcond *cond = dyn_cast (s)) + return gimple_cond_code (cond); + return ERROR_MARK; } // If statement S has a supported range_op handler return TRUE. @@ -123,9 +109,8 @@ get_code_and_type (gimple *s, enum tree_code &code) bool gimple_range_op_handler::supported_p (gimple *s) { - enum tree_code code; - tree type = get_code_and_type (s, code); - if (type && range_op_handler (code, type)) + enum tree_code code = get_code (s); + if (range_op_handler (code)) return true; if (is_a (s) && gimple_range_op_handler (s)) return true; @@ -135,14 +120,11 @@ gimple_range_op_handler::supported_p (gimple *s) // Construct a handler object for statement S. gimple_range_op_handler::gimple_range_op_handler (gimple *s) + : range_op_handler (get_code (s)) { - enum tree_code code; - tree type = get_code_and_type (s, code); m_stmt = s; m_op1 = NULL_TREE; m_op2 = NULL_TREE; - if (type) - set_op_handler (code, type); if (m_operator) switch (gimple_code (m_stmt)) @@ -382,8 +364,8 @@ public: const frange &rh, relation_trio) const override { frange neg; - range_op_handler abs_op (ABS_EXPR, type); - range_op_handler neg_op (NEGATE_EXPR, type); + range_op_handler abs_op (ABS_EXPR); + range_op_handler neg_op (NEGATE_EXPR); if (!abs_op || !abs_op.fold_range (r, type, lh, frange (type))) return false; if (!neg_op || !neg_op.fold_range (neg, type, r, frange (type))) @@ -1091,7 +1073,7 @@ public: virtual bool fold_range (irange &r, tree type, const irange &lh, const irange &rh, relation_trio rel) const { - range_op_handler handler (m_code, type); + range_op_handler handler (m_code); gcc_checking_assert (handler); bool saved_flag_wrapv = flag_wrapv; diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 0f37bb5e336..0bbd289078d 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -1911,7 +1911,7 @@ ipa_vr_operation_and_type_effects (value_range *dst_vr, if (!irange::supports_p (dst_type) || !irange::supports_p (src_type)) return false; - range_op_handler handler (operation, dst_type); + range_op_handler handler (operation); return (handler && handler.fold_range (*dst_vr, dst_type, *src_vr, value_range (dst_type)) @@ -1970,7 +1970,7 @@ ipa_value_range_from_jfunc (ipa_node_params *info, cgraph_edge *cs, value_range op_res, res; tree op = ipa_get_jf_pass_through_operand (jfunc); value_range op_vr; - range_op_handler handler (operation, vr_type); + range_op_handler handler (operation); ipa_range_set_and_normalize (op_vr, op); @@ -2767,7 +2767,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc, tree op = ipa_get_jf_pass_through_operand (jfunc); value_range op_vr; value_range op_res,res; - range_op_handler handler (operation, operand_type); + range_op_handler handler (operation); ipa_range_set_and_normalize (op_vr, op); diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc index b328bb8ce14..eae2f949f48 100644 --- a/gcc/ipa-fnsummary.cc +++ b/gcc/ipa-fnsummary.cc @@ -491,7 +491,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, value_range res; if (!op->val[0]) { - range_op_handler handler (op->code, op->type); + range_op_handler handler (op->code); if (!handler || !res.supports_type_p (op->type) || !handler.fold_range (res, op->type, vr, @@ -501,7 +501,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, else if (!op->val[1]) { value_range op0; - range_op_handler handler (op->code, op->type); + range_op_handler handler (op->code); ipa_range_set_and_normalize (op0, op->val[0]); @@ -520,7 +520,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node, { value_range res; value_range val_vr; - range_op_handler handler (c->code, boolean_type_node); + range_op_handler handler (c->code); ipa_range_set_and_normalize (val_vr, c->val); diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 757484a9de9..24f2235884f 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -2244,7 +2244,7 @@ operator_plus::op1_range (frange &r, tree type, const frange &lhs, { if (lhs.undefined_p ()) return false; - range_op_handler minus (MINUS_EXPR, type); + range_op_handler minus (MINUS_EXPR); if (!minus) return false; frange wlhs = float_widen_lhs_range (type, lhs); @@ -2361,7 +2361,7 @@ operator_mult::op1_range (frange &r, tree type, { if (lhs.undefined_p ()) return false; - range_op_handler rdiv (RDIV_EXPR, type); + range_op_handler rdiv (RDIV_EXPR); if (!rdiv) return false; frange wlhs = float_widen_lhs_range (type, lhs); @@ -2716,7 +2716,7 @@ range_op_float_tests () ASSERT_EQ (r, r1); // [-INF,+INF] + [-INF,+INF] could be a NAN. - range_op_handler plus (PLUS_EXPR, float_type_node); + range_op_handler plus (PLUS_EXPR); r0.set_varying (float_type_node); r1.set_varying (float_type_node); r0.clear_nan (); diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 046b7691bb6..3e8b1222b1c 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -125,30 +125,11 @@ unified_table::unified_table () // set (MAX_EXPR, op_max); } -// The tables are hidden and accessed via a simple extern function. - -range_operator * -get_op_handler (enum tree_code code, tree) -{ - return unified_tree_table[code]; -} - range_op_handler::range_op_handler () { m_operator = NULL; } -void -range_op_handler::set_op_handler (tree_code code, tree type) -{ - m_operator = get_op_handler (code, type); -} - -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) @@ -1692,7 +1673,7 @@ operator_plus::op1_range (irange &r, tree type, if (lhs.undefined_p ()) return false; // Start with the default operation. - range_op_handler minus (MINUS_EXPR, type); + range_op_handler minus (MINUS_EXPR); if (!minus) return false; bool res = minus.fold_range (r, type, lhs, op2); @@ -1908,7 +1889,7 @@ operator_minus::op1_range (irange &r, tree type, if (lhs.undefined_p ()) return false; // Start with the default operation. - range_op_handler minus (PLUS_EXPR, type); + range_op_handler minus (PLUS_EXPR); if (!minus) return false; bool res = minus.fold_range (r, type, lhs, op2); @@ -2046,8 +2027,7 @@ operator_mult::op1_range (irange &r, tree type, wide_int offset; if (op2.singleton_p (offset) && offset != 0) - return range_op_handler (TRUNC_DIV_EXPR, type).fold_range (r, type, - lhs, op2); + return range_op_handler (TRUNC_DIV_EXPR).fold_range (r, type, lhs, op2); return false; } @@ -2375,7 +2355,7 @@ operator_exact_divide::op1_range (irange &r, tree type, // the time however. // If op2 is a multiple of 2, we would be able to set some non-zero bits. if (op2.singleton_p (offset) && offset != 0) - return range_op_handler (MULT_EXPR, type).fold_range (r, type, lhs, op2); + return range_op_handler (MULT_EXPR).fold_range (r, type, lhs, op2); return false; } @@ -2946,9 +2926,8 @@ operator_cast::op1_range (irange &r, tree type, // Add this to the unsigned LHS range(s). int_range_max lim_range (type, lim, lim); int_range_max lhs_neg; - range_op_handler (PLUS_EXPR, type).fold_range (lhs_neg, type, - converted_lhs, - lim_range); + range_op_handler (PLUS_EXPR).fold_range (lhs_neg, type, + converted_lhs, lim_range); // lhs_neg now has all the negative versions of the LHS. // Now union in all the values from SIGNED MIN (0x80000) to // lim-1 in order to fill in all the ranges with the upper @@ -3987,7 +3966,7 @@ operator_bitwise_not::fold_range (irange &r, tree type, // ~X is simply -1 - X. int_range<1> minusone (type, wi::minus_one (TYPE_PRECISION (type)), wi::minus_one (TYPE_PRECISION (type))); - return range_op_handler (MINUS_EXPR, type).fold_range (r, type, minusone, lh); + return range_op_handler (MINUS_EXPR).fold_range (r, type, minusone, lh); } bool @@ -4233,8 +4212,8 @@ operator_negate::fold_range (irange &r, tree type, if (empty_range_varying (r, type, lh, rh)) return true; // -X is simply 0 - X. - return range_op_handler (MINUS_EXPR, type).fold_range (r, type, - range_zero (type), lh); + return range_op_handler (MINUS_EXPR).fold_range (r, type, + range_zero (type), lh); } bool diff --git a/gcc/range-op.h b/gcc/range-op.h index 15c45137af2..295e5116dd1 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -185,7 +185,6 @@ 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; } @@ -213,7 +212,6 @@ public: protected: unsigned dispatch_kind (const vrange &lhs, const vrange &op1, const vrange& op2) const; - void set_op_handler (enum tree_code code, tree type); range_operator *m_operator; }; @@ -226,9 +224,8 @@ range_cast (vrange &r, tree type) Value_Range tmp (r); Value_Range varying (type); varying.set_varying (type); - range_op_handler op (CONVERT_EXPR, type); // Call op_convert, if it fails, the result is varying. - if (!op || !op.fold_range (r, type, tmp, varying)) + if (!range_op_handler (CONVERT_EXPR).fold_range (r, type, tmp, varying)) { r.set_varying (type); return false; @@ -249,9 +246,8 @@ range_cast (Value_Range &r, tree type) // Ensure we are in the correct mode for the call to fold. r.set_type (type); - range_op_handler op (CONVERT_EXPR, type); // Call op_convert, if it fails, the result is varying. - if (!op || !op.fold_range (r, type, tmp, varying)) + if (!range_op_handler (CONVERT_EXPR).fold_range (r, type, tmp, varying)) { r.set_varying (type); return false; @@ -286,7 +282,7 @@ protected: inline range_operator * range_op_table::operator[] (enum tree_code code) { - gcc_checking_assert (code > 0 && code < MAX_TREE_CODES); + gcc_checking_assert (code >= 0 && code < MAX_TREE_CODES); return m_range_tree[code]; } diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index b576cce6db6..6d3b7c2290e 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -593,7 +593,7 @@ compute_distributive_range (tree type, value_range &op0_range, gcc_assert (INTEGRAL_TYPE_P (type) && !TYPE_OVERFLOW_TRAPS (type)); if (result_range) { - range_op_handler op (code, type); + range_op_handler op (code); if (!op.fold_range (*result_range, type, op0_range, op1_range)) result_range->set_varying (type); } @@ -640,7 +640,7 @@ compute_distributive_range (tree type, value_range &op0_range, range_cast (op0_range, ssizetype); range_cast (op1_range, ssizetype); value_range wide_range; - range_op_handler op (code, ssizetype); + range_op_handler op (code); bool saved_flag_wrapv = flag_wrapv; flag_wrapv = 1; if (!op.fold_range (wide_range, ssizetype, op0_range, op1_range)) diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc index 47255a4125d..619b50fb4bb 100644 --- a/gcc/tree-ssa-loop-unswitch.cc +++ b/gcc/tree-ssa-loop-unswitch.cc @@ -139,7 +139,7 @@ struct unswitch_predicate count = EDGE_SUCC (bb, 0)->count ().max (EDGE_SUCC (bb, 1)->count ()); if (irange::supports_p (TREE_TYPE (lhs))) { - auto range_op = range_op_handler (code, TREE_TYPE (lhs)); + auto range_op = range_op_handler (code); int_range<2> rhs_range (TREE_TYPE (rhs)); if (CONSTANT_CLASS_P (rhs)) { diff --git a/gcc/value-query.cc b/gcc/value-query.cc index a84f164d77b..adef93415b7 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -228,8 +228,7 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt) if (COMPARISON_CLASS_P (expr) && !Value_Range::supports_type_p (TREE_TYPE (op0))) return false; - range_op_handler op (TREE_CODE (expr), - BINARY_CLASS_P (expr) ? type : TREE_TYPE (op0)); + range_op_handler op (TREE_CODE (expr)); if (op) { Value_Range r0 (TREE_TYPE (op0)); @@ -245,7 +244,7 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt) } if (UNARY_CLASS_P (expr)) { - range_op_handler op (TREE_CODE (expr), type); + range_op_handler op (TREE_CODE (expr)); tree op0_type = TREE_TYPE (TREE_OPERAND (expr, 0)); if (op && Value_Range::supports_type_p (op0_type)) { diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index 65cf7694d40..7df2cd6e961 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -218,7 +218,7 @@ relation_oracle::validate_relation (relation_kind rel, vrange &op1, vrange &op2) return VREL_VARYING; // If there is no handler, leave the relation as is. - range_op_handler handler (code, t1); + range_op_handler handler (code); if (!handler) return rel; diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 86c1bf8ebc6..ac4a83c6097 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -292,8 +292,8 @@ range_of_var_in_loop (vrange &v, tree name, class loop *l, gimple *stmt, wide_int w = wide_int::from (nit, TYPE_PRECISION (type), TYPE_SIGN (type)); int_range<1> niter (type, w, w); int_range_max max_step; - range_op_handler mult_handler (MULT_EXPR, type); - range_op_handler plus_handler (PLUS_EXPR, type); + range_op_handler mult_handler (MULT_EXPR); + range_op_handler plus_handler (PLUS_EXPR); if (!mult_handler.fold_range (max_step, type, niter, rstep) || !plus_handler.fold_range (max_init, type, rinit, max_step)) return false; @@ -317,7 +317,7 @@ simplify_using_ranges::fold_cond_with_ops (enum tree_code code, tree type = TREE_TYPE (op0); int_range<1> res; - range_op_handler handler (code, type); + range_op_handler handler (code); if (handler && handler.fold_range (res, type, r0, r1)) { if (res == range_true (type)) -- 2.40.1 From patchwork Mon Jun 12 15:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793976 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=nDWbrFXC; 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 4Qfwkt3XDtz20Vx for ; Tue, 13 Jun 2023 01:36:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D82B3831E14 for ; Mon, 12 Jun 2023 15:36:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D82B3831E14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584164; bh=31DmD0jc+Kwh+HRHVh0772ghc6dscDjymhdRapE1GQc=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nDWbrFXCTp/sL2sjmqbZJpRuo5/NDV95AfJYCe5+WnEKHkGd+uke5JBJxaRHh/fgR DvpcaQ/Ms0Qc2K3oOWd5TXie/UwNEBXSAJ8k/coZAR94Y/hTDAuQXoG4asbeWhUlVj VVU106fQkcUCK5Wx5ZqJIQ3Hk+y6LsyAVhjIwgAE= 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 EF849385735A for ; Mon, 12 Jun 2023 15:33:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF849385735A 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-86-nyYdc6L5NG6xth2D7yKDTg-1; Mon, 12 Jun 2023 11:33:16 -0400 X-MC-Unique: nyYdc6L5NG6xth2D7yKDTg-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-75d42a5097bso486436485a.3 for ; Mon, 12 Jun 2023 08:33:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686583995; x=1689175995; 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=D1/W4Djxz0YhjUzTWHje8v2HVf6HI2TE5H5eyd1cDjc=; b=kT59HvI/6xFpaZv0Z2jzUqjR9AZSe6l9gSSp3VqjPx30gTxx7becFiAR/cpRBcG3yY IvNpaQpSisfRDoyF+RhY/BXOGzIU3PC8EgDgrkAt47PWvmkX9hNrtzYxmvOs8DlKqRL2 KuiXryRRyZRrZXfRndgvb7WBJPMXluGluch2RRawqnS4nm/gxFIg+cd6JBHc/r0gQ+RL CroRN4AxB+Qfrxc+oRB63ns9a/cLsqSB+kb0Od8yJLM9wJSOeaMo4rUtlsXLqxdkN9Zf JAQSX4A32p1oGwDGd2p3Ajj2itytzMxa+5sFxnUa5Ejw/RP/NUSb5TSvecIJrNbNNliw xV0Q== X-Gm-Message-State: AC+VfDwH/2Ip8GEWv2bITnTDXm1hvW7ZPL7leDzd8dGTVTz/hlXx2C88 sUSYuh0IdxgMaEe3UbLind4fh+rhSLMTQVITD2VqbQ1peQGv16ld/IWHtCfAOd6iv+LWH3XtqyM sABtWx43Cx6plGzal4+hLHMe196KNp0G8e+JjMJwrjU2in3IdtVCFU0IOZsFQFzn2eVnjOHGMUx Bosw== X-Received: by 2002:a05:6214:230d:b0:625:af4b:4162 with SMTP id gc13-20020a056214230d00b00625af4b4162mr10430428qvb.14.1686583995494; Mon, 12 Jun 2023 08:33:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BST86ErLD131EQkwAB95dwEahiXkDH3T6yoJbLTJdHbtZqFLuKMPn3qVofqhzykjMvQyFIA== X-Received: by 2002:a05:6214:230d:b0:625:af4b:4162 with SMTP id gc13-20020a056214230d00b00625af4b4162mr10430282qvb.14.1686583993342; Mon, 12 Jun 2023 08:33:13 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id fy26-20020a05622a5a1a00b003f86bc1753bsm3475566qtb.80.2023.06.12.08.33.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:12 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:33:12 -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 14/17] - Switch from unified table to range_op_table. There can be only one. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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" Now that the unified table is the only one,  remove it and simply use range_op_table as the class instead of inheriting from it. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 5bb9d2acd1987f788a52a2be9bca10c47033020a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:56:06 -0400 Subject: [PATCH 14/17] Switch from unified table to range_op_table. There can be only one. Now that there is only a single range_op_table, make the base table the only table. * range-op.cc (unified_table): Delete. (range_op_table operator_table): Instantiate. (range_op_table::range_op_table): Rename from unified_table. (range_op_handler::range_op_handler): Use range_op_table. * range-op.h (range_op_table::operator []): Inline. (range_op_table::set): Inline. --- gcc/range-op.cc | 14 +++++--------- gcc/range-op.h | 33 +++++++++++---------------------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 3e8b1222b1c..382f5d50ffa 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -49,13 +49,6 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-ccp.h" #include "range-op-mixed.h" -// Instantiate a range_op_table for unified operations. -class unified_table : public range_op_table -{ - public: - unified_table (); -} unified_tree_table; - // Instantiate the operators which apply to multiple types here. operator_equal op_equal; @@ -80,9 +73,12 @@ operator_bitwise_or op_bitwise_or; operator_min op_min; operator_max op_max; +// Instantaite a range operator table. +range_op_table operator_table; + // Invoke the initialization routines for each class of range. -unified_table::unified_table () +range_op_table::range_op_table () { initialize_integral_ops (); initialize_pointer_ops (); @@ -134,7 +130,7 @@ range_op_handler::range_op_handler () range_op_handler::range_op_handler (tree_code code) { - m_operator = unified_tree_table[code]; + m_operator = operator_table[code]; } // Create a dispatch pattern for value range discriminators LHS, OP1, and OP2. diff --git a/gcc/range-op.h b/gcc/range-op.h index 295e5116dd1..328910d0ec5 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -266,35 +266,24 @@ extern void wi_set_zero_nonzero_bits (tree type, class range_op_table { public: - range_operator *operator[] (enum tree_code code); - void set (enum tree_code code, range_operator &op); + range_op_table (); + inline range_operator *operator[] (enum tree_code code) + { + gcc_checking_assert (code >= 0 && code < MAX_TREE_CODES); + return m_range_tree[code]; + } protected: + inline void set (enum tree_code code, range_operator &op) + { + gcc_checking_assert (m_range_tree[code] == NULL); + m_range_tree[code] = &op; + } range_operator *m_range_tree[MAX_TREE_CODES]; void initialize_integral_ops (); void initialize_pointer_ops (); void initialize_float_ops (); }; - -// Return a pointer to the range_operator instance, if there is one -// associated with tree_code CODE. - -inline range_operator * -range_op_table::operator[] (enum tree_code code) -{ - gcc_checking_assert (code >= 0 && code < MAX_TREE_CODES); - return m_range_tree[code]; -} - -// Add OP to the handler table for CODE. - -inline void -range_op_table::set (enum tree_code code, range_operator &op) -{ - gcc_checking_assert (m_range_tree[code] == NULL); - m_range_tree[code] = &op; -} - extern range_operator *ptr_op_widen_mult_signed; extern range_operator *ptr_op_widen_mult_unsigned; extern range_operator *ptr_op_widen_plus_signed; -- 2.40.1 From patchwork Mon Jun 12 15:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793980 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=jg4XYKBK; 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 4Qfwm04xjYz20Vx for ; Tue, 13 Jun 2023 01:37:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 563B8388B6B1 for ; Mon, 12 Jun 2023 15:37:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 563B8388B6B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584222; bh=KhDJ6zqZyuJU4pxZpP74nMwvJkFnIKwY3FJ9znhaW0g=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=jg4XYKBKWDpFBTanwI2wZhg+EkP6OaiJjiRIlGaWSzGX89lxCyCRq7tiKCT0M8FxQ kotHZTO8gTMmys65hkeqZ9p5aLhsau4R1/wg/NRGNpsVwoO3wkbbXeNRAmu5fpwRaB zkzbAtXCO2ruk8KpaXtBWmIUVDABKObBL2SParno= 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 AD3E43858C78 for ; Mon, 12 Jun 2023 15:33:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD3E43858C78 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-Pr6Di9CeP4iI_aBkfoyxYQ-1; Mon, 12 Jun 2023 11:33:21 -0400 X-MC-Unique: Pr6Di9CeP4iI_aBkfoyxYQ-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-39aa9617c6bso2425147b6e.1 for ; Mon, 12 Jun 2023 08:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686584000; x=1689176000; 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=0b5GSsjoKmV85Fxg5Q+pSQar09PcscYJupMzWDm0zQU=; b=jnAsiZCV/apVzsOKf6pGozx6chflGvnV2bwqFim8Wk6L8m30oYYe/uP+pTdlMdjknY vSjRRt5Li8a8Bup87xsQWN9kzb0uiPAMQRi6bMen/EVlkXjKuKpRCyv+a4/vU+VvXgBi 4tbfJCYnaGkYg5Btp5eYHZy1AZhcX30mK2dsqK0xH0sN+7AGAHKy/m4rHDVvozLITLDa 9zDsfaDVkmuLei43NzWAR6IUeX0MDKwhYF7Kbxv4+clLxnDfewEpo5juCVaMmVT94WnX CrOn6JdmKV5oSNIQGKgCFNF3yLUtzpHD0AhG9NnAveqXTLwoTURcF722/HHb8/cNh5f5 hFbw== X-Gm-Message-State: AC+VfDwX+n2irdO8FXoAW2JPvLjANTOopNoKYpNkYOUa/Yu6hLCm55XA NWHfPkrTRKUxllucKgIzX4Db6IRk3RPH2lji5rHi4HvffouZ58XUpvO+o/MyDNNMi5D+T5kZUt5 5BrBWbstmt2O+5hkNh9jDfNt3/j+OaF9G0LlD3R9cCIfBQ/J6dJuzw/r2/GswwQxZVpc/IyBcqg Ba+g== X-Received: by 2002:a05:6808:1905:b0:39a:bd0e:449 with SMTP id bf5-20020a056808190500b0039abd0e0449mr5657313oib.26.1686584000292; Mon, 12 Jun 2023 08:33:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lEqnM2Y22RPrKyGxc1spWqKEabrAOE+7qnU/zJhtpdfTbhQeOyi1i3MdGUEkMjmsx76h5bw== X-Received: by 2002:a05:6808:1905:b0:39a:bd0e:449 with SMTP id bf5-20020a056808190500b0039abd0e0449mr5657276oib.26.1686583999831; Mon, 12 Jun 2023 08:33:19 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id g16-20020ac84690000000b003f8e6071e43sm3504711qto.3.2023.06.12.08.33.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:19 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:33:18 -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 15/17] - Provide a default range_operator via range_op_handler. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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 provides range_op_handler with a default range_operator, so you no longer need to check if it has a valid handler or not. The valid check now turns into a "is this something other than a default operator" check.   IT means you can now simply invoke fold without checking.. ie instead of range_op_handler handler(CONVERT_EXPR); if (handler &&  handler.fold_range (......)) we can simply write if (range_op_handler(CONVERT_EXPR).fold_range (....)) The new method range_op() will return the a pointer to the custom range_operator, or NULL if its the default.   THis allos use of range_op_handler() to behave as if you were indexing a range table/ if that happens to be needed. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 3c4399657d35a0b5bf7caeb88c6ddc0461322d3f Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 16:59:38 -0400 Subject: [PATCH 15/17] Provide a default range_operator via range_op_handler. range_op_handler now provides a default range_operator for any opcode, so there is no longer a need to check for a valid operator. * gimple-range-op.cc (gimple_range_op_handler): Set m_operator manually as there is no access to the default operator. (cfn_copysign::fold_range): Don't check for validity. (cfn_ubsan::fold_range): Ditto. (gimple_range_op_handler::maybe_builtin_call): Don't set to NULL. * range-op.cc (default_operator): New. (range_op_handler::range_op_handler): Use default_operator instead of NULL. (range_op_handler::operator bool): Move from header, compare against default operator. (range_op_handler::range_op): New. * range-op.h (range_op_handler::operator bool): Move. --- gcc/gimple-range-op.cc | 28 +++++++++++++--------------- gcc/range-op.cc | 32 ++++++++++++++++++++++++++++++-- gcc/range-op.h | 3 ++- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 4cbc981ee04..021a9108ecf 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -120,21 +120,22 @@ gimple_range_op_handler::supported_p (gimple *s) // Construct a handler object for statement S. gimple_range_op_handler::gimple_range_op_handler (gimple *s) - : range_op_handler (get_code (s)) { + range_op_handler oper (get_code (s)); m_stmt = s; m_op1 = NULL_TREE; m_op2 = NULL_TREE; - if (m_operator) + if (oper) switch (gimple_code (m_stmt)) { case GIMPLE_COND: m_op1 = gimple_cond_lhs (m_stmt); m_op2 = gimple_cond_rhs (m_stmt); // Check that operands are supported types. One check is enough. - if (!Value_Range::supports_type_p (TREE_TYPE (m_op1))) - m_operator = NULL; + if (Value_Range::supports_type_p (TREE_TYPE (m_op1))) + m_operator = oper.range_op (); + gcc_checking_assert (m_operator); return; case GIMPLE_ASSIGN: m_op1 = gimple_range_base_of_assignment (m_stmt); @@ -153,7 +154,9 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s) m_op2 = gimple_assign_rhs2 (m_stmt); // Check that operands are supported types. One check is enough. if ((m_op1 && !Value_Range::supports_type_p (TREE_TYPE (m_op1)))) - m_operator = NULL; + return; + m_operator = oper.range_op (); + gcc_checking_assert (m_operator); return; default: gcc_unreachable (); @@ -165,6 +168,7 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s) maybe_builtin_call (); else maybe_non_standard (); + gcc_checking_assert (m_operator); } // Calculate what we can determine of the range of this unary @@ -364,11 +368,10 @@ public: const frange &rh, relation_trio) const override { frange neg; - range_op_handler abs_op (ABS_EXPR); - range_op_handler neg_op (NEGATE_EXPR); - if (!abs_op || !abs_op.fold_range (r, type, lh, frange (type))) + if (!range_op_handler (ABS_EXPR).fold_range (r, type, lh, frange (type))) return false; - if (!neg_op || !neg_op.fold_range (neg, type, r, frange (type))) + if (!range_op_handler (NEGATE_EXPR).fold_range (neg, type, r, + frange (type))) return false; bool signbit; @@ -1073,14 +1076,11 @@ public: virtual bool fold_range (irange &r, tree type, const irange &lh, const irange &rh, relation_trio rel) const { - range_op_handler handler (m_code); - gcc_checking_assert (handler); - bool saved_flag_wrapv = flag_wrapv; // Pretend the arithmetic is wrapping. If there is any overflow, // we'll complain, but will actually do wrapping operation. flag_wrapv = 1; - bool result = handler.fold_range (r, type, lh, rh, rel); + bool result = range_op_handler (m_code).fold_range (r, type, lh, rh, rel); flag_wrapv = saved_flag_wrapv; // If for both arguments vrp_valueize returned non-NULL, this should @@ -1230,8 +1230,6 @@ gimple_range_op_handler::maybe_builtin_call () m_operator = &op_cfn_constant_p; else if (frange::supports_p (TREE_TYPE (m_op1))) m_operator = &op_cfn_constant_float_p; - else - m_operator = NULL; break; CASE_FLT_FN (CFN_BUILT_IN_SIGNBIT): diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 382f5d50ffa..a271e00fa07 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -121,16 +121,44 @@ range_op_table::range_op_table () // set (MAX_EXPR, op_max); } +// Instantiate a default range operator for opcodes with no entry. + +range_operator default_operator; + +// Create a default range_op_handler. + range_op_handler::range_op_handler () { - m_operator = NULL; + m_operator = &default_operator; } -// Constructing without a type must come from the unified table. +// Create a range_op_handler for CODE. Use a default operatoer if CODE +// does not have an entry. range_op_handler::range_op_handler (tree_code code) { m_operator = operator_table[code]; + if (!m_operator) + m_operator = &default_operator; +} + +// Return TRUE if this handler has a non-default operator. + +range_op_handler::operator bool () const +{ + return m_operator != &default_operator; +} + +// Return a pointer to the range operator assocaited with this handler. +// If it is a default operator, return NULL. +// This is the equivalent of indexing the range table. + +range_operator * +range_op_handler::range_op () const +{ + if (m_operator != &default_operator) + return m_operator; + return NULL; } // Create a dispatch pattern for value range discriminators LHS, OP1, and OP2. diff --git a/gcc/range-op.h b/gcc/range-op.h index 328910d0ec5..8243258eea5 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -186,7 +186,8 @@ class range_op_handler public: range_op_handler (); range_op_handler (enum tree_code code); - inline operator bool () const { return m_operator != NULL; } + operator bool () const; + range_operator *range_op () const; bool fold_range (vrange &r, tree type, const vrange &lh, -- 2.40.1 From patchwork Mon Jun 12 15:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793977 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=Q+dwEyZh; 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 4Qfwl325Z0z20Vx for ; Tue, 13 Jun 2023 01:36:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45B8F3831E16 for ; Mon, 12 Jun 2023 15:36:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45B8F3831E16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584173; bh=1oMLIYkDH3SmkQ8opiAREUNmEDSMuvR7lau9gNu2a7k=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Q+dwEyZhGKf7u/7+JwodWxDbMTLjCLOFs2lJ4XOPKW8Fp+7Y7qcFes+rWmc/9zqXs /V4NMI7hBYrdliiSmXZWlI7MbHAVI2FFNzDJe/rAOouJcRiyC4iMRmrzlC1+jb7smB rtQyx3NLNdtrjlEaVdy662KGYd8ozyKN1jkULmXk= 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 B5E8F384B828 for ; Mon, 12 Jun 2023 15:33:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5E8F384B828 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-qXuYAgL1PeuQIB2lKVUa2g-1; Mon, 12 Jun 2023 11:33:26 -0400 X-MC-Unique: qXuYAgL1PeuQIB2lKVUa2g-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-39acaa239b2so3050720b6e.1 for ; Mon, 12 Jun 2023 08:33:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686584004; x=1689176004; 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=KIifriKxNdHZJHtdnBzoZ5XruvRKzUQhG1c+uC/12p4=; b=NDUsuIFIm+WxvpIHFKGuU64036OJ/6tgjKxbjxDMB6dstDZ08mfLxt+/IMK5zvScEt Tgg4V9tIK0zezsaGFuy/oJy8FDda7ozMfUN7pBp+BS4q+NQDfmgjQ0NMWvMiB4oRJ36D xtL8L0rJqXCuF+8+0UzZNjaXq5nOFVoNzzm3saUW6GA/di+tP+iJ/WRJ/E1TKUOP16pg ccU3g7VmJ8g+tqNhRfVnvvW+v50K9ks2UWGz0Ur53pfymtq++BWRkPcVGMMfLE946ZMS Q9ynvGyrUMoyorgYJ8tVmegQQAvmdcDnapiyNEG9RKoD3wuH2woBhyINjpujMurgEzWn 7ErA== X-Gm-Message-State: AC+VfDxp9WDTmo77W0usG0tWRw8naKzzWXYBenKjKquS+4RsTHVexc6W d4w6GjiPSBKCBgn6gHX4o1sVLdbILB0sJPj3fpT46hWVJGNnI2LxL9yHIi0QbCefyFyC/CU43h1 x1kSMcuO3sQ+jHTnoDfdmLUN2k+03WtNExkE3bXtzrPBNjKVf1OVn3W0F4JYDE5W6VBmF5ocMFK m4Uw== X-Received: by 2002:a05:6808:f11:b0:398:43a7:e9fe with SMTP id m17-20020a0568080f1100b0039843a7e9femr5214515oiw.20.1686584004766; Mon, 12 Jun 2023 08:33:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5kbFVRPNuWEp8IWB//MpONxMiIej+v8G9QE6sXk6QkDaAIiZ7QkpJlAHaK58rfFz99OflWYA== X-Received: by 2002:a05:6808:f11:b0:398:43a7:e9fe with SMTP id m17-20020a0568080f1100b0039843a7e9femr5214503oiw.20.1686584004512; Mon, 12 Jun 2023 08:33:24 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id j27-20020a05620a001b00b0074a6c29df4dsm2939333qki.119.2023.06.12.08.33.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:24 -0700 (PDT) Message-ID: Date: Mon, 12 Jun 2023 11:33:23 -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 16/17] - Provide interface for non-standard operators. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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 removes the hack introduced late last year for the non-standard range-op support. Instead of adding a a pointer to a range_operator in the header file, and then setting the operator from another file via that pointer, the table itself is extended and  we provide new #defines to declare new operators. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 6d3b6847bcb36221185a6259d19d743f4cfe1b5a Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Sat, 10 Jun 2023 17:06:36 -0400 Subject: [PATCH 16/17] Provide interface for non-standard operators. THis removes the hack introduced for WIDEN_MULT which exported a pointer to the operator and the gimple-range-op.cc set the operator to this pointer whenn it was appropriate. Instead, we simple change the range-op table to be unsigned indexed, and add new opcodes to the end of the table, allowing them to be indexed directly via range_op_handler::range_op. * gimple-range-op.cc (gimple_range_op_handler::maybe_non_standard): Use range_op_handler directly. * range-op.cc (range_op_handler::range_op_handler): Unsigned param instead of tree-code. (ptr_op_widen_plus_signed): Delete. (ptr_op_widen_plus_unsigned): Delete. (ptr_op_widen_mult_signed): Delete. (ptr_op_widen_mult_unsigned): Delete. (range_op_table::initialize_integral_ops): Add new opcodes. * range-op.h (range_op_handler): Use unsigned. (OP_WIDEN_MULT_SIGNED): New. (OP_WIDEN_MULT_UNSIGNED): New. (OP_WIDEN_PLUS_SIGNED): New. (OP_WIDEN_PLUS_UNSIGNED): New. (RANGE_OP_TABLE_SIZE): New. (range_op_table::operator []): Use unsigned. (range_op_table::set): Use unsigned. (m_range_tree): Make unsigned. (ptr_op_widen_mult_signed): Remove. (ptr_op_widen_mult_unsigned): Remove. (ptr_op_widen_plus_signed): Remove. (ptr_op_widen_plus_unsigned): Remove. --- gcc/gimple-range-op.cc | 11 +++++++---- gcc/range-op.cc | 11 ++++++----- gcc/range-op.h | 26 ++++++++++++++++---------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 021a9108ecf..72c7b866f90 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -1168,8 +1168,11 @@ public: void gimple_range_op_handler::maybe_non_standard () { - range_operator *signed_op = ptr_op_widen_mult_signed; - range_operator *unsigned_op = ptr_op_widen_mult_unsigned; + range_op_handler signed_op (OP_WIDEN_MULT_SIGNED); + gcc_checking_assert (signed_op); + range_op_handler unsigned_op (OP_WIDEN_MULT_UNSIGNED); + gcc_checking_assert (unsigned_op); + if (gimple_code (m_stmt) == GIMPLE_ASSIGN) switch (gimple_assign_rhs_code (m_stmt)) { @@ -1195,9 +1198,9 @@ gimple_range_op_handler::maybe_non_standard () std::swap (m_op1, m_op2); if (signed1 || signed2) - m_operator = signed_op; + m_operator = signed_op.range_op (); else - m_operator = unsigned_op; + m_operator = unsigned_op.range_op (); break; } default: diff --git a/gcc/range-op.cc b/gcc/range-op.cc index a271e00fa07..8a661fdb042 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -135,7 +135,7 @@ range_op_handler::range_op_handler () // Create a range_op_handler for CODE. Use a default operatoer if CODE // does not have an entry. -range_op_handler::range_op_handler (tree_code code) +range_op_handler::range_op_handler (unsigned code) { m_operator = operator_table[code]; if (!m_operator) @@ -1726,7 +1726,6 @@ public: const wide_int &rh_lb, const wide_int &rh_ub) const; } op_widen_plus_signed; -range_operator *ptr_op_widen_plus_signed = &op_widen_plus_signed; void operator_widen_plus_signed::wi_fold (irange &r, tree type, @@ -1760,7 +1759,6 @@ public: const wide_int &rh_lb, const wide_int &rh_ub) const; } op_widen_plus_unsigned; -range_operator *ptr_op_widen_plus_unsigned = &op_widen_plus_unsigned; void operator_widen_plus_unsigned::wi_fold (irange &r, tree type, @@ -2184,7 +2182,6 @@ public: const wide_int &rh_ub) const; } op_widen_mult_signed; -range_operator *ptr_op_widen_mult_signed = &op_widen_mult_signed; void operator_widen_mult_signed::wi_fold (irange &r, tree type, @@ -2217,7 +2214,6 @@ public: const wide_int &rh_ub) const; } op_widen_mult_unsigned; -range_operator *ptr_op_widen_mult_unsigned = &op_widen_mult_unsigned; void operator_widen_mult_unsigned::wi_fold (irange &r, tree type, @@ -4298,6 +4294,11 @@ range_op_table::initialize_integral_ops () set (IMAGPART_EXPR, op_unknown); set (REALPART_EXPR, op_unknown); set (ABSU_EXPR, op_absu); + set (OP_WIDEN_MULT_SIGNED, op_widen_mult_signed); + set (OP_WIDEN_MULT_UNSIGNED, op_widen_mult_unsigned); + set (OP_WIDEN_PLUS_SIGNED, op_widen_plus_signed); + set (OP_WIDEN_PLUS_UNSIGNED, op_widen_plus_unsigned); + } #if CHECKING_P diff --git a/gcc/range-op.h b/gcc/range-op.h index 8243258eea5..3602bc4e123 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -185,7 +185,7 @@ class range_op_handler { public: range_op_handler (); - range_op_handler (enum tree_code code); + range_op_handler (unsigned); operator bool () const; range_operator *range_op () const; @@ -262,31 +262,37 @@ extern void wi_set_zero_nonzero_bits (tree type, wide_int &maybe_nonzero, wide_int &mustbe_nonzero); +// These are extra operators that do not fit in the normal scheme of things. +// Add them to the end of the tree-code vector, and provide a name for +// each allowing for easy access when required. + +#define OP_WIDEN_MULT_SIGNED ((unsigned) MAX_TREE_CODES) +#define OP_WIDEN_MULT_UNSIGNED ((unsigned) MAX_TREE_CODES + 1) +#define OP_WIDEN_PLUS_SIGNED ((unsigned) MAX_TREE_CODES + 2) +#define OP_WIDEN_PLUS_UNSIGNED ((unsigned) MAX_TREE_CODES + 3) +#define RANGE_OP_TABLE_SIZE ((unsigned) MAX_TREE_CODES + 4) + // This implements the range operator tables as local objects. class range_op_table { public: range_op_table (); - inline range_operator *operator[] (enum tree_code code) + inline range_operator *operator[] (unsigned code) { - gcc_checking_assert (code >= 0 && code < MAX_TREE_CODES); + gcc_checking_assert (code < RANGE_OP_TABLE_SIZE); return m_range_tree[code]; } protected: - inline void set (enum tree_code code, range_operator &op) + inline void set (unsigned code, range_operator &op) { + gcc_checking_assert (code < RANGE_OP_TABLE_SIZE); gcc_checking_assert (m_range_tree[code] == NULL); m_range_tree[code] = &op; } - range_operator *m_range_tree[MAX_TREE_CODES]; + range_operator *m_range_tree[RANGE_OP_TABLE_SIZE]; void initialize_integral_ops (); void initialize_pointer_ops (); void initialize_float_ops (); }; - -extern range_operator *ptr_op_widen_mult_signed; -extern range_operator *ptr_op_widen_mult_unsigned; -extern range_operator *ptr_op_widen_plus_signed; -extern range_operator *ptr_op_widen_plus_unsigned; #endif // GCC_RANGE_OP_H -- 2.40.1 From patchwork Mon Jun 12 15:33:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1793981 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=PL3Rk+PY; 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 4QfwmK1cknz20Vx for ; Tue, 13 Jun 2023 01:37:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A96E3853D3E for ; Mon, 12 Jun 2023 15:37:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A96E3853D3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584239; bh=vsJQkc/D0ARvzYMp8+88ixFcjag9kIPmg3woykvUqmY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=PL3Rk+PYq8ZModnTbmovCVRvIyRN3A2BauJGd/xKuWv6XLcEHS2ZDdONgWLUYMEK2 X2JDzcRRtQ2Md1IzbJk7w6I+qSrj+oObFOc3GvEhWZC80NpO1KZal2F46QcYmbhBNQ 5WDCrHGhwzsmZwD815jL7YMZ1+zoEpIixpH1ypCk= 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 EB866385735D for ; Mon, 12 Jun 2023 15:33:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB866385735D Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-eTH_pIuiNs-NzuriK7qFCA-1; Mon, 12 Jun 2023 11:33:31 -0400 X-MC-Unique: eTH_pIuiNs-NzuriK7qFCA-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-39cc25f5c7aso1740321b6e.3 for ; Mon, 12 Jun 2023 08:33:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686584009; x=1689176009; h=subject:cc: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=x5NMi7ARx/HDlhvz6jXd3U3Ah/inudEFOVeKVrCk+Eg=; b=DCmKcT6AQm6ZdtpiAt0monG8yOLRsXkvuQCsN4rsxwZmeKW1c42xC1jXoQhG+QCY0p 4mVWXuxHqQkOog5GcxbvOmdJzLZZHtcb9Ryi9rhGgIjGOpzX8LP2u6WsDcBz9CPiHRga FpcgklGRJNKTOaovoCev5Ka5LS+bDt0xcqjuHpiOOZAaYX0oDywf4WUt5LJDmq8T0SYa u2hSkuXknLlgEcTe5nkqTqX5AUXFFBjVXGrX7QKC81SDNE7tT6swW+RN21dgxL2CHPYn /IcNSdvqSwxmVApsnBx6/zh8lu2cavTkH0KEPonv3LSiHTa2N1/iNPpVh2Nti4hyQAyH 1oQQ== X-Gm-Message-State: AC+VfDy99z4KU0Bt7S1gAoMUnTXOW/rhmA6bGzsDnte2iYtEHB9zH9Nc N0/gdF98dWsKSTiyLaLYarkf7a9zmxUKq+Y8vKjeGbigSxW8+bq05JlpHlEp4ek7cJ2r48eW8Ab +sp/8cJADF+N8WGe1wLJTO6dK0EC41JnSu8gInajWhfCKkSgC4xUC0ngLVL8i7TP5T6Nd1IA1ci tTRw== X-Received: by 2002:a05:6808:180e:b0:398:2f92:65ca with SMTP id bh14-20020a056808180e00b003982f9265camr5442988oib.7.1686584009756; Mon, 12 Jun 2023 08:33:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4U+wbYCKUCNB4S17ADZ0J3DKefIXBFCqcmL0JO7DCxAYkqCAEuCeWYCLbHScDzCdEzR7lJFw== X-Received: by 2002:a05:6808:180e:b0:398:2f92:65ca with SMTP id bh14-20020a056808180e00b003982f9265camr5442965oib.7.1686584009456; Mon, 12 Jun 2023 08:33:29 -0700 (PDT) Received: from ?IPV6:2607:fea8:51df:4200::ca58? ([2607:fea8:51df:4200::ca58]) by smtp.gmail.com with ESMTPSA id c2-20020ac86e82000000b003f7369c7302sm3454892qtv.89.2023.06.12.08.33.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 08:33:29 -0700 (PDT) Message-ID: <65b29c92-eae6-b709-7928-84a881527724@redhat.com> Date: Mon, 12 Jun 2023 11:33:28 -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 17/17] PR tree-optimization/110205 - Add some overrides. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.2 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" Add some missing overrides, and add the diaptch pattern for FII which will be used for integer to float conversion. Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew From 1bed4b49302e2fd7bf89426117331ae89ebdc90b Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Mon, 12 Jun 2023 09:47:43 -0400 Subject: [PATCH 17/17] Add some overrides. PR tree-optimization/110205 * range-op-float.cc (range_operator::fold_range): Add default FII fold routine. (Class operator_gt): Add missing final overrides. * range-op.cc (range_op_handler::fold_range): Add RO_FII case. (operator_lshift ::update_bitmask): Add final override. (operator_rshift ::update_bitmask): Add final override. * range-op.h (range_operator::fold_range): Add FII prototype. --- gcc/range-op-float.cc | 10 ++++++++++ gcc/range-op-mixed.h | 9 +++++---- gcc/range-op.cc | 10 ++++++++-- gcc/range-op.h | 4 ++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index 24f2235884f..f5c0cec75c4 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -157,6 +157,16 @@ range_operator::fold_range (irange &r ATTRIBUTE_UNUSED, return false; } +bool +range_operator::fold_range (frange &r ATTRIBUTE_UNUSED, + tree type ATTRIBUTE_UNUSED, + const irange &lh ATTRIBUTE_UNUSED, + const irange &rh ATTRIBUTE_UNUSED, + relation_trio) const +{ + return false; +} + bool range_operator::op1_range (frange &r ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED, diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h index bdc488b8754..6944742ecbc 100644 --- a/gcc/range-op-mixed.h +++ b/gcc/range-op-mixed.h @@ -239,26 +239,27 @@ public: using range_operator::op1_op2_relation; bool fold_range (irange &r, tree type, const irange &op1, const irange &op2, - relation_trio = TRIO_VARYING) const; + 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; + 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; + 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; + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override; }; class operator_ge : public range_operator diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 8a661fdb042..f0dff53ec1e 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -219,6 +219,10 @@ range_op_handler::fold_range (vrange &r, tree type, return m_operator->fold_range (as_a (r), type, as_a (lh), as_a (rh), rel); + case RO_FII: + return m_operator->fold_range (as_a (r), type, + as_a (lh), + as_a (rh), rel); default: return false; } @@ -2401,7 +2405,8 @@ public: tree type, const wide_int &, const wide_int &) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override { update_known_bitmask (r, LSHIFT_EXPR, lh, rh); } } op_lshift; @@ -2432,7 +2437,8 @@ public: const irange &op1, const irange &op2, relation_kind rel) const; - void update_bitmask (irange &r, const irange &lh, const irange &rh) const + void update_bitmask (irange &r, const irange &lh, + const irange &rh) const final override { update_known_bitmask (r, RSHIFT_EXPR, lh, rh); } } op_rshift; diff --git a/gcc/range-op.h b/gcc/range-op.h index 3602bc4e123..af94c2756a7 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -72,6 +72,10 @@ public: const frange &lh, const frange &rh, relation_trio = TRIO_VARYING) const; + virtual bool fold_range (frange &r, tree type, + const irange &lh, + const irange &rh, + relation_trio = TRIO_VARYING) const; // Return the range for op[12] in the general case. LHS is the range for // the LHS of the expression, OP[12]is the range for the other -- 2.40.1