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

--- Comment #29 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Alexandre Oliva <aol...@gcc.gnu.org>:

https://gcc.gnu.org/g:52e4ede030979d8aff2f88364e1d11c61fb212aa

commit r15-6866-g52e4ede030979d8aff2f88364e1d11c61fb212aa
Author: Alexandre Oliva <ol...@adacore.com>
Date:   Mon Jan 13 10:49:51 2025 -0300

    [ifcombine] propagate signbit mask to XOR right-hand operand

    If a single-bit bitfield takes up the sign bit of a storage unit,
    comparing the corresponding bitfield between two objects loads the
    storage units, XORs them, converts the result to signed char, and
    compares it with zero: ((signed char)(a.<byte> ^ c.<byte>) >= 0).

    fold_truth_andor_for_ifcombine recognizes the compare with zero as a
    sign bit test, then it decomposes the XOR into an equality test.

    The problem is that, after this decomposition, that figures out the
    width of the accessed fields, we apply the sign bit mask to the
    left-hand operand of the compare, but we failed to also apply it to
    the right-hand operand when both were taken from the same XOR.

    This patch fixes that.


    for  gcc/ChangeLog

            PR tree-optimization/118409
            * gimple-fold.cc (fold_truth_andor_for_ifcombine): Apply the
            signbit mask to the right-hand XOR operand too.

    for  gcc/testsuite/ChangeLog

            PR tree-optimization/118409
            * gcc.dg/field-merge-20.c: New.

Reply via email to