From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 940FD384AB58 for ; Fri, 3 May 2024 18:49:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 940FD384AB58 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 940FD384AB58 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714762151; cv=none; b=xp39b77Wu2U/+Eu1Uh+4cX6mVyUoUrE/qCBd/HqvdGzfUeec2Gz/2EYyeiecbD3Cr/i/p8Wj7fhPpRkQ361qNnTZfsbwNWWNBtUaduy6nvg+NK9+A/Qgq99KnkMPWfLpitp2GHHsSRvD3LNz/SAD9/uvRx98w1EN7tuotPsUZAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714762151; c=relaxed/simple; bh=RWf2eLRcEAji2jvKNOhLKDI7Ai6WrHp1hfQz0kc5z5w=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: Mime-Version:Subject:Date:Message-Id:To; b=OgbuyumJJoK3WNPgR+M0NWvDn/DVUYtPJMVB91FUlCnbY21n2hPF3/jJm/SKHd3e5BS8vVTspcyYaGUgBzHy1H9WeeB9XSYowLFyAUR2D0+QpGnVcqyR57g3vAnGqB1vvRRMTPw8zgdV19hr9l2D10ZqBUsl/4FN9N5lV4mBrHM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 70BE5206E4; Fri, 3 May 2024 18:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1714762148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D8v+Qm3WvjmkHSOctBzqUsvB32+PJY1I0u8Hha2WtpA=; b=WI7IcXZ4oA7YikyFZUHReigpzGNd7XHbF7OkF7Jrl1sUXo1FldqHNIBdMODn2zdwgu8uT7 XpDtBTpyfrCJWvzTKZB8N2304Y3+66zX0yta52EyfzI6tb9LwTaKSY50/aYnQhrOBjtXUH ErqG30wsjELVcfp1QOb4H5D50SzGdNU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1714762148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D8v+Qm3WvjmkHSOctBzqUsvB32+PJY1I0u8Hha2WtpA=; b=5pdM2xoiixwOw4TVUYhvuTTa04QJYcNeojgqguhKOd/wLTfdB8XL/PcDUf8w/UC7NVBeHe xckucOuX0JIjKoBw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1714762148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D8v+Qm3WvjmkHSOctBzqUsvB32+PJY1I0u8Hha2WtpA=; b=WI7IcXZ4oA7YikyFZUHReigpzGNd7XHbF7OkF7Jrl1sUXo1FldqHNIBdMODn2zdwgu8uT7 XpDtBTpyfrCJWvzTKZB8N2304Y3+66zX0yta52EyfzI6tb9LwTaKSY50/aYnQhrOBjtXUH ErqG30wsjELVcfp1QOb4H5D50SzGdNU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1714762148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D8v+Qm3WvjmkHSOctBzqUsvB32+PJY1I0u8Hha2WtpA=; b=5pdM2xoiixwOw4TVUYhvuTTa04QJYcNeojgqguhKOd/wLTfdB8XL/PcDUf8w/UC7NVBeHe xckucOuX0JIjKoBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 632D213991; Fri, 3 May 2024 18:49:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PoMzGKQxNWb/aAAAD6G6ig (envelope-from ); Fri, 03 May 2024 18:49:08 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] middle-end/114931 - type_hash_canon and structual equality types Date: Fri, 3 May 2024 20:48:57 +0200 Message-Id: <05B84303-9D17-4DAE-A9D9-A77DA3EA7878@suse.de> References: Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org In-Reply-To: To: Martin Uecker X-Mailer: iPhone Mail (21E236) X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; APPLE_IOS_MAILER_COMMON(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[tugraz.at:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Spam-Score: -4.30 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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: > Am 03.05.2024 um 20:37 schrieb Martin Uecker : >=20 > =EF=BB=BFAm Freitag, dem 03.05.2024 um 20:18 +0200 schrieb Jakub Jelinek: >>> On Fri, May 03, 2024 at 08:04:18PM +0200, Martin Uecker wrote: >>> A change that is not optimal but would avoid a lot of trouble is to >>> only use the tag of the struct for computing a TYPE_CANONICAL, which >>> could then be set already for incomplete types and never needs to >>> change again. We would not differentiate between different struct >>> types with the same tag for aliasing analysis, but in most cases >>> I would expect different structs to have a different tag. >>=20 >> Having incompatible types have the same TYPE_CANONICAL would lead to wron= g >> code IMHO, while for aliasing purposes that might be conservative (though= >> not sure, the alias set computation is based on what types the element ha= ve >> etc., so if the alias set is computed for say struct S { int s; }; and >> then the same alias set used for struct S { long long a; double b; union {= >> short c; float d; } c; };, I think nothing good will come out of that), >=20 > The C type systems requires us to form equivalence classes though. > For example >=20 > int (*r)[1]; > int (*q)[]; > int (*p)[3]; >=20 > need to be in the same equivalence class even though r and p are > not compatible, while at the same time r and q and q and p > are compatible. TYPE_CANONICAL as used by the middle-end cannot express this but useless_typ= e_conversion_p is directed and has similar behavior. Note the dual-use for T= BAA and compatibility was convenient but maybe we have to separate both sinc= e making the equivalence class for TBAA larger is more conservative while fo= r compatibility it=E2=80=99s the other way around=E2=80=A6 Richard=20 >=20 >> but middle-end also uses TYPE_CANONICAL to see if types are the same, >> say e.g. useless_type_conversion_p says that conversions from one >> RECORD_TYPE to a different RECORD_TYPE are useless if they have the >> same TYPE_CANONICAL. >> /* For aggregates we rely on TYPE_CANONICAL exclusively and require >> explicit conversions for types involving to be structurally >> compared types. */ >> else if (AGGREGATE_TYPE_P (inner_type) >> && TREE_CODE (inner_type) =3D=3D TREE_CODE (outer_type)) >> return TYPE_CANONICAL (inner_type) >> && TYPE_CANONICAL (inner_type) =3D=3D TYPE_CANONICAL (outer_typ= e); >> So, if you have struct S { int s; } and struct S { short a, b; }; and >> VIEW_CONVERT_EXPR between them, that VIEW_CONVERT_EXPR will be removed >> as useless, etc. >=20 > Maybe we could limit for purposes of computing TYPE_CANONICAL of derived > types, e.g. TYPE_CANONICAL of structs stays the same with the transition > from TYPE_STRUCT_EQUALITY to TYPE_CANONICAL but all the derived types > remain stable. >=20 > Martin >=20 >>=20 >> BTW, the idea of lazily updating TYPE_CANONICAL is basically what I've >> described as the option to update all the derived types where it would >> pretty much do that for all TYPE_STRUCTURAL_EQUALITY_P types in the >> hash table (see if they are derived from the type in question and recompu= te >> the TYPE_CANONICAL after recomputing all the TYPE_CANONICAL of its base >> types), except perhaps even more costly (if the trigger would be some >> build_array_type/build_function_type/... function is called and found >> a cached TYPE_STRUCTURAL_EQUALITY_P type). Note also that >> TYPE_STRUCTURAL_EQUALITY_P isn't the case just for the C23 types which >> are marked that way when incomplete and later completed, but by various >> other cases for types which will be permanently like that, so doing >> expensive checks each time some build*_type* is called that refers >> to those would be expensive. >>=20 >> Jakub >>=20 >=20