From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B839C3858D20; Wed, 10 Apr 2024 07:41:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B839C3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712734883; bh=aCPDoWffBlDtx8xzXNNZZrrSgcojk+8ZSbOjsKC/PUg=; h=From:To:Subject:Date:From; b=n9CeHIgu1rN9WNWU+XVob+LlZZtfrjTfkfWG1ZmPz8kPnZ99yVN6NAHYyk6l6xAtm mGJDGTa39V5CAGwre3KJbsfmS+FWhF0J+tVHVM9FX2e7Ik2OvtWahVDVTjTK91Lfg6 2GAkIfB1IyyYwoqVFxppy0tBcJSz5jOPtUAbdEi4= From: "dizhao at os dot amperecomputing.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114674] New: [aarch64] ldp_fusion fails to merge 2 strs due to imprecise alignment info Date: Wed, 10 Apr 2024 07:41:23 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dizhao at os dot amperecomputing.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=3D114674 Bug ID: 114674 Summary: [aarch64] ldp_fusion fails to merge 2 strs due to imprecise alignment info Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: dizhao at os dot amperecomputing.com Target Milestone: --- For the case below: typedef struct { unsigned int f1; unsigned int f2; } test_struct; static test_struct ts =3D { 123, 456 }; void foo(void) { ts.f2 =3D 36969 * (ts.f2 & 65535) + (ts.f1 >> 16); ts.f1 =3D 18000 * (ts.f2 & 65535) + (ts.f2 >> 16); } When compiled with "-O3 --param=3Daarch64-stp-policy=3Daligned", gcc failed= to fuse the memory access instructions into stp/ldp, the dump file 312r.ldp_fusion1 says "ldp/stp policy says no". However, the accessing to ts.f1 is aligned t= o 64 bit: (insn 26 23 33 2 (set (mem/c:SI (lo_sum:DI (reg/f:DI 113) (symbol_ref:DI ("*.LANCHOR0") [flags 0x182])) [1 ts.f1+0 S4 A64]) ... So it looks like the 2 str instructions should be fused with aarch64-stp-policy=3Daligned. After debugged this a bit, it seems the problem is ldp_bb_info::fuse_pair changed the alignment info when calling adjust_address_nv, to rewrite the b= ase of ts.f1.=