1 ; RUN: opt -S -ipconstprop < %s | FileCheck %s
3 ; void bar(int, float, double);
10 ; #pragma omp parallel for firstprivate(q)
11 ; for (int i = 2; i < N; i++) {
16 ; Verify the constant value of q is propagated into the outlined function.
18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20 %struct.ident_t = type { i32, i32, i32, i32, i8* }
22 @.str = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
23 @0 = private unnamed_addr global %struct.ident_t { i32 0, i32 514, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0) }, align 8
24 @1 = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0) }, align 8
26 define dso_local void @foo(i32 %N) {
28 %N.addr = alloca i32, align 4
29 %p = alloca float, align 4
30 store i32 %N, i32* %N.addr, align 4
31 store float 3.000000e+00, float* %p, align 4
32 store i32 7, i32* %N.addr, align 4
33 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @1, i32 3, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*, float*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), i32* nonnull %N.addr, float* nonnull %p, i64 4617315517961601024)
37 define internal void @.omp_outlined.(i32* noalias %.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) %N, float* dereferenceable(4) %p, i64 %q) {
39 %q.addr = alloca i64, align 8
40 %.omp.lb = alloca i32, align 4
41 %.omp.ub = alloca i32, align 4
42 %.omp.stride = alloca i32, align 4
43 %.omp.is_last = alloca i32, align 4
44 ; CHECK: store i64 4617315517961601024, i64* %q.addr, align 8
45 store i64 %q, i64* %q.addr, align 8
46 %conv = bitcast i64* %q.addr to double*
47 %tmp = load i32, i32* %N, align 4
48 %sub3 = add nsw i32 %tmp, -3
49 %cmp = icmp sgt i32 %tmp, 2
50 br i1 %cmp, label %omp.precond.then, label %omp.precond.end
52 omp.precond.then: ; preds = %entry
53 store i32 0, i32* %.omp.lb, align 4
54 store i32 %sub3, i32* %.omp.ub, align 4
55 store i32 1, i32* %.omp.stride, align 4
56 store i32 0, i32* %.omp.is_last, align 4
57 %tmp5 = load i32, i32* %.global_tid., align 4
58 call void @__kmpc_for_static_init_4(%struct.ident_t* nonnull @0, i32 %tmp5, i32 34, i32* nonnull %.omp.is_last, i32* nonnull %.omp.lb, i32* nonnull %.omp.ub, i32* nonnull %.omp.stride, i32 1, i32 1)
59 %tmp6 = load i32, i32* %.omp.ub, align 4
60 %cmp6 = icmp sgt i32 %tmp6, %sub3
61 br i1 %cmp6, label %cond.true, label %cond.false
63 cond.true: ; preds = %omp.precond.then
66 cond.false: ; preds = %omp.precond.then
67 %tmp7 = load i32, i32* %.omp.ub, align 4
70 cond.end: ; preds = %cond.false, %cond.true
71 %cond = phi i32 [ %sub3, %cond.true ], [ %tmp7, %cond.false ]
72 store i32 %cond, i32* %.omp.ub, align 4
73 %tmp8 = load i32, i32* %.omp.lb, align 4
74 br label %omp.inner.for.cond
76 omp.inner.for.cond: ; preds = %omp.inner.for.inc, %cond.end
77 %.omp.iv.0 = phi i32 [ %tmp8, %cond.end ], [ %add11, %omp.inner.for.inc ]
78 %tmp9 = load i32, i32* %.omp.ub, align 4
79 %cmp8 = icmp sgt i32 %.omp.iv.0, %tmp9
80 br i1 %cmp8, label %omp.inner.for.cond.cleanup, label %omp.inner.for.body
82 omp.inner.for.cond.cleanup: ; preds = %omp.inner.for.cond
83 br label %omp.inner.for.end
85 omp.inner.for.body: ; preds = %omp.inner.for.cond
86 %add10 = add nsw i32 %.omp.iv.0, 2
87 %tmp10 = load float, float* %p, align 4
88 %tmp11 = load double, double* %conv, align 8
89 call void @bar(i32 %add10, float %tmp10, double %tmp11)
90 br label %omp.body.continue
92 omp.body.continue: ; preds = %omp.inner.for.body
93 br label %omp.inner.for.inc
95 omp.inner.for.inc: ; preds = %omp.body.continue
96 %add11 = add nsw i32 %.omp.iv.0, 1
97 br label %omp.inner.for.cond
99 omp.inner.for.end: ; preds = %omp.inner.for.cond.cleanup
100 br label %omp.loop.exit
102 omp.loop.exit: ; preds = %omp.inner.for.end
103 %tmp12 = load i32, i32* %.global_tid., align 4
104 call void @__kmpc_for_static_fini(%struct.ident_t* nonnull @0, i32 %tmp12)
105 br label %omp.precond.end
107 omp.precond.end: ; preds = %omp.loop.exit, %entry
111 declare dso_local void @__kmpc_for_static_init_4(%struct.ident_t*, i32, i32, i32*, i32*, i32*, i32*, i32, i32)
113 declare dso_local void @bar(i32, float, double)
115 declare dso_local void @__kmpc_for_static_fini(%struct.ident_t*, i32)
117 declare !callback !0 dso_local void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
119 !1 = !{i64 2, i64 -1, i64 -1, i1 true}