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

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:de67f943b858099b40f73632a51e66147ec79c9b

commit r12-7012-gde67f943b858099b40f73632a51e66147ec79c9b
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu Feb 3 09:45:16 2022 +0100

    ranger: Fix up wi_fold_in_parts for small precision types [PR104334]

    The wide-int.h templates expect that when an int/long etc. operand is used
    it will be sign-extended based on the types precision.
    wi_fold_in_parts passes 3 such non-zero constants to wi::lt_p, wi::gt_p
    and wi::eq_p - 1, 3 and 4, which means it was doing weird things if either
    some of 1, 3 or 4 weren't representable in type, or if type was unsigned 3
bit
    type 4 should be written as -4.
    The following patch promotes the subtraction operands to widest_int and
    uses that as the type for ?h_range variables and compares them as such.
    We don't need the overflow handling because there is never an overflow.

    2022-02-02  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/104334
            * range-op.cc (range_operator::wi_fold_in_parts): Change lh_range
            and rh_range type to widest_int and subtract in widest_int.  Remove
            ov_rh, ov_lh and sign vars, always perform comparisons as signed
            and use >, < and == operators for it.

            * g++.dg/opt/pr104334.C: New test.

Reply via email to