This patch is in a series of patches to provide builtins for compatibility with
the XL compiler. This patch implements the software divide builtin as
wrappers for a floating point divide. XL provided these builtins because it
didn't produce software estimates by default at -Ofast. When compiled
with -Ofast these builtins will produce the software estimate for divide.
Details
- Reviewers
nemanjai stefanp - Group Reviewers
Restricted Project - Commits
- rG67a3d1e27551: [PowerPC] swdiv builtins for XL compatibility
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll | ||
---|---|---|
36 ↗ | (On Diff #362400) | A "fast" fdiv never produces NaN, per LangRef. Using fcmp like this is fragile at best. (Maybe you want "fdiv arcp"?) |
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll | ||
---|---|---|
36 ↗ | (On Diff #362400) | 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. |
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll | ||
---|---|---|
36 ↗ | (On Diff #362400) | 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. |
llvm/include/llvm/IR/IntrinsicsPowerPC.td | ||
---|---|---|
1436 ↗ | (On Diff #363189) | Line too long? |
1724 ↗ | (On Diff #363189) | Minor indentation nit. |
1727 ↗ | (On Diff #363189) | Minor indentation nit. |
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | ||
451 ↗ | (On Diff #363189) | Nit: Add a comment before creating the pass as the other pass calls also follow a comment. |
Updating the patch to emit a fdiv for each of the builtins without any fast math flags. This will be safe and will still emit a software estimate when -Ofast is used.
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll | ||
---|---|---|
36 ↗ | (On Diff #362400) | 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. |
Do we already have a backend test case for fdiv emitting a software estimate when -Ofast is used?
Added a backend testcase which goes from fdiv fast to software estimate. Added a runline in the front end testcase that sets the fast math flags.
I've added a testcase in llvm/test/CodeGen/PowerPC/fdiv.ll which goes from fdiv fast to the assembly for the software divide estimate.
LGTM. Please note in the commit message that this is simply a wrapper for a floating point divide. XL provided this builtin because it doesn't produce software estimates by default at -Ofast.
nit: alignment with CHECKs below. Same for the other test cases.