[PATCH] D106959: [PowerPC] swdiv builtins for XL compatibility
Quinn Pham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 24 07:36:29 PDT 2021
quinnp added inline comments.
================
Comment at: llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll:36
+; CHECK-NEXT: %2 = fdiv fast float %0, %1
+; CHECK-NEXT: %3 = fcmp une float %2, %2
+; CHECK-NEXT: br i1 %3, label %swdiv_HWDIV, label %swdiv_MERGE
----------------
efriedma wrote:
> quinnp wrote:
> > efriedma wrote:
> > > A "fast" fdiv never produces NaN, per LangRef. Using fcmp like this is fragile at best.
> > >
> > > (Maybe you want "fdiv arcp"?)
> > Thank you, I see what you mean. I have changed it to emit a `fdiv ninf arcp` instead of a `fdiv fast`. I included the `ninf` flag because without it the compiler doesn't produce the software div estimate.
> ninf is also an issue, although maybe less likely to bite in practice. Consider what happens if someone passes infinity to swdivs: the fdiv reduces to poison, so the branch is undefined behavior.
We've decided to emit an `fdiv` without any fast math flags for these builtins. This will be safe and will emit the software estimate for `-Ofast`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106959/new/
https://reviews.llvm.org/D106959
More information about the llvm-commits
mailing list