On 07/13/2017 02:53 AM, Richard Sandiford wrote:
> The main loop of simplify_comparison starts with:
>
> if (GET_MODE_CLASS (mode) != MODE_INT
> && ! (mode == VOIDmode
> && (GET_CODE (op0) == COMPARE || COMPARISON_P (op0))))
> break;
>
> So VOIDmode is only acceptable when comparing a COMPARE,
> EQ, NE, etc. operand against a constant. After this, the loop
> calls simplify_compare_const to:
>
> (a) bring the constant op1 closer to 0 where possible and
> (b) use nonzero_bits and num_sign_bit_copies to get a simpler
> constant.
>
> (a) works for both integer and VOID modes, (b) is specific
> to integer modes.
>
> The loop then has a big switch statement that handles further
> simplifications. This switch statement checks for COMPARISON_P
> codes but not for COMPARE.
>
> This patch uses scalar_int_mode to make the split between
> (a) and (b) more explicit. It also takes the COMPARISON_P
> handling out of the switch statement and does it first,
> so that the rest of the loop can treat the mode as a
> scalar_int_mode.
>
> 2017-07-13 Richard Sandiford <richard.sandif...@linaro.org>
> Alan Hayward <alan.hayw...@arm.com>
> David Sherwood <david.sherw...@arm.com>
>
> gcc/
> * combine.c (simplify_compare_const): Check that the mode is a
> scalar_int_mode (rather than VOIDmode) before testing its
> precision.
> (simplify_comparison): Move COMPARISON_P handling out of the
> loop and restrict the latter part of the loop to scalar_int_modes.
> Check is_a <scalar_int_mode> before calling HWI_COMPUTABLE_MODE_P
> and when considering SUBREG_REGs. Use is_int_mode instead of
> checking GET_MODE_CLASS against MODE_INT.
OK.
jeff