Page MenuHomePhabricator

[PowerPC] swdiv builtins for XL compatibility
Needs ReviewPublic

Authored by quinnp on Jul 28 2021, 7:22 AM.

Details

Reviewers
nemanjai
stefanp
Group Reviewers
Restricted Project
Summary

This patch is in a series of patches to provide builtins for compatibility with
the XL compiler. This patch adds software divide builtins with checking.

Diff Detail

Event Timeline

quinnp created this revision.Jul 28 2021, 7:22 AM
quinnp requested review of this revision.Jul 28 2021, 7:22 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 28 2021, 7:22 AM
quinnp added reviewers: Restricted Project, nemanjai, stefanp.Jul 28 2021, 7:25 AM
quinnp retitled this revision from [PowerPC] swdiv builtins for XL compatibility] to [PowerPC] swdiv builtins for XL compatibility.
quinnp updated this revision to Diff 362400.Jul 28 2021, 8:28 AM

Fixing a failing test case.

efriedma added inline comments.
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll
37

A "fast" fdiv never produces NaN, per LangRef. Using fcmp like this is fragile at best.

(Maybe you want "fdiv arcp"?)

NeHuang added inline comments.
llvm/test/CodeGen/PowerPC/O3-pipeline.ll
211

unrelated change?

llvm/test/CodeGen/PowerPC/int-ppc-ftdivdp.ll
8

nit: pwr7 for aix run lines

9

can we also add a run line for 64 bit AIX?

quinnp updated this revision to Diff 363189.Jul 30 2021, 1:12 PM

Addressing review comments.

quinnp marked 3 inline comments as done.Jul 30 2021, 1:13 PM
quinnp marked an inline comment as done.Jul 30 2021, 1:26 PM
quinnp added inline comments.
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll
37

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.

quinnp marked an inline comment as done.Jul 30 2021, 1:29 PM
efriedma added inline comments.Jul 30 2021, 1:39 PM
llvm/test/CodeGen/PowerPC/LowerCheckedFPArith.ll
37

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.

amyk added a subscriber: amyk.Jul 30 2021, 3:03 PM
amyk added inline comments.
llvm/include/llvm/IR/IntrinsicsPowerPC.td
1436

Line too long?

1724

Minor indentation nit.

1727

Minor indentation nit.

llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
451

Nit: Add a comment before creating the pass as the other pass calls also follow a comment.

NeHuang added inline comments.Aug 6 2021, 9:15 AM
clang/test/CodeGen/builtins-ppc-xlcompat-swdiv.c
17

nit: alignment with CHECKs below. Same for the other test cases.

llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
452

+1,