https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128092
--- Comment #2 from Oleksandr Kulkov <adamant.pwn at gmail dot com> --- Created attachment 65929 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65929&action=edit Candidate patch: normalize IPA bit lattice operands before folding The attached candidate patch normalizes the IPA lattice value and mask to the operation's precision and signedness before folding. Bits above that precision are otherwise marked unknown, which makes value_mask_to_min_max mistake them for a varying sign bit and misfold MAX_EXPR. Targeted testing on x86_64 with GCC 17 commit 7d652a985 (2026-10-08): the original and reduced testcases pass, the new torture test changes from five failures to all passes (including LTO), and five existing IPA tests still pass. The affected function is unchanged in current trunk, 5b40bde87. Assisted-by: OpenAI Codex
