1a2223612SMichael Kruse // Check code generation
2*532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
3a2223612SMichael Kruse 
4a2223612SMichael Kruse // Check same results after serialization round-trip
5*532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -emit-pch -o %t %s
6*532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -verify -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 -include-pch %t -emit-llvm %s -o - | FileCheck %s --check-prefix=IR
7a2223612SMichael Kruse // expected-no-diagnostics
8a2223612SMichael Kruse 
9a2223612SMichael Kruse #ifndef HEADER
10a2223612SMichael Kruse #define HEADER
11a2223612SMichael Kruse 
12a2223612SMichael Kruse // placeholder for loop body code.
body(...)13a2223612SMichael Kruse extern "C" void body(...) {}
14a2223612SMichael Kruse 
15a2223612SMichael Kruse 
16a2223612SMichael Kruse // IR-LABEL: @func(
17a2223612SMichael Kruse // IR-NEXT:  [[ENTRY:.*]]:
18a2223612SMichael Kruse // IR-NEXT:    %[[I:.+]] = alloca i32, align 4
19a2223612SMichael Kruse // IR-NEXT:    store i32 7, i32* %[[I]], align 4
20a2223612SMichael Kruse // IR-NEXT:    br label %[[FOR_COND:.+]]
21a2223612SMichael Kruse // IR-EMPTY:
22a2223612SMichael Kruse // IR-NEXT:  [[FOR_COND]]:
23a2223612SMichael Kruse // IR-NEXT:    %[[TMP0:.+]] = load i32, i32* %[[I]], align 4
24a2223612SMichael Kruse // IR-NEXT:    %[[CMP:.+]] = icmp slt i32 %[[TMP0]], 17
25a2223612SMichael Kruse // IR-NEXT:    br i1 %[[CMP]], label %[[FOR_BODY:.+]], label %[[FOR_END:.+]]
26a2223612SMichael Kruse // IR-EMPTY:
27a2223612SMichael Kruse // IR-NEXT:  [[FOR_BODY]]:
28a2223612SMichael Kruse // IR-NEXT:    %[[TMP1:.+]] = load i32, i32* %[[I]], align 4
291b1c8d83Shyeongyu kim // IR-NEXT:    call void (...) @body(i32 noundef %[[TMP1]])
30a2223612SMichael Kruse // IR-NEXT:    br label %[[FOR_INC:.+]]
31a2223612SMichael Kruse // IR-EMPTY:
32a2223612SMichael Kruse // IR-NEXT:  [[FOR_INC]]:
33a2223612SMichael Kruse // IR-NEXT:    %[[TMP2:.+]] = load i32, i32* %[[I]], align 4
34a2223612SMichael Kruse // IR-NEXT:    %[[ADD:.+]] = add nsw i32 %[[TMP2]], 3
35a2223612SMichael Kruse // IR-NEXT:    store i32 %[[ADD]], i32* %[[I]], align 4
36a2223612SMichael Kruse // IR-NEXT:    br label %[[FOR_COND]], !llvm.loop ![[LOOP2:[0-9]+]]
37a2223612SMichael Kruse // IR-EMPTY:
38a2223612SMichael Kruse // IR-NEXT:  [[FOR_END]]:
39a2223612SMichael Kruse // IR-NEXT:    ret void
40a2223612SMichael Kruse // IR-NEXT:  }
func()41a2223612SMichael Kruse extern "C" void func() {
42a2223612SMichael Kruse   #pragma omp unroll full
43a2223612SMichael Kruse   for (int i = 7; i < 17; i += 3)
44a2223612SMichael Kruse     body(i);
45a2223612SMichael Kruse }
46a2223612SMichael Kruse 
47a2223612SMichael Kruse #endif /* HEADER */
48a2223612SMichael Kruse 
49a2223612SMichael Kruse 
50a2223612SMichael Kruse // IR: ![[LOOP2]] = distinct !{![[LOOP2]], ![[LOOPPROP3:[0-9]+]], ![[LOOPPROP4:[0-9]+]]}
51a2223612SMichael Kruse // IR: ![[LOOPPROP3]] = !{!"llvm.loop.mustprogress"}
52a2223612SMichael Kruse // IR: ![[LOOPPROP4]] = !{!"llvm.loop.unroll.full"}
53