@@ -14,6 +14,16 @@ void func1() {
1414 : parallel for )
1515 for (int i = 0 ; i < 100 ; i++)
1616 ;
17+
18+ #pragma omp metadirective when(user = {condition(0)} \
19+ : parallel for ) \
20+ when (implementation = {extension (match_none)} \
21+ : parallel) default (parallel for )
22+
23+ for (int i = 0 ; i < 100 ; i++)
24+ ;
25+
26+
1727}
1828
1929// CHECK-LABEL: define dso_local void @_Z5func1v()
@@ -48,7 +58,7 @@ void func1() {
4858// CHECK-NEXT: store i32 [[INC6]], ptr [[I1]], align 4
4959// CHECK-NEXT: br label %[[FOR_COND2]], !llvm.loop [[LOOP5:![0-9]+]]
5060// CHECK: [[FOR_END7]]:
51- // CHECK-NEXT : ret void
61+ // CHECK: ret void
5262
5363void func2 () {
5464#pragma omp metadirective when(user = {condition(1)} \
@@ -69,4 +79,47 @@ void func2() {
6979// CHECK-NEXT: ret void
7080
7181
82+ void func3 () {
83+ #pragma omp metadirective when(user = {condition(0)} \
84+ : parallel for ) \
85+ when (implementation = {extension (match_none)} \
86+ : parallel) default (parallel for )
87+
88+ for (int i = 0 ; i < 100 ; i++)
89+ ;
90+
91+ }
92+
93+ // CHECK-LABEL: define dso_local void @_Z5func3v()
94+ // CHECK: entry
95+ // CHECK-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @1, i32 0, ptr @_Z5func3v.omp_outlined)
96+ // CHECK-NEXT: ret void
97+ // CHECK-NEXT: }
98+
99+ // CHECK-LABEL: define internal void @_Z5func3v.omp_outlined
100+ // CHECK-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]],
101+ // CHECK-SAME: ptr noalias noundef [[DOTBOUND_TID_:%.*]])
102+ // CHECK-NEXT: entry
103+ // CHECK-NEXT: [[GLOB_TID__ADDR:%.*]] = alloca ptr, align 8
104+ // CHECK-NEXT: [[BOUND_TID__ADDR:%.*]] = alloca ptr, align 8
105+ // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4
106+ // CHECK-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[GLOB_TID__ADDR]], align 8
107+ // CHECK-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[BOUND_TID__ADDR]], align 8
108+ // CHECK-NEXT: store i32 0, ptr [[I]], align 4
109+ // CHECK-NEXT: br label %for.cond
110+ // CHECK:for.cond:
111+ // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[I]], align 4
112+ // CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 100
113+ // CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
114+ // CHECK:for.body:
115+ // CHECK-NEXT: br label [[FOR_INC:%.*]]
116+ // CHECK:for.inc:
117+ // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[I]], align 4
118+ // CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP1]], 1
119+ // CHECK-NEXT: store i32 [[INC]], ptr [[I]], align 4
120+ // CHECK-NEXT: br label [[FOR_COND:%.*]]
121+ // CHECK:for.end:
122+ // CHECK-NEXT: ret void
123+ // CHECK-NEXT:}
124+
72125#endif
0 commit comments