mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 03:46:53 -05:00
As the testcase shows, a missing unshare_expr caused that the condition was only evaluated once instead of every time when a 'declare variant' was resolved. PR middle-end/121922 gcc/ChangeLog: * omp-general.cc (omp_dynamic_cond): Use 'unshare_expr' for the user condition. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/declare-variant-1.c: New test. Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com>
41 lines
681 B
C
41 lines
681 B
C
/* { dg-do run } */
|
|
/* { dg-additional-options "-fdump-tree-gimple" } */
|
|
|
|
/* PR middle-end/121922 */
|
|
|
|
/* Failed to re-check the global flag due to tree sharing. */
|
|
|
|
extern int flag;
|
|
int flag = 0;
|
|
|
|
int
|
|
test_with_flag ()
|
|
{
|
|
return flag;
|
|
}
|
|
|
|
#pragma omp declare variant (test_with_flag) match (user={condition(score(10): flag > 1)})
|
|
int
|
|
test ()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void
|
|
doit ()
|
|
{
|
|
flag = 0;
|
|
if (test () != 0) __builtin_abort ();
|
|
flag = 1;
|
|
if (test () != 0) __builtin_abort ();
|
|
flag = 42;
|
|
if (test () != 42) __builtin_abort ();
|
|
}
|
|
|
|
int main ()
|
|
{
|
|
doit ();
|
|
}
|
|
|
|
/* { dg-final { scan-tree-dump-times "flag\\.\[^=\]*= flag;\[\n\r\]+ *if \\(flag\\.\[^>\]*> 1\\)" 3 "gimple" } } */
|