| 1 |
; This LLVM IR was generated using Intel SYCL Clang compiler (https://github.com/intel/llvm) |
| 2 |
; |
| 3 |
; SYCL source code of this program can be found below. |
| 4 |
; |
| 5 |
; template<typename N, typename Func> |
| 6 |
; __attribute__((sycl_kernel)) |
| 7 |
; void kernel(Func f) { |
| 8 |
; f(); |
| 9 |
; } |
| 10 |
; |
| 11 |
; int main() { |
| 12 |
; int buf1[10], buf2[10]; |
| 13 |
; const int c = 42; |
| 14 |
; |
| 15 |
; kernel<class EmbeddedLoopTest>([=]() mutable { |
| 16 |
; [[intel::ivdep(buf1, 3)]] |
| 17 |
; for (int i = 0; i < 6; ++i) { |
| 18 |
; buf1[i] *= (buf2[i + 4] + c); |
| 19 |
; [[intel::ivdep(2)]] |
| 20 |
; for (int j = 0; j < 7; ++j) |
| 21 |
; buf2[i] *= (buf1[i] + buf2[i + 3]); |
| 22 |
; } |
| 23 |
; }); |
| 24 |
; |
| 25 |
; int *ptr1 = buf1; |
| 26 |
; int *ptr2 = buf2; |
| 27 |
; kernel<class VaryingSafelenOnPointersTest>([=]() mutable { |
| 28 |
; [[intel::ivdep(ptr1, 3)]] |
| 29 |
; [[intel::ivdep(ptr2, 2)]] |
| 30 |
; for (int i = 0; i < 6; ++i) { |
| 31 |
; ptr1[i] *= (ptr2[i + 4] + c); |
| 32 |
; ptr2[i] *= (ptr1[i] + ptr2[i + 3]); |
| 33 |
; } |
| 34 |
; }); |
| 35 |
; |
| 36 |
; return 0; |
| 37 |
; } |
| 38 |
|
| 39 |
; UNSUPPORTED: system-windows |
| 40 |
; REQUIRES: llvm-spirv, regkeys, dg2-supported |
| 41 |
|
| 42 |
; RUN: llvm-as %s -o %t.bc |
| 43 |
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_fpga_loop_controls -o %t.spv |
| 44 |
|
| 45 |
; CHECK-LLVM is the base prefix, which includes simple checks for |
| 46 |
; "llvm.loop.parallel_access_indices" MD nodes with only 1 index group operand |
| 47 |
; CHECK-LLVM-MD-OP-<N> is the group of prefixes to check for more |
| 48 |
; complicated cases of "llvm.loop.parallel_access_indices" nodes, the ones |
| 49 |
; containing multiple index group operands that could come in indeterminate order |
| 50 |
; RUN: ocloc compile -spirv_input -file %t.spv -device dg2 -options " -igc_opts 'ShaderDumpTranslationOnly=1'" 2>&1 | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-MD-OP1 |
| 51 |
; RUN: ocloc compile -spirv_input -file %t.spv -device dg2 -options " -igc_opts 'ShaderDumpTranslationOnly=1'" 2>&1 | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-MD-OP2 |
| 52 |
|
| 53 |
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" |
| 54 |
target triple = "spir64-unknown-unknown" |
| 55 |
|
| 56 |
%struct._ZTS15__wrapper_class.__wrapper_class = type { [10 x i32] } |
| 57 |
%struct._ZTS15__wrapper_class.__wrapper_class.0 = type { [10 x i32] } |
| 58 |
; CHECK-LLVM: %[[CLOSURE_NAME_EMB:"class.*"]] = type { [10 x i32], [10 x i32] } |
| 59 |
; CHECK-LLVM: %[[CLOSURE_NAME_SFLN:"class.*"]] = type { i32 addrspace(4)*, i32 addrspace(4)* } |
| 60 |
%"class._ZTSZ4mainE3$_0.anon" = type { [10 x i32], [10 x i32] } |
| 61 |
%"class._ZTSZ4mainE3$_0.anon.0" = type { i32 addrspace(4)*, i32 addrspace(4)* } |
| 62 |
|
| 63 |
; Function Attrs: convergent norecurse uwtable |
| 64 |
define dso_local spir_kernel void @_ZTSZ4mainE16EmbeddedLoopTest(%struct._ZTS15__wrapper_class.__wrapper_class* byval(%struct._ZTS15__wrapper_class.__wrapper_class) align 4 %_arg_, %struct._ZTS15__wrapper_class.__wrapper_class.0* byval(%struct._ZTS15__wrapper_class.__wrapper_class.0) align 4 %_arg_1) #0 !kernel_arg_buffer_location !4 { |
| 65 |
entry: |
| 66 |
%0 = alloca %"class._ZTSZ4mainE3$_0.anon", align 4 |
| 67 |
%1 = bitcast %"class._ZTSZ4mainE3$_0.anon"* %0 to i8* |
| 68 |
call void @llvm.lifetime.start.p0i8(i64 80, i8* %1) #3 |
| 69 |
%2 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon"* %0, i32 0, i32 0 |
| 70 |
%3 = getelementptr inbounds %struct._ZTS15__wrapper_class.__wrapper_class, %struct._ZTS15__wrapper_class.__wrapper_class* %_arg_, i32 0, i32 0 |
| 71 |
%arrayinit.begin = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0 |
| 72 |
br label %arrayinit.body |
| 73 |
|
| 74 |
arrayinit.body: ; preds = %arrayinit.body, %entry |
| 75 |
%arrayinit.index = phi i64 [ 0, %entry ], [ %arrayinit.next, %arrayinit.body ] |
| 76 |
%4 = getelementptr inbounds i32, i32* %arrayinit.begin, i64 %arrayinit.index |
| 77 |
%arrayidx = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %arrayinit.index |
| 78 |
%5 = load i32, i32* %arrayidx, align 4, !tbaa !5 |
| 79 |
store i32 %5, i32* %4, align 4, !tbaa !5 |
| 80 |
%arrayinit.next = add nuw i64 %arrayinit.index, 1 |
| 81 |
%arrayinit.done = icmp eq i64 %arrayinit.next, 10 |
| 82 |
br i1 %arrayinit.done, label %arrayinit.end, label %arrayinit.body |
| 83 |
|
| 84 |
arrayinit.end: ; preds = %arrayinit.body |
| 85 |
%6 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon"* %0, i32 0, i32 1 |
| 86 |
%7 = getelementptr inbounds %struct._ZTS15__wrapper_class.__wrapper_class.0, %struct._ZTS15__wrapper_class.__wrapper_class.0* %_arg_1, i32 0, i32 0 |
| 87 |
%arrayinit.begin2 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0 |
| 88 |
br label %arrayinit.body3 |
| 89 |
|
| 90 |
arrayinit.body3: ; preds = %arrayinit.body3, %arrayinit.end |
| 91 |
%arrayinit.index4 = phi i64 [ 0, %arrayinit.end ], [ %arrayinit.next6, %arrayinit.body3 ] |
| 92 |
%8 = getelementptr inbounds i32, i32* %arrayinit.begin2, i64 %arrayinit.index4 |
| 93 |
%arrayidx5 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %arrayinit.index4 |
| 94 |
%9 = load i32, i32* %arrayidx5, align 4, !tbaa !5 |
| 95 |
store i32 %9, i32* %8, align 4, !tbaa !5 |
| 96 |
%arrayinit.next6 = add nuw i64 %arrayinit.index4, 1 |
| 97 |
%arrayinit.done7 = icmp eq i64 %arrayinit.next6, 10 |
| 98 |
br i1 %arrayinit.done7, label %arrayinit.end8, label %arrayinit.body3 |
| 99 |
|
| 100 |
arrayinit.end8: ; preds = %arrayinit.body3 |
| 101 |
%10 = addrspacecast %"class._ZTSZ4mainE3$_0.anon"* %0 to %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* |
| 102 |
call spir_func void @"_ZZ4mainEN3$_0clEv"(%"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %10) #4 |
| 103 |
%11 = bitcast %"class._ZTSZ4mainE3$_0.anon"* %0 to i8* |
| 104 |
call void @llvm.lifetime.end.p0i8(i64 80, i8* %11) #3 |
| 105 |
ret void |
| 106 |
} |
| 107 |
|
| 108 |
; Function Attrs: argmemonly nounwind willreturn |
| 109 |
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 |
| 110 |
|
| 111 |
; CHECK-LLVM: define internal spir_func void {{.*}}(%[[CLOSURE_NAME_EMB]] addrspace(4)* %this) |
| 112 |
; Function Attrs: convergent inlinehint norecurse nounwind uwtable |
| 113 |
define internal spir_func void @"_ZZ4mainEN3$_0clEv"(%"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this) #2 align 2 { |
| 114 |
entry: |
| 115 |
; CHECK-LLVM: %this.addr = alloca %[[CLOSURE_NAME_EMB]] |
| 116 |
%this.addr = alloca %"class._ZTSZ4mainE3$_0.anon" addrspace(4)*, align 8 |
| 117 |
%i = alloca i32, align 4 |
| 118 |
%cleanup.dest.slot = alloca i32, align 4 |
| 119 |
%j = alloca i32, align 4 |
| 120 |
; CHECK-LLVM: %this1 = load %[[CLOSURE_NAME_EMB]] addrspace(4)*, %[[CLOSURE_NAME_EMB]] addrspace(4)** %this.addr |
| 121 |
store %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this, %"class._ZTSZ4mainE3$_0.anon" addrspace(4)** %this.addr, align 8, !tbaa !9 |
| 122 |
%this1 = load %"class._ZTSZ4mainE3$_0.anon" addrspace(4)*, %"class._ZTSZ4mainE3$_0.anon" addrspace(4)** %this.addr, align 8 |
| 123 |
%0 = bitcast i32* %i to i8* |
| 124 |
call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3 |
| 125 |
store i32 0, i32* %i, align 4, !tbaa !5 |
| 126 |
br label %for.cond |
| 127 |
|
| 128 |
for.cond: ; preds = %for.inc18, %entry |
| 129 |
%1 = load i32, i32* %i, align 4, !tbaa !5 |
| 130 |
%cmp = icmp slt i32 %1, 6 |
| 131 |
br i1 %cmp, label %for.body, label %for.cond.cleanup |
| 132 |
|
| 133 |
for.cond.cleanup: ; preds = %for.cond |
| 134 |
store i32 2, i32* %cleanup.dest.slot, align 4 |
| 135 |
%2 = bitcast i32* %i to i8* |
| 136 |
call void @llvm.lifetime.end.p0i8(i64 4, i8* %2) #3 |
| 137 |
br label %for.end20 |
| 138 |
|
| 139 |
for.body: ; preds = %for.cond |
| 140 |
; CHECK-LLVM: %[[BUF2_EMB_OUTER_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_EMB]], %[[CLOSURE_NAME_EMB]] addrspace(4)* %this1, i32 0, i32 1 |
| 141 |
%3 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this1, i32 0, i32 1 |
| 142 |
%4 = load i32, i32* %i, align 4, !tbaa !5 |
| 143 |
%add = add nsw i32 %4, 4 |
| 144 |
%idxprom = sext i32 %add to i64 |
| 145 |
; CHECK-LLVM-NOT: getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %[[BUF2_EMB_OUTER_CLOSURE_ACCESS]]{{.*}}, !llvm.index.group |
| 146 |
%arrayidx = getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %3, i64 0, i64 %idxprom |
| 147 |
%5 = load i32, i32 addrspace(4)* %arrayidx, align 4, !tbaa !5 |
| 148 |
%add2 = add nsw i32 %5, 42 |
| 149 |
; CHECK-LLVM: %[[BUF1_EMB_OUTER_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_EMB]], %[[CLOSURE_NAME_EMB]] addrspace(4)* %this1, i32 0, i32 0 |
| 150 |
%6 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this1, i32 0, i32 0 |
| 151 |
%7 = load i32, i32* %i, align 4, !tbaa !5 |
| 152 |
%idxprom3 = sext i32 %7 to i64 |
| 153 |
; CHECK-LLVM: getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %[[BUF1_EMB_OUTER_CLOSURE_ACCESS]]{{.*}}, !llvm.index.group ![[BUF1_EMB_OUTER_IDX_GR:[0-9]+]] |
| 154 |
%arrayidx4 = getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %6, i64 0, i64 %idxprom3, !llvm.index.group !11 |
| 155 |
%8 = load i32, i32 addrspace(4)* %arrayidx4, align 4, !tbaa !5 |
| 156 |
%mul = mul nsw i32 %8, %add2 |
| 157 |
store i32 %mul, i32 addrspace(4)* %arrayidx4, align 4, !tbaa !5 |
| 158 |
%9 = bitcast i32* %j to i8* |
| 159 |
call void @llvm.lifetime.start.p0i8(i64 4, i8* %9) #3 |
| 160 |
store i32 0, i32* %j, align 4, !tbaa !5 |
| 161 |
br label %for.cond5 |
| 162 |
|
| 163 |
for.cond5: ; preds = %for.inc, %for.body |
| 164 |
%10 = load i32, i32* %j, align 4, !tbaa !5 |
| 165 |
%cmp6 = icmp slt i32 %10, 7 |
| 166 |
br i1 %cmp6, label %for.body8, label %for.cond.cleanup7 |
| 167 |
|
| 168 |
for.cond.cleanup7: ; preds = %for.cond5 |
| 169 |
store i32 5, i32* %cleanup.dest.slot, align 4 |
| 170 |
%11 = bitcast i32* %j to i8* |
| 171 |
call void @llvm.lifetime.end.p0i8(i64 4, i8* %11) #3 |
| 172 |
br label %for.end |
| 173 |
|
| 174 |
for.body8: ; preds = %for.cond5 |
| 175 |
; CHECK-LLVM: %[[BUF1_EMB_INNER_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_EMB]], %[[CLOSURE_NAME_EMB]] addrspace(4)* %this1, i32 0, i32 0 |
| 176 |
%12 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this1, i32 0, i32 0 |
| 177 |
%13 = load i32, i32* %i, align 4, !tbaa !5 |
| 178 |
%idxprom9 = sext i32 %13 to i64 |
| 179 |
; CHECK-LLVM: getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %[[BUF1_EMB_INNER_CLOSURE_ACCESS]]{{.*}}, !llvm.index.group ![[BUF1_EMB_INNER_IDX_GR:[0-9]+]] |
| 180 |
%arrayidx10 = getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %12, i64 0, i64 %idxprom9, !llvm.index.group !12 |
| 181 |
%14 = load i32, i32 addrspace(4)* %arrayidx10, align 4, !tbaa !5 |
| 182 |
; CHECK-LLVM: %[[BUF2_EMB_INNER_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_EMB]], %[[CLOSURE_NAME_EMB]] addrspace(4)* %this1, i32 0, i32 1 |
| 183 |
%15 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this1, i32 0, i32 1 |
| 184 |
%16 = load i32, i32* %i, align 4, !tbaa !5 |
| 185 |
%add11 = add nsw i32 %16, 3 |
| 186 |
%idxprom12 = sext i32 %add11 to i64 |
| 187 |
; CHECK-LLVM: getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %[[BUF2_EMB_INNER_CLOSURE_ACCESS]]{{.*}}, !llvm.index.group ![[BUF2_EMB_INNER_IDX_GR:[0-9]+]] |
| 188 |
%arrayidx13 = getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %15, i64 0, i64 %idxprom12, !llvm.index.group !14 |
| 189 |
%17 = load i32, i32 addrspace(4)* %arrayidx13, align 4, !tbaa !5 |
| 190 |
%add14 = add nsw i32 %14, %17 |
| 191 |
; CHECK-LLVM: %[[BUF2_EMB_INNER_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_EMB]], %[[CLOSURE_NAME_EMB]] addrspace(4)* %this1, i32 0, i32 1 |
| 192 |
%18 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon", %"class._ZTSZ4mainE3$_0.anon" addrspace(4)* %this1, i32 0, i32 1 |
| 193 |
%19 = load i32, i32* %i, align 4, !tbaa !5 |
| 194 |
%idxprom15 = sext i32 %19 to i64 |
| 195 |
; CHECK-LLVM: getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %[[BUF2_EMB_INNER_CLOSURE_ACCESS]]{{.*}}, !llvm.index.group ![[BUF2_EMB_INNER_IDX_GR]] |
| 196 |
%arrayidx16 = getelementptr inbounds [10 x i32], [10 x i32] addrspace(4)* %18, i64 0, i64 %idxprom15, !llvm.index.group !14 |
| 197 |
%20 = load i32, i32 addrspace(4)* %arrayidx16, align 4, !tbaa !5 |
| 198 |
%mul17 = mul nsw i32 %20, %add14 |
| 199 |
store i32 %mul17, i32 addrspace(4)* %arrayidx16, align 4, !tbaa !5 |
| 200 |
br label %for.inc |
| 201 |
|
| 202 |
for.inc: ; preds = %for.body8 |
| 203 |
%21 = load i32, i32* %j, align 4, !tbaa !5 |
| 204 |
%inc = add nsw i32 %21, 1 |
| 205 |
store i32 %inc, i32* %j, align 4, !tbaa !5 |
| 206 |
; CHECK-LLVM: br label %{{.*}}, !llvm.loop ![[EMB_INNER_MD_LOOP:[0-9]+]] |
| 207 |
br label %for.cond5, !llvm.loop !15 |
| 208 |
|
| 209 |
for.end: ; preds = %for.cond.cleanup7 |
| 210 |
br label %for.inc18 |
| 211 |
|
| 212 |
for.inc18: ; preds = %for.end |
| 213 |
%22 = load i32, i32* %i, align 4, !tbaa !5 |
| 214 |
%inc19 = add nsw i32 %22, 1 |
| 215 |
store i32 %inc19, i32* %i, align 4, !tbaa !5 |
| 216 |
; CHECK-LLVM: br label %{{.*}}, !llvm.loop ![[EMB_OUTER_MD_LOOP:[0-9]+]] |
| 217 |
br label %for.cond, !llvm.loop !18 |
| 218 |
|
| 219 |
for.end20: ; preds = %for.cond.cleanup |
| 220 |
ret void |
| 221 |
} |
| 222 |
|
| 223 |
; Function Attrs: argmemonly nounwind willreturn |
| 224 |
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 |
| 225 |
|
| 226 |
; Function Attrs: convergent norecurse uwtable |
| 227 |
define dso_local spir_kernel void @_ZTSZ4mainE18VaryingSafelenOnPointersTest(i32 addrspace(1)* %_arg_, i32 addrspace(1)* %_arg_1) #0 !kernel_arg_buffer_location !4 { |
| 228 |
entry: |
| 229 |
%_arg_.addr = alloca i32 addrspace(1)*, align 8 |
| 230 |
%_arg_.addr2 = alloca i32 addrspace(1)*, align 8 |
| 231 |
%0 = alloca %"class._ZTSZ4mainE3$_0.anon.0", align 8 |
| 232 |
store i32 addrspace(1)* %_arg_, i32 addrspace(1)** %_arg_.addr, align 8, !tbaa !9 |
| 233 |
store i32 addrspace(1)* %_arg_1, i32 addrspace(1)** %_arg_.addr2, align 8, !tbaa !9 |
| 234 |
%1 = bitcast %"class._ZTSZ4mainE3$_0.anon.0"* %0 to i8* |
| 235 |
call void @llvm.lifetime.start.p0i8(i64 16, i8* %1) #3 |
| 236 |
%2 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0"* %0, i32 0, i32 0 |
| 237 |
%3 = load i32 addrspace(1)*, i32 addrspace(1)** %_arg_.addr, align 8, !tbaa !9 |
| 238 |
%4 = addrspacecast i32 addrspace(1)* %3 to i32 addrspace(4)* |
| 239 |
store i32 addrspace(4)* %4, i32 addrspace(4)** %2, align 8, !tbaa !20 |
| 240 |
%5 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0"* %0, i32 0, i32 1 |
| 241 |
%6 = load i32 addrspace(1)*, i32 addrspace(1)** %_arg_.addr2, align 8, !tbaa !9 |
| 242 |
%7 = addrspacecast i32 addrspace(1)* %6 to i32 addrspace(4)* |
| 243 |
store i32 addrspace(4)* %7, i32 addrspace(4)** %5, align 8, !tbaa !22 |
| 244 |
%8 = addrspacecast %"class._ZTSZ4mainE3$_0.anon.0"* %0 to %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* |
| 245 |
call spir_func void @"_ZZ4mainEN3$_1clEv"(%"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %8) #4 |
| 246 |
%9 = bitcast %"class._ZTSZ4mainE3$_0.anon.0"* %0 to i8* |
| 247 |
call void @llvm.lifetime.end.p0i8(i64 16, i8* %9) #3 |
| 248 |
ret void |
| 249 |
} |
| 250 |
|
| 251 |
; CHECK-LLVM: define internal spir_func void {{.*}}(%[[CLOSURE_NAME_SFLN]] addrspace(4)* %this) |
| 252 |
; Function Attrs: convergent inlinehint norecurse nounwind |
| 253 |
define internal spir_func void @"_ZZ4mainEN3$_1clEv"(%"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this) #2 align 2 { |
| 254 |
entry: |
| 255 |
; CHECK-LLVM: %this.addr = alloca %[[CLOSURE_NAME_SFLN]] |
| 256 |
%this.addr = alloca %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)*, align 8 |
| 257 |
%i = alloca i32, align 4 |
| 258 |
store %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this, %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)** %this.addr, align 8, !tbaa !9 |
| 259 |
; CHECK-LLVM: %this1 = load %[[CLOSURE_NAME_SFLN]] addrspace(4)*, %[[CLOSURE_NAME_SFLN]] addrspace(4)** %this.addr |
| 260 |
%this1 = load %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)*, %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)** %this.addr, align 8 |
| 261 |
%0 = bitcast i32* %i to i8* |
| 262 |
call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3 |
| 263 |
store i32 0, i32* %i, align 4, !tbaa !5 |
| 264 |
br label %for.cond |
| 265 |
|
| 266 |
for.cond: ; preds = %for.inc, %entry |
| 267 |
%1 = load i32, i32* %i, align 4, !tbaa !5 |
| 268 |
%cmp = icmp slt i32 %1, 6 |
| 269 |
br i1 %cmp, label %for.body, label %for.cond.cleanup |
| 270 |
|
| 271 |
for.cond.cleanup: ; preds = %for.cond |
| 272 |
%2 = bitcast i32* %i to i8* |
| 273 |
call void @llvm.lifetime.end.p0i8(i64 4, i8* %2) #3 |
| 274 |
br label %for.end |
| 275 |
|
| 276 |
for.body: ; preds = %for.cond |
| 277 |
; CHECK-LLVM: %[[BUF2_SFLN_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_SFLN]], %[[CLOSURE_NAME_SFLN]] addrspace(4)* %this1, i32 0, i32 1 |
| 278 |
; CHECK-LLVM: %[[BUF2_SFLN_CLOSURE_ACCESS_LOAD:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[BUF2_SFLN_CLOSURE_ACCESS]] |
| 279 |
%3 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this1, i32 0, i32 1 |
| 280 |
%4 = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %3, align 8, !tbaa !22 |
| 281 |
%5 = load i32, i32* %i, align 4, !tbaa !5 |
| 282 |
%add = add nsw i32 %5, 4 |
| 283 |
%idxprom = sext i32 %add to i64 |
| 284 |
; CHECK-LLVM: getelementptr inbounds i32, i32 addrspace(4)* %[[BUF2_SFLN_CLOSURE_ACCESS_LOAD]]{{.*}}, !llvm.index.group ![[BUF2_SFLN_INDEX_GROUP:[0-9]+]] |
| 285 |
%ptridx = getelementptr inbounds i32, i32 addrspace(4)* %4, i64 %idxprom, !llvm.index.group !23 |
| 286 |
%6 = load i32, i32 addrspace(4)* %ptridx, align 4, !tbaa !5 |
| 287 |
%add2 = add nsw i32 %6, 42 |
| 288 |
; CHECK-LLVM: %[[BUF1_SFLN_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_SFLN]], %[[CLOSURE_NAME_SFLN]] addrspace(4)* %this1, i32 0, i32 0 |
| 289 |
; CHECK-LLVM: %[[BUF1_SFLN_CLOSURE_ACCESS_LOAD:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[BUF1_SFLN_CLOSURE_ACCESS]] |
| 290 |
%7 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this1, i32 0, i32 0 |
| 291 |
%8 = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %7, align 8, !tbaa !20 |
| 292 |
%9 = load i32, i32* %i, align 4, !tbaa !5 |
| 293 |
%idxprom3 = sext i32 %9 to i64 |
| 294 |
; CHECK-LLVM: getelementptr inbounds i32, i32 addrspace(4)* %[[BUF1_SFLN_CLOSURE_ACCESS_LOAD]]{{.*}}, !llvm.index.group ![[BUF1_SFLN_INDEX_GROUP:[0-9]+]] |
| 295 |
%ptridx4 = getelementptr inbounds i32, i32 addrspace(4)* %8, i64 %idxprom3, !llvm.index.group !24 |
| 296 |
%10 = load i32, i32 addrspace(4)* %ptridx4, align 4, !tbaa !5 |
| 297 |
%mul = mul nsw i32 %10, %add2 |
| 298 |
store i32 %mul, i32 addrspace(4)* %ptridx4, align 4, !tbaa !5 |
| 299 |
; CHECK-LLVM: %[[BUF1_SFLN_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_SFLN]], %[[CLOSURE_NAME_SFLN]] addrspace(4)* %this1, i32 0, i32 0 |
| 300 |
; CHECK-LLVM: %[[BUF1_SFLN_CLOSURE_ACCESS_LOAD:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[BUF1_SFLN_CLOSURE_ACCESS]] |
| 301 |
%11 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this1, i32 0, i32 0 |
| 302 |
%12 = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %11, align 8, !tbaa !20 |
| 303 |
%13 = load i32, i32* %i, align 4, !tbaa !5 |
| 304 |
%idxprom5 = sext i32 %13 to i64 |
| 305 |
; CHECK-LLVM: getelementptr inbounds i32, i32 addrspace(4)* %[[BUF1_SFLN_CLOSURE_ACCESS_LOAD]]{{.*}}, !llvm.index.group ![[BUF1_SFLN_INDEX_GROUP]] |
| 306 |
%ptridx6 = getelementptr inbounds i32, i32 addrspace(4)* %12, i64 %idxprom5, !llvm.index.group !24 |
| 307 |
%14 = load i32, i32 addrspace(4)* %ptridx6, align 4, !tbaa !5 |
| 308 |
; CHECK-LLVM: %[[BUF2_SFLN_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_SFLN]], %[[CLOSURE_NAME_SFLN]] addrspace(4)* %this1, i32 0, i32 1 |
| 309 |
; CHECK-LLVM: %[[BUF2_SFLN_CLOSURE_ACCESS_LOAD:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[BUF2_SFLN_CLOSURE_ACCESS]] |
| 310 |
%15 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this1, i32 0, i32 1 |
| 311 |
%16 = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %15, align 8, !tbaa !22 |
| 312 |
%17 = load i32, i32* %i, align 4, !tbaa !5 |
| 313 |
%add7 = add nsw i32 %17, 3 |
| 314 |
%idxprom8 = sext i32 %add7 to i64 |
| 315 |
; CHECK-LLVM: getelementptr inbounds i32, i32 addrspace(4)* %[[BUF2_SFLN_CLOSURE_ACCESS_LOAD]]{{.*}}, !llvm.index.group ![[BUF2_SFLN_INDEX_GROUP]] |
| 316 |
%ptridx9 = getelementptr inbounds i32, i32 addrspace(4)* %16, i64 %idxprom8, !llvm.index.group !23 |
| 317 |
%18 = load i32, i32 addrspace(4)* %ptridx9, align 4, !tbaa !5 |
| 318 |
%add10 = add nsw i32 %14, %18 |
| 319 |
; CHECK-LLVM: %[[BUF2_SFLN_CLOSURE_ACCESS:[0-9]+]] = getelementptr inbounds %[[CLOSURE_NAME_SFLN]], %[[CLOSURE_NAME_SFLN]] addrspace(4)* %this1, i32 0, i32 1 |
| 320 |
; CHECK-LLVM: %[[BUF2_SFLN_CLOSURE_ACCESS_LOAD:[0-9]+]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[BUF2_SFLN_CLOSURE_ACCESS]] |
| 321 |
%19 = getelementptr inbounds %"class._ZTSZ4mainE3$_0.anon.0", %"class._ZTSZ4mainE3$_0.anon.0" addrspace(4)* %this1, i32 0, i32 1 |
| 322 |
%20 = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %19, align 8, !tbaa !22 |
| 323 |
%21 = load i32, i32* %i, align 4, !tbaa !5 |
| 324 |
%idxprom11 = sext i32 %21 to i64 |
| 325 |
; CHECK-LLVM: getelementptr inbounds i32, i32 addrspace(4)* %[[BUF2_SFLN_CLOSURE_ACCESS_LOAD]]{{.*}}, !llvm.index.group ![[BUF2_SFLN_INDEX_GROUP]] |
| 326 |
%ptridx12 = getelementptr inbounds i32, i32 addrspace(4)* %20, i64 %idxprom11, !llvm.index.group !23 |
| 327 |
%22 = load i32, i32 addrspace(4)* %ptridx12, align 4, !tbaa !5 |
| 328 |
%mul13 = mul nsw i32 %22, %add10 |
| 329 |
store i32 %mul13, i32 addrspace(4)* %ptridx12, align 4, !tbaa !5 |
| 330 |
br label %for.inc |
| 331 |
|
| 332 |
for.inc: ; preds = %for.body |
| 333 |
%23 = load i32, i32* %i, align 4, !tbaa !5 |
| 334 |
%inc = add nsw i32 %23, 1 |
| 335 |
store i32 %inc, i32* %i, align 4, !tbaa !5 |
| 336 |
; CHECK-LLVM: br label %{{.*}}, !llvm.loop ![[SFLN_MD_LOOP:[0-9]+]] |
| 337 |
br label %for.cond, !llvm.loop !25 |
| 338 |
|
| 339 |
for.end: ; preds = %for.cond.cleanup |
| 340 |
ret void |
| 341 |
} |
| 342 |
|
| 343 |
attributes #0 = { convergent norecurse uwtable "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "tune-cpu"="generic" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 344 |
attributes #1 = { argmemonly nounwind willreturn } |
| 345 |
attributes #2 = { convergent inlinehint norecurse nounwind uwtable "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 346 |
attributes #3 = { nounwind } |
| 347 |
attributes #4 = { convergent } |
| 348 |
|
| 349 |
!llvm.module.flags = !{!0} |
| 350 |
!opencl.spir.version = !{!1} |
| 351 |
!spirv.Source = !{!2} |
| 352 |
!llvm.ident = !{!3} |
| 353 |
|
| 354 |
!0 = !{i32 1, !"wchar_size", i32 4} |
| 355 |
!1 = !{i32 1, i32 2} |
| 356 |
!2 = !{i32 4, i32 100000} |
| 357 |
!3 = !{!"clang version 12.0.0"} |
| 358 |
!4 = !{i32 -1, i32 -1} |
| 359 |
!5 = !{!6, !6, i64 0} |
| 360 |
!6 = !{!"int", !7, i64 0} |
| 361 |
!7 = !{!"omnipotent char", !8, i64 0} |
| 362 |
!8 = !{!"Simple C++ TBAA"} |
| 363 |
!9 = !{!10, !10, i64 0} |
| 364 |
!10 = !{!"any pointer", !7, i64 0} |
| 365 |
; Double-nested (embedded) loop example |
| 366 |
; |
| 367 |
; Legacy metadata |
| 368 |
; CHECK-LLVM-DAG: ![[IVDEP_LEGACY_SFLN_2:[0-9]+]] = !{!"llvm.loop.ivdep.safelen", i32 2} |
| 369 |
; Inner loop |
| 370 |
; CHECK-LLVM-DAG: ![[BUF1_EMB_INNER_IDX_GR]] = !{![[BUF1_EMB_OUTER_IDX_GR]], ![[BUF1_EMB_INNER_IDX_NODE:[0-9]+]]} |
| 371 |
; CHECK-LLVM-DAG: ![[BUF1_EMB_INNER_IDX_NODE]] = distinct !{} |
| 372 |
; CHECK-LLVM-DAG: ![[BUF2_EMB_INNER_IDX_GR]] = distinct !{} |
| 373 |
; CHECK-LLVM-DAG: ![[EMB_INNER_MD_LOOP]] = distinct !{![[EMB_INNER_MD_LOOP]], ![[IVDEP_LEGACY_SFLN_2]], ![[IVDEP_INNER_EMB:[0-9]+]]} |
| 374 |
; The next 2 directives should overlap |
| 375 |
; CHECK-LLVM-MD-OP1-DAG: ![[IVDEP_INNER_EMB]] = !{!"llvm.loop.parallel_access_indices",{{.*}} ![[BUF1_EMB_INNER_IDX_NODE]]{{.*}}, i32 2} |
| 376 |
; CHECK-LLVM-MD-OP2-DAG: ![[IVDEP_INNER_EMB]] = !{!"llvm.loop.parallel_access_indices",{{.*}} ![[BUF2_EMB_INNER_IDX_GR]]{{.*}}, i32 2} |
| 377 |
; |
| 378 |
; Outer loop |
| 379 |
; CHECK-LLVM-DAG: ![[BUF1_EMB_OUTER_IDX_GR]] = distinct !{} |
| 380 |
; CHECK-LLVM-DAG: ![[EMB_OUTER_MD_LOOP]] = distinct !{![[EMB_OUTER_MD_LOOP]], ![[IVDEP_OUTER_EMB:[0-9]+]]} |
| 381 |
; CHECK-LLVM-DAG: ![[IVDEP_OUTER_EMB]] = !{!"llvm.loop.parallel_access_indices", ![[BUF1_EMB_OUTER_IDX_GR]], i32 3} |
| 382 |
!11 = distinct !{} |
| 383 |
!12 = !{!11, !13} |
| 384 |
!13 = distinct !{} |
| 385 |
!14 = distinct !{} |
| 386 |
!15 = distinct !{!15, !16, !17} |
| 387 |
!16 = !{!"llvm.loop.parallel_access_indices", !13, !14, i32 2} |
| 388 |
!17 = !{!"llvm.loop.ivdep.safelen", i32 2} |
| 389 |
!18 = distinct !{!18, !19} |
| 390 |
!19 = !{!"llvm.loop.parallel_access_indices", !11, i32 3} |
| 391 |
!20 = !{!21, !10, i64 0} |
| 392 |
!21 = !{!"_ZTSZ4mainE3$_1", !10, i64 0, !10, i64 8} |
| 393 |
!22 = !{!21, !10, i64 8} |
| 394 |
; One-dimensional loop with varying ivdep parameters example |
| 395 |
; |
| 396 |
; CHECK-LLVM-DAG: ![[BUF1_SFLN_INDEX_GROUP]] = distinct !{} |
| 397 |
; CHECK-LLVM-DAG: ![[BUF2_SFLN_INDEX_GROUP]] = distinct !{} |
| 398 |
; CHECK-LLVM-DAG: ![[SFLN_MD_LOOP]] = distinct !{![[SFLN_MD_LOOP]], ![[IVDEP_BUF2_SFLN:[0-9]+]], ![[IVDEP_BUF1_SFLN:[0-9]+]]} |
| 399 |
; CHECK-LLVM-DAG: ![[IVDEP_BUF1_SFLN]] = !{!"llvm.loop.parallel_access_indices", ![[BUF1_SFLN_INDEX_GROUP]], i32 3} |
| 400 |
; CHECK-LLVM-DAG: ![[IVDEP_BUF2_SFLN]] = !{!"llvm.loop.parallel_access_indices", ![[BUF2_SFLN_INDEX_GROUP]], i32 2} |
| 401 |
!23 = distinct !{} |
| 402 |
!24 = distinct !{} |
| 403 |
!25 = distinct !{!25, !26, !27} |
| 404 |
!26 = !{!"llvm.loop.parallel_access_indices", !24, i32 3} |
| 405 |
!27 = !{!"llvm.loop.parallel_access_indices", !23, i32 2} |