On 5/23/24 8:25 PM, Hongtao Liu wrote:
CC for review.

On Tue, May 21, 2024 at 1:12 PM liuhongt <hongtao....@intel.com> wrote:

When mask is (1 << (prec - imm) - 1) which is used to clear upper bits
of A, then it can be simplified to LSHIFTRT.

i.e Simplify
(and:v8hi
   (ashifrt:v8hi A 8)
   (const_vector 0xff x8))
to
(lshifrt:v8hi A 8)

Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
Ok of trunk?

gcc/ChangeLog:

         PR target/114428
         * simplify-rtx.cc
         (simplify_context::simplify_binary_operation_1):
         Simplify (AND (ASHIFTRT A imm) mask) to (LSHIFTRT A imm) for
         specific mask.

Can you add a testcase for this? I don't mind if it's x86 specific and does a bit of asm scanning.

Also note that the context for this patch has changed, so it won't automatically apply. So be extra careful when updating so that it goes into the right place (all the more reason to have a testcase validating that the optimization works correctly).


I think the patch itself is fine. So further review is just for the testcase and should be easy.

jeff

ps.  It seems to help RISC-V as well :-)


Reply via email to