From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B12413856954; Fri, 12 May 2023 09:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B12413856954 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683884105; bh=tTXt5x4z2LLt096fz6jNyco7bTpjoMy/i7OObHEvOVY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mU54KSDtQu02lH6+wy3vRAwJ9acs2bFYRuzydV2lSocbCY1UwIEVbWBzCa4a/MbHH +U33VoY+7mXYe33FM25h1SJe6qr2mc3QTtt/POodlIKoju3+U6ZECYULgqJn6cNUoR WvPoW/a3tLgaauShKlYEm7r9nHDmrxR9QOBHL+IQ= From: "guojiufu 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: Fri, 12 May 2023 09:35:05 +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: guojiufu 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 #24 from Jiu Fu Guo --- (In reply to Jiu Fu Guo from comment #23) > /* Simplify ((t + -N*M) / N + M) -> t / N: (t + -C) >> N + (C>>N) =3D=3D>= t >> N > */ > (for div (trunc_div exact_div) div was not used in this matcher, yet. Here rshift is used: t/(1<>N". > (simplify > (plus (rshift (plus @0 INTEGER_CST@1) INTEGER_CST@2) INTEGER_CST@3) > (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && > (wi::to_wide (@3) << wi::to_wide (@2)) =3D=3D -wi::to_wide (@1)) > (if (TYPE_OVERFLOW_UNDEFINED (type)) > (div @0 @2) This should be "(rshift @0 @2)", otherwise it will be error if relax "TYPE_UNSIGNED (type)"=