[PATCH] D101727: Fix PR47960 - Incorrect transformation of fabs with nnan flag
Krishna Kariya via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 3 08:41:17 PDT 2021
Krishnakariya updated this revision to Diff 349553.
Krishnakariya marked 2 inline comments as done.
Krishnakariya added a comment.
I have made changes in FMF propagation logic.
FMF like nnan and ninf should be propagated only if present in select instruction, while for other flags like arcp, reassoc, it doesn't really depend on select instruction.
Another thing that I want to point out is that after dropping nnan flag, the below test encounters an error.
Example link: https://alive2.llvm.org/ce/z/YEcHxG
define double @select_fcmp_nnan_nsz_olt_zero(double %x) {
%0:
%ltzero = fcmp olt double %x, 0.000000
%negx = fsub nnan nsz double -0.000000, %x
%fabs = select i1 %ltzero, double %negx, double %x
ret double %fabs
}
=>
define double @select_fcmp_nnan_nsz_olt_zero(double %x) {
%0:
%1 = fabs nsz double %x
ret double %1
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
double %x = #x8000000000000000 (-0.0)
Source:
i1 %ltzero = #x0 (0)
double %negx = #x0000000000000000 (+0.0)
double %fabs = #x8000000000000000 (-0.0)
Target:
double %1 = #x0000000000000000 (+0.0)
Source value: #x8000000000000000 (-0.0)
Target value: #x0000000000000000 (+0.0)
Repository:
rG LLVM Github Monorepo
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.349553.patch
Type: text/x-patch
Size: 18706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/8e65b92d/attachment.bin>
More information about the llvm-commits
mailing list