[PATCH] D80974: [DAGCombine] Adding a hook to improve the precision of fsqrt if the input is denormal

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 1 21:07:16 PDT 2020


steven.zhang created this revision.
steven.zhang added reviewers: spatel, RKSimon, jsji, hfinkel, PowerPC.
Herald added subscribers: ecnelises, wuzish, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
steven.zhang added a parent revision: D80706: [DAGCombine] Add hook to allow target specific test for sqrt input.

For now, we will hardcode the result as 0.0 if the input is denormal or 0. That will have the impact the precision. As the fsqrt added belong to the cold path of the cmp+branch, it won't impact the performance for normal inputs for PowerPC. Besides, it removes the xxlxor of the hot path.

  clang without this patch
  
  sqrt(2.2250738585072014e-308) = 1.4916681462400413e-154
  sqrt(2.2250738585072009e-308) = 0
  sqrt(4.9406564584124654e-324) = 0
  
  With this patch:
  
  sqrt(2.2250738585072014e-308) = 1.4916681462400413e-154
  sqrt(2.2250738585072009e-308) = 1.4916681462400412e-154
  sqrt(4.9406564584124654e-324) = 2.2227587494850775e-162


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80974

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/fma-mutate.ll
  llvm/test/CodeGen/PowerPC/recipest.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80974.267782.patch
Type: text/x-patch
Size: 10494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200602/4183e731/attachment.bin>


More information about the llvm-commits mailing list