This is an archive of the discontinued LLVM Phabricator instance.

[Clang][OpenMP] Add the support for floating-point variables for specific atomic clauses
ClosedPublic

Authored by tianshilei1992 on Apr 30 2022, 7:13 PM.

Details

Summary

Currently when using atomic update with floating-point variables, if
the operation is add or sub, cmpxchg, instead of atomicrmw is emitted, as
shown in [1]. In fact, about three years ago, llvm-svn: 351850 added the
support for FP operations. This patch adds the support in OpenMP as well.

[1] https://godbolt.org/z/M7b4ba9na

Diff Detail

Event Timeline

tianshilei1992 created this revision.Apr 30 2022, 7:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2022, 7:13 PM
tianshilei1992 requested review of this revision.Apr 30 2022, 7:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2022, 7:13 PM
ABataev added inline comments.May 2 2022, 5:41 AM
clang/lib/CodeGen/CGStmtOpenMP.cpp
5936–5939

Do we have a test for this? If X is not integer, I rather doubt that hasSignedIntegerRepresentation is meaningful here

tianshilei1992 added inline comments.May 2 2022, 1:54 PM
clang/lib/CodeGen/CGStmtOpenMP.cpp
5936–5939

I think you're right. How can we check if Update is signed or not?

always use UIToFP because that is the only case that UpdateVal is a ConstantInt, where we created the constant integer for ++ or -- operation.

tianshilei1992 marked an inline comment as done.May 2 2022, 3:36 PM
jdoerfert accepted this revision.May 2 2022, 4:01 PM

always use UIToFP because that is the only case that UpdateVal is a ConstantInt, where we created the constant integer for ++ or -- operation.

Makes sense. LG.

This revision is now accepted and ready to land.May 2 2022, 4:01 PM
This revision was landed with ongoing or failed builds.May 3 2022, 8:31 AM
This revision was automatically updated to reflect the committed changes.