|
| 1 | +; RUN: split-file %s %t |
| 2 | +; RUN: opt -passes=dxil-refine-types -S -mtriple=dxil-pc-shadermodel6.0-library < %t/explicit-64.ll | FileCheck %s |
| 3 | +; RUN: opt -passes='instcombine,dxil-refine-types' -S -mtriple=dxil-pc-shadermodel6.0-library < %t/generated-64.ll | FileCheck %s |
| 4 | +; RUN: opt -passes=dxil-refine-types -S -mtriple=dxil-pc-shadermodel6.0-library < %t/explicit-32.ll | FileCheck %s |
| 5 | +; RUN: opt -passes='instcombine,dxil-refine-types' -S -mtriple=dxil-pc-shadermodel6.0-library < %t/generated-32.ll | FileCheck %s |
| 6 | + |
| 7 | +; RUN: opt -passes='instcombine,dxil-refine-types' -S -mtriple=dxil-pc-shadermodel6.0-library < %t/folded.ll | FileCheck %s --check-prefix=FOLDED |
| 8 | + |
| 9 | +; Tests that dxil-refine-types will catch the access pattern generated by inst-combine |
| 10 | + |
| 11 | +; CHECK-LABEL: @test( |
| 12 | +; CHECK: %[[#FROM:]] = load %struct.PromotedStruct, ptr %get_access |
| 13 | +; CHECK: store %struct.PromotedStruct %[[#FROM]], ptr %param |
| 14 | +; CHECK: call void @external_barrier(ptr{{.*}}%param) |
| 15 | +; CHECK: %[[#TO:]] = load %struct.PromotedStruct, ptr %param |
| 16 | +; CHECK: store %struct.PromotedStruct %[[#TO]], ptr %set_access |
| 17 | +; CHECK: ret void |
| 18 | + |
| 19 | +;--- explicit-64.ll |
| 20 | + |
| 21 | +%"StructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 22 | +%"RWStructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 23 | +%struct.PromotedStruct = type { i32, float } |
| 24 | + |
| 25 | +@src = external constant %"StructuredBuffer<struct.PromotedStruct>" |
| 26 | +@dest = external constant %"RWStructuredBuffer<struct.PromotedStruct>" |
| 27 | + |
| 28 | +define void @test(i32 %idx) { |
| 29 | + %param = alloca %struct.PromotedStruct, align 1 |
| 30 | + %src = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @src, align 4 |
| 31 | + %get_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %src, i32 %idx) |
| 32 | + %1 = load i64, ptr %get_access, align 1 |
| 33 | + store i64 %1, ptr %param, align 1 |
| 34 | + |
| 35 | + call void @external_barrier(ptr %param) |
| 36 | + |
| 37 | + %dest = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @dest, align 4 |
| 38 | + %set_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %dest, i32 %idx) |
| 39 | + %2 = load i64, ptr %param, align 1 |
| 40 | + store i64 %2, ptr %set_access, align 1 |
| 41 | + ret void |
| 42 | +} |
| 43 | + |
| 44 | +declare void @external_barrier(ptr) |
| 45 | + |
| 46 | +;--- generated-64.ll |
| 47 | + |
| 48 | +%"StructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 49 | +%"RWStructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 50 | +%struct.PromotedStruct = type { i32, float } |
| 51 | + |
| 52 | +@src = external constant %"StructuredBuffer<struct.PromotedStruct>" |
| 53 | +@dest = external constant %"RWStructuredBuffer<struct.PromotedStruct>" |
| 54 | + |
| 55 | +define void @test(i32 %idx) { |
| 56 | + %param = alloca %struct.PromotedStruct, align 1 |
| 57 | + %src = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @src, align 4 |
| 58 | + %get_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %src, i32 %idx) |
| 59 | + call void @llvm.memcpy.p0.p0.i32(ptr align 1 %param, ptr align 1 %get_access, i32 8, i1 false) |
| 60 | + |
| 61 | + call void @external_barrier(ptr %param) |
| 62 | + |
| 63 | + %dest = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @dest, align 4 |
| 64 | + %set_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %dest, i32 %idx) |
| 65 | + call void @llvm.memcpy.p0.p0.i32(ptr align 1 %set_access, ptr align 1 %param, i32 8, i1 false) |
| 66 | + ret void |
| 67 | +} |
| 68 | + |
| 69 | +declare void @external_barrier(ptr) |
| 70 | + |
| 71 | +;--- explicit-32.ll |
| 72 | + |
| 73 | +%"StructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 74 | +%"RWStructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 75 | +%struct.PromotedStruct = type { i16, half } |
| 76 | + |
| 77 | +@src = external constant %"StructuredBuffer<struct.PromotedStruct>" |
| 78 | +@dest = external constant %"RWStructuredBuffer<struct.PromotedStruct>" |
| 79 | + |
| 80 | +define void @test(i32 %idx) { |
| 81 | + %param = alloca %struct.PromotedStruct, align 1 |
| 82 | + %src = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @src, align 4 |
| 83 | + %get_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %src, i32 %idx) |
| 84 | + %1 = load i32, ptr %get_access, align 1 |
| 85 | + store i32 %1, ptr %param, align 1 |
| 86 | + |
| 87 | + call void @external_barrier(ptr %param) |
| 88 | + |
| 89 | + %dest = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @dest, align 4 |
| 90 | + %set_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %dest, i32 %idx) |
| 91 | + %2 = load i32, ptr %param, align 1 |
| 92 | + store i32 %2, ptr %set_access, align 1 |
| 93 | + ret void |
| 94 | +} |
| 95 | + |
| 96 | +declare void @external_barrier(ptr) |
| 97 | + |
| 98 | +;--- generated-32.ll |
| 99 | + |
| 100 | +%"StructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 101 | +%"RWStructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 102 | +%struct.PromotedStruct = type { i32, i32 } |
| 103 | + |
| 104 | +@src = external constant %"StructuredBuffer<struct.PromotedStruct>" |
| 105 | +@dest = external constant %"RWStructuredBuffer<struct.PromotedStruct>" |
| 106 | + |
| 107 | +define void @test(i32 %idx) { |
| 108 | + %param = alloca %struct.PromotedStruct, align 1 |
| 109 | + %src = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @src, align 4 |
| 110 | + %get_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %src, i32 %idx) |
| 111 | + call void @llvm.memcpy.p0.p0.i32(ptr align 1 %param, ptr align 1 %get_access, i32 8, i1 false) |
| 112 | + |
| 113 | + call void @external_barrier(ptr %param) |
| 114 | + |
| 115 | + %dest = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @dest, align 4 |
| 116 | + %set_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %dest, i32 %idx) |
| 117 | + call void @llvm.memcpy.p0.p0.i32(ptr align 1 %set_access, ptr align 1 %param, i32 8, i1 false) |
| 118 | + ret void |
| 119 | +} |
| 120 | + |
| 121 | +declare void @external_barrier(ptr) |
| 122 | + |
| 123 | +;--- folded.ll |
| 124 | + |
| 125 | +; FOLDED-LABEL: @test_folded( |
| 126 | +; FOLDED: %[[#TO:]] = load %struct.PromotedStruct, ptr %get_access |
| 127 | +; FOLDED: store %struct.PromotedStruct %[[#TO]], ptr %set_access |
| 128 | +; FOLDED: ret void |
| 129 | + |
| 130 | +%"StructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 131 | +%"RWStructuredBuffer<struct.PromotedStruct>" = type { %struct.PromotedStruct } |
| 132 | +%struct.PromotedStruct = type { i32, float } |
| 133 | + |
| 134 | +@src = external constant %"StructuredBuffer<struct.PromotedStruct>" |
| 135 | +@dest = external constant %"RWStructuredBuffer<struct.PromotedStruct>" |
| 136 | + |
| 137 | +define void @test_folded(i32 %idx) { |
| 138 | + %param = alloca %struct.PromotedStruct, align 1 |
| 139 | + %src = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @src, align 4 |
| 140 | + %get_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %src, i32 %idx) |
| 141 | + call void @llvm.memcpy.p0.p0.i32(ptr align 1 %param, ptr align 1 %get_access, i32 8, i1 false) |
| 142 | + |
| 143 | + %dest = load target("dx.RawBuffer", %struct.PromotedStruct, 1, 0), ptr @dest, align 4 |
| 144 | + %set_access = call noundef nonnull align 1 dereferenceable(8) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_s_struct.PromotedStructs_1_0t(target("dx.RawBuffer", %struct.PromotedStruct, 1, 0) %dest, i32 %idx) |
| 145 | + call void @llvm.memcpy.p0.p0.i32(ptr align 1 %set_access, ptr align 1 %param, i32 8, i1 false) |
| 146 | + ret void |
| 147 | +} |
0 commit comments