On Wed, Apr 16, 2025 at 6:25 AM Eric Botcazou <botca...@adacore.com> wrote:
>
> Hi,
>
> this is a regression introduced on the mainline and 14 branch by:
>   https://gcc.gnu.org/pipermail/gcc-cvs/2023-October/391658.html
>
> The change bypasses int_fits_type_p (essentially) to work around the
> signedness constraints, but in doing so disregards the peculiarities of
> boolean types whose precision is not 1 that are dealt with by the predicate,
> leading to the creation of a problematic conversion here.
>
> Fixed by special-casing boolean types whose precision is not 1, as done in
> several other places.
>
> Tested on x86-64/Linux, OK for the mainline and 14 branch?

LGTM. I do wonder if this could be documented somewhere if not
already. Because I suspect there are other places which miss that if
TYPE_PRECISION are equal, you might still need a cast for boolean
types. Maybe a helper function might be useful too.

Thanks,
Andrew

>
>
> 2025-04-15  Eric Botcazou  <ebotca...@adacore.com>
>
>         * tree-ssa-phiopt.cc (factor_out_conditional_operation): Do not
>         bypass the int_fits_type_p test for boolean types whose precision
>         is not 1.
>
>
> 2025-04-15  Eric Botcazou  <ebotca...@adacore.com>
>
>         * gnat.dg/opt105.adb: New test.
>         * gnat.dg/opt105_pkg.ads, gnat.dg/opt105_pkg.adb: New helper.
>
> --
> Eric Botcazou

Reply via email to