From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 95B593849AEE; Mon, 22 Apr 2024 08:27:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95B593849AEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713774441; bh=Eckohu5RM0WWbZpXPuXJuQvuVKrjGiKZsRkSak90sbM=; h=From:To:Subject:Date:From; b=xdVyr+nipMRp8hD7aFI/SNKeYBZPXnGDI4t9hnMMt/dQyEQE6h96iLkHdcMEcm9X/ GRUuRouGPOmTQ0Ssdbc70D5mKia8kRScU7LpPe+f2apn0tupJX8ghGGxeJW9pazO7K mqBpBZExTIoTlu8ilbQ+MvsvLRs0qGwkfL0WzmgM= From: "absoler at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114800] New: redundant set-zero when initiate a struct Date: Mon, 22 Apr 2024 08:27:18 +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: 13.2.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=3D114800 Bug ID: 114800 Summary: redundant set-zero when initiate a struct Product: gcc Version: 13.2.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: --- I found a weird case that ``` struct thresh_restart { int *f0; int f1; int f2; int f3; }; int arr[10]; void __attribute__((noinline)) foo(struct thresh_restart *p) { arr[0] =3D p->f3; arr[1] =3D p->f1; } void func(int *b) { struct thresh_restart tr =3D { .f0 =3D b, .f1 =3D 1, .f2 =3D 2, .f3 =3D 3, }; foo(&tr); } ``` such code is compiled as: (gcc-13.2.0 -O2, regression [11/12/13/trunk]) https://godbolt.org/z/rb4o6xc7E ``` func(int*): sub $0x28,%rsp pxor %xmm0,%xmm0 mov %rsp,%rdi movaps %xmm0,(%rsp) movq $0x0,0x10(%rsp) # redundancy movl $0x1,0x8(%rsp) movl $0x3,0x10(%rsp) call 401120 add $0x28,%rsp ret ```=