[PATCH] D121243: [InstCombine] Preserve FMF in foldLogicOfFCmps.
Nuno Lopes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 8 14:15:25 PST 2022
nlopes added a comment.
In D121243#3368365 <https://reviews.llvm.org/D121243#3368365>, @nlopes wrote:
>> For this transform only -- because we are guaranteed to repeat the values in each fcmp -- I was expecting that we could 'or' the relevant flags. But there's a surprising corner case with `true` and `false` fcmp predicates according to Alive2:
>> https://alive2.llvm.org/ce/z/Nffn3L
>>
>> The behavior -- blocking poison via predicate? -- does not seem to be documented in the LangRef.
>
> oops, that seems to be a bug in Alive2.
> We convert `fcmp true` to `true`, but that is wrong as we lose the fast-math flags. Let me fix that.
Fixed (not poison anymore):
define i1 @src(double %a, double %b) {
%0:
%cmp = fcmp ninf true double %a, %b
%cmp1 = fcmp nnan oge double %a, %b
%retval = and i1 %cmp, %cmp1
ret i1 %retval
}
=>
define i1 @tgt(double %a, double %b) {
%0:
%r = fcmp nnan ninf oeq double %a, %b
ret i1 %r
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
double %a = #x0015250a74408022 (0.000000000000?)
double %b = #x88018b0635082009 (-0.000000000000?)
Source:
i1 %cmp = #x1 (1)
i1 %cmp1 = #x1 (1)
i1 %retval = #x1 (1)
Target:
i1 %r = #x0 (0)
Source value: #x1 (1)
Target value: #x0 (0)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121243/new/
https://reviews.llvm.org/D121243
More information about the llvm-commits
mailing list