On Sun, Aug 8, 2021 at 12:43 PM Roger Sayle <ro...@nextmovesoftware.com> wrote:
>
>
> This middle-end patch implements several related improvements to
> tree-ssa's conditional (bit) constant propagation pass.  The current
> code handling ordered comparisons contains the comment "If the
> most significant bits are not known we know nothing" which is not
> entirely true [this test even prevents this pass understanding these
> comparisons always have a zero or one result].  This patch introduces
> a new value_mask_to_min_max helper function, that understands the
> different semantics of the most significant bit on signed vs.
> unsigned values.  This allows us to generalize ordered comparisons,
> GE_EXPR, GT_EXPR, LE_EXPR and LT_EXPR, where the code is tweaked to
> correctly handle the potential equal cases.  Then finally support
> is added for the related tree codes MIN_EXPR, MAX_EXPR, ABS_EXPR
> and ABSU_EXPR.
>
> Regression testing revealed three test cases in the testsuite that
> were checking for specific optimizations that are now being performed
> earlier than expected.  These tests can continue to check their
> original transformations by explicitly adding -fno-tree-ccp to their
> dg-options (some already specify -fno-ipa-vrp or -fno-tree-forwprop
> for the same reason).
>
> This patch has been tested on x86_64-pc-linux-gnu with a
> "make bootstrap" and "make -k check" with no new failures.
>
> Ok for mainline?

OK.

Thanks,
Richard.

>
> 2021-08-08  Roger Sayle  <ro...@nextmovesoftware.com>
>
> gcc/ChangeLog
>         * tree-ssa-ccp.c (value_mask_to_min_max): Helper function to
>         determine the upper and lower bounds from a mask-value pair.
>         (bit_value_unop) [ABS_EXPR, ABSU_EXPR]: Add support for
>         absolute value and unsigned absolute value expressions.
>         (bit_value_binop):  Initialize *VAL's precision.
>         [LT_EXPR, LE_EXPR]: Use value_mask_to_min_max to determine
>         upper and lower bounds of operands.  Add LE_EXPR/GE_EXPR
>         support when the operands are unknown but potentially equal.
>         [MIN_EXPR, MAX_EXPR]: Support minimum/maximum expressions.
>
> gcc/testsuite/ChangeLog
>         * gcc.dg/pr68217.c: Add -fno-tree-ccp option.
>         * gcc.dg/tree-ssa/vrp24.c: Add -fno-tree-ccp option.
>         * g++.dg/ipa/pure-const-3.C: Add -fno-tree-ccp option.
>
> Roger
> --
> Roger Sayle
> NextMove Software
> Cambridge, UK
>

Reply via email to