OSDN Git Service

[X86] Don't use RCP14 and RSQRT14 for reciprocal estimations or for legacy SSE rcp...
authorCraig Topper <craig.topper@intel.com>
Sat, 4 Nov 2017 18:26:41 +0000 (18:26 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 4 Nov 2017 18:26:41 +0000 (18:26 +0000)
commit1b23a75d3e2aee53c7c7d89ac0384101e963006e
tree4269db6f2b39ed5222968538f2cb8e0030109772
parentcf0e1f6fa7363158cd4463563880cd68b95dd8ed
[X86] Don't use RCP14 and RSQRT14 for reciprocal estimations or for legacy SSE rcp/rsqrt intrinsics when AVX512 features are enabled.

Summary:
AVX512 added RCP14 and RSQRT instructions which improve accuracy over the legacy RCP and RSQRT instruction, but not enough accuracy to remove the need for a Newton Raphson refinement.

Currently we use these new instructions for the legacy packed SSE instrinics, but not the scalar instrinsics. And we use it for fast math optimization of division and reciprocal sqrt.

I think switching the legacy instrinsics maybe surprising to the user since it changes the answer based on which processor you're using regardless of any fastmath settings. It's also weird that we did something different between scalar and packed.

As far at the reciprocal estimation, I think it creates unnecessary deltas in our output behavior (and prevents EVEX->VEX). A little playing around with gcc and icc and godbolt suggest they don't change which instructions they use here.

This patch adds new X86ISD nodes for the RCP14/RSQRT14 and uses those for the new intrinsics. Leaving the old intrinsics to use the old instructions.

Going forward I think our focus should be on
-Supporting 512-bit vectors, which will have to use the RCP14/RSQRT14.
-Using RSQRT28/RCP28 to remove the Newton Raphson step on processors with AVX512ER
-Supporting double precision.

Reviewers: zvi, DavidKreitzer, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317413 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
lib/Target/X86/X86InstrAVX512.td
lib/Target/X86/X86InstrFragmentsSIMD.td
lib/Target/X86/X86InstrSSE.td
lib/Target/X86/X86IntrinsicsInfo.h
test/CodeGen/X86/avx-intrinsics-x86.ll
test/CodeGen/X86/avx-schedule.ll
test/CodeGen/X86/recip-fastmath.ll
test/CodeGen/X86/recip-fastmath2.ll
test/CodeGen/X86/sse-intrinsics-x86.ll
test/CodeGen/X86/sse-schedule.ll