aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSandra Loosemore <sloosemore@baylibre.com>2025-02-09 21:34:34 +0000
committerSandra Loosemore <sloosemore@baylibre.com>2025-02-11 17:04:48 +0000
commit84854ce5b84c86aed23016de5ca05372bc7fa7cf (patch)
treeebb3da1284719aa012562fee33e4268a4532cdbc /gcc
parent4abac2ffdb071ca9337e4f31fa79cd38df1ac7c3 (diff)
downloadgcc-84854ce5b84c86aed23016de5ca05372bc7fa7cf.zip
gcc-84854ce5b84c86aed23016de5ca05372bc7fa7cf.tar.gz
gcc-84854ce5b84c86aed23016de5ca05372bc7fa7cf.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/omp-general.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc
index 2ce79bf..0d6f02e 100644
--- a/gcc/omp-general.cc
+++ b/gcc/omp-general.cc
@@ -2350,8 +2350,26 @@ omp_context_selector_props_compare (enum omp_tss_code set,
if (set == OMP_TRAIT_SET_USER
&& sel == OMP_TRAIT_USER_CONDITION)
{
- if (integer_zerop (OMP_TP_VALUE (p1))
- != integer_zerop (OMP_TP_VALUE (p2)))
+ /* Recognize constants that have equal truth values,
+ otherwise assume all expressions are unique. */
+ tree v1 = OMP_TP_VALUE (p1);
+ tree v2 = OMP_TP_VALUE (p2);
+ if (TREE_CODE (v1) != INTEGER_CST
+ || TREE_CODE (v2) != INTEGER_CST
+ || integer_zerop (v1) != integer_zerop (v2))
+ return 2;
+ break;
+ }
+ if (set == OMP_TRAIT_SET_TARGET_DEVICE
+ && sel == OMP_TRAIT_DEVICE_NUM)
+ {
+ /* Recognize constants that have equal values,
+ otherwise assume all expressions are unique. */
+ tree v1 = OMP_TP_VALUE (p1);
+ tree v2 = OMP_TP_VALUE (p2);
+ if (TREE_CODE (v1) != INTEGER_CST
+ || TREE_CODE (v2) != INTEGER_CST
+ || tree_int_cst_compare (v1, v2) != 0)
return 2;
break;
}
@@ -2469,7 +2487,9 @@ omp_context_selector_set_compare (enum omp_tss_code set, tree ctx1, tree ctx2)
{
tree score1 = OMP_TS_SCORE (ts1);
tree score2 = OMP_TS_SCORE (ts2);
- if (score1 && score2 && !simple_cst_equal (score1, score2))
+ if ((score1 && score2 && !simple_cst_equal (score1, score2))
+ || (score1 && !score2)
+ || (!score1 && score2))
return 2;
int r = omp_context_selector_props_compare (set, OMP_TS_CODE (ts1),