From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B12EC3945C1A; Tue, 12 May 2020 09:18:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B12EC3945C1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589275129; bh=wy3894YwMy3KzB49ZEryUkJbnstEi3o+qdcXhG+KFrk=; h=From:To:Subject:Date:From; b=v4X3i7FwSNDcMa0pLCAUCjXV21iq6QQjOa4fZmIQZkK+buKfYeSrodF/QbaKsWhxE AtM8oG3AW9ZYgIyYlb3n6mDeL+H9BK0btQP02+MiMrNEFwiQtN++hMS0MqW8t14ZY6 izcoSg4net3v6pJlrDI4Y1SnGqFJ1lOo7ntkdzl0= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/95078] New: Missing fwprop for SIB address Date: Tue, 12 May 2020 09:18:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht 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 cc target_milestone cf_gcctarget 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 09:18:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95078 Bug ID: 95078 Summary: Missing fwprop for SIB address Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com CC: hjl.tools at gmail dot com Target Milestone: --- Target: i386, x86-64 cat test.c int foo (int* p1, int* p2, int scale) { int ret =3D *(p1 + scale * 4 + 11); *p2 =3D 3; int ret2 =3D *(p1 + scale * 4 + 11); return ret + ret2; } gcc11 -O2 test.c -S=20 foo(int*, int*, int): sall $2, %edx movslq %edx, %rdx leaq 44(%rdi,%rdx,4), %rdx --- redundant could be fwprop movl (%rdx), %eax movl $3, (%rsi) addl (%rdx), %eax ret fwprop failed to propagate this because it think cost of address 44(%rdi,%rdx,4) is more expensive than (%rdx), that's correct locally, but under global view, if it could be propagated into both movl, leaq would be eliminated, which benifits performance. The ideal place to handle this issue is TER opt in pass_expand, but current= ly TER only handle simple situation ---- single use and block level 48 A pass is made through the function, one block at a time. No cross b= lock=20 49 information is tracked.=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20 50=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 51 Variables which only have one use, and whose defining stmt is conside= red=20=20 52 a replaceable expression (see ssa_is_replaceable_p) are tracked to see whether=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 53 they can be replaced at their use location.=20=20=20=20=20=20=20 Should TER be extended? Another testcase has this issue in more complex cfg Refer to https://godbolt.org/z/ofjH9R=