[TargetLowering] Improve expansion of FSHL/FSHR
authorJay Foad <jay.foad@amd.com>
Thu, 2 Apr 2020 10:36:01 +0000 (11:36 +0100)
committerJay Foad <jay.foad@amd.com>
Thu, 14 May 2020 15:36:22 +0000 (16:36 +0100)
commit17941437a2ed8abefef719345391da94e6df8ebb
treecc42f885414beca63d1cfd152bee9e7821af3a95
parent0c5db3e4aa197bab6e4d9f8c02ca0edf4fa9dce3
[TargetLowering] Improve expansion of FSHL/FSHR

Use an extra shift-by-1 instead of a compare and select to handle the
shift-by-zero case. This sometimes saves one instruction (if the compare
couldn't be combined with a previous instruction). It also works better
on targets that don't have good select instructions.

Note that currently this change doesn't affect most targets because
expandFunnelShift is not used because funnel shift intrinsics are
lowered early in SelectionDAGBuilder. But there is work afoot to change
that; see D77152.

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