On Tue, Jun 11, 2024 at 01:36:35PM +0800, liuhongt wrote:
> In theory, const_wide_int can also be handle with extra check for each 
> components of the HOST_WIDE_INT array, and the check is need for both
> shift and bit_and operands.
> I assume the optimization opportnunity is rare, so the patch just add
> extra check to make sure GET_MODE_INNER (mode) can fix into a
> HOST_WIDE_INT.

I think if you only handle CONST_INT_P, you should check just for that, and
in both places where you check for CONST_VECTOR_DUPLICATE_P (there is one
spot 2 lines above this).
So add
&& CONST_INT_P (XVECEXP (XEXP (op0, 1), 0, 0))
and
&& CONST_INT_P (XVECEXP (op1, 0, 0))
tests right below those && CONST_VECTOR_DUPLICATE_P (something) tests.
> 
> gcc/ChangeLog:
> 
>       PR target/115384
>       * simplify-rtx.cc (simplify_context::simplify_binary_operation_1):
>       Only do the simplification of (AND (ASHIFTRT A imm) mask)
>       to (LSHIFTRT A imm) when inner mode fits HOST_WIDE_INT.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.target/i386/pr115384.c: New test.

        Jakub

Reply via email to