From patchwork Thu Aug 3 18:25:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1816628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=un32OjxP; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RGy3G1dXQz1yZl for ; Fri, 4 Aug 2023 04:26:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27CA93857B8E for ; Thu, 3 Aug 2023 18:26:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27CA93857B8E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691087176; bh=+P3+kfJS/abCp0Dom4orvKBG7WxhlIzISnB7d6pLduw=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=un32OjxPfncj64PLogsbq4ZurTLbBazvJFri+IlIqujrXVojGyi6ai2czmVRtxDAd tlKEDdw+JdBtBx+k4S+ondzhLkVz1/WZ/kchlCBFjfLsPcojX9WNIEJ0s4k0XBTpj0 Ui+TmkFChx4nUVulpAew5y1DnJ6jvFE9yq6RAisk= 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 1A4F9385842C for ; Thu, 3 Aug 2023 18:25:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A4F9385842C Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-8DLqbQFXMJqQ9XXJ-Svr8Q-1; Thu, 03 Aug 2023 14:25:55 -0400 X-MC-Unique: 8DLqbQFXMJqQ9XXJ-Svr8Q-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-63cf5bb17c6so13283536d6.0 for ; Thu, 03 Aug 2023 11:25:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691087154; x=1691691954; 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=fVTmBecWEN6UwwrraC83/qAXXImtrOCN7UG0JZ54xD8=; b=bevUYOUYC2ltW/u5MU4XtlyMu8qjkQbNhP2Szowc0kUO8MZdMtPBzt45Gs6jJuJ6H8 HbGLh/Y6JLpaZJAkeoXXIqwyy5+QQrYVDuLw+0j1QFFLr17tEzhswpMpwEZkwLEPLo1O vNa7N4+H2YtZjW0KgOqcGXqRScOQPMf5GP7QDgOsbb9ZlvQTiOpUBEHW80lynUqB/amK akWjyVWMmIqNlsYp8QZW5J1AnS4R2/+exIEoP/J1BEGuHyFLdeVK5Lq+EcjhWblZ48pU wT8kRgyhKTtmx1FUW4WBr1oeF6pwANb/3uOeC6Dn0386AM+kuY4MxR1o9A78fkHvSrz7 CPlg== X-Gm-Message-State: ABy/qLafH4ygUTeSiCXw0w/uvfYsFOe0PXnEQVuQV5PzduATECDlZiGR MAu/h04tn6Ua7fNTzqyF5W13uhEYi45Z+L8zect4Tnu9vFAmALTwPIFfEMrwh1nagiVK7SymE0x NDAZT4Ifvpwmu6MVRVeH2uBRRQ1kAMIUXiWvjrBh+oNIyNmmWjVBkbjij3+5T2CZ66ulBk+V+tz LRmA== X-Received: by 2002:a0c:e98e:0:b0:63d:4ec:af65 with SMTP id z14-20020a0ce98e000000b0063d04ecaf65mr17743399qvn.19.1691087154385; Thu, 03 Aug 2023 11:25:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlGUawncj27eZiMeJqMc+9VkWWVMa0LbuYQ1JufBFqQr6MOBNbK8Dxl1ZVFcO+LSgcrX/3raEA== X-Received: by 2002:a0c:e98e:0:b0:63d:4ec:af65 with SMTP id z14-20020a0ce98e000000b0063d04ecaf65mr17743387qvn.19.1691087154061; Thu, 03 Aug 2023 11:25:54 -0700 (PDT) Received: from [192.168.0.174] ([104.219.124.192]) by smtp.gmail.com with ESMTPSA id i11-20020a0cf38b000000b0063d67548802sm80070qvk.137.2023.08.03.11.25.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Aug 2023 11:25:53 -0700 (PDT) Message-ID: <496bc1ca-ab30-6e79-7b00-5dd1fc54b261@redhat.com> Date: Thu, 3 Aug 2023 14:25:53 -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] Provide a routine for NAME == NAME relation. 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" We've been assuming x == x is always VREL_EQ in GORI, but this is not always going to be true with floating point.  Provide an API to return the relation. Bootstraps on  x86_64-pc-linux-gnu with no regressions.   Pushed. Andrew From 430ff4f3e670e02185991190a5e2d90e61b39e07 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 2 Aug 2023 10:58:37 -0400 Subject: [PATCH 2/3] Provide a routine for NAME == NAME relation. We've been assuming x == x s VREL_EQ in GORI, but this is not always going to be true with floating point. Provide an API to return the relation. * gimple-range-gori.cc (gori_compute::compute_operand1_range): Use identity relation. (gori_compute::compute_operand2_range): Ditto. * value-relation.cc (get_identity_relation): New. * value-relation.h (get_identity_relation): New prototype. --- gcc/gimple-range-gori.cc | 10 ++++++++-- gcc/value-relation.cc | 14 ++++++++++++++ gcc/value-relation.h | 3 +++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 6dc15a0ce3f..c37e54bcf84 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -1142,7 +1142,10 @@ gori_compute::compute_operand1_range (vrange &r, // If op1 == op2, create a new trio for just this call. if (op1 == op2 && gimple_range_ssa_p (op1)) - trio = relation_trio (trio.lhs_op1 (), trio.lhs_op2 (), VREL_EQ); + { + relation_kind k = get_identity_relation (op1, op1_range); + trio = relation_trio (trio.lhs_op1 (), trio.lhs_op2 (), k); + } if (!handler.calc_op1 (r, lhs, op2_range, trio)) return false; } @@ -1218,7 +1221,10 @@ gori_compute::compute_operand2_range (vrange &r, // If op1 == op2, create a new trio for this stmt. if (op1 == op2 && gimple_range_ssa_p (op1)) - trio = relation_trio (trio.lhs_op1 (), trio.lhs_op2 (), VREL_EQ); + { + relation_kind k = get_identity_relation (op1, op1_range); + trio = relation_trio (trio.lhs_op1 (), trio.lhs_op2 (), k); + } // Intersect with range for op2 based on lhs and op1. if (!handler.calc_op2 (r, lhs, op1_range, trio)) return false; diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index 7df2cd6e961..f2c668a0193 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -183,6 +183,20 @@ relation_transitive (relation_kind r1, relation_kind r2) return relation_kind (rr_transitive_table[r1][r2]); } +// When operands of a statement are identical ssa_names, return the +// approriate relation between operands for NAME == NAME, given RANGE. +// +relation_kind +get_identity_relation (tree name, vrange &range ATTRIBUTE_UNUSED) +{ + // Return VREL_UNEQ when it is supported for floats as appropriate. + if (frange::supports_p (TREE_TYPE (name))) + return VREL_EQ; + + // Otherwise return VREL_EQ. + return VREL_EQ; +} + // This vector maps a relation to the equivalent tree code. static const tree_code relation_to_code [VREL_LAST] = { diff --git a/gcc/value-relation.h b/gcc/value-relation.h index be6e277421b..f00f84f93b6 100644 --- a/gcc/value-relation.h +++ b/gcc/value-relation.h @@ -91,6 +91,9 @@ inline bool relation_equiv_p (relation_kind r) void print_relation (FILE *f, relation_kind rel); +// Return relation for NAME == NAME with RANGE. +relation_kind get_identity_relation (tree name, vrange &range); + class relation_oracle { public: -- 2.40.1