[PATCH] D116952: [ConstantFolding] Respect denormal handling mode attributes when folding instructions

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 08:21:57 PDT 2022


shchenz added a comment.

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

And from the semantic of the case, `%_res` not equal to `%_add` should be wrong, (1.264810e-321 + 3.789480e-321 == 5.054290e-321), so we should expect `false` here?


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