236 lines · plain
1; The only pass criterion is that spirv-val considers output valid.2 3; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}4 5%subgr = type { i64, i64 }6%t_range = type { %t_arr }7%t_arr = type { [1 x i64] }8%t_arr2 = type { [4 x i32] }9 10define internal spir_func noundef i32 @geti32() {11entry:12 ret i32 10013}14 15define internal spir_func noundef i64 @geti64() {16entry:17 ret i64 20018}19 20define internal spir_func void @enable_if(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %this, i64 noundef %dim0) {21entry:22 %this.addr = alloca ptr addrspace(4), align 823 %dim0.addr = alloca i64, align 824 store ptr addrspace(4) %this, ptr %this.addr, align 825 store i64 %dim0, ptr %dim0.addr, align 826 %this1 = load ptr addrspace(4), ptr %this.addr, align 827 %0 = load i64, ptr %dim0.addr, align 828 call spir_func void @enable_if_2(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %this1, i64 noundef %0)29 ret void30}31 32 33define internal spir_func void @test(ptr addrspace(4) noundef align 8 dereferenceable_or_null(16) %this, ptr addrspace(4) noundef align 4 dereferenceable(16) %bits, ptr noundef byval(%t_range) align 8 %pos) {34entry:35 %this.addr = alloca ptr addrspace(4), align 836 %bits.addr = alloca ptr addrspace(4), align 837 %cur_pos = alloca i64, align 838 %__range4 = alloca ptr addrspace(4), align 839 %__begin0 = alloca ptr addrspace(4), align 840 %__end0 = alloca ptr addrspace(4), align 841 %cleanup.dest.slot = alloca i32, align 442 %elem = alloca ptr addrspace(4), align 843 %agg.tmp = alloca %t_range, align 844 %agg.tmp.ascast = addrspacecast ptr %agg.tmp to ptr addrspace(4)45 store ptr addrspace(4) %this, ptr %this.addr, align 846 store ptr addrspace(4) %bits, ptr %bits.addr, align 847 %pos.ascast = addrspacecast ptr %pos to ptr addrspace(4)48 %this1 = load ptr addrspace(4), ptr %this.addr, align 849 %call = call spir_func noundef i64 @getp(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %pos.ascast, i32 noundef 0)50 store i64 %call, ptr %cur_pos, align 851 %0 = load ptr addrspace(4), ptr %bits.addr, align 852 store ptr addrspace(4) %0, ptr %__range4, align 853 %1 = load ptr addrspace(4), ptr %__range4, align 854 %call2 = call spir_func noundef ptr addrspace(4) @beginp(ptr addrspace(4) noundef align 4 dereferenceable_or_null(16) %1)55 store ptr addrspace(4) %call2, ptr %__begin0, align 856 %2 = load ptr addrspace(4), ptr %__range4, align 857 %call3 = call spir_func noundef ptr addrspace(4) @endp(ptr addrspace(4) noundef align 4 dereferenceable_or_null(16) %2)58 store ptr addrspace(4) %call3, ptr %__end0, align 859 br label %for.cond60 61for.cond: ; preds = %for.inc, %entry62 %3 = load ptr addrspace(4), ptr %__begin0, align 863 %4 = load ptr addrspace(4), ptr %__end0, align 864 %cmp = icmp ne ptr addrspace(4) %3, %465 br i1 %cmp, label %for.body, label %for.cond.cleanup66 67for.cond.cleanup: ; preds = %for.cond68 br label %for.end69 70for.body: ; preds = %for.cond71 %5 = load ptr addrspace(4), ptr %__begin0, align 872 store ptr addrspace(4) %5, ptr %elem, align 873 %6 = load i64, ptr %cur_pos, align 874 %call4 = call spir_func noundef i32 @maskp(ptr addrspace(4) noundef align 8 dereferenceable_or_null(16) %this1)75 %conv = zext i32 %call4 to i6476 %cmp5 = icmp ult i64 %6, %conv77 br i1 %cmp5, label %if.then, label %if.else78 79if.then: ; preds = %for.body80 %7 = load ptr addrspace(4), ptr %elem, align 881 %8 = load i64, ptr %cur_pos, align 882 call spir_func void @enable_if(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %agg.tmp.ascast, i64 noundef %8)83 call spir_func void @extract_bits(ptr addrspace(4) noundef align 8 dereferenceable_or_null(16) %this1, ptr addrspace(4) noundef align 4 dereferenceable(4) %7, ptr noundef byval(%t_range) align 8 %agg.tmp)84 %9 = load i64, ptr %cur_pos, align 885 %add = add i64 %9, 3286 store i64 %add, ptr %cur_pos, align 887 br label %if.end88 89if.else: ; preds = %for.body90 %10 = load ptr addrspace(4), ptr %elem, align 891 store i32 0, ptr addrspace(4) %10, align 492 br label %if.end93 94if.end: ; preds = %if.else, %if.then95 br label %for.inc96 97for.inc: ; preds = %if.end98 %11 = load ptr addrspace(4), ptr %__begin0, align 899 %incdec.ptr = getelementptr inbounds nuw i32, ptr addrspace(4) %11, i32 1100 store ptr addrspace(4) %incdec.ptr, ptr %__begin0, align 8101 br label %for.cond102 103for.end: ; preds = %for.cond.cleanup104 ret void105}106 107define internal spir_func noundef i64 @getp(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %this, i32 noundef %dimension) {108entry:109 %this.addr.i = alloca ptr addrspace(4), align 8110 %dimension.addr.i = alloca i32, align 4111 %retval = alloca i64, align 8112 %this.addr = alloca ptr addrspace(4), align 8113 %dimension.addr = alloca i32, align 4114 %retval.ascast = addrspacecast ptr %retval to ptr addrspace(4)115 store ptr addrspace(4) %this, ptr %this.addr, align 8116 store i32 %dimension, ptr %dimension.addr, align 4117 %this1 = load ptr addrspace(4), ptr %this.addr, align 8118 %0 = load i32, ptr %dimension.addr, align 4119 store ptr addrspace(4) %this1, ptr %this.addr.i, align 8120 store i32 %0, ptr %dimension.addr.i, align 4121 %this1.i = load ptr addrspace(4), ptr %this.addr.i, align 8122 %common_array1 = bitcast ptr addrspace(4) %this1 to ptr addrspace(4)123 %1 = load i32, ptr %dimension.addr, align 4124 %idxprom = sext i32 %1 to i64125 %arrayidx = getelementptr inbounds [1 x i64], ptr addrspace(4) %common_array1, i64 0, i64 %idxprom126 %2 = load i64, ptr addrspace(4) %arrayidx, align 8127 ret i64 %2128}129 130define internal spir_func noundef ptr addrspace(4) @beginp(ptr addrspace(4) noundef align 4 dereferenceable_or_null(16) %this) {131entry:132 %retval = alloca ptr addrspace(4), align 8133 %this.addr = alloca ptr addrspace(4), align 8134 %retval.ascast = addrspacecast ptr %retval to ptr addrspace(4)135 store ptr addrspace(4) %this, ptr %this.addr, align 8136 %this1 = load ptr addrspace(4), ptr %this.addr, align 8137 %MData1 = bitcast ptr addrspace(4) %this1 to ptr addrspace(4)138 %arraydecay2 = bitcast ptr addrspace(4) %MData1 to ptr addrspace(4)139 ret ptr addrspace(4) %arraydecay2140}141 142define internal spir_func noundef ptr addrspace(4) @endp(ptr addrspace(4) noundef align 4 dereferenceable_or_null(16) %this) {143entry:144 %retval = alloca ptr addrspace(4), align 8145 %this.addr = alloca ptr addrspace(4), align 8146 %retval.ascast = addrspacecast ptr %retval to ptr addrspace(4)147 store ptr addrspace(4) %this, ptr %this.addr, align 8148 %this1 = load ptr addrspace(4), ptr %this.addr, align 8149 %MData1 = bitcast ptr addrspace(4) %this1 to ptr addrspace(4)150 %arraydecay2 = bitcast ptr addrspace(4) %MData1 to ptr addrspace(4)151 %add.ptr = getelementptr inbounds nuw i32, ptr addrspace(4) %arraydecay2, i64 4152 ret ptr addrspace(4) %add.ptr153}154 155define internal spir_func noundef i32 @maskp(ptr addrspace(4) noundef align 8 dereferenceable_or_null(16) %this) {156entry:157 %retval = alloca i32, align 4158 %this.addr = alloca ptr addrspace(4), align 8159 %retval.ascast = addrspacecast ptr %retval to ptr addrspace(4)160 store ptr addrspace(4) %this, ptr %this.addr, align 8161 %this1 = load ptr addrspace(4), ptr %this.addr, align 8162 %bits_num = getelementptr inbounds nuw %subgr, ptr addrspace(4) %this1, i32 0, i32 1163 %0 = load i64, ptr addrspace(4) %bits_num, align 8164 %conv = trunc i64 %0 to i32165 ret i32 %conv166}167 168define internal spir_func void @enable_if_2(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %this, i64 noundef %dim0) {169entry:170 %this.addr = alloca ptr addrspace(4), align 8171 %dim0.addr = alloca i64, align 8172 store ptr addrspace(4) %this, ptr %this.addr, align 8173 store i64 %dim0, ptr %dim0.addr, align 8174 %this1 = load ptr addrspace(4), ptr %this.addr, align 8175 %common_array1 = bitcast ptr addrspace(4) %this1 to ptr addrspace(4)176 %0 = load i64, ptr %dim0.addr, align 8177 store i64 %0, ptr addrspace(4) %common_array1, align 8178 ret void179}180 181define internal spir_func void @extract_bits(ptr addrspace(4) noundef align 8 dereferenceable_or_null(16) %this, ptr addrspace(4) noundef align 4 dereferenceable(4) %bits, ptr noundef byval(%t_range) align 8 %pos) {182entry:183 %this.addr = alloca ptr addrspace(4), align 8184 %bits.addr = alloca ptr addrspace(4), align 8185 %Res = alloca i64, align 8186 store ptr addrspace(4) %this, ptr %this.addr, align 8187 store ptr addrspace(4) %bits, ptr %bits.addr, align 8188 %pos.ascast = addrspacecast ptr %pos to ptr addrspace(4)189 %this1 = load ptr addrspace(4), ptr %this.addr, align 8190 %Bits1 = bitcast ptr addrspace(4) %this1 to ptr addrspace(4)191 %0 = load i64, ptr addrspace(4) %Bits1, align 8192 store i64 %0, ptr %Res, align 8193 %bits_num = getelementptr inbounds nuw %subgr, ptr addrspace(4) %this1, i32 0, i32 1194 %1 = load i64, ptr addrspace(4) %bits_num, align 8195 %call = call spir_func noundef i64 @geti64()196 %2 = load i64, ptr %Res, align 8197 %and = and i64 %2, %call198 store i64 %and, ptr %Res, align 8199 %call2 = call spir_func noundef i64 @geti64()200 %call3 = call spir_func noundef i32 @geti32()201 %conv = zext i32 %call3 to i64202 %cmp = icmp ult i64 %call2, %conv203 br i1 %cmp, label %if.then, label %if.else204 205if.else: ; preds = %entry206 %3 = load ptr addrspace(4), ptr %bits.addr, align 8207 store i32 0, ptr addrspace(4) %3, align 4208 br label %if.end11209 210if.then: ; preds = %entry211 %call4 = call spir_func noundef i64 @geti64()212 %cmp5 = icmp ugt i64 %call4, 0213 br i1 %cmp5, label %if.then6, label %if.end214 215if.then6: ; preds = %if.then216 %call7 = call spir_func noundef i64 @geti64()217 %4 = load i64, ptr %Res, align 8218 %shr = lshr i64 %4, %call7219 store i64 %shr, ptr %Res, align 8220 br label %if.end221 222if.end: ; preds = %if.then6, %if.then223 %call8 = call spir_func noundef i64 @geti64()224 %5 = load i64, ptr %Res, align 8225 %and9 = and i64 %5, %call8226 store i64 %and9, ptr %Res, align 8227 %6 = load i64, ptr %Res, align 8228 %conv10 = trunc i64 %6 to i32229 %7 = load ptr addrspace(4), ptr %bits.addr, align 8230 store i32 %conv10, ptr addrspace(4) %7, align 4231 br label %if.end11232 233if.end11: ; preds = %if.else, %if.end234 ret void235}236