@@ -13924,8 +13924,10 @@ lower_omp_ordered (gimple_stmt_iterator
gomp_ordered *ord_stmt = as_a <gomp_ordered *> (stmt);
gcall *x;
gbind *bind;
- bool simd
- = find_omp_clause (gimple_omp_ordered_clauses (ord_stmt), OMP_CLAUSE_SIMD);
+ bool simd = find_omp_clause (gimple_omp_ordered_clauses (ord_stmt),
+ OMP_CLAUSE_SIMD);
+ bool threads = find_omp_clause (gimple_omp_ordered_clauses (ord_stmt),
+ OMP_CLAUSE_THREADS);
if (find_omp_clause (gimple_omp_ordered_clauses (ord_stmt),
OMP_CLAUSE_DEPEND))
@@ -13948,7 +13950,8 @@ lower_omp_ordered (gimple_stmt_iterator
if (simd)
{
- x = gimple_build_call_internal (IFN_GOMP_SIMD_ORDERED_START, 0);
+ x = gimple_build_call_internal (IFN_GOMP_SIMD_ORDERED_START, 1,
+ build_int_cst (NULL_TREE, threads));
cfun->has_simduid_loops = true;
}
else
@@ -13962,7 +13965,8 @@ lower_omp_ordered (gimple_stmt_iterator
gimple_omp_set_body (stmt, NULL);
if (simd)
- x = gimple_build_call_internal (IFN_GOMP_SIMD_ORDERED_END, 0);
+ x = gimple_build_call_internal (IFN_GOMP_SIMD_ORDERED_END, 1,
+ build_int_cst (NULL_TREE, threads));
else
x = gimple_build_call (builtin_decl_explicit (BUILT_IN_GOMP_ORDERED_END),
0);
@@ -177,6 +177,21 @@ adjust_simduid_builtins (hash_table<simd
break;
case IFN_GOMP_SIMD_ORDERED_START:
case IFN_GOMP_SIMD_ORDERED_END:
+ if (integer_onep (gimple_call_arg (stmt, 0)))
+ {
+ enum built_in_function bcode
+ = (ifn == IFN_GOMP_SIMD_ORDERED_START
+ ? BUILT_IN_GOMP_ORDERED_START
+ : BUILT_IN_GOMP_ORDERED_END);
+ gimple *g
+ = gimple_build_call (builtin_decl_explicit (bcode), 0);
+ tree vdef = gimple_vdef (stmt);
+ gimple_set_vdef (g, vdef);
+ SSA_NAME_DEF_STMT (vdef) = g;
+ gimple_set_vuse (g, gimple_vuse (stmt));
+ gsi_replace (&i, g, true);
+ continue;
+ }
gsi_remove (&i, true);
unlink_stmt_vdef (stmt);
continue;
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+extern void abort (void);
+int a[1024], b = -1;
+
+int
+main ()
+{
+ int i;
+ #pragma omp parallel for simd ordered
+ for (i = 0; i < 1024; i++)
+ {
+ a[i] = i;
+ #pragma omp ordered threads simd
+ {
+ if (b + 1 != i)
+ abort ();
+ b = i;
+ }
+ a[i] += 3;
+ }
+ if (b != 1023)
+ abort ();
+ for (i = 0; i < 1024; i++)
+ if (a[i] != i + 3)
+ abort ();
+ return 0;
+}