[PATCH] D61917: [IR] allow fast-math-flags on select of FP values
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 09:45:47 PDT 2019
spatel added a comment.
In D61917#1510408 <https://reviews.llvm.org/D61917#1510408>, @hfinkel wrote:
> Just to make sure that I understand the general direction here: We want to make all fast-math flags apply only to inputs, not outputs, and so we're going to end up adding fast-math flags on all instructions that might take floating-point inputs?
I think we want to have FMF apply to the value itself. That should allow removing FMF from fcmp by adjusting our analysis/pattern matching to detect the FMF on fcmp's operands. That would simplify the definition of FPMathOperator too - if it's an FP value (produces an FP value), it's an FPMO. To make that complete, I think we'd eventually allow adding FMF as an attribute to FP function arguments.
Some motivating examples:
define float @PR39535(float %x) {
%cmp = fcmp nsz oeq float %x, 0.0 ; 'nsz' behavior is implicit in any fcmp, so this is strange
%cond = select i1 %cmp, float %x, float 0.0 ; if this has 'nsz', we can simplify to '0.0' because both arms of the select are the same
ret float %cond
}
define i1 @orderedLessZeroUIToFP_nnan(i32 %x) {
%a = uitofp i32 %x to float ; if this has 'nnan', the result is a number and >=0.0 (the fcmp must be true)
%uge = fcmp nnan oge float %a, 0.000000e+00
ret i1 %uge
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61917/new/
https://reviews.llvm.org/D61917
More information about the llvm-commits
mailing list