From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DCABF3858C2F; Thu, 12 Oct 2023 07:56:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCABF3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697097414; bh=9WoEAljnUnlXc3L41YvMyeEaYu6DLGW81dBWEXZ6hrg=; h=From:To:Subject:Date:From; b=JOZlNTLyhNHdpszxpNUZ/oUSzwI+PLI9W1FwDzHjSRLY7slnCgQkQfG/H9WY78Bg7 ba91Rs/35S/qaTQvWEtqZ59hmuHskZ6m0bJfAQK/Nw5J3IlXZRsm1w6ac0MwryEUnL RYCAife5qi2ABY6KHKMQ01EiNwkqRlBxBtxw0kSU= From: "652023330028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111780] New: Missed optimization of '(t*4)/(t*2) -> 2' Date: Thu, 12 Oct 2023 07:56:54 +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=3D111780 Bug ID: 111780 Summary: Missed optimization of '(t*4)/(t*2) -> 2' 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 found some optimizations (regarding Arithmetic optimization) that= GCC may have missed. We would greatly appreicate if you can take a look and let= us know what you think. Given the following code: https://godbolt.org/z/G9rWK7c3q int n1; void func1(int a){ if(a>1&&a<4) n1=3D(a+a+a+a)/(a+a); } Different from PR 111718, this missed optimization appears to be due to a missed pattern: (t*4)/(t*2) -> 2 # DEBUG BEGIN_STMT # RANGE [irange] int [8, 8][12, 12] NONZERO 0xc _3 =3D a_7(D) * 4; # RANGE [irange] int [4, 4][6, 6] NONZERO 0x6 _4 =3D a_7(D) * 2; # RANGE [irange] int [1, 3] NONZERO 0x3 _5 =3D _3 / _4; # .MEM_9 =3D VDEF <.MEM_8(D)> n1D.2761 =3D _5; Or a more general pattern: (t*m)/(t*n) -> m/n , where m and n are constants. Thank you very much for your time and effort! We look forward to hearing fr= om you.=