small fixes to the hierarchical barrier

llvm-svn: 225793
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp
index cbd1edd..79cfd3a 100644
--- a/openmp/runtime/src/kmp_barrier.cpp
+++ b/openmp/runtime/src/kmp_barrier.cpp
@@ -834,6 +834,9 @@
         KA_TRACE(20, ("__kmp_hierarchical_barrier_gather: T#%d(%d:%d) set team %d arrived(%p) = %u\n",
                       gtid, team->t.t_id, tid, team->t.t_id, &team->t.t_bar[bt].b_arrived, team->t.t_bar[bt].b_arrived));
     }
+    // If nested, but outer level is top-level, resume use of oncore optimization
+    if (this_thr->th.th_team->t.t_level <=2) thr_bar->use_oncore_barrier = 1;
+    else thr_bar->use_oncore_barrier = 0;
     // Is the team access below unsafe or just technically invalid?
     KA_TRACE(20, ("__kmp_hierarchical_barrier_gather: T#%d(%d:%d) exit for barrier type %d\n",
                   gtid, team->t.t_id, tid, bt));
@@ -896,7 +899,7 @@
         KMP_MB();  // Flush all pending memory write invalidates.
     }
 
-    if (this_thr->th.th_team->t.t_level == 1) thr_bar->use_oncore_barrier = 1;
+    if (this_thr->th.th_team->t.t_level <= 1) thr_bar->use_oncore_barrier = 1;
     else thr_bar->use_oncore_barrier = 0;
     nproc = this_thr->th.th_team_nproc;