|
| 1 | +; RUN: %opt %s -hlsl-passes-resume -scalarrepl-param-hlsl -S | FileCheck %s |
| 2 | + |
| 3 | +; This case should fail to do memcpy replacement because init block does not |
| 4 | +; dominate init.end block. |
| 5 | +; However, it should not produce invalid IR, as it would have with #6510 due |
| 6 | +; to attempting to replace constant dest with instruction source, while |
| 7 | +; assuming the source was not constant. |
| 8 | + |
| 9 | +; This makes sure memcpy was split and elements are properly copied to the |
| 10 | +; scalar array, then that the scalar array is used for the result. |
| 11 | + |
| 12 | +; Generated using: |
| 13 | +; ExtractIRForPassTest.py -p scalarrepl-param-hlsl -o array-to-cbvec-1.ll array-to-cbvec-1.hlsl -- -T vs_6_0 |
| 14 | +; uint4 VectorArray[2]; |
| 15 | +; |
| 16 | +; uint2 main(int i : IN) : OUT { |
| 17 | +; static const uint ScalarArray[8] = (uint[8])VectorArray; |
| 18 | +; return uint2(ScalarArray[1], ScalarArray[6]); |
| 19 | +; } |
| 20 | + |
| 21 | +; CHECK-NOT: badref |
| 22 | +; CHECK-NOT: store <4 x float> zeroinitializer |
| 23 | + |
| 24 | +; Copy array elements from constant to scalar array |
| 25 | +; CHECK: %[[VectorArray:.*]] = getelementptr inbounds %"$Globals", %"$Globals"* %{{.*}}, i32 0, i32 0 |
| 26 | +; CHECK: %[[gep_VA0:.*]] = getelementptr [2 x <4 x i32>], [2 x <4 x i32>]* %[[VectorArray]], i32 0, i32 0 |
| 27 | +; CHECK: %[[ld_VA0:.*]] = load <4 x i32>, <4 x i32>* %[[gep_VA0]] |
| 28 | +; CHECK: %[[ea_VA0_1:.*]] = extractelement <4 x i32> %[[ld_VA0]], i64 1 |
| 29 | +; CHECK: store i32 %[[ea_VA0_1]], i32* getelementptr inbounds ([8 x i32], [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB", i32 0, i32 1) |
| 30 | +; CHECK: %[[gep_VA1:.*]] = getelementptr [2 x <4 x i32>], [2 x <4 x i32>]* %[[VectorArray]], i32 0, i32 1 |
| 31 | +; CHECK: %[[ld_VA1:.*]] = load <4 x i32>, <4 x i32>* %[[gep_VA1]] |
| 32 | +; CHECK: %[[ea_VA1_2:.*]] = extractelement <4 x i32> %[[ld_VA1]], i64 2 |
| 33 | +; CHECK: store i32 %[[ea_VA1_2]], i32* getelementptr inbounds ([8 x i32], [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB", i32 0, i32 6) |
| 34 | + |
| 35 | +; Load from scalar array and return it |
| 36 | +; CHECK: %[[ld_SA1:.*]] = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB", i32 0, i32 1), align 4 |
| 37 | +; CHECK: %[[ld_SA6:.*]] = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB", i32 0, i32 6), align 4 |
| 38 | +; CHECK: %[[ie_SA1:.*]] = insertelement <2 x i32> undef, i32 %[[ld_SA1]], i64 0 |
| 39 | +; CHECK: %[[ie_SA6:.*]] = insertelement <2 x i32> %[[ie_SA1]], i32 %[[ld_SA6]], i64 1 |
| 40 | +; CHECK: store <2 x i32> %[[ie_SA6]], <2 x i32>* %0 |
| 41 | + |
| 42 | +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" |
| 43 | +target triple = "dxil-ms-dx" |
| 44 | + |
| 45 | +%"$Globals" = type { [2 x <4 x i32>] } |
| 46 | +%dx.types.Handle = type { i8* } |
| 47 | +%dx.types.ResourceProperties = type { i32, i32 } |
| 48 | + |
| 49 | +@"\01?VectorArray@@3QBV?$vector@I$03@@B" = external constant [2 x <4 x i32>], align 4 |
| 50 | +@"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB" = internal global [8 x i32] zeroinitializer, align 4 |
| 51 | +@"$Globals" = external constant %"$Globals" |
| 52 | + |
| 53 | +; Function Attrs: nounwind |
| 54 | +define <2 x i32> @main(i32 %i) #0 { |
| 55 | +entry: |
| 56 | + %0 = alloca i32 |
| 57 | + store i32 0, i32* %0 |
| 58 | + %1 = call %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %\22$Globals\22*, i32)"(i32 0, %"$Globals"* @"$Globals", i32 0) |
| 59 | + %2 = call %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %\22$Globals\22)"(i32 14, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 13, i32 32 }, %"$Globals" undef) |
| 60 | + %3 = call %"$Globals"* @"dx.hl.subscript.cb.rn.%\22$Globals\22* (i32, %dx.types.Handle, i32)"(i32 6, %dx.types.Handle %2, i32 0) |
| 61 | + %4 = getelementptr inbounds %"$Globals", %"$Globals"* %3, i32 0, i32 0 |
| 62 | + %i.addr = alloca i32, align 4, !dx.temp !13 |
| 63 | + store i32 %i, i32* %i.addr, align 4, !tbaa !23 |
| 64 | + %5 = load i32, i32* %0, !dbg !27 ; line:4 col:5 |
| 65 | + %6 = and i32 %5, 1, !dbg !27 ; line:4 col:5 |
| 66 | + %7 = icmp ne i32 %6, 0, !dbg !27 ; line:4 col:5 |
| 67 | + br i1 %7, label %init.end, label %init, !dbg !27 ; line:4 col:5 |
| 68 | + |
| 69 | +init: ; preds = %entry |
| 70 | + %8 = or i32 %5, 1, !dbg !27 ; line:4 col:5 |
| 71 | + store i32 %8, i32* %0, !dbg !27 ; line:4 col:5 |
| 72 | + %9 = bitcast [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB" to i8*, !dbg !31 ; line:4 col:49 |
| 73 | + %10 = bitcast [2 x <4 x i32>]* %4 to i8*, !dbg !31 ; line:4 col:49 |
| 74 | + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %9, i8* %10, i64 32, i32 1, i1 false), !dbg !31 ; line:4 col:49 |
| 75 | + br label %init.end, !dbg !27 ; line:4 col:5 |
| 76 | + |
| 77 | +init.end: ; preds = %init, %entry |
| 78 | + %11 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB", i32 0, i32 1), align 4, !dbg !32, !tbaa !23 ; line:5 col:18 |
| 79 | + %12 = load i32, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @"\01?ScalarArray@?1??main@@YA?AV?$vector@I$01@@H@Z@4QBIB", i32 0, i32 6), align 4, !dbg !33, !tbaa !23 ; line:5 col:34 |
| 80 | + %13 = insertelement <2 x i32> undef, i32 %11, i64 0, !dbg !34 ; line:5 col:17 |
| 81 | + %14 = insertelement <2 x i32> %13, i32 %12, i64 1, !dbg !34 ; line:5 col:17 |
| 82 | + ret <2 x i32> %14, !dbg !35 ; line:5 col:5 |
| 83 | +} |
| 84 | + |
| 85 | +; Function Attrs: nounwind |
| 86 | +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #0 |
| 87 | + |
| 88 | +; Function Attrs: nounwind readnone |
| 89 | +declare %"$Globals"* @"dx.hl.subscript.cb.rn.%\22$Globals\22* (i32, %dx.types.Handle, i32)"(i32, %dx.types.Handle, i32) #1 |
| 90 | + |
| 91 | +; Function Attrs: nounwind readnone |
| 92 | +declare %dx.types.Handle @"dx.hl.createhandle..%dx.types.Handle (i32, %\22$Globals\22*, i32)"(i32, %"$Globals"*, i32) #1 |
| 93 | + |
| 94 | +; Function Attrs: nounwind readnone |
| 95 | +declare %dx.types.Handle @"dx.hl.annotatehandle..%dx.types.Handle (i32, %dx.types.Handle, %dx.types.ResourceProperties, %\22$Globals\22)"(i32, %dx.types.Handle, %dx.types.ResourceProperties, %"$Globals") #1 |
| 96 | + |
| 97 | +attributes #0 = { nounwind } |
| 98 | +attributes #1 = { nounwind readnone } |
| 99 | + |
| 100 | +!llvm.module.flags = !{!0} |
| 101 | +!pauseresume = !{!1} |
| 102 | +!llvm.ident = !{!2} |
| 103 | +!dx.version = !{!3} |
| 104 | +!dx.valver = !{!4} |
| 105 | +!dx.shaderModel = !{!5} |
| 106 | +!dx.typeAnnotations = !{!6, !9} |
| 107 | +!dx.entryPoints = !{!16} |
| 108 | +!dx.fnprops = !{!20} |
| 109 | +!dx.options = !{!21, !22} |
| 110 | + |
| 111 | +!0 = !{i32 2, !"Debug Info Version", i32 3} |
| 112 | +!1 = !{!"hlsl-hlemit", !"hlsl-hlensure"} |
| 113 | +!2 = !{!"dxc(private) 1.8.0.14508 (main, 263a77335-dirty)"} |
| 114 | +!3 = !{i32 1, i32 0} |
| 115 | +!4 = !{i32 1, i32 7} |
| 116 | +!5 = !{!"vs", i32 6, i32 0} |
| 117 | +!6 = !{i32 0, %"$Globals" undef, !7} |
| 118 | +!7 = !{i32 32, !8} |
| 119 | +!8 = !{i32 6, !"VectorArray", i32 3, i32 0, i32 7, i32 5} |
| 120 | +!9 = !{i32 1, <2 x i32> (i32)* @main, !10} |
| 121 | +!10 = !{!11, !14} |
| 122 | +!11 = !{i32 1, !12, !13} |
| 123 | +!12 = !{i32 4, !"OUT", i32 7, i32 5} |
| 124 | +!13 = !{} |
| 125 | +!14 = !{i32 0, !15, !13} |
| 126 | +!15 = !{i32 4, !"IN", i32 7, i32 4} |
| 127 | +!16 = !{<2 x i32> (i32)* @main, !"main", null, !17, null} |
| 128 | +!17 = !{null, null, !18, null} |
| 129 | +!18 = !{!19} |
| 130 | +!19 = !{i32 0, %"$Globals"* @"$Globals", !"$Globals", i32 0, i32 -1, i32 1, i32 32, null} |
| 131 | +!20 = !{<2 x i32> (i32)* @main, i32 1} |
| 132 | +!21 = !{i32 -2147483584} |
| 133 | +!22 = !{i32 -1} |
| 134 | +!23 = !{!24, !24, i64 0} |
| 135 | +!24 = !{!"int", !25, i64 0} |
| 136 | +!25 = !{!"omnipotent char", !26, i64 0} |
| 137 | +!26 = !{!"Simple C/C++ TBAA"} |
| 138 | +!27 = !DILocation(line: 4, column: 5, scope: !28) |
| 139 | +!28 = !DISubprogram(name: "main", scope: !29, file: !29, line: 3, type: !30, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, function: <2 x i32> (i32)* @main) |
| 140 | +!29 = !DIFile(filename: "t:\5Carray-mapping.hlsl", directory: "") |
| 141 | +!30 = !DISubroutineType(types: !13) |
| 142 | +!31 = !DILocation(line: 4, column: 49, scope: !28) |
| 143 | +!32 = !DILocation(line: 5, column: 18, scope: !28) |
| 144 | +!33 = !DILocation(line: 5, column: 34, scope: !28) |
| 145 | +!34 = !DILocation(line: 5, column: 17, scope: !28) |
| 146 | +!35 = !DILocation(line: 5, column: 5, scope: !28) |
0 commit comments