brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · cfa6c98 Raw
71 lines · plain
1; RUN: opt -S -passes=dxil-op-lower %s | FileCheck %s2 3target triple = "dxil-pc-shadermodel6.0-compute"4 5@A.str = internal unnamed_addr constant [2 x i8] c"A\00", align 16@B.str = internal unnamed_addr constant [2 x i8] c"A\00", align 17 8declare i32 @some_val();9 10define void @test_buffers_with_nuri() {11 12  %val = call i32 @some_val()13  %foo = alloca i32, align 414 15  ; RWBuffer<float> A[10];16  ;17  ; A[NonUniformResourceIndex(val)];18 19  %nuri1 = tail call noundef i32 @llvm.dx.resource.nonuniformindex(i32 %val)20  %res1 = call target("dx.TypedBuffer", float, 1, 0, 0)21            @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 10, i32 %nuri1, ptr @A.str)22  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 %val, i1 true) #[[ATTR:.*]]23  ; CHECK-NOT: @llvm.dx.cast.handle24  ; CHECK-NOT: @llvm.dx.resource.nonuniformindex25 26  ; A[NonUniformResourceIndex(val + 1) % 10];27  %add1 = add i32 %val, 128  %nuri2 = tail call noundef i32 @llvm.dx.resource.nonuniformindex(i32 %add1)29  %rem1 = urem i32 %nuri2, 1030  %res2 = call target("dx.TypedBuffer", float, 1, 0, 0)31           @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 10, i32 %rem1, ptr @A.str)32  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 %rem1, i1 true) #[[ATTR]]33 34  ; A[10 + 3 * NonUniformResourceIndex(GI)];35  %mul1 = mul i32 %nuri1, 336  %add2 = add i32 %mul1, 1037  %res3 = call target("dx.TypedBuffer", float, 1, 0, 0)38           @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 10, i32 %add2, ptr @A.str)39  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 %add2, i1 true) #[[ATTR]]40 41  ; NonUniformResourceIndex value going through store & load - the flag is not going to get picked up:42  %a = tail call noundef i32 @llvm.dx.resource.nonuniformindex(i32 %val)43  store i32 %a, ptr %foo44  %b = load i32, ptr %foo45  %res4 = call target("dx.TypedBuffer", float, 1, 0, 0)46           @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 10, i32 %b, ptr @A.str)47  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 %b, i1 false) #[[ATTR]]48 49  ; NonUniformResourceIndex index value on a single resouce (not an array) - the flag is not going to get picked up:50  ;51  ; RWBuffer<float> B : register(u20);52  ; B[NonUniformResourceIndex(val)];53  %nuri3 = tail call noundef i32 @llvm.dx.resource.nonuniformindex(i32 %val)54  %res5 = call target("dx.TypedBuffer", float, 1, 0, 0)55           @llvm.dx.resource.handlefrombinding(i32 20, i32 0, i32 1, i32 %nuri1, ptr @B.str)56  ; CHECK: call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 %val, i1 false) #[[ATTR]]57 58  ; NonUniformResourceIndex on unrelated value - the call is removed:59  ; foo = NonUniformResourceIndex(val);60  %nuri4 = tail call noundef i32 @llvm.dx.resource.nonuniformindex(i32 %val)61  store i32 %nuri4, ptr %foo62  ; CHECK: store i32 %val, ptr %foo63  ; CHECK-NOT: @llvm.dx.resource.nonuniformindex64 65  ret void66}67 68; CHECK: attributes #[[ATTR]] = {{{.*}} memory(read) {{.*}}}69 70attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }71