From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 84EA0385E02B; Mon, 8 Jan 2024 08:25:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84EA0385E02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704702345; bh=esAIFbFQKLIhUv+rvySCtkiK/YHBNlvqAPTSDcoPfQA=; h=From:To:Subject:Date:From; b=MAK/iZ9QA8BWwBMR9FepMDI0I5OD90Lg1u+wILPK6+r1TwTANDaH00phJSsZpBjh7 ecftSZ2erjH6H/v+VNXHK7vaoG76qBMprXp1pWgJsmT4rMcEPO5WNrqwR8NWnaGefh VDDb0DN/v17GUU50HfElg5EMbNo8wbzPDRGpKJJA= From: "652023330028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113265] New: [Regression] Missed optimization for redundancy computation elimination may be due to constant propagation about 0 too late Date: Mon, 08 Jan 2024 08:25:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 652023330028 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=3D113265 Bug ID: 113265 Summary: [Regression] Missed optimization for redundancy computation elimination may be due to constant propagation about 0 too late Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: 652023330028 at smail dot nju.edu.cn Target Milestone: --- Hello, we noticed that maybe there is a missed optimization for redundancy computation elimination. https://godbolt.org/z/drfejE5cP int x,y,z; void func(int a, int b){ a=3Db-x; b=3Da; y=3D0; z=3D(y+a)/(-b); } GCC -O3 : func(int, int): mov ecx, DWORD PTR x[rip] mov eax, esi mov DWORD PTR y[rip], 0 sub eax, ecx sub ecx, esi cdq idiv ecx mov DWORD PTR z[rip], eax ret Earlier GCC versions get the expected optimizations: Expected code (GCC 7.5): func(int, int): mov DWORD PTR y[rip], 0 mov DWORD PTR z[rip], -1 ret The following code is optimized by gcc as expected: void func2(int a, int b){ a=3Db-x; b=3Da; y=3D0; z=3D(0+a)/(-b); } Comparing the code for func and func2 and their ccp1(tree), we suspect that this issue may be caused by too late propagation about y=3D0. Thank you very much for your time and effort! We look forward to hearing fr= om you=