[X86] Add post-isel pseudos for rotate by immediate using SHLD/SHRD
authorCraig Topper <craig.topper@intel.com>
Wed, 27 Mar 2019 17:29:34 +0000 (17:29 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 27 Mar 2019 17:29:34 +0000 (17:29 +0000)
commit7c9afc35bce9e19d95966e73e6e9d6b8c7f42767
treef34c4c3f270fb4426954bf4c2dcc91bdd217987f
parent89daf49e5c56a7e4b3bc72fad64be53139912670
[X86] Add post-isel pseudos for rotate by immediate using SHLD/SHRD

Haswell CPUs have special support for SHLD/SHRD with the same register for both sources. Such an instruction will go to the rotate/shift unit on port 0 or 6. This gives it 1 cycle latency and 0.5 cycle reciprocal throughput. When the register is not the same, it becomes a 3 cycle operation on port 1. Sandybridge and Ivybridge always have 1 cyc latency and 0.5 cycle reciprocal throughput for any SHLD.

When FastSHLDRotate feature flag is set, we try to use SHLD for rotate by immediate unless BMI2 is enabled. But MachineCopyPropagation can look through a copy and change one of the sources to be different. This will break the hardware optimization.

This patch adds psuedo instruction to hide the second source input until after register allocation and MachineCopyPropagation. I'm not sure if this is the best way to do this or if there's some other way we can make this work.

Fixes PR41055

Differential Revision: https://reviews.llvm.org/D59391

llvm-svn: 357096
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/lib/Target/X86/X86InstrShiftRotate.td
llvm/test/CodeGen/X86/rot32.ll
llvm/test/CodeGen/X86/rot64.ll