Skip to content

Commit 84854ce

Browse files
author
Sandra Loosemore
committed
OpenMP: Bug fixes for comparing context selectors
gcc/ChangeLog * omp-general.cc (omp_context_selector_props_compare): Handle arbitrary expressions in the "user" and "device_num" selectors. (omp_context_selector_set_compare): Detect mismatch when one selector specifies a score and the other doesn't.
1 parent 4abac2f commit 84854ce

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

gcc/omp-general.cc

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,8 +2350,26 @@ omp_context_selector_props_compare (enum omp_tss_code set,
23502350
if (set == OMP_TRAIT_SET_USER
23512351
&& sel == OMP_TRAIT_USER_CONDITION)
23522352
{
2353-
if (integer_zerop (OMP_TP_VALUE (p1))
2354-
!= integer_zerop (OMP_TP_VALUE (p2)))
2353+
/* Recognize constants that have equal truth values,
2354+
otherwise assume all expressions are unique. */
2355+
tree v1 = OMP_TP_VALUE (p1);
2356+
tree v2 = OMP_TP_VALUE (p2);
2357+
if (TREE_CODE (v1) != INTEGER_CST
2358+
|| TREE_CODE (v2) != INTEGER_CST
2359+
|| integer_zerop (v1) != integer_zerop (v2))
2360+
return 2;
2361+
break;
2362+
}
2363+
if (set == OMP_TRAIT_SET_TARGET_DEVICE
2364+
&& sel == OMP_TRAIT_DEVICE_NUM)
2365+
{
2366+
/* Recognize constants that have equal values,
2367+
otherwise assume all expressions are unique. */
2368+
tree v1 = OMP_TP_VALUE (p1);
2369+
tree v2 = OMP_TP_VALUE (p2);
2370+
if (TREE_CODE (v1) != INTEGER_CST
2371+
|| TREE_CODE (v2) != INTEGER_CST
2372+
|| tree_int_cst_compare (v1, v2) != 0)
23552373
return 2;
23562374
break;
23572375
}
@@ -2469,7 +2487,9 @@ omp_context_selector_set_compare (enum omp_tss_code set, tree ctx1, tree ctx2)
24692487
{
24702488
tree score1 = OMP_TS_SCORE (ts1);
24712489
tree score2 = OMP_TS_SCORE (ts2);
2472-
if (score1 && score2 && !simple_cst_equal (score1, score2))
2490+
if ((score1 && score2 && !simple_cst_equal (score1, score2))
2491+
|| (score1 && !score2)
2492+
|| (!score1 && score2))
24732493
return 2;
24742494

24752495
int r = omp_context_selector_props_compare (set, OMP_TS_CODE (ts1),

0 commit comments

Comments
 (0)