[PATCH] D116952: [ConstantFolding] Respect denormal handling mode attributes when folding instructions
Nuno Lopes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 09:26:55 PDT 2022
nlopes added a comment.
In D116952#3601819 <https://reviews.llvm.org/D116952#3601819>, @shchenz wrote:
> In D116952#3601629 <https://reviews.llvm.org/D116952#3601629>, @nlopes wrote:
>
>> In D116952#3600716 <https://reviews.llvm.org/D116952#3600716>, @shchenz wrote:
>>
>>> define zeroext i1 @foo() #0 {
>>> %_add = fadd fast double 1.264810e-321, 3.789480e-321
>>> %_res = fcmp fast une double %_add, 5.054290e-321
>>> ret i1 %_res
>>> }
>>>
>>> attributes #0 = { "denormal-fp-math"="positive-zero" }
>>>
>>> llc 1.ll -mtriple=powerpc64le-unknown-linux-gnu
>>>
>>> Hi, this patch causes mis-compile for above case, now `%_res` is true while before this patch it is false. We can not handle the denormal constantFP in fcmp? Will the denormal constantFP be in other opcodes as well?
>>
>> Alive says that LLVM is correct:
>>
>> define i1 @foo() denormal-fp-math=positive-zero,positive-zero {
>> %_add = fadd double 0.000000, 0.000000, exceptions=ignore
>> %_res = fcmp une double %_add, 0.000000
>> ret i1 %_res
>> }
>> =>
>> define i1 @foo() noread nowrite nofree willreturn denormal-fp-math=positive-zero,positive-zero {
>> ret i1 1
>> }
>> Transformation seems to be correct!
>
> Alive 2 says "ERROR: Couldn't prove the correctness of the transformation"...
>
> https://alive2.llvm.org/ce/z/GPLj4Z
The online version is outdated, sorry.
> And from the semantic of the case, `%_add` not equal to `5.054290e-321` should be wrong, (1.264810e-321 + 3.789480e-321 == 5.054290e-321), so we should expect `false` here?
%_add = #x00000000000003ff
Which is a subnormal, so per the function attribute it is changed to +0.0.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116952/new/
https://reviews.llvm.org/D116952
More information about the llvm-commits
mailing list