From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A75F43858CDB; Sat, 11 Feb 2023 17:32:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A75F43858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676136766; bh=HdQwQ6E3VqCJx8qAbdjAJiYLDQ7JYHcbvjFPndPeV0U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dUwb6crTP7LYtpp6ZYqhW/2qHOFSugO1P4phrgGtW09ThwatIj+R0HJNL58Os0twx J7zyRV9i0yWeqlKYyZcd0655V0G2UQ4UtGSb9e7XJj5Wyg4wNz80t0edgUdVk9z7Y6 nced1BfZ5Lvr3hXOYOECU5zLJU7IFPpVVWO/hOXc= From: "bergner at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108757] We do not simplify (a - (N*M)) / N + M -> a / N Date: Sat, 11 Feb 2023 17:32:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: bergner at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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=3D108757 --- Comment #5 from Peter Bergner --- (In reply to Segher Boessenkool from comment #4) > If N is a power of two optimising this to a/N is valid, but for other val= ues > of N it is not (division is not the inverse of multiplication in C). It = also > only works for unsigned of course. Isn't this valid for any N & M, such that M is a factor of N? Meaning, as = long as N / M has no remainder, it seems like this should be ok. For example, N= =3D 30 & M =3D 2 should be just as ok as the N =3D 32 & M =3D 2 case, correct?=