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: 106679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2672118vqr; Mon, 12 Jun 2023 08:33:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MHH3I0tNbgMX/6cGaF+djTz0APwX6lmwvLct6aMdXRrXHSCSptT57xKXBIDF5z4C/l4jE X-Received: by 2002:a17:907:6e88:b0:94e:bf3e:638 with SMTP id sh8-20020a1709076e8800b0094ebf3e0638mr10038774ejc.11.1686584035736; Mon, 12 Jun 2023 08:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584035; cv=none; d=google.com; s=arc-20160816; b=eBwjBoXn1jEAl8NrTRfh1EBHTegrBiReBFrzp+rSzxpigi5RaInHtWD012l/6uJl7E CTGPOnWBa8cc2410QAxwOzFHe65RMXtD8Dz88dxcjbIC+uhVtNnTkK88zS1T/3GGsde0 GK14lTjetgXaC5pWLMBqV+FYmUuLKt6h8cuLmCjqNpJ0GEAwV7/EHxZx/l7jV4bfPwtD fbAQDHUZa+wDgMAaL04i8VxBRHnllMCXlCZdB/zn6nTQtCM27PohIQmAkkiVRMBvcyh0 WT6iF1ovxOnCYjwGJv4gfLUjV2/Au/xGxO3TfG7SIpHt9vKczYLfCcOnmmUTh/jDh6Fn vdOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=qJ9oX0STGaAfc1m5nRcggMnAM480j+70PdgfC4z+mR0=; b=pK+Ubux2Otvbe4XjihWYRXSLdgoN2HiTouzfWUYtHeY+COacMiynxYxcIoWmXT3Ak+ wBu0MXa/LC5gXlQr1408+fDQGYi7U6uYA7yk3Vc5vIywgSM3+qgnY3yARuAOKBFVM9Jx ByCbkV+6xc9z5+t7R3sNihz8Ao9rIiUlSO99AB13At4sHqML+O0DQZZaC0RaBy5yY0Te 4I8sW12Wskd49uDo9qSWsDPEdwCRtfqqK1aTx0iD+HxdEttKg5QMuED+E/N1D4Yq/bRS qJjhbMAKD0srudIcTQ051wMzNrf5YPfS28eExpURmnFhCurRkbjzUth2uqk/1ecsD7Ut CTeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FaHelUXX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m12-20020a1709061ecc00b00977d9310917si5499410ejj.656.2023.06.12.08.33.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:33:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FaHelUXX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C873F3856618 for ; Mon, 12 Jun 2023 15:33:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C873F3856618 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686583982; 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=FaHelUXXjjjC4kqsl18tPsF8ManW3Wd4AcQu0N5LP8dFZoig2EO3PQtqBAgI4rqbd PBRpil9l5led/iiASz3OV8wvD+hWpMnuQhlCn5abzw30+2iEftt6C8Jdzs5B4dEijr gBqUx1JgrHbsTwsCP/Qusyv2wp3NtZDxp/JBbq7o= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511541502218068?= X-GMAIL-MSGID: =?utf-8?q?1768511541502218068?= 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: 106681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2672401vqr; Mon, 12 Jun 2023 08:34:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Zof/ggsyb/GPsDMIJOzBnw4d8hS7x9xP6QXOUdceLM1Lf1/zBGF58SWLKFerce7MKjW4c X-Received: by 2002:a17:907:7f1e:b0:96f:f56a:e9be with SMTP id qf30-20020a1709077f1e00b0096ff56ae9bemr10852594ejc.8.1686584066096; Mon, 12 Jun 2023 08:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584066; cv=none; d=google.com; s=arc-20160816; b=aYNBw9aHW9M2y+C1uRw7AMzxiQK2FbzZ7UYDXPFfAxQ4Mhfjqw2+kQamb3GAR7XRck TCynDJGwWhw0IE8Vug1B1mSnCs02JXfVfp5x2fTx558UBldzLOb6bNzn/1O8ijybsdYd NTkM05/If0C6z7wCJF7kCT4gITk31e1hyg369eLkxJKs3qdef8XLClUI3hCyyAZ04TS0 De9xyOd6vX7x0FEabQKvQoKUPK1s2d7M3LM9PkqeLr0qi3cUyD8CZXuQC5cZdEerGu3N TdRzGPHU3a+zc5ZDTHN77OXJSBTB/+9GBj9qi221bgT6Vvtovbbd5FVZBY+UzOKU5hjY GqTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=doOXsoIKz93AKkEz7X7uGRcTASL7dfkx6UR5SNI5iC0=; b=DmCEH3cHWSqM7QYsFUukypApvslRaZ6OViNFGJRhT2rpFVc8rp7lLif12GZvo7dp66 eOHvlVpebX1yQbTl2FC7HlAS2OdGp3d8O8031VsJt4Gti5E3tgtwmEa+gbA8KiwHRrq3 dg+UEuWaTyQ21Yf875d+yc0VpxGVTVBycT5oFNi6u3BjpfVBxYUu8cXgWPxVdQzXbBwg fmku/oTa7mxP0lIk7WtS+BmB+ioWhS6An+5bgRtsanNOnklj2CIpK1AB3gT3Ce/wPU0q bx6OXAIhLFRn01OE2KjyViGrSe95IqFFAHJYZjqccRUgIBs5G95jNW/0evE5oSHHEyEQ rO2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=B97vljfW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g15-20020a1709064e4f00b0096f8736bffcsi1975625ejw.666.2023.06.12.08.34.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:34:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=B97vljfW; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE19B3853D33 for ; Mon, 12 Jun 2023 15:33:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE19B3853D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686583995; bh=doOXsoIKz93AKkEz7X7uGRcTASL7dfkx6UR5SNI5iC0=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=B97vljfWaBw/Vg/2vGFSCOsOLGsmiy+NMdbA9KoK16z5Ab/f5voLzDtosbqj1UU7q Ke4XmJX7VRwegLwCErHJR9G0GZqmsqIEVC4gntIydMVBUiFNdDUyfq+isd9axq9F2E mCbLFsif8mZ5+kImffZ/0yIRBH266IRP5kmLbsh0= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511573682536551?= X-GMAIL-MSGID: =?utf-8?q?1768511573682536551?= 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: 106682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2672625vqr; Mon, 12 Jun 2023 08:34:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6gjVS/hY+uxEkEYo1zcGaHjKCfyUja1INbNHwx9F4PqeoMFRtLZ15WlDK73T03talVuih6 X-Received: by 2002:a17:907:6d24:b0:97d:cda7:f09c with SMTP id sa36-20020a1709076d2400b0097dcda7f09cmr7242491ejc.16.1686584087932; Mon, 12 Jun 2023 08:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584087; cv=none; d=google.com; s=arc-20160816; b=uqUCByv+ynvr0daJYGI74TwYbRjN/C5iMlFWRD1VnxbONtrfqogg9WbHaMvAiWaiKh VktrCuNCAS7tatHtyf9XDL7+T0SX09HGPpe7+08w1/kH8OTTEVX1UootdTLBhEGpizqp yt1SA0j8lWWxEVYleCaE0N6imfeGE9A39joSdYkv1iDmG3QG/Hob376waKvrcSef1Hv6 MliOYjbvJhzDXABSd+JfVyeaaPbmVoY0nSJYVh5gH1ExG080qlkY5ByP74SlarniNuJN 2v80g1+r28U+3+PxMqCpQB8TAL6uV9VUtLEHSsPgmJjeBEwTxZreygEYva9xMDMyHIpF Jl0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=vpNWyOiMyW3+E18vfWZNM9bRVbU1ymVupBpkB2FFirg=; b=S8VSWwhueFqM4glBclwFR1vbY7GiK/FpiUmk3/2PIQmMq96UGO6rmZuH3DLv2m9p/N t/vLBJALwxCf6lodN82s3v89HpjJQ5eD+kKeZ+mM6+9h+t2cWabeaCqwnZcOnEhjJ04g tPZEjGU/vRQvMdgw97+Gx50vZT8087Ws9tH86ILGeuZlJvOuNFD2J3Bqt/8iizPu4ixB cnaqy9y6otB3yRP8c4gVzXrF42y0vHs6t4grB1l0qua635/06FicHoID7jTtR3B2dkhW XWlhrUbjbJnXf5aq9AteBD1PhjYXdml8jqUHVS/b/uvqkdwPkpjTD76uzzq3ESYtMqxJ LQIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=u7W0LtAg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f12-20020a1709062c4c00b0097104874bfesi5609591ejh.259.2023.06.12.08.34.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:34:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=u7W0LtAg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3996384D1A1 for ; Mon, 12 Jun 2023 15:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3996384D1A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584004; 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=u7W0LtAgnDtVP/uAqXzdwTxVtWIo5mVslGRdUub1BM3ExCLs8fAimqVsx3ZYO08cm UpVDm44SZ07lsR/oUsST5e1fcBM26QRrMmxs8CAtYpoFrMs3+wcXvvV+o8pnpn/8dy 39AufrISi2nopHQVvrlU4km8msDnQMq33ONZMJVs= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511596705616405?= X-GMAIL-MSGID: =?utf-8?q?1768511596705616405?= 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: 106683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2673868vqr; Mon, 12 Jun 2023 08:36:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EZIgP6EJln4i0CVlD7QNjqjRZYeTVcHY3uUct/04KbYG5uciHYQUnngSNZDFJnEU5lVOi X-Received: by 2002:a2e:9ccf:0:b0:2b1:bacc:b3de with SMTP id g15-20020a2e9ccf000000b002b1baccb3demr3166784ljj.4.1686584195419; Mon, 12 Jun 2023 08:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584195; cv=none; d=google.com; s=arc-20160816; b=vZ/+j74q+LUW2y2I03NbkM3t/PefIs7RSdSgWaaeT1kc1cqRJaRrlLdYnAIQ+kzFIN gO5EtGReQGuYkwldoQGQEI/86xZeuV5Z8EXgYQU1EhhlpQT3PPzdN7isTn9emkf8fAED hi8ZHMGbDAhRgTiJu7EMwbaTo3XyY69KWaxDmaG1KBGHEikX9khi8U6aJNYTpOVsj3yJ 9r85x/IwShYHJaxuPnVLd8nV31ubTX4kGSBk0dLTqY1DV4ev4LdJTV7LnqajYrzhFvSl K6yq8EFqRF0r60+tLs9VnlU9/NOOjePmQOGVn2UdXVG+TuAEIUPKmLJcvqPoZuy7uw5q TeEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=40qPu3jeHFLKggS5K31LPiY/2Ni7JYd6kioJ2GTm7+k=; b=HtDWjc9yNEibtdupSQ9b71fFaclmGJ9SZ5juuiDAJCdrx3f2FTOqFriUCbKYEefnbd V07UbfEhRJzeQ6HnciQfTBDR9B/M7R+DvOSfwgi8FXO6Kj1/iw2KCGz0ixNsm/9tj2KU Dg2joFwPqvXWWPcpdUAtAL9GpCI81ZH6NQugc4eH4ze6MzyRRNshHe9Zjx5baOodap16 bIUEO/d9LGiFSHYaxrDe9Kzl9ACu2nVnDvsMPUM3zLbKtXOCAoL4JfGbCpXS2+tfufPE wyxiaBVJLyiONb91twBZyyawbavIN5aEKiCKefkJAb3yaF+3gJzcUDKg2KeR9VnL4CnO Lq/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sHLKmBHG; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o10-20020a1709062e8a00b00977c804675dsi5456714eji.74.2023.06.12.08.36.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sHLKmBHG; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C6B4385B534 for ; Mon, 12 Jun 2023 15:34:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C6B4385B534 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584055; 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=sHLKmBHGcJwtsOZzl6eGVc20UMHv5uKTOHcvzIjIhlc4kek7TfEUCKKFX6JYA1hKw dMkHN/1cAwKO2wFlFJ4UkdvatdznOa+pswB2qfOcHoOhcxD+rVAu2NqIh0hhIxE5Sy IJ3c4tICukqrmqHL3OrmW7xkPyXONFXxbvtOcRhs= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511709150845946?= X-GMAIL-MSGID: =?utf-8?q?1768511709150845946?= 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: 106686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2674428vqr; Mon, 12 Jun 2023 08:37:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4DjAFt6E8GKfqZ6HNbK4Pr23infno0x9L60SPywwMyUGle/xpXzRTo6eDHfle3eqzKixMR X-Received: by 2002:a17:907:7e9e:b0:96f:fc9d:6e9c with SMTP id qb30-20020a1709077e9e00b0096ffc9d6e9cmr10708526ejc.63.1686584247562; Mon, 12 Jun 2023 08:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584247; cv=none; d=google.com; s=arc-20160816; b=h16SR4c/oEUJt6ag79i+Tc6kAagqmKQ/hK7PX78b4xoB4a5IBGfGJCe6MJHPJ63FPH kcj2OpHmXdXWxdXAu43GsXui6pubk+R0fmfXQ57ECGQIgDGaE8h4bDszhrujsyPXanEp lbU6rtPvJK1IrP0C7QnQZarHc0KKV33RHqzVDMpZY4I0HdQ+oUZof4rWIFEEuABwuXas do7ofguTa7ln8q2qAvlqtcGfjTimvMW6B0h7hOpSy+z+LQOTURJDRmK+fozuw+sfSjcK Fr7RnHJmJMxDkbxkwBg1/ydrTdqvn78GWPupgT/Tymn6Jl6U240qGPQ+ejKD4F5O26Cf s+DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=zJBrDKGmYkii7BC1HyA/nYY7oMknsfKAuOQTVherBPA=; b=wkgOu2K+r1EV/hAMtqYWVLjvFp2JYx+oxhZ8MDV80G/WLNjIHyHoVodbBptIDtqKXv 6/Lyot0d9R2PivOB1iW0dIeIR8AGuoip58Az4z9k9dYIfb50ZC22LscBrV5IsnLGp6Bu 4liaxhxkk/3bOkKQI0sV4PDnUUIRouCDUGEKsxaebofmN24nQDa3NUQ1QjyHfr+ZMrk/ TrbVg+VV+0us9P6coBQJoXh2nwQdytqALijrFheUpswz3u5YYJDQ8I6mJa+vLpP9nIch USAupHXVTKlA8ec0RjPnh+eNP4rn5/tesipZFvWn3KIeNE6Xf1IF5Ke1BZvNXbHirwZp /RmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VgdLrD7n; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r16-20020a170906549000b00965aaefe6e2si5835019ejo.918.2023.06.12.08.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VgdLrD7n; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB7B83882673 for ; Mon, 12 Jun 2023 15:34:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB7B83882673 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584075; 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=VgdLrD7ndhgsp2B1y5DN4B9dVzB+UMoyzF7KbPVwOy3OdjE+BqRbLgLYj8fYbLcWu 1qXeG2vVf2hljJ5MNnKsw20EuwmCPvibHRns6jBlDPPBLsAhCRSyNyWfDWMG/Hl6pS iVWjB4yB2lFV9GBafrG1zFpRX1kMSL9ujRN93bwQ= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511763997240161?= X-GMAIL-MSGID: =?utf-8?q?1768511763997240161?= 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: 106689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2676183vqr; Mon, 12 Jun 2023 08:40:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mZhTZkrpOYZECMOYDl7CW9Q/x8nCxluY7NLwawWwIOKDznEbANN3mMV3/iaiEBW1M1+Ui X-Received: by 2002:a17:907:9710:b0:96f:a8c2:77ad with SMTP id jg16-20020a170907971000b0096fa8c277admr11267097ejc.63.1686584415435; Mon, 12 Jun 2023 08:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584415; cv=none; d=google.com; s=arc-20160816; b=CIEk93hKUQnjdqfphHUeHgCKfcU5t+wKXH4R8lWkjQuAr03oddRCHxpbdXFf8vOMd0 DKpNFiAphDeUmDLF20k5dc7u7dq2bT936P9CQD8E0Phxeu9zYtJP9EEL40xEIR0QRFsc TViyFa7fEkJGugBhKpowVvKBeuDGUSpmh2nk+pfZuMv4S58s/u4UZ+X3ukCHpe0KCj+C 346IWOjzWDdD6E9djRHHvf8UmM5N5k8bP/IHLSKeSP1mAVAXoaV8E7qj4tnsw5ofslYr leXQnr/wPi0z/xjfJDVzHALg1ZpAum+z9SRo6HfKsB6pTfqpj08gsoyTRnls34TP8z+V GhiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=UbbGRRCaeQLL7L7unOxH5SgZujwelow7IXWw0BOyCko=; b=f+lt9djBm2lpxkMRTvwjsFcUNOjRVkdVby+2po/8KO/24DhlwZBgddu2AbfsB0Zx4x UWNnOyKL2BO3H0jCApUf78kwpkL3lGkCrQ+fionHkPE3sCDPDPac/04ENX3NcCOSVmJT geAegDMUVIF7Y7mrNBb6f4tXDuarJCfMjbXKi4g9ZZvauUVW9WPt9ODhWX7ArwZQuTwJ tVBqUi8BAenu4lMu3cV1ie97hD5FWfwsyMULgbPNKWmfscz9EanSipNXoFMwERF++6BL xxpQTYSsgEETC0M1TBiLXi9Qv5q+Wh9lTgxXNhS2iHe6eq+Rts2GCGC597EwsuObDTjq hxpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nqEcGNqo; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b5-20020a170906194500b00977e10fafd3si2313557eje.1045.2023.06.12.08.40.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:40:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nqEcGNqo; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95B773895FFA for ; Mon, 12 Jun 2023 15:35:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95B773895FFA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584140; bh=UbbGRRCaeQLL7L7unOxH5SgZujwelow7IXWw0BOyCko=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nqEcGNqoRJDf2n5hGqa060ADkKHquiLffB2GTNKY6FoT8uVQXk9ph+iBiF+orqxyB +UnRfF3LYGufeeEbFWkjkjMzbr8/Nm0xtSqy+CZMyYb/pynMWq9Sa1uipEF+i7fYeX so2IJNO6FpTU9KcpYFbyj4/6N2ArBVUlyvR5p9ig= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511939806563195?= X-GMAIL-MSGID: =?utf-8?q?1768511939806563195?= 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: 106684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2673898vqr; Mon, 12 Jun 2023 08:36:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69Ru4o3vA/vINYq6k7tCrAfy5sqW40MtjXuRQMwFkwBRno/5c4ur7QRmSKtkRumzkx1vV4 X-Received: by 2002:a17:907:2d86:b0:96a:ee54:9f19 with SMTP id gt6-20020a1709072d8600b0096aee549f19mr10963960ejc.48.1686584198269; Mon, 12 Jun 2023 08:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584198; cv=none; d=google.com; s=arc-20160816; b=GUGEdvXtVNq8tZ/cuP9TJ7qQqgOwp+Lf+BjD0XGcBP3moWhKX8rMaF3U3j0PKNGPVD 8eRrckXRWNpSF3JiQJ5XpnHnzW3pwCs2C9BgErBH2bWZrthQVIM0zRZhurrzVTwJuu+Z C/f9G/wxEZqUpbVOPD5pDBi9av6myMjqkCar913iqKqs7Gc3ZzN4BMvJbbVRie7RRZqb hxsnx2mwTqa+Mhd2k9y96S/zIApcDzR/rXDl8nIhkcVErTgvW1CnPwyzHmD1WhJU5W/a PATIHo09bKGSn0wEkJ9bJPYeQzAf/HlcDeg0IWCT3Pg/X3c1ngI8ihFQtfszbxIeNEel PCsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=KjjAi8c6o+m2sRfxeHyDy+pBcVV+mPX9/F0oJG/OFGA=; b=nsyA77iTyO837PfISzqFRfYICv05xeeevr1wBEctWnzu3t879i4Y6NtnqqETgOP72W 4MZYd5XR54PD10IkmT/spCO0vehR1f4PZOHBkvdSFaaA8AojdTBwUaPUmF/Iqm8til+z lQI5G2UcAmBunCLpWyMD7qBx2h4c513MeUHFo6k7UpRjP4BK1UJurMfeS3fDTmR0KLpP n6UP8dZaVUUr5zzZ2sXInxd9QpSsSo9/t2s+eHS1hBkoDcUcfNrXK0QFmbtj63jU4/Nw Ov/9YkH8Zy0p26qfP2NGD/59zLzZT+4O7vORC9lc9/LSvPeIqX+VpRmp0LA88qZb4SBS pnXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pWvcbNwv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w1-20020a170906184100b00977cc168e2csi5035810eje.262.2023.06.12.08.36.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:36:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pWvcbNwv; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3C363854803 for ; Mon, 12 Jun 2023 15:34:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3C363854803 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584056; 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=pWvcbNwvS4HqLfjYZLMFGs8DwNP3449VBIOMwBjvPh0UAQ1noTwB8sNKknvv6Lo2B ZwoSGOqzvz5nO+F1wkbpVUKaM/KFgipAE4cwiouZw1DrcaznJJYUJYkGxYNEM0tUII LrdgWVqSM1lEiP9Xw0Qq4a5IKvzqqztgRU+i8Bso= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511712462811083?= X-GMAIL-MSGID: =?utf-8?q?1768511712462811083?= 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: 106687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2675679vqr; Mon, 12 Jun 2023 08:39:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ECcrCBpvjZ2RUASMBybFPUorPoz/7EPFbt8IHnlPQtYm0B6zN2YDiTZV9KJWKLE/jQp+Z X-Received: by 2002:a05:6402:150e:b0:50d:dba8:c64a with SMTP id f14-20020a056402150e00b0050ddba8c64amr5256793edw.18.1686584368444; Mon, 12 Jun 2023 08:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584368; cv=none; d=google.com; s=arc-20160816; b=Dh1Lv3DG2VgOQXArQP9H18EJf0d3Wawa/7jKlBYuM/yhD+RN2srnSd9qjflhnHkgll HPamev7+fgVHCIdhIKio8XKh5LXdj6pIESudM7NxVrvtV+uB3DwJgnVOYdfP1HfS/0kg 6hiKwxLIK/DcXR5nO+2/KFAf4vVm2ojpCtp0Ch/LQxsaSKrFqd24ketNYMW1Glgoa0LW D+qjSxlvJiohFcVIUy3ZwK3KCIarrq/WKBvPFOFSz5UG6Mi6vQZBu/FCT4ejZknf0VW1 xokNwKScK+sBZuczymzmPyu5WH20phlMSzDKxaudytXkGMiobxh/fn0WO7xZai/ZlHN5 Ftcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=F3ATWGyffw4IRA5oSYxTLPiS1RHKB9suGtYGpzVHQ/o=; b=cgsI8b4viF5RZB5rgHoACilamuTzzkWcq3X1gkIYblnJgVv858wShZbmWEpbDc86cZ x6OLE2DI97N65YJiCtE+pmI6191dcyn0vwAmkD/cj9VPhSv24uzLRpKcoKJyNBxCdUWY QleP/2ekb2LUrxSAQn4Ixg1DT1D3yTKrzm7FVi08cnlZ54EJ4zC6qLdbvnViGhGtz1+Z wqPZ6K4zt/Wh9hbJnwrPjw3t0vdPnL3FH1ULByxI1CW+8I8BYj7DT+9CZbRoVzzsxVSi QpHzLEv/1/JedLJ7Rgv01b4g+6NQtjOpm6l9edpSFwMpZaqKLXhzlCQKL4R3zkml1r6+ hIFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EsxzbCRV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e22-20020a056402105600b00516a1ec543bsi6312708edu.477.2023.06.12.08.39.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=EsxzbCRV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 259A738207F9 for ; Mon, 12 Jun 2023 15:35:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 259A738207F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584120; 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=EsxzbCRV4jUYkw1VX6dA67WgwXDybQcNrRFI2+Mvih+gUaq9yCILTzm0b7uSggIXR DStY7yZujxEwtXOmuXL3qWTb0rTyxPuJQsV4SS5c/YUqtBJJIf1MQa5ZF5OdT0n1a+ MDhNjk6iPyPTMQqvtAGvMnN4o+HkNrh7O4aNBf2E= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511890479364991?= X-GMAIL-MSGID: =?utf-8?q?1768511890479364991?= 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: 106693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2677512vqr; Mon, 12 Jun 2023 08:42:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hptyNKdBKZMBq+7OCwg6YCKioTJ5lCRdgo0d3LhjAFuIga/ZIhASArwRlTc3IfMK8FTOk X-Received: by 2002:a17:907:ea8:b0:974:623c:f136 with SMTP id ho40-20020a1709070ea800b00974623cf136mr8660375ejc.21.1686584554009; Mon, 12 Jun 2023 08:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584554; cv=none; d=google.com; s=arc-20160816; b=neVRhvXxxrjnS6iJ+vU0Xu+yd0nPX09QoTGGd2RSWioARmVr3FQy5o9AOkI2kADgWj 55eTR/addeioHIcZd0lRLwNSSUI0EAisHhP6hFdhcmoOQFEN/nKnIOX03Z/kWMJL0tD4 iEdA5X9B42AtJAPd98nwLE+ATLnfxE8kFNevPv2L8HLLB4WnBUqojwWm4OA6gE1EZfmh TYUTbrcv1tlaq9j32hjd8sAlPiXvEv/cRVHrrWsC+KQXzPP3KNfCqt8pL+AzHz2DnHSt 3027FpdaMnyivTBOYILboHz4eKYlZsZ7WnSKhuAB6mR8we+74HezBI2RXYUcBrEa7uS6 Ebrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Noqm5QhwhY28z4Q0yCwBiaMOcKjHBNnCTsZDqlOX8M8=; b=R3eVwWc7lNcRmIUCUfpMP+PnwKvU9aY9YFCVuYcJ2Mwh53ALCKF9LG8gitSj8AcWMp tYsCCopWS6Zd+7QHvyquX2FvckKYvKhPtagRguU/1QSQAVMoa8anrJgUTzaqV/wdyMdF hIof2fDermi34pixFQRGf9CIKyO38oDcs85vC06iSXwohx12rYIrQPI2MzsWSf/2MQKx QPQXqWhT/F2y+Q6MWT8TORurIpL/+ujm1mYc6N0RuYLl/ujbWyDv6Gv90d29dwpdlQw5 Sy+fPmt2GaplnEGJyz652hO03MhCZfcPY8luPpErcpMSN2m68Ub43Fxm2dK93JpNTvAl i2SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DTA+EyGT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gz22-20020a170906f2d600b00973771bddcdsi5673564ejb.685.2023.06.12.08.42.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DTA+EyGT; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A222438930ED for ; Mon, 12 Jun 2023 15:36:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A222438930ED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584209; bh=Noqm5QhwhY28z4Q0yCwBiaMOcKjHBNnCTsZDqlOX8M8=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=DTA+EyGTcX6mRHakjLX5KPn/pux8g5obTdJ7Aee06jeE+dOuiOQB+jekJcWyhO4IX KBuefKfqbvx6Q+mOqlzD4OCIoq7HQZdm98i8tD3N5P5jf0sQ0pyIpFAtj/0vZtLGRv 3zIZmfcCqWXoS20zt5uf36BeYIFBsTZYfELVkh6M= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512085712708579?= X-GMAIL-MSGID: =?utf-8?q?1768512085712708579?= 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: 106696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2678664vqr; Mon, 12 Jun 2023 08:44:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6o9rGA8L8GDUy71a4TUtA+gWtrYAaSG6xVBHwhebixhZhnp0RTuITMrRIM08N6wPWj2XSW X-Received: by 2002:a17:907:74a:b0:978:af67:c7f6 with SMTP id xc10-20020a170907074a00b00978af67c7f6mr9284426ejb.13.1686584669705; Mon, 12 Jun 2023 08:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584669; cv=none; d=google.com; s=arc-20160816; b=U5bBB+RCMYvkKusLcnnhx1l/g3hitPgTBoJ/ocq0Uaj1sK+cC6geWS5bw80L6nPB7s CmF/6OKoweFJnUtjx+EyKc3dchF9XHBMaRolJI6PF1CM/aiC+6oyE0ZB0hKp+naSFF+m gekGxdI1SMPkiNVEh2L6JCubXs4qqwQKycQ2IOnnUrOGEBMcb6Ps99KM/uKFhHhFQsuh k1jEDjl5aJDnUXTyudDJEnMHFmGL8SWdkuK8vNqkCmnCKJookpirrs12uOxgao8y3eKQ H4IavupLodk//cSK9phh53Ds/DnHEJWqVOEdi+q/aA85rZ1rhgPSTPArRhiWl3ohaVdJ NVpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=AeM/9ZEjMz/7TxGw4FKU+IRjnExPbrIpcl3MFkAFHVE=; b=igG5OK7OIIYftYbdQobSulNzN9NMZU8GSmmm/LjYeSnT37wU1/wQXuLKXB9hueDgT+ 5/Bd1nqY9axWok9gnjRZHwndCiJsnEqAV3aOnTQDlF6D6TVsamIWX1I9PR2Ve0/ZWXEp VEdly5ela5QCFiDZ44NCJOpBpyRmguiRpIwDziBSIDcjbx7ywxQ5Ds7XPWd6bWzGhvaC MXusPayftBEaBItUUJnzd9UViDpW87g1j7ZvIDALKpZtfnwb2MjDH/3wm/Bakalx3MNl PDwI1JGmGv63xJogbxl+p+uFvjcL4FWvmfFU0GUG5UjGgud33QjvLIrpYrI/fDfMQELa +4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QpoaE5Ru; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g8-20020a1709064e4800b0096f6d4fde85si1865298ejw.269.2023.06.12.08.44.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:44:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QpoaE5Ru; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D6A6394202E for ; Mon, 12 Jun 2023 15:37:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D6A6394202E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584271; 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=QpoaE5RuR0FoRt+mm4aszz6XK48IxxLB1hy3sCGfrrXBhiiRSk7Bs0iYT0f4YozvJ QeRyYazBU9Mv3AUfLZWUT4rYMm0wqFqnW+VAhLVRF+C1eq7T7B3gUfsJlq8KL3S+Bu abIsPvSYk5Ly4hIaGIBeVMZtpnijf6mVetsASCXQ= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512206202578810?= X-GMAIL-MSGID: =?utf-8?q?1768512206202578810?= 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: 106685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2674159vqr; Mon, 12 Jun 2023 08:37:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6r26LF6WSV4kSz4fU+V1SRlV0BLHC/TZU1LPKFB2bMvi6W/sAj87NFCrR+ozbEiaPn48fv X-Received: by 2002:a17:906:6a08:b0:978:adec:4ad1 with SMTP id qw8-20020a1709066a0800b00978adec4ad1mr9920479ejc.32.1686584222784; Mon, 12 Jun 2023 08:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584222; cv=none; d=google.com; s=arc-20160816; b=NRAJkGx+bT0d3SI8J+4pi3uYeJ32pizCI1avuZS06eKzfBK1LlGmMuW1o3AwYk6N/x 1uImLEcWhY1XMY+VHL4Zp+9k38QVcy7iNBmbM3ySS1mYk6OijhV/XpbirF8HjsKQ+DX0 dJ1sCyotoxYPe3gjpNABTEta6Dfx5xNwaSmntbF0IPlaB45EIg6oPVcSJlkk89nO7qRR RKnD/b4nF5i+4Nivs3i3QxkoqtX6AVfjVtN8oHzj+7BM/2dZs54lnjWRQ9OX9JHhY7Rv E75ghWddEkzSmY++sdHSqf3EZBmL2DzxOQ0TB3C6NcphUsnAH+6OpJ+tP8EklSGJVEyf avNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=efQ7i0+XsYgSXa9VnMx07t3rMo9zrsUI5oKOVbWu+fc=; b=aSwaj981x6MZFEFZhpYu9TOiSQu19sen47GL6EcUr3sZB/5FeFrpI9T9wsJKZyVZ2B oV5jJHyZYp6AU4xNy9Va+Zx4md8bstgtoHIeQk5tMdU2OUQQrCGInrZhrj7XZEh4thTa 8l98Axf1423FlEBWayln/9YHhEoGyEdhM9E6CuGHNYURw9h/frgHgpw9lvgwYw/awjkr WYMO74mGLZ2Un6xybfc+N2ZLVvTBdDqCAgYMfZ7yg12ZIHTYEpFTTmm0IfXeUNlgpxV5 U8PlcOpt3aZnQbdsnrV8lKfjR/4IKG7Rkj49zDiDVihNAhOlDf01oEmFD1AVtiaM5XJB P1Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="D3KfpL/u"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y20-20020a170906471400b0097e2a90d223si3603662ejq.720.2023.06.12.08.37.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:37:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="D3KfpL/u"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4F7F388264A for ; Mon, 12 Jun 2023 15:34:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4F7F388264A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584065; 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=D3KfpL/ufwkAJhu7ZyvYM5NbWTLR2Qgzsp8fpIOnfwQ5YUogThyhdUeYl61dT7qFZ xeoiZ1OBd0mLN6ZFcAen9LpMSvr9zpgFE2ph7w1zzPHSpecO/IjdPk64WkvIkMYlWW o9zwCKP0OuZ6gM3v7iL+BLKJlkCbjUCYBbEwFS+U= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511738042691201?= X-GMAIL-MSGID: =?utf-8?q?1768511738042691201?= 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: 106697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2679117vqr; Mon, 12 Jun 2023 08:45:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gb6p98YZKFuRoY9o11LCEDlGuIQw/GGBImNlMLuHxDLrHWXQXerZXK/KBWEZfOTYvd8XA X-Received: by 2002:a17:907:2da1:b0:973:84b0:b077 with SMTP id gt33-20020a1709072da100b0097384b0b077mr10591976ejc.33.1686584713893; Mon, 12 Jun 2023 08:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584713; cv=none; d=google.com; s=arc-20160816; b=imn7JPyueIgq1WFTCLYD3frVsMg+zZ11fb43DXgFmnj6EDRUu4r/Df+TWziqGccmec JtRWtrYbgcZgFKNgIhPe3qa/HkL14bjDglWm3MycvfMsi5NzfIn1cLMh61K7nukXQEf+ CwCQ009VWm3whgCr7a88v3NFWC5xBcvDT3fXVck99zELyiZ2pt4V3TtvFfo2xLsF2UJ6 /KGf7coqs7O2d1zKdyeSexrRYinZm1F8GD8nb+oWjj7RC1700DTJJdJOl9POfedf3KTF AVvyhQ4L94/oaM/tcK0woUpI2GTniC6XV9GKZysDRTGvucZDtwuvU2ONX65YHUSDO5mO wXmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=8OH7Vk3JdxFUwWY3S1IMh8qV5Id7NXYIFRDIj75FDVo=; b=RTJkyqedLVxkKYOaqOKfcNgU5UpIvrXdMVy4VWl9sWF7MQVihyk0vom9/2Pt16hPSP 9Hw7Mv6onawTjdoSbUX+53CW+3KW1FtNY/cLQ3KCEwwMovNdHOX6Ynw412XvR/uNftwr zlaO1sbcU8oue9rXbnUL2FIOTXLfKGt4WOTMHBn9BVmy5WcIRsVJNJCQ+LWzH+VKhNya HyNc8yepQSuKmtx05EdtZTVxsU09URkrRPQUVANIh/sY38Gckt82gO6chf5cLBZo2BMZ vaajXGzTCuzk5ZSZ5i+H0Pf3fzUKW+mmMnCxjPz1yalb1kOurD2PUHr1hQW1rp9UHzVN uJeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="n/grQcR7"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ka22-20020a170907991600b00977d0db2c6asi5033356ejc.63.2023.06.12.08.45.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="n/grQcR7"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 226C33858C74 for ; Mon, 12 Jun 2023 15:38:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 226C33858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584330; bh=8OH7Vk3JdxFUwWY3S1IMh8qV5Id7NXYIFRDIj75FDVo=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=n/grQcR7OUWU6avpuTGP8H9oVkF+fxjDKpEF+8Wm2NzK1Z29NNU1ZKbTJLFO9yXfc MVd8LMRAFV4sxO8iNKPVPxoYvlc6rq+YaR/pcFnGpCSYFScwOCtLZW3SPNl9lgCBLr 9zbGkoSxD0C6cAdo++owalvErgRmdWfDnZwYQvyE= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512253210910029?= X-GMAIL-MSGID: =?utf-8?q?1768512253210910029?= 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: 106688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2675826vqr; Mon, 12 Jun 2023 08:39:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+4zmj51AT8oW2TT76Av8WLLzngDXcSS6KuyTr90axBswu9XbmU7viQvMNlJhxHwJJUDT+ X-Received: by 2002:a17:907:6e26:b0:96f:912d:7922 with SMTP id sd38-20020a1709076e2600b0096f912d7922mr11578862ejc.53.1686584382188; Mon, 12 Jun 2023 08:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584382; cv=none; d=google.com; s=arc-20160816; b=f5bGCfMtltvaLAI7rsCddfq7ITVWrNMjclfYPXrU8p83Z8vmOhSzR+Yr/1PWAtBwe6 reTg9haMInAJrdhBQNBndLRnbc7X5fYKdswDXEYpaJA/nL/hw1ZBuzbiG81Uo6CG6e8f Y4/59iABeozjq9Yx7cw2/6Aavan0YvRPMhYUlA7PUG4uLfRTA4qynj2SPq1t7xFgIoB7 jO1nT1cqyeCJUNSwPK7qOYprcR5GzA4A+GqFQCk3dewm83LXPZ0o6ochFHZ0TyDP6xP9 oCn/NlojwhPlG5saYYu3VocjZgWvcYI+0hGUojBjKYb3fCooUEywH+Tfpv3xw4yqISWd zmUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=x3OaFfB0OPOuhKgnrwPMY9ss8qcCNevDApfnXjdGnlQ=; b=IW70GzEqwy7cffkYCedl1baE7qF4vOrtvoGGO4e8HGL1wr9qoUxHlrhNsVGSzZN8fK cPeDdfJ4kgRGQwCHskZGoI7pPjvuuRk41rhy2RgeDRrXjIjEuplLednpuG9Hw59+cVhc vntpMMGn1ADSgHVvhaBLGTv8Cdx7Yl80dplfpZ92DC8In/qcbmcVgZ/T5B2BdCQiJ4mU bltOGdfCowQpQM8DsRx0U4h4aVMe6eXlvDZCk3eDsGF1iR8Zd7i2Qw/MeWcmM+1rESAs KT+duHSg/Fohh1KmGtA4FzEBERrlzecjCGPQ8arWgvdIaKY5BpEh7vcQTvrKA2sh4YRo qnUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CKeKoDs9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qn2-20020a170907210200b0097454835fb5si5036148ejb.378.2023.06.12.08.39.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:39:42 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CKeKoDs9; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42A243894C03 for ; Mon, 12 Jun 2023 15:35:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A243894C03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584124; bh=x3OaFfB0OPOuhKgnrwPMY9ss8qcCNevDApfnXjdGnlQ=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=CKeKoDs95sRU3odOWWsj+CREO8omBYhAZgyI+3WElFOPyQxIhLQFKnJHf0WFYeeAf E297q0Qevq13EjIJncpoiZpJGDyo8gGwP5Tok6FLL2Cq9zovt8N+egOtfePPdmDPuE TN967tQrf3/fz7SDHNE7v7LpySF7Bi5EH9OmAgfc= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768511905076737061?= X-GMAIL-MSGID: =?utf-8?q?1768511905076737061?= 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: 106690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2677171vqr; Mon, 12 Jun 2023 08:41:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4B/W0rB4ctqWUSoSYPTO1Dd4bRIw40KK+VJ8O6PJ+/G/5jx4DZzwLXa61/xZiAsq852mXN X-Received: by 2002:a05:6402:114c:b0:50b:fb85:8608 with SMTP id g12-20020a056402114c00b0050bfb858608mr5560588edw.25.1686584513536; Mon, 12 Jun 2023 08:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584513; cv=none; d=google.com; s=arc-20160816; b=g71ilXDtEjbBco8/7WM4Ryl5TacRV7tFc/VtMBZYzDIRq7k89kD7eFXIYyUybBnlNZ CECiz0M55j+j0pITsUj/acPxs0yGZOnlYHXfRDTo/a3JOK2OVI62NAYJp3EXOBT806FI 9Ko2dG0fMN/VKYuG+VWF278jb4b9K6F65Iamu58/DePKdLjyLk5Xx7kdZG09vquDq4CK xLgPPmFTH39Qzg8erZMYhFdyenHqEeLYSGp9qh4TDTWsEUEnmGf5n/c4k1aFkGO52DiE f5t0EmCN4b8rFqgsmJ7HY6QiH3BX0ZNm8rKlWT4EfgJoBABHpImThWybaRA6qtLMG3yl LdyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=31DmD0jc+Kwh+HRHVh0772ghc6dscDjymhdRapE1GQc=; b=NYXgt7nMeGweV05MOTC9bPWSTKbkMgkEnbIu6dxZ9tzmoUrcPtEcu5rvLiyw6gKiVi vfRZU/TZEQ8AN/+RS1YrwRu2RTCWdC94EXNf0/2Ve3uy+lc803yUxim++8sg6/v+5qn/ Tg4R3Rxr99y2GsOiPEo9p751ex5aWz2WLzpRPiKjCpkKyv4qp/MCN6JazZKViwfOIPD0 Ca3Me8nXFar9zalolRCIuPBpt5TsvIebK5I79+o/uIqRMbACIFfrk3joQF6oD3WYhQak qPxBy3embDFhoCq/YF+RaYAhthiNJaCCJ/L9KuELE7JDOeJ9IsfSVjudpNdG+QHvurTS yNcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZhVzBq4r; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r12-20020aa7d58c000000b00514a246ddfesi6052665edq.525.2023.06.12.08.41.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:41:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZhVzBq4r; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D2AC3815760 for ; Mon, 12 Jun 2023 15:36:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D2AC3815760 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584189; 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=ZhVzBq4rvJ3V6w+nt4MwJyPjaVoltOwsM0Ru2C5GBtRIt0qLVTYXP+2JtJa3xMrhj tg3ao3cQJ2yhT9lvz0xEs72kv8udJGaSQghwBmD+c/m25LQ7X4QPvPTtnnZFiYESSH xj8xkRv3IfrvSJUt+hsDXXrRRFNE8DZDRWBwUM8g= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512042667256760?= X-GMAIL-MSGID: =?utf-8?q?1768512042667256760?= 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: 106694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2678293vqr; Mon, 12 Jun 2023 08:43:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PVNOrW3U3517BW/5zrpGSKVDAQaY9Icf7zPWo5ChAfE31ns2en8o4XYsCNoK6Q+7uaeZp X-Received: by 2002:a05:6512:2f5:b0:4f1:26f5:7814 with SMTP id m21-20020a05651202f500b004f126f57814mr5022673lfq.20.1686584631315; Mon, 12 Jun 2023 08:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584631; cv=none; d=google.com; s=arc-20160816; b=xGPckZZ+V7oR249LnvunXECGrtFdBYt4f3Z31z/BMa+8N1SiAMW6b3n6XbjYhxwmbV em5nHMmZvTR4NRiAJvUaA3IiIdN3KXPlgj1a0belsR706UC9JV2zyvlLZEAeoFOQBsYf G9hG0iQxrcPBsCbIdiP03/vfQagEtjnkvvr1EKRjLQ3cWSj/zHcCINg2Vbz6/L2OtXR4 MqslJSsjHZ/F0QNdsQt/LQarjKRUq6UXSr1Ql5gUSE7bgJdU9brlQRVxV14G7UvcjJ0S gXlUmM6+EAadj+2qSXLgNiJX2PPhPYWCh/FazPfY8Mz8nJH+TrJrLZSHFTxLg4AZRJu4 HB/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=KhDJ6zqZyuJU4pxZpP74nMwvJkFnIKwY3FJ9znhaW0g=; b=dWgMy4MtbQGYGtbbvGCfAInQ541ooMKBtzF/eeZeTd/Vvouynq73YB6JawWrBOXZlg BRcE16FzTWoBk38bEWuieP1WToRhb4fjKTXU72Kb4GZP3qqZFNorXTPo4R0B6aPefIp9 FEwDAe9UF2vJ8zq/BQgOsQ+YqKOJtwKUlH1/AHqtKnFfaEh9+aWk+dwAxDNlkAnLFRZG 18JzqRCcPsXT9VqF2/2w+SYn8IHJSefcD20Lk23jo+SYOz7GIhlrz2kAOIuy5RvYXDiw ZYjPPhw5KaK0ZRUW9VZySbKLFunJZeCh0373mCBGS0zOzFNb1ELRbi/jQAy6xI9/rFO+ gIRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DkVvTUNB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c11-20020a056402120b00b0050bca43ff51si6436133edw.277.2023.06.12.08.43.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:43:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=DkVvTUNB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4592C3939C00 for ; Mon, 12 Jun 2023 15:37:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4592C3939C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584250; bh=KhDJ6zqZyuJU4pxZpP74nMwvJkFnIKwY3FJ9znhaW0g=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=DkVvTUNB6Rnm+G8ZBhSCllQOFJ+9JsnOL+Bfn9iYB2Ug0F7aKaW6sWQ9s37k+G1S8 Y8wtrY4nSDOfv3Rc4jLFl+KGdHYDFFgo6unjIrZxOvIhjL5fQ4/KV6RHVGNmi5KuW9 akc+uZZvnAa84Xg1a2KB29kWAFQmDmObSlOz7GKY= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512165953554363?= X-GMAIL-MSGID: =?utf-8?q?1768512165953554363?= 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: 106692 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2677312vqr; Mon, 12 Jun 2023 08:42:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vwSbK2qhrgYNQIAjDppV67YDe5PeesxGBETxEkOfO4iDEU/A7fa/o2CO9P7CpW6mHXgF/ X-Received: by 2002:a17:907:2688:b0:967:a127:7e79 with SMTP id bn8-20020a170907268800b00967a1277e79mr9596028ejc.28.1686584531456; Mon, 12 Jun 2023 08:42:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584531; cv=none; d=google.com; s=arc-20160816; b=wTi9DMsyS1YTzL3A2C3ytdHAFuYDlceQzT9EgyZ109mB0eudluClbFkF1rt8lLfLge D/v8n9krnyoLXAQDW2imdXJhqZcbBtM17+pVUyqUMSIc20Prp2Zl5FvK34I6eFPtGVhL S9jLc6qCEU40nI7VRf4szKA+Vxpz/R4zCX1fPAEqxGwaT6RzzDnE+HVKMJan6v777v3Q qjyZ9p43fwvatT3hq5QCPb3iVfmp8X7SilqXv/Z6rt+dF6m9VPxIZsijSC0QCbDx51QX HN21svGVPZpm5uLkLJYG/1ahY/ob7yvqcIEJT4+GAk4JbFAUxlRQwNqS5ANJt7idSV27 x2sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=1oMLIYkDH3SmkQ8opiAREUNmEDSMuvR7lau9gNu2a7k=; b=te7Zxp/3oMrav0hQCp9npnKnEB671yaJwBf6+G2PPrnQ1jQXSH6AuWNPVXqFBKrf2P knn5gVOufnI81wKpurow4buc/Y8CmRAWcogyiI+ubjN6+YqP4/JrFc9u7YebIxTq9E8z uYJ3W4TRQKsGGq3dEueYCzoyT4dMVErtw0uFu/pA044Yy7IIW4twXILA/5VSB4Jrvxe7 fJn1Ro52uRDeNxHTGoNkoJZCQLjnnDYyX5MEEW/WjKajZ3CcWZePgaiDI6Dx459ryKdy 7rBWzDZG6KRbM1ZFZC8KXsuyir4hJ87lSsaHD2YBHPgFG5qwoTNStJnCCannrst0e/N/ iTNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xpx2fOW7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e24-20020a1709067e1800b00975425ec9absi5485674ejr.550.2023.06.12.08.42.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:42:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xpx2fOW7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC625389EC67 for ; Mon, 12 Jun 2023 15:36:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC625389EC67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584198; bh=1oMLIYkDH3SmkQ8opiAREUNmEDSMuvR7lau9gNu2a7k=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xpx2fOW7fHxEKZa8Fgb8lixa5jF0DwJme6982LZiVvO0E+PPxHf//Slr6Ze1dtc+P BiHZ/RRppDPee4ogsFt5DCJ75GXDfyNvKG9DfttStroq54OHB28zlSbTS3XJOTcs32 RUR5OUGDuuOv7v9CjEOe7hgMokWoD+tFcX3u5muk= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512061581443154?= X-GMAIL-MSGID: =?utf-8?q?1768512061581443154?= 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: 106695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2678606vqr; Mon, 12 Jun 2023 08:44:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nwZasD/4EUvzrn7u1+1gGXJ0x2DyeKolssZ92KLUi/ifdLUJ/KR1H2w+ScUsS84e0hqFu X-Received: by 2002:a2e:93d6:0:b0:2ac:8f73:1f9c with SMTP id p22-20020a2e93d6000000b002ac8f731f9cmr2896977ljh.1.1686584662481; Mon, 12 Jun 2023 08:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686584662; cv=none; d=google.com; s=arc-20160816; b=E5G3lI9dP2+NOsIrCEpQLTYtd0YUgo11zM/fU6LcI0ziu5Szt8srLVBF+NNnnWbm34 X2T2RjCGHxvm3cWHaMeIE9pLeEL7QbCGonMLjiDg7x5DhhhPXjjzzEDyjNIUCKrsx1sd 9YBLGbKuW3zSnFk4WbI/A6lEYd+O1L2eMB3m0mpO1XLIZ1H2Kc1tzNzUXMwBV6upDqWA LDmz76xtOK+N8e8Wr5qTKfZenPa6tf8aivOJwPXkzPKW380f3+r1f7chST6L8RTKCUlL K47ZsiPVgD7MsO/WIIurnTy/pkO7iw3MH1/7gNVsKkCy5yzXi7J/071d3awmjI9pbRYA KD8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:content-language :subject:cc:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=vsJQkc/D0ARvzYMp8+88ixFcjag9kIPmg3woykvUqmY=; b=vA+AAeuzTdhca3+qtvcEy8D0srIFDffAl99JK1ou0ePGx5NMU51TAXMOJCLvSpqQtP 1WNQkt6XUNGCZu8kdDVKop3Oy6aJmnUA3UYT8pRgFiN1jYi8KR2Dty+YlE5wnfCWnRnp cwD8cfmByZA4Qj1rfurtApKZQT22rWJZFRr2De3a13OnUGc8O2hgNRo+gEM3M4b4aZjA YnUZqig3uqOOlJgy7SUWjwSgdK5/TeZBxmPJQJR1r6BRAc7b5BBRhw/t45UEJa0HyaSW QKznOcTLtiZh+aXM/pNmJLk4KG6VG2SYSbKbuS3fQcLMDbGISFbR8h2ZqbkcHixg0FQS GePg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JXa1dDfq; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j10-20020a170906474a00b0096f60dfbcabsi5177609ejs.1021.2023.06.12.08.44.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 08:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JXa1dDfq; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 547313942026 for ; Mon, 12 Jun 2023 15:37:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 547313942026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686584267; 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=JXa1dDfqYgpz3G8ieihDPo8l2rNsfihYO2MjUBUJuecHkFPJq7w3CGCGxqKRUHwmD vwmuWPYP5iHshijo49KUOEyPypWF4wJ3TWL+gP69gR5dalLVIYafmZ02cItZ39frYy L0sp7TWn+9ef7jE61NOWM1+dZO7yCsdmc8bKUNF8= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768512199007382432?= X-GMAIL-MSGID: =?utf-8?q?1768512199007382432?= 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