From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 164523858C56; Tue, 27 Sep 2022 07:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 164523858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664263550; bh=kQZEevJJ4BgemQbNv1cJSrMrTgnTRKBszLK74enapDU=; h=From:To:Subject:Date:From; b=jRKWVAKAIrt2n7MkLozCKXIAehZKbMRIrj/UJv3OHeuLesiIzATF5TSSwNFXFHVac viiJxIBVsNKa13W83kufzlRuv85t/P5aUVZPHc9r1kSigdqfqKCiyzG6VRPOZi8LD/ LTYa5WGK+6KtnBKgHfOEsBP8yWgyzuR+gKQvpLFU= From: "absoler at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/107047] New: load introduced of struct fields after assigning it to a local variable Date: Tue, 27 Sep 2022 07:25:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: absoler at smail dot nju.edu.cn 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=3D107047 Bug ID: 107047 Summary: load introduced of struct fields after assigning it to a local variable Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: absoler at smail dot nju.edu.cn Target Milestone: --- for gcc-12.1.0, with this code: struct S6 { short f0; char f1; int f2; }; struct S6 g_36 =3D {2UL,4L,0x32B3D10AL}; int g_48 =3D (-1L); void func_30() { struct S6 f[4][7]; f[1][6] =3D g_36; if (f[1][6].f0 || f[1][6].f1) g_48 =3D f[1][6].f1; } when compiled with -O1 option, generated binaries will be like: 0000000000401186 : 401186: 48 83 ec 70 sub $0x70,%rsp 40118a: f7 05 d4 2e 00 00 ff testl $0xffffff,0x2ed4(%rip) = # 404068 401191: ff ff 00=20 401194: 74 0d je 4011a3 401196: 0f be 05 cd 2e 00 00 movsbl 0x2ecd(%rip),%eax # 40406a 40119d: 89 05 bd 2e 00 00 mov %eax,0x2ebd(%rip) # 404060 4011a3: 48 83 c4 70 add $0x70,%rsp 4011a7: c3 retq=20=20=20 we can see the use of f[1][6] is replaced by g_36 in the if-condition and "= g_48 =3D f[1][6].f1", and the f is not optimized away.=