This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Avoid unnecessary fadd for unsigned to ppcf128
ClosedPublic

Authored by qiucf on Oct 20 2020, 3:24 AM.

Details

Summary

Unsigned 32-bit or shorter integer to ppcf128 conversion are currently expanded as signed-to-double with an extra fadd to 'complement'. But on PowerPC we have native instruction to directly convert unsigned to double since ISA v2.06. This patch exploits it.


Another question about this: is it safe to change fadd ppc_fp128 to fadd double to eliminate libcall? Not all i64 integers are fully representable in double. So for those numbers in ppcf128 (lower part is not all-zero), can we only do addition for both higher parts?

Diff Detail

Event Timeline

qiucf created this revision.Oct 20 2020, 3:24 AM
qiucf requested review of this revision.Oct 20 2020, 3:24 AM
qiucf edited the summary of this revision. (Show Details)Oct 20 2020, 3:34 AM
qiucf added reviewers: uweigand, steven.zhang, kbarton, jsji, nemanjai, Restricted Project, craig.topper, kpn.

This is not PowerPC specific patch, though ppcfp128 could be expanded.

This is not PowerPC specific patch, though ppcfp128 could be expanded.

It's target-specific: no other target supports ppcfp128, and we don't "expand" other floats.

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
1638

Does the result of isOperationLegalOrCustom() actually matter here? Even if it's not legal, the UINT_TO_FP is going to be faster than the alternative.

qiucf updated this revision to Diff 300145.Oct 22 2020, 7:18 PM
qiucf marked an inline comment as done.

Always prefer UINT_TO_FP

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
1638

Ah, that's right.

efriedma added inline comments.Oct 22 2020, 8:12 PM
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
1638

With that change, I think ConvOp is just N->getOpcode()?

Also, the SIGN_EXTEND/ZERO_EXTEND isn't necessary.

qiucf updated this revision to Diff 300571.Oct 25 2020, 8:44 PM
qiucf marked an inline comment as done.

Address comments

This revision is now accepted and ready to land.Oct 29 2020, 12:28 PM
This revision was automatically updated to reflect the committed changes.