[TargetLowering] Improve expandFunnelShift shift amount masking
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 24 May 2020 10:25:09 +0000 (11:25 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sun, 24 May 2020 10:25:09 +0000 (11:25 +0100)
commit16031067252dc466cdc4311ab1491f996e5b4848
treeb418fa67b4cde2f86a446c62519ffcfb66737482
parent72210ce7f57192652414ebbdf9f643f86532d700
[TargetLowering] Improve expandFunnelShift shift amount masking

For the 'inverse shift', we currently always perform a subtraction of the original (masked) shift amount.

But for the case where we are handling power-of-2 type widths, we can replace:

(sub bw-1, (and amt, bw-1) ) -> (and (xor amt, bw-1), bw-1) -> (and ~amt, bw-1)

This allows x86 shifts to fold away the and-mask.

Followup to D77301 + D80466.

http://volta.cs.utah.edu:8080/z/Nod0Gr

Differential Revision: https://reviews.llvm.org/D80489
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/X86/fshl.ll
llvm/test/CodeGen/X86/fshr.ll