From patchwork Mon Jan 23 17:44:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 47269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1733868wrn; Mon, 23 Jan 2023 09:45:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXter9Zsmlo8KQToD9ohp3o8kpdVGWxw+e35gU5Wl+jIzp3nFP+/Qvjqvb7ZyWqVfsNVY9a4 X-Received: by 2002:a17:907:2106:b0:7c1:32:3574 with SMTP id qn6-20020a170907210600b007c100323574mr29491488ejb.12.1674495959262; Mon, 23 Jan 2023 09:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674495959; cv=none; d=google.com; s=arc-20160816; b=meShNV9o4oXrbeClg+JJlZjkl4xsDRZ1QSTpy7rPFp7Zqbu2HVF9xSW1KzN4jc2phn giNVf/Wg0bK05FClB5oBruox5JI1ZXJTH14567Et9tUyz+SmBqI/Jn/pVZeG0wZnrjoS +fbQUY1pB3jNQ4iwyxjCAOWfwOAsIXEn+/CwMHWPMsgf0SWkSCD72rAJBC5orQTHlwS0 I7lxajwl901SnAO0AcoE7bPvgqXDlltgfRzPgq2Qg2tZbutiWnTdUrBooFFguhEmHXa+ JyCBtCa9BqsVXGODbese0sIDCe6s3Af8njbKIHmY9FiI4K+qhWfgXr9lcbswhYVEd16v M8RQ== 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=ZhfFqBcDFsWValA4v7NuWxRJMYHy/UciHiA8NSFLKFU=; b=yrrMS17WKcKHFOQBH5J2tSZpe/uYsPRbVQHPhgVMo660lPo8HJi/SdIapjvlYQUJSL ZYF4I4Bqdr+FWnhiyv8kwXRM/hCmyVc4TB9W3kjrws3KZVtAZ077Yq6AOFfb6XW+BMQd r6SG0S1H3TfRyVq7wEiKuA+JBzV/xkz4ZJ5QOvUYn8d7rZ+RnN8cAxHHFmh7hS7fVhK9 Vkfw1MVuoF7DOURpn2I+/OJD/cLdMsYNnxiScgdqAJ4hpyIW584CAjdDChkt+ZeUr/Vd kee4GMDY/48F6paG/gSaHeF00PzxmEQPuH9aa8SHn8sdxAiWgbvPA/diBDCJw46kPg79 OYpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gxAc7mlv; 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 gb7-20020a170907960700b008705caf2257si28747949ejc.513.2023.01.23.09.45.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 09:45:59 -0800 (PST) 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=gxAc7mlv; 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 5DCD03857007 for ; Mon, 23 Jan 2023 17:45:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DCD03857007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674495935; bh=ZhfFqBcDFsWValA4v7NuWxRJMYHy/UciHiA8NSFLKFU=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=gxAc7mlvOsCaBg5fXuwFK+5SrgKm7BRtkxVbXBw4+oMFf4+ES1gPmBbOkUnOir3vg MdhFFerdLH9TVa+2orhbFhNX1oLST12KIi5dNK5eKsozXyHdf11iVW/sKPJrqmt2yY cOarmfbuXklgmSnbJqPE6uen+p1DhwcoB12StG6w= 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 7FB7C3858D32 for ; Mon, 23 Jan 2023 17:44:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FB7C3858D32 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_128_GCM_SHA256) id us-mta-94-x1wYhwgnOGmLUle3hktDhw-1; Mon, 23 Jan 2023 12:44:47 -0500 X-MC-Unique: x1wYhwgnOGmLUle3hktDhw-1 Received: by mail-qk1-f199.google.com with SMTP id az16-20020a05620a171000b00709129a745eso6973406qkb.8 for ; Mon, 23 Jan 2023 09:44:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=hTzNRz1vzPjueGOw88N4cv6u0DmFwjmztIEbyVusoj4=; b=PB7f0p78u6PUNL0YYGn6ASkZhP+tX4KN5PdrXjaonpEH3leiIagpMI050mOTKfTEiu tj6nYlZij56fURshzAkAoQZg6GSQd5lOhsRdhm3VkWGtLrXXT5I0icAkUFZCfjyxzCLZ lrMQrYm7T3UKOlBRLKBDObPl4czle94MgwzZbY70TTpYfdwEerApL+PafMjZBgxyziBZ 1Ri7r19uT3zplNS5Yqb4UISrogvfNowyAs+W1DVV/XHUi7aNLSa/DU9eB+FfxZTgBjRS lnmw3iUh6orGNbeev8wbmVWB4rxsqG9i4UGdBjt5CmuWMdmnGKZoai3+S7HNYNKxPI8p ARAg== X-Gm-Message-State: AFqh2krDKGNyDN/AqAufam48rTB4QzCjjPdd4EikbWLZiQR4XWLa5UTN 2S51KOFslUim2sOlKKPAZumWDATXGejF/MXqqE/smHZn/VkRdVjb7k8R6voxF6zG1SePUm9msmv FDVrxsqhkpoSj3xWcUn6E7vX6mtvuJbCLHxUHarbaegUsnuPOZXjnQYU1Bu0zKEPHjABUIA== X-Received: by 2002:ac8:7a8b:0:b0:3b6:2b50:15eb with SMTP id x11-20020ac87a8b000000b003b62b5015ebmr46282622qtr.57.1674495884982; Mon, 23 Jan 2023 09:44:44 -0800 (PST) X-Received: by 2002:ac8:7a8b:0:b0:3b6:2b50:15eb with SMTP id x11-20020ac87a8b000000b003b62b5015ebmr46282596qtr.57.1674495884648; Mon, 23 Jan 2023 09:44:44 -0800 (PST) Received: from ?IPV6:2607:fea8:a263:f600::27bf? ([2607:fea8:a263:f600::27bf]) by smtp.gmail.com with ESMTPSA id az20-20020a05620a171400b007091068cff1sm7411980qkb.28.2023.01.23.09.44.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Jan 2023 09:44:44 -0800 (PST) Message-ID: <2b7a5b75-aa71-b399-ff07-1f62dfac6cdc@redhat.com> Date: Mon, 23 Jan 2023 12:44:42 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 To: gcc-patches Cc: "hernandez, aldy" , Jakub Jelinek , Richard Biener Subject: [PATCH 1/2] Use value_relation class instead of direct calls to intersect/union. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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?1755836275216146291?= X-GMAIL-MSGID: =?utf-8?q?1755836275216146291?= In order to fix 108447, this patch changes the calls to relation_union and relation_intersection to instead utilize the value_relation class, and make the calls through that instead. value_relation manages the operands of a relation, and thus understands whether this is a floating point relation and can make any adjustments required to get the proper results.  THis patch doesn't do anything additional, just that isolation so we can track if it introduces anything speerate from the next change which adds another relation. Bootstraps on x86_64-pc-linux-gnu with no regressions.  OK? Andrew From 566421cb3b91272b56b01ff9ad5a243cada38ff7 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 20 Jan 2023 17:13:08 -0500 Subject: [PATCH 1/2] Use value_relation class instead of direct calls to intersect/union. There are subtle differences how union and intersection behave depending on whetehr the operands are float or integral. Directly calling relation_union or relation_intersect does not expose the origin of the operands, but value_relation does have them. THis patch makes sure calls are through the value relation class. * gimple-range-fold.cc (fold_using_range::relation_fold_and_or): Call union and intersect through a value_relation class. * value-relation.cc (value_relation::intersect): Make parameter const. (value_relation::union_): Likewise. (dom_oracle::set_one_relation): Use value-relation class for union and intersect. (path_oracle::register_relation): Likewise. * value-relation.h (value_relation::intersect): Add const to param. (value_relation::union_): Likewise. --- gcc/gimple-range-fold.cc | 17 +++++------------ gcc/value-relation.cc | 17 ++++++++--------- gcc/value-relation.h | 4 ++-- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 91eb6298254..500c482eeec 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1039,14 +1039,6 @@ fold_using_range::relation_fold_and_or (irange& lhs_range, gimple *s, if (!ssa1_dep1 || !ssa1_dep2 || !ssa2_dep1 || !ssa2_dep2) return; - // Make sure they are the same dependencies, and detect the order of the - // relationship. - bool reverse_op2 = true; - if (ssa1_dep1 == ssa2_dep1 && ssa1_dep2 == ssa2_dep2) - reverse_op2 = false; - else if (ssa1_dep1 != ssa2_dep2 || ssa1_dep2 != ssa2_dep1) - return; - int_range<2> bool_one (boolean_true_node, boolean_true_node); relation_kind relation1 = handler1.op1_op2_relation (bool_one); @@ -1054,15 +1046,16 @@ fold_using_range::relation_fold_and_or (irange& lhs_range, gimple *s, if (relation1 == VREL_VARYING || relation2 == VREL_VARYING) return; - if (reverse_op2) - relation2 = relation_negate (relation2); + value_relation vr1 (relation1, ssa1_dep1, ssa1_dep2); + value_relation vr2 (relation2, ssa2_dep1, ssa2_dep2); + // Only one of the follwoing intersection/unions is performed. // x && y is false if the relation intersection of the true cases is NULL. - if (is_and && relation_intersect (relation1, relation2) == VREL_UNDEFINED) + if (is_and && vr1.intersect (vr2) && vr1.kind () == VREL_UNDEFINED) lhs_range = int_range<2> (boolean_false_node, boolean_false_node); // x || y is true if the union of the true cases is NO-RELATION.. // ie, one or the other being true covers the full range of possibilties. - else if (!is_and && relation_union (relation1, relation2) == VREL_VARYING) + else if (!is_and && vr1.union_ (vr2) && vr1.kind () == VREL_VARYING) lhs_range = bool_one; else return; diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index 6f8a1b7e7d3..432828e2b13 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -782,7 +782,7 @@ value_relation::negate () // Perform an intersection between 2 relations. *this &&= p. bool -value_relation::intersect (value_relation &p) +value_relation::intersect (const value_relation &p) { // Save previous value relation_kind old = related; @@ -800,7 +800,7 @@ value_relation::intersect (value_relation &p) // Perform a union between 2 relations. *this ||= p. bool -value_relation::union_ (value_relation &p) +value_relation::union_ (const value_relation &p) { // Save previous value relation_kind old = related; @@ -1118,8 +1118,7 @@ dom_oracle::set_one_relation (basic_block bb, relation_kind k, tree op1, // will be the aggregate of all the previous ones. curr = find_relation_dom (bb, v1, v2); if (curr != VREL_VARYING) - k = relation_intersect (curr, k); - + vr.intersect (value_relation (curr, op1, op2)); bitmap_set_bit (bm, v1); bitmap_set_bit (bm, v2); bitmap_set_bit (m_relation_set, v1); @@ -1127,7 +1126,7 @@ dom_oracle::set_one_relation (basic_block bb, relation_kind k, tree op1, ptr = (relation_chain *) obstack_alloc (&m_chain_obstack, sizeof (relation_chain)); - ptr->set_relation (k, op1, op2); + ptr->set_relation (vr.kind (), op1, op2); ptr->m_next = m_relations[bbi].m_head; m_relations[bbi].m_head = ptr; } @@ -1528,9 +1527,9 @@ path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1, if (ssa1 == ssa2) return; + value_relation vr (k, ssa1, ssa2); if (dump_file && (dump_flags & TDF_DETAILS)) { - value_relation vr (k, ssa1, ssa2); fprintf (dump_file, " Registering value_relation (path_oracle) "); vr.dump (dump_file); fprintf (dump_file, " (root: bb%d)\n", bb->index); @@ -1538,9 +1537,9 @@ path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1, relation_kind curr = query_relation (bb, ssa1, ssa2); if (curr != VREL_VARYING) - k = relation_intersect (curr, k); + vr.intersect (value_relation (curr, ssa1, ssa2)); - if (k == VREL_EQ) + if (vr.kind () == VREL_EQ) { register_equiv (bb, ssa1, ssa2); return; @@ -1550,7 +1549,7 @@ path_oracle::register_relation (basic_block bb, relation_kind k, tree ssa1, bitmap_set_bit (m_relations.m_names, SSA_NAME_VERSION (ssa2)); relation_chain *ptr = (relation_chain *) obstack_alloc (&m_chain_obstack, sizeof (relation_chain)); - ptr->set_relation (k, ssa1, ssa2); + ptr->set_relation (vr.kind (), ssa1, ssa2); ptr->m_next = m_relations.m_head; m_relations.m_head = ptr; } diff --git a/gcc/value-relation.h b/gcc/value-relation.h index 664fd71c925..354a0fd4130 100644 --- a/gcc/value-relation.h +++ b/gcc/value-relation.h @@ -426,8 +426,8 @@ public: inline tree op1 () const { return name1; } inline tree op2 () const { return name2; } - bool union_ (value_relation &p); - bool intersect (value_relation &p); + bool union_ (const value_relation &p); + bool intersect (const value_relation &p); void negate (); bool apply_transitive (const value_relation &rel); -- 2.39.0