[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 07:02:21 PDT 2022


nlopes added a comment.

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!


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