[PATCH] D42323: [DAGCombiner] filter out denorm inputs when calculating sqrt estimate (PR34994)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 15:18:45 PST 2018


spatel created this revision.
spatel added reviewers: hfinkel, DavidKreitzer, RKSimon.
Herald added a subscriber: mcrosier.

As shown in the example in PR34994:
https://bugs.llvm.org/show_bug.cgi?id=34994
...we can return a very wrong answer (inf instead of 0.0) for square root when using a reciprocal square root estimate instruction.

Here, I've conditionalized the filtering out of denorms based on the function having "denormal-fp-math"="ieee" in its attributes. The other options for this attribute are 'preserve-sign' and 'positive-zero'.

So we don't generate this extra code by default with just '-ffast-math' (because then there's no denormal attribute string at all), but it works if you specify '-ffast-math -fdenormal-fp-math=ieee' from clang.


https://reviews.llvm.org/D42323

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/X86/sqrt-fastmath.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42323.130700.patch
Type: text/x-patch
Size: 5154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180119/20c8747b/attachment.bin>


More information about the llvm-commits mailing list