| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
%struct.B = type { [2 x i32] } |
| 5 |
%struct.A = type { i64, %struct.B } |
| 6 |
|
| 7 |
@__const.foo.b = private unnamed_addr addrspace(2) constant %struct.B { [2 x i32] [i32 1, i32 2] }, align 4 |
| 8 |
@__const.bar.a = private unnamed_addr addrspace(2) constant %struct.A { i64 0, %struct.B { [2 x i32] [i32 1, i32 2] } }, align 8 |
| 9 |
|
| 10 |
define spir_func void @foo(ptr noalias sret(%struct.A) %agg.result) { |
| 11 |
entry: |
| 12 |
%b = alloca %struct.B, align 4 |
| 13 |
%0 = bitcast ptr %b to ptr |
| 14 |
call void @llvm.lifetime.start.p0(i64 8, ptr %0) |
| 15 |
%1 = bitcast ptr %b to ptr |
| 16 |
call void @llvm.memcpy.p0.p2.i32(ptr align 4 %1, ptr addrspace(2) align 4 @__const.foo.b, i32 8, i1 false) |
| 17 |
; CHECK: OpCopyMemorySized %[[#]] %[[#]] %[[#]] Aligned 4 |
| 18 |
%b1 = getelementptr inbounds %struct.A, ptr %agg.result, i32 0, i32 1 |
| 19 |
%2 = bitcast ptr %b1 to ptr |
| 20 |
%3 = bitcast ptr %b to ptr |
| 21 |
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %2, ptr align 4 %3, i32 8, i1 false) |
| 22 |
; CHECK: %[[#PTR1:]] = OpInBoundsPtrAccessChain %[[#]] %[[#]] %[[#]] %[[#]] |
| 23 |
; CHECK: OpCopyMemorySized %[[#PTR1]] %[[#]] %[[#]] Aligned 8 |
| 24 |
%4 = bitcast ptr %b to ptr |
| 25 |
call void @llvm.lifetime.end.p0(i64 8, ptr %4) |
| 26 |
ret void |
| 27 |
} |
| 28 |
|
| 29 |
declare void @llvm.lifetime.start.p0(i64, ptr captures(none)) |
| 30 |
|
| 31 |
declare void @llvm.memcpy.p0.p2.i32(ptr captures(none) writeonly, ptr addrspace(2) captures(none) readonly, i32, i1) |
| 32 |
|
| 33 |
declare void @llvm.memcpy.p0.p0.i32(ptr captures(none) writeonly, ptr captures(none) readonly, i32, i1) |
| 34 |
|
| 35 |
declare void @llvm.lifetime.end.p0(i64, ptr captures(none)) |
| 36 |
|
| 37 |
define spir_func void @bar(ptr noalias sret(%struct.B) %agg.result) { |
| 38 |
entry: |
| 39 |
%a = alloca %struct.A, align 8 |
| 40 |
%0 = bitcast ptr %a to ptr |
| 41 |
call void @llvm.lifetime.start.p0(i64 16, ptr %0) |
| 42 |
%1 = bitcast ptr %a to ptr |
| 43 |
call void @llvm.memcpy.p0.p2.i32(ptr align 8 %1, ptr addrspace(2) align 8 @__const.bar.a, i32 16, i1 false) |
| 44 |
; CHECK: OpCopyMemorySized %[[#]] %[[#]] %[[#]] Aligned 8 |
| 45 |
%b = getelementptr inbounds %struct.A, ptr %a, i32 0, i32 1 |
| 46 |
%2 = bitcast ptr %agg.result to ptr |
| 47 |
%3 = bitcast ptr %b to ptr |
| 48 |
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %2, ptr align 8 %3, i32 8, i1 false) |
| 49 |
; CHECK: %[[#PTR2:]] = OpInBoundsPtrAccessChain %[[#]] %[[#]] %[[#]] %[[#]] |
| 50 |
; CHECK: OpCopyMemorySized %[[#]] %[[#PTR2]] %[[#]] Aligned 4 |
| 51 |
%4 = bitcast ptr %a to ptr |
| 52 |
call void @llvm.lifetime.end.p0(i64 16, ptr %4) |
| 53 |
ret void |
| 54 |
} |