From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4D46E3858CDB; Sat, 30 Dec 2023 04:29:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D46E3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703910578; bh=9YE4nVcVCnMbH0RogIJLhobUJPJya5RnSzPsV4WZ1Q8=; h=From:To:Subject:Date:From; b=JyTcV3HnI3m50ms6kPCp44krOWmMFs0eUSPtbpo/ZP8KVwKLKncmHZGwH1n3OnQUA a9i1mSt42AcsjO1liy8/1Gif8yKa3pCGR9ZQe6vg6DB+dRjdG4p/5T/8Udur7kWw2M f4ngXzQE/Uxdr5WFYq88gd4OcYE5p9NC2zoiRKfU= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113176] New: `(n / 4) ? n / 4 : 0` is not optimized to just `n /4` Date: Sat, 30 Dec 2023 04:29:37 +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: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org 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 keywords 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=3D113176 Bug ID: 113176 Summary: `(n / 4) ? n / 4 : 0` is not optimized to just `n /4` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int unopt(int n) { if (n / 4) return n / 4; else return 0; } int unopt1(int n) { return (n / 4) ? n / 4 : 0; } int opt(int n) { return n / 4; } ``` I would have expected unopt be transformed into opt but currently it is not. This is because GCC decides to transform `(n / 4) !=3D 0` into `(unsigned i= nt) n + 3 > 6`.=