https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128111

--- Comment #18 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:adbe7fb7f384b0dd0abbf2d26a978679b4a03345

commit r17-6722-gadbe7fb7f384b0dd0abbf2d26a978679b4a03345
Author: Jakub Jelinek <[email protected]>
Date:   Thu Nov 26 09:42:46 2026 +0100

    bitintlower: Fix up big-endian .CLMUL bitint lowering [PR128111]

    The builtin-clmulg-1.c test FAILs on powerpc64-linux and s390x-linux,
    first on the unsigned _BitInt(129) test.

    On Wed, Nov 25, 2026 at 04:19:36PM +0100, Stefan Schulze Frielinghaus
wrote:
    > Only skimming over bitint_large_huge::lower_clmul shows that
    > pseudo-code's src1[idx2 - idx] and src1[idx2 - idx3] count limbs from
    > the least significant one.  idx2 is an array index and on big-endian
    > limb number N is at index p - N whereas on little-endian it is just N.
    > Thus, its limb number is p - idx2.  idx3 is already a limb number.  The
    > pseudo-code reads limb number (p - idx2) - idx3.  Since limb number N is
    > at array index p - N, the array index is p - ((p - idx2) - idx3) which
    > equals idx2 + idx3.  Likewise for idex2 - idx.
    >
    > I gave the following a shot and it fixed the test for me:

    I think I'd prefer instead just negate those for big-endian so that
    it can be used consistently without further changes.

    2026-11-26  Stefan Schulze Frielinghaus  <[email protected]>
                Jakub Jelinek  <[email protected]>

            PR middle-end/128111
            * gimple-lower-bitint.cc (bitint_large_huge::lower_clmul): For
            big-endian compute idx3 as older idx3 - p instead of p - idx3
            and idx4 as idx - p instead of p - idx.

    Reviewed-by: Richard Biener <[email protected]>

Reply via email to