[PATCH] D101727: Fix PR47960 - Incorrect transformation of fabs with nnan flag

Krishna Kariya via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 4 05:12:24 PDT 2021


Krishnakariya updated this revision to Diff 356374.
Krishnakariya added a comment.

In D101727#2832971 <https://reviews.llvm.org/D101727#2832971>, @spatel wrote:

> I'm confused. This patch started by just switching the FMF propagation source from the fneg/fsub to the select. Now, we are back to taking flags from fneg and then intersecting some flags from the select.
>
> But this approach has known bugs, as you have shown in the new Alive2 example. Why is this version of the patch better than just propagating all flags from the select?

I am sorry for the confusion. This version has few issues which were detected by Alive2. So, I have made new changes as follows:

1. flags are propagated if present in select instruction.
2. FSub logic: Removed the check for nnan's flag presence in fsub instruction for doing the optimization. Example: https://alive2.llvm.org/ce/z/tYeZub (fsub).
3. FNeg logic: Instead of checking the presence of nnan and nsz flag in fneg instruction, added a check for nsz instruction in select instruction. Example: https://alive2.llvm.org/ce/z/TbuLnk (fneg), https://alive2.llvm.org/ce/z/yBDCZ_ (fsub).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101727/new/

https://reviews.llvm.org/D101727

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/fabs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101727.356374.patch
Type: text/x-patch
Size: 27876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210704/97a8a10c/attachment.bin>


More information about the llvm-commits mailing list