From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 01CDF381E717; Wed, 26 Oct 2022 08:31:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01CDF381E717 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666773119; bh=XuHmDZgd1u5MMgWp5gPohA/qzxOgcPWmBhRKKGfLPOk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aNMOv/wLeYO72r3uQTpcULs0Nugrm+u7HmHf3Eln03yMTa1pJPaztHS7gX2FQ5b/T JVQ7O+CnlFsMtUPZWAktfT6Vc3ohGZXTBqtvQ5bsLg3W77IJVQ9woqiHpsDbSAEZmo cTJIDnm+tFIxZfpHG5vV438ntp1Fd4T44v3EEWxI= From: "absoler at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107047] load introduced of struct/union fields after assigning it to a local variable Date: Wed, 26 Oct 2022 08:31:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: absoler at smail dot nju.edu.cn X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D107047 --- Comment #3 from absoler at smail dot nju.edu.cn --- and for union there's similar behavior: union U2 { long long f0; unsigned short f2; int f4; }; void func_17(union U2 p_20); void func_1() { func_17(g_39[0]); } void func_17(union U2 e) { int *f =3D &g_30; if (e.f0 || e.f2) *f =3D e.f2; } are compiled with gcc-12.1 -O1 to: 0000000000402020 : func_17(): /home/csmith-2.3.0/test/output2.c:87 402020: 48 83 3d 68 3e 00 00 cmpq $0x0,0x3e68(%rip) # 405e90 402027: 00=20 402028: 74 0d je 402037 /home/csmith-2.3.0/test/output2.c:88 40202a: 0f b7 05 5f 3e 00 00 movzwl 0x3e5f(%rip),%eax # 405e90 402031: 89 05 71 3e 00 00 mov %eax,0x3e71(%rip) # 405ea8 uses of e.f0 and e.f2 are replaced by g_39[0]=