This is an archive of the discontinued LLVM Phabricator instance.

[clang] Support vectors in __builtin_isfpclass
ClosedPublic

Authored by sepavloff on Jun 20 2023, 6:33 AM.

Details

Summary

Builtin function __builtin_isfpclass now can be called for a vector
of floating-point values. In this case it is applied to the vector
elementwise and produces vector of boolean values.

Diff Detail

Event Timeline

sepavloff created this revision.Jun 20 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 6:33 AM
sepavloff requested review of this revision.Jun 20 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 20 2023, 6:33 AM
Herald added a subscriber: wdng. · View Herald Transcript

This seems reasonable to me, but I do wonder if changing the return type from int to bool will cause surprises for anyone. I see why it's done, but this seems more like a C interface (to me) which would return an int; returning a bool gets promoted to int when you sneeze near it, so I wonder about performance implications. But at the same time, we wouldn't want a vector of ints returns in the vector case, I would suspect.

sepavloff updated this revision to Diff 553908.Aug 28 2023, 6:21 AM

Use representation of logical vectors similar to OpenCL

This seems reasonable to me, but I do wonder if changing the return type from int to bool will cause surprises for anyone. I see why it's done, but this seems more like a C interface (to me) which would return an int; returning a bool gets promoted to int when you sneeze near it, so I wonder about performance implications. But at the same time, we wouldn't want a vector of ints returns in the vector case, I would suspect.

The new implementation uses the representation close to OpenCL, when it makes result of comparisons: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#operators-relational. It is a vector of integers, where each element is of the same bit size as the source vector element. They must be already supported by the codegen.

sepavloff updated this revision to Diff 553960.Aug 28 2023, 9:06 AM

Fix documentation

aaron.ballman accepted this revision.Aug 29 2023, 7:27 AM

Changes LGTM, but should come with a release note.

clang/docs/LanguageExtensions.rst
3543–3546
This revision is now accepted and ready to land.Aug 29 2023, 7:27 AM
sepavloff updated this revision to Diff 554750.Aug 30 2023, 9:17 AM

Update documentation

This revision was landed with ongoing or failed builds.Sep 1 2023, 9:54 PM
This revision was automatically updated to reflect the committed changes.