https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128051
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:60d71abfe4b45507027b6ad63a9ef247b4fc004b commit r17-5456-g60d71abfe4b45507027b6ad63a9ef247b4fc004b Author: Richard Biener <[email protected]> Date: Wed Oct 21 08:31:28 2026 +0200 tree-optimization/128051 - sign-extension when widening inner mask In decode_field_reference, when combining an inner BIT_AND_EXPR mask with an incoming mask of wider precision (from an outer condition), the inner mask was unconditionally zero-extended using UNSIGNED. When the inner mask is of a signed type and its sign bit is set, converting the masked value to the wider type sign-extends it, so tests of the upper extension bits in the incoming mask are tests of the sign bit of the inner expression. Hardcoding UNSIGNED zeroed out the upper bits of the mask, which wiped out any extension bits from the incoming mask and caused decode_field_reference to conclude that no sign-extension bits were tested. This resulted in dropping the sign-bit check and miscompiling the outer condition. PR tree-optimization/128051 * gimple-fold.cc (decode_field_reference): Use TYPE_SIGN of mask operand when extending and_mask to prec_in. * gcc.dg/torture/pr128051.c: New testcase.
