This is an archive of the discontinued LLVM Phabricator instance.

__builtin_signbit fix for ppcf128 type
ClosedPublic

Authored by abeserminji on Oct 28 2015, 7:50 AM.

Details

Summary

Function__builtin_signbit returns wrong value for type ppcf128 on big endian machines. This patch fixes how value is generated in that case, and generate correct value.

Diff Detail

Repository
rL LLVM

Event Timeline

abeserminji retitled this revision from to __builtin_signbit for ppcf128 type.
abeserminji updated this object.
abeserminji added reviewers: hfinkel, rjmccall.
abeserminji set the repository for this revision to rL LLVM.
abeserminji retitled this revision from __builtin_signbit for ppcf128 type to __builtin_signbit fix for ppcf128 type.Oct 28 2015, 7:56 AM
abeserminji updated this object.
abeserminji added a reviewer: petarj.
abeserminji added a subscriber: cfe-commits.
rjmccall edited edge metadata.Oct 28 2015, 10:54 AM

Just a few comment suggestions, but functionally LGTM.

lib/CodeGen/CGBuiltin.cpp
246 ↗(On Diff #38660)

Hmm, let's merge these the old and new comments a bit:

We want the sign bit of the higher-order double. The bitcast we just
did works as if the double-double was stored to memory and then
read as an i128. The "store" will put the higher-order double in the
lower address in both little- and big-Endian modes, but the "load"
will treat those bits as a different part of the i128: the low bits in
little-Endian, the high bits in big-Endian. Therefore, on big-Endian
we need to shift the high bits down to the low before truncating.

252 ↗(On Diff #38660)

Typo: dobule.

Also, we're not quite extracting the sign yet; we're truncating as a way to extract the higher-order double, which we'll extract the sign from in a second.

abeserminji edited edge metadata.

Modified comments as suggested by @rjmccall

LGTM, thanks!

abeserminji updated this revision to Diff 39513.Nov 6 2015, 4:55 AM
abeserminji marked 2 inline comments as done.

Comment modified

petarj accepted this revision.Nov 6 2015, 6:53 AM
petarj edited edge metadata.
This revision is now accepted and ready to land.Nov 6 2015, 6:53 AM
This revision was automatically updated to reflect the committed changes.