From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 76C3A394D82B; Tue, 1 Dec 2020 15:25:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76C3A394D82B From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/97459] __uint128_t remainder for division by 3 Date: Tue, 01 Dec 2020 15:25:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2020 15:25:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97459 --- Comment #23 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:855bb43f6d0bee5a74b5d3739456ca34b4609a50 commit r11-5614-g855bb43f6d0bee5a74b5d3739456ca34b4609a50 Author: Jakub Jelinek Date: Tue Dec 1 16:25:06 2020 +0100 Improve double-word mod even on powerpc [PR97459] I have noticed that while my (already committed, thanks for review) patch works on x86, it doesn't work on powerpc*. The problem is that we don't have lshr double-word optab (neither TImode nor for -m32 DImod= e), but as expander has code for double-word shift, that doesn't really mat= ter. As the implementation is prepared to punt whenever something can't be expanded with OPTAB_DIRECT and in the end also punts if any library cal= ls would be emitted, the optab_handler checks were just to save compile ti= me. On the other side, for even divisors, we know that (1 << bit) % (2 * x) for bit > 0 will never be equal to 1, because both dividend and divisor are even and so remainder will be even too, so we can save some compile time by adding an early exit. The even divisors can be handled with the approach Thomas wrote about (perhaps generalized into divisors equal to what expand_doubleword_mod can handle times some power of two where we can handle power of two mod= ulo cheaply), but that would be done in a different function... And we could use ctz to find the power of two... 2020-12-01 Jakub Jelinek PR rtl-optimization/97459 * optabs.c (expand_doubleword_mod): Punt early for even op1. (expand_binop): Don't require lshr_optab double-word handler.=