From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7BD893858417; Wed, 7 Feb 2024 10:38:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BD893858417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707302322; bh=WgjdIzcSY//NGyKeFIDxUpymqF2bBWzCRkEhy3Nu/nw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f9Th5AqDeWIq9k5F5myqAx4Ag3mNJ7B9Stu7wJfxrWmAcO5WO2VQQ7Feu6HPtU7PT CuQkfaMeTq3WwrfoGyI6sTKzYSqTYj1MejgK45aYLvPd/TJdYf0AigK3OwgOOqvr1M 9aj4oiXRBK7jjNwaen4kYWxuHSfWP0LN7W+frUnw= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/87744] Some valid instantiations of linear_congruential_engine produce compiler errors when __int128 isn't available Date: Wed, 07 Feb 2024 10:38:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 7.3.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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=3D87744 --- Comment #13 from Jonathan Wakely --- (In reply to Jakub Jelinek from comment #11) > Though, if it is common enough, one could try to optimize the __ll[0] =3D= =3D 0 > && __xx[0] =3D=3D 0 case, one can do then either 32x32->64 or 64x64->64 > multiplication and be done with it. But if it is rare in random's usage,= it > would just make the code larger. We will only use this new type when the calculation a*(m-1)+c doesn't fit i= n 64 bits, and the input values should be uniformly distributed in [0,m) for a g= ood choice of parameters (and for a bad choice of parameters, you have bigger problems than the calculation being slow!) For a small value of a and large value of c we would use this new type but = the multiplication step would overflow infrequently, but I don't think that's a good choice of parameters and not worth optimizing for. So I think we should just use the full 64x64 multiplication unconditionally. For operator% the if (__l._M_hi =3D=3D 0) branch is probably worth it, beca= use the general case is so much more expensive.=