[X86] Heuristic to selectively build Newton-Raphson SQRT estimation
authorNikolai Bozhenov <nikolai.bozhenov@intel.com>
Thu, 4 Aug 2016 12:47:28 +0000 (12:47 +0000)
committerNikolai Bozhenov <nikolai.bozhenov@intel.com>
Thu, 4 Aug 2016 12:47:28 +0000 (12:47 +0000)
commitf679530ba18023d29765bde397fa77048bf17985
tree26d32ee662bbb6f153eb39b81350d1d6859cd044
parent8950cead7f2032d4dee6b17be4eb4c6b5d755403
[X86] Heuristic to selectively build Newton-Raphson SQRT estimation

On modern Intel processors hardware SQRT in many cases is faster than RSQRT
followed by Newton-Raphson refinement. The patch introduces a simple heuristic
to choose between hardware SQRT instruction and Newton-Raphson software
estimation.

The patch treats scalars and vectors differently. The heuristic is that for
scalars the compiler should optimize for latency while for vectors it should
optimize for throughput. It is based on the assumption that throughput bound
code is likely to be vectorized.

Basically, the patch disables scalar NR for big cores and disables NR completely
for Skylake. Firstly, scalar SQRT has shorter latency than NR code in big cores.
Secondly, vector SQRT has been greatly improved in Skylake and has better
throughput compared to NR.

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

llvm-svn: 277725
llvm/include/llvm/Target/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86Subtarget.cpp
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/sqrt-fastmath-tune.ll [new file with mode: 0644]