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

--- Comment #16 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:c96a6c2c264776d8138c6b303d005e74f047cfa0

commit r15-6773-gc96a6c2c264776d8138c6b303d005e74f047cfa0
Author: Alexandre Oliva <ol...@adacore.com>
Date:   Fri Jan 10 09:32:33 2025 -0300

    [ifcombine] adjust for narrowing converts before shifts [PR118206]

    A narrowing conversion and a shift both drop bits from the loaded
    value, but we need to take into account which one comes first to get
    the right number of bits and mask.

    Fold when applying masks to parts, comparing the parts, and combining
    the results, in the odd chance either mask happens to be zero.


    for  gcc/ChangeLog

            PR tree-optimization/118206
            * gimple-fold.cc (decode_field_reference): Account for upper
            bits dropped by narrowing conversions whether before or after
            a right shift.
            (fold_truth_andor_for_ifcombine): Fold masks, compares, and
            combined results.

    for  gcc/testsuite/ChangeLog

            PR tree-optimization/118206
            * gcc.dg/field-merge-18.c: New.

Reply via email to