This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Test for infinity in testFPKind().
ClosedPublic

Authored by jonpa on Mar 3 2021, 6:03 PM.

Details

Summary

Recognize builtin_isinf and BIbuiltin_isfinite (and a few other builtin opcodes for finite checks) in testFPKind().

TDC can check for infinity, and for finite with an inversion of the result.

'finite', '__finite', ... seemed to always work as double with extension/trunction from float/long double. I would guess it is expected to handle those as well with TDC, or?

Diff Detail

Event Timeline

jonpa requested review of this revision.Mar 3 2021, 6:03 PM
jonpa created this revision.
jonpa added inline comments.Mar 3 2021, 6:04 PM
clang/lib/CodeGen/TargetInfo.cpp
7228

What are these variants all about...?

thopre added inline comments.Mar 4 2021, 2:14 AM
clang/lib/CodeGen/TargetInfo.cpp
7228

They were introduced in https://reviews.llvm.org/D24483

uweigand added inline comments.Mar 4 2021, 3:55 AM
clang/lib/CodeGen/TargetInfo.cpp
7228

This "invert" logic doesn't look correct. "isfinite" and "isinf" both need to return false on NaNs. I think you should just drop the invert logic and use a TDC mask of 0xFC0 (zero, normal, or subnormal) to implement "isfinite".

thopre added inline comments.Mar 4 2021, 4:02 AM
clang/lib/CodeGen/TargetInfo.cpp
7228

My bad, I made the same mistake in https://reviews.llvm.org/D97125. I'll revert for now and will notify this review once I've got it fixed.

thopre added inline comments.Mar 4 2021, 7:42 AM
clang/lib/CodeGen/TargetInfo.cpp
7228

I've fixed https://reviews.llvm.org/D97125 and added some isfinite cases.. Thanks @uweigand for pointing the NaN case.

jonpa updated this revision to Diff 330753.Mar 15 2021, 11:59 AM

This "invert" logic doesn't look correct. "isfinite" and "isinf" both need to return false on NaNs. I think you should just drop the invert logic and use a TDC mask of 0xFC0 (zero, normal, or subnormal) to implement "isfinite".

Rebased and updated per review.

uweigand accepted this revision.Mar 15 2021, 1:40 PM

LGTM, thanks!

This revision is now accepted and ready to land.Mar 15 2021, 1:40 PM
This revision was landed with ongoing or failed builds.Mar 15 2021, 2:04 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2021, 2:04 PM