[Libomptarget] Add branch prediction intrinsic to state check
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 20 May 2022 19:37:55 +0000 (15:37 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Fri, 20 May 2022 19:38:54 +0000 (15:38 -0400)
Summary:
We usually used the `OMP_LIKELY` and `OMP_UNLIKELY` macros to add branch
prediction intrinsics to help the optimizer ignore unlikely loops. This
wasn't applied to this one loop so add that in.

openmp/libomptarget/DeviceRTL/src/State.cpp

index f299aa0..c891063 100644 (file)
@@ -289,7 +289,7 @@ uint32_t &lookupForModify32Impl(uint32_t ICVStateTy::*Var, IdentTy *Ident) {
                  TeamState.ICVState.LevelVar == 0))
     return TeamState.ICVState.*Var;
   uint32_t TId = mapping::getThreadIdInBlock();
-  if (!ThreadStates[TId]) {
+  if (OMP_UNLIKELY(!ThreadStates[TId])) {
     ThreadStates[TId] = reinterpret_cast<ThreadStateTy *>(memory::allocGlobal(
         sizeof(ThreadStateTy), "ICV modification outside data environment"));
     ASSERT(ThreadStates[TId] != nullptr && "Nullptr returned by malloc!");