[Bug tree-optimization/126462] [16/17 Regression] Wrong code with xor-rotate idiom since r16-6592

"jakub at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126462

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Both
        && ((~((HOST_WIDE_INT_1U << tree_to_uhwi (@1)) - 1)) & tree_to_uhwi
(@4)) == 0
and
        && (((((HOST_WIDE_INT_1U << tree_to_uhwi (@1)) - 1)) & tree_to_uhwi
(@2)) == 0)
in there of course only work if tree_to_uhwi (@1) < HOST_BITS_PER_WIDE_INT,
which is not the case for __int128 rotates or _BitInt(N) for N > 64.
So, either the optimization should be guarded on tree_to_uhwi (@1) <
HOST_BITS_PER_WIDE_INT, or better rewrite it with wide_int APIs,
(~((HOST_WIDE_INT_1U << tree_to_uhwi (@1)) - 1))
is wi::mask (tree_to_uhwi (@1), true, TYPE_PRECISION (type))
and
(((HOST_WIDE_INT_1U << tree_to_uhwi (@1)) - 1))
is wi::mask (tree_to_uhwi (@1), false, TYPE_PRECISION (type)),
the tree_fits_uhwi_p (@2) or (@4) should go and be masked with wi::to_wide on
that.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.