From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CDDF83858408; Thu, 28 Dec 2023 14:55:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDDF83858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703775357; bh=gfdne9PEnKT8jTaQnC950Zclq8ZJD6niRZu1Ca5votI=; h=From:To:Subject:Date:From; b=SQoSwZlpYnsEFk+Zat/dK8Oj5u38n2BX3npKdNI/Z4S/sIVkoEnci9Q+OvKnRCkpB rMksWud9N8DmgCDiorEBuF5DTnVaxC4Ry1pi5bJyRW8ysiNCSqxgu6iatCz20FCQE3 k1+ufIy46CwDXwCTkKOTdk9a0tVQPInyjxEyVEGQ= From: "powerboat9.gamer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113164] New: [missed optimization] struct fields should not alias Date: Thu, 28 Dec 2023 14:55:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: powerboat9.gamer at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113164 Bug ID: 113164 Summary: [missed optimization] struct fields should not alias Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: powerboat9.gamer at gmail dot com Target Milestone: --- I have the following code > struct sss { > int a; > int b; > }; >=20 > int foo(struct sss *a, struct sss *b) { > return &a->a =3D=3D &b->b; > } When I compile it with > gcc -c -O3 -Wall -Wextra test.c I get > 0000000000000000 : > 0: 48 83 c6 04 add $0x4,%rsi > 4: 31 c0 xor %eax,%eax > 6: 48 39 fe cmp %rdi,%rsi > 9: 0f 94 c0 sete %al > c: c3 ret , but GCC should be able to infer that the two pointers being compared can = not alias.=