From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 B310E3858D33 for ; Wed, 1 Mar 2023 13:03:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B310E3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677675823; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=CVc14GMufLjFzTWkTpF1ahqmVznsPzfje7LpZxI1LXk=; b=Lb88t24TxhQs7m5u3Qm+YfeZQVRmlcehb9PDzXdKqvgNooV5MeP+o1QLPvmnH0AXpC/JqB LYbfql8i3i2OxAgsFUmW/CFKRYeZYItxayaNoBKXCqp0hxiwx3vWyGdxkAvL1jRMQU3F/U X7R2i2ZqqEtCJypCCNH8bLEYlfXpy+M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-490-OsatFXdvPmmxXuuyYSxpyQ-1; Wed, 01 Mar 2023 08:03:42 -0500 X-MC-Unique: OsatFXdvPmmxXuuyYSxpyQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0633787A9ED; Wed, 1 Mar 2023 13:03:42 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAA6C2026D4B; Wed, 1 Mar 2023 13:03:41 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 321D3Ywp1630816 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 1 Mar 2023 14:03:34 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 321D3XjC1630815; Wed, 1 Mar 2023 14:03:33 +0100 Date: Wed, 1 Mar 2023 14:03:33 +0100 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches Subject: Re: [Patch] OpenMP: Ignore side-effects when finding struct comps [PR108545] Message-ID: Reply-To: Jakub Jelinek References: <437597e7-a9ee-f6f1-3490-dd4e75ee13de@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <437597e7-a9ee-f6f1-3490-dd4e75ee13de@codesourcery.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,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 List-Id: On Tue, Feb 28, 2023 at 02:06:43PM +0100, Tobias Burnus wrote: > (This is marked as P1 regression) > > Since the structure handling updates, a hash is now used to find expressions which are identical; > unfortunately, this mishandles 'volatile' vars as expressions involving them are not regarded > as identical. This leads to spurious *multiple* 'map(struct:x' that later causes an ICE. > (For details, see also the PR, https://gcc.gnu.org/PR108545 ) Do we use that hashing even say for ARRAY_REFs with array indexes? Using OEP_MATCH_SIDE_EFFECTS will mean that volatile int idx; a.b[idx] and a.b[idx] will compare equal. On the other side, if idx yielded different values on the same construct between the two, I think it would be invalid OpenMP (trying to map the two different array elements from the same array section), so perhaps we are ok. > --- a/gcc/gimplify.cc > +++ b/gcc/gimplify.cc > @@ -8958,6 +8958,28 @@ enum omp_tsort_mark { > PERMANENT > }; > > +/* Hash for trees based on operand_equal_p. > + Like tree_operand_hash but accepts side effects. */ > +struct tree_operand_sideeff_hash : ggc_ptr_hash Not sure about the name, it isn't about that it accepts side effects, but that it ignores them in the equality comparisons. OEP_MATCH_SIDE_EFFECTS is probably misnamed too. So perhaps struct tree_operand_hash_no_se (+ adjust the comment)? Also, can't you derive it from tree_operand_hash? Than you wouldn't need to provide your own hash, you could inherit tree_operand_hash::hash and just override equal. > + return iterative_hash_expr (t, 0); > +} > + > +inline bool > +tree_operand_sideeff_hash::equal (const value_type &t1, > + const compare_type &t2) > +{ > + return operand_equal_p (t1, t2, OEP_MATCH_SIDE_EFFECTS); > +} > + > /* A group of OMP_CLAUSE_MAP nodes that correspond to a single "map" > clause. */ > > @@ -9432,7 +9454,6 @@ omp_index_mapping_groups_1 (hash_map node = OMP_CLAUSE_CHAIN (node), j++) > { > tree decl = OMP_CLAUSE_DECL (node); > - > /* Sometimes we see zero-offset MEM_REF instead of INDIRECT_REF, > meaning node-hash lookups don't work. This is a workaround for > that, but ideally we should just create the INDIRECT_REF at Why? No change around this and I think it is nicer to have empty line separating start of block declarations from the rest. > @@ -9590,7 +9611,7 @@ omp_mapped_by_containing_struct (hash_map static bool > omp_tsort_mapping_groups_1 (omp_mapping_group ***outlist, > vec *groups, > - hash_map > + hash_map This is too long, even with the shorter name. > *grpmap, > omp_mapping_group *grp) > { > @@ -9670,7 +9691,7 @@ omp_tsort_mapping_groups_1 (omp_mapping_group ***outlist, > > static omp_mapping_group * > omp_tsort_mapping_groups (vec *groups, > - hash_map > + hash_map This could fit after the change though. Otherwise LGTM. Jakub