[PATCH] D44308: [ConstantFold] fp_binop AnyConstant, undef --> NaN

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 08:06:59 PST 2018


spatel created this revision.
spatel added reviewers: andrew.w.kaylor, lattner, efriedma, scanon, arsenm, reames, nhaehnle.
Herald added subscribers: wdng, mcrosier.

With the first update to the LangRef ( https://reviews.llvm.org/D44216 / https://reviews.llvm.org/rL327138 ) in place, we can proceed with more constant folding.

I'm intentionally taking the conservative path here: no matter what the constant or the FMF, we can always fold to NaN. This is because the undef operand can be chosen as NaN, and in our simplified default FP env, nothing else happens - NaN just propagates to the result. If we find some way/need to propagate undef instead, that can be added subsequently.

The tests show that we always choose the same quiet NaN constant (0x7FF8000000000000 in IR text). There were suggestions to improve that with a 'NaN' string token or not always print a 64-bit hex value, but those are independent changes. We might also consider setting/propagating the payload of NaN constants as an enhancement.


https://reviews.llvm.org/D44308

Files:
  lib/IR/ConstantFold.cpp
  test/CodeGen/AMDGPU/skip-if-dead.ll
  test/Transforms/InstCombine/fsub.ll
  test/Transforms/InstSimplify/fp-undef.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44308.137752.patch
Type: text/x-patch
Size: 11969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180309/0f1121b3/attachment.bin>


More information about the llvm-commits mailing list