brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.7 KiB · 51018ff Raw
251 lines · plain
1; The goal of this test case is to ensure that translation does not crash when during branching2; optimization analyzeBranch() requires helper methods of removeBranch() and insertBranch()3; to manage subsequent operations.4 5; RUN: llc -O0 -mtriple=spirv64-unknown-linux %s -o - | FileCheck %s6; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}7 8; RUN: llc -O0 -mtriple=spirv32-unknown-linux %s -o - | FileCheck %s9; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}10 11; CHECK: OpFunction12 13%struct = type { %arr }14%arr = type { [3 x i64] }15 16@.str.6 = private unnamed_addr addrspace(1) constant [3 x i8] c", \00", align 117@.str.20 = private unnamed_addr addrspace(1) constant [6 x i8] c"item(\00", align 118@.str.21 = private unnamed_addr addrspace(1) constant [8 x i8] c"range: \00", align 119@.str.22 = private unnamed_addr addrspace(1) constant [7 x i8] c", id: \00", align 120 21define spir_func i32 @foo(ptr addrspace(4) %Buf, ptr addrspace(4) %Item) {22entry:23  %ref.tmp = alloca %struct24  %ref.tmp7 = alloca %struct25  br label %for.cond.i26 27for.cond.i:                                       ; preds = %for.inc.i, %entry28  %Len.0.i = phi i32 [ 0, %entry ], [ %inc.i, %for.inc.i ]29  %idxprom.i = zext i32 %Len.0.i to i6430  %arrayidx.i = getelementptr inbounds i8, ptr addrspace(1) @.str.20, i64 %idxprom.i31  %0 = load i8, ptr addrspace(1) %arrayidx.i32  %cmp.not.i = icmp eq i8 %0, 033  br i1 %cmp.not.i, label %for.cond1.i, label %for.inc.i34 35for.inc.i:                                        ; preds = %for.cond.i36  %inc.i = add i32 %Len.0.i, 137  br label %for.cond.i, !llvm.loop !138 39for.cond1.i:                                      ; preds = %for.body3.i, %for.cond.i40  %I.0.i = phi i32 [ %inc9.i, %for.body3.i ], [ 0, %for.cond.i ]41  %cmp2.i = icmp ult i32 %I.0.i, %Len.0.i42  br i1 %cmp2.i, label %for.body3.i, label %for.cond.preheader43 44for.cond.preheader:                               ; preds = %for.cond1.i45  %MIndex.i = getelementptr inbounds i8, ptr addrspace(4) %Item, i64 2446  br label %for.cond47 48for.body3.i:                                      ; preds = %for.cond1.i49  %idxprom4.i = zext i32 %I.0.i to i6450  %arrayidx5.i = getelementptr inbounds i8, ptr addrspace(1) @.str.20, i64 %idxprom4.i51  %1 = load i8, ptr addrspace(1) %arrayidx5.i52  %arrayidx7.i = getelementptr inbounds i8, ptr addrspace(4) %Buf, i64 %idxprom4.i53  store i8 %1, ptr addrspace(4) %arrayidx7.i54  %inc9.i = add nuw i32 %I.0.i, 155  br label %for.cond1.i, !llvm.loop !256 57for.cond:                                         ; preds = %exit, %for.cond.preheader58  %Len.0 = phi i32 [ %add9, %exit ], [ %Len.0.i, %for.cond.preheader ]59  %I.0 = phi i32 [ %inc, %exit ], [ 0, %for.cond.preheader ]60  %cmp = icmp ult i32 %I.0, 261  br i1 %cmp, label %for.body, label %for.cond.cleanup62 63for.cond.cleanup:                                 ; preds = %for.cond64  %inc10 = add i32 %Len.0, 165  %idxprom = zext i32 %Len.0 to i6466  %arrayidx = getelementptr inbounds i8, ptr addrspace(4) %Buf, i64 %idxprom67  store i8 41, ptr addrspace(4) %arrayidx68  ret i32 %inc1069 70for.body:                                         ; preds = %for.cond71  %idx.ext = zext i32 %Len.0 to i6472  %add.ptr = getelementptr inbounds i8, ptr addrspace(4) %Buf, i64 %idx.ext73  %cmp1 = icmp eq i32 %I.0, 074  %cond = select i1 %cmp1, ptr addrspace(1) @.str.21, ptr addrspace(1) @.str.2275  br label %for.cond.i2576 77for.cond.i25:                                     ; preds = %for.inc.i30, %for.body78  %Len.0.i26 = phi i32 [ 0, %for.body ], [ %inc.i31, %for.inc.i30 ]79  %idxprom.i27 = zext i32 %Len.0.i26 to i6480  %arrayidx.i28 = getelementptr inbounds i8, ptr addrspace(1) %cond, i64 %idxprom.i2781  %2 = load i8, ptr addrspace(1) %arrayidx.i2882  %cmp.not.i29 = icmp eq i8 %2, 083  br i1 %cmp.not.i29, label %for.cond1.i33, label %for.inc.i3084 85for.inc.i30:                                      ; preds = %for.cond.i2586  %inc.i31 = add i32 %Len.0.i26, 187  br label %for.cond.i25, !llvm.loop !188 89for.cond1.i33:                                    ; preds = %for.body3.i36, %for.cond.i2590  %I.0.i34 = phi i32 [ %inc9.i40, %for.body3.i36 ], [ 0, %for.cond.i25 ]91  %cmp2.i35 = icmp ult i32 %I.0.i34, %Len.0.i2692  br i1 %cmp2.i35, label %for.body3.i36, label %detail.exit93 94for.body3.i36:                                    ; preds = %for.cond1.i3395  %idxprom4.i37 = zext i32 %I.0.i34 to i6496  %arrayidx5.i38 = getelementptr inbounds i8, ptr addrspace(1) %cond, i64 %idxprom4.i3797  %3 = load i8, ptr addrspace(1) %arrayidx5.i3898  %arrayidx7.i39 = getelementptr inbounds i8, ptr addrspace(4) %add.ptr, i64 %idxprom4.i3799  store i8 %3, ptr addrspace(4) %arrayidx7.i39100  %inc9.i40 = add nuw i32 %I.0.i34, 1101  br label %for.cond1.i33, !llvm.loop !2102 103detail.exit:          ; preds = %for.cond1.i33104  %add3 = add i32 %Len.0, %Len.0.i26105  %idx.ext4 = zext i32 %add3 to i64106  %add.ptr5 = getelementptr inbounds i8, ptr addrspace(4) %Buf, i64 %idx.ext4107  br i1 %cmp1, label %cond.true, label %cond.false108 109cond.true:                                        ; preds = %detail.exit110  call void @llvm.memcpy.p0.p4.i64(ptr align 8 %ref.tmp7, ptr addrspace(4) align 8 %Item, i64 24, i1 false)111  call void @llvm.memset.p0.i64(ptr align 8 %ref.tmp, i8 0, i64 24, i1 false)112  br label %for.cond.i42113 114for.cond.i42:                                     ; preds = %for.body.i, %cond.true115  %i.0.i = phi i32 [ 0, %cond.true ], [ %inc.i45, %for.body.i ]116  %cmp.i = icmp ult i32 %i.0.i, 3117  br i1 %cmp.i, label %for.body.i, label %cond.end118 119for.body.i:                                       ; preds = %for.cond.i42120  %idxprom.i43 = zext nneg i32 %i.0.i to i64121  %arrayidx.i44 = getelementptr inbounds [3 x i64], ptr %ref.tmp7, i64 0, i64 %idxprom.i43122  %4 = load i64, ptr %arrayidx.i44, align 8123  %arrayidx.i.i = getelementptr inbounds [3 x i64], ptr %ref.tmp, i64 0, i64 %idxprom.i43124  store i64 %4, ptr %arrayidx.i.i, align 8125  %inc.i45 = add nuw nsw i32 %i.0.i, 1126  br label %for.cond.i42, !llvm.loop !3127 128cond.false:                                       ; preds = %detail.exit129  call void @llvm.memcpy.p0.p4.i64(ptr align 8 %ref.tmp, ptr addrspace(4) align 8 %MIndex.i, i64 24, i1 false)130  br label %cond.end131 132cond.end:                                         ; preds = %cond.false, %for.cond.i42133  store i8 123, ptr addrspace(4) %add.ptr5134  br label %for.cond.i46135 136for.cond.i46:                                     ; preds = %for.inc.i52, %cond.end137  %Len.0.i47 = phi i32 [ 1, %cond.end ], [ %Len.1.i, %for.inc.i52 ]138  %I.0.i48 = phi i32 [ 0, %cond.end ], [ %inc7.i, %for.inc.i52 ]139  %cmp.i49 = icmp ult i32 %I.0.i48, 3140  br i1 %cmp.i49, label %for.body.i50, label %exit141 142for.body.i50:                                     ; preds = %for.cond.i46143  %idxprom.i.i = zext nneg i32 %I.0.i48 to i64144  %arrayidx.i.i51 = getelementptr inbounds [3 x i64], ptr %ref.tmp, i64 0, i64 %idxprom.i.i145  %5 = load i64, ptr %arrayidx.i.i51, align 8146  %idx.ext.i = zext i32 %Len.0.i47 to i64147  %add.ptr.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr5, i64 %idx.ext.i148  br label %do.body.i.i.i149 150do.body.i.i.i:                                    ; preds = %do.body.i.i.i, %for.body.i50151  %Val.addr.0.i.i.i = phi i64 [ %5, %for.body.i50 ], [ %div.i.i.i, %do.body.i.i.i ]152  %NumDigits.0.i.i.i = phi i32 [ 0, %for.body.i50 ], [ %inc.i.i.i, %do.body.i.i.i ]153  %Val.addr.0.i.i.i.frozen = freeze i64 %Val.addr.0.i.i.i154  %div.i.i.i = udiv i64 %Val.addr.0.i.i.i.frozen, 10155  %6 = mul i64 %div.i.i.i, 10156  %rem.i.i.i.decomposed = sub i64 %Val.addr.0.i.i.i.frozen, %6157  %7 = trunc i64 %rem.i.i.i.decomposed to i8158  %retval.0.i.i.i.i = or disjoint i8 %7, 48159  %inc.i.i.i = add i32 %NumDigits.0.i.i.i, 1160  %idxprom.i.i.i = zext i32 %NumDigits.0.i.i.i to i64161  %arrayidx.i.i.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr.i, i64 %idxprom.i.i.i162  store i8 %retval.0.i.i.i.i, ptr addrspace(4) %arrayidx.i.i.i163  %tobool.not.i.i.i = icmp ult i64 %Val.addr.0.i.i.i, 10164  br i1 %tobool.not.i.i.i, label %while.cond.i.i.i, label %do.body.i.i.i, !llvm.loop !4165 166while.cond.i.i.i:                                 ; preds = %while.body.i.i.i, %do.body.i.i.i167  %J.0.i.i.i = phi i32 [ %inc.i54.i.i, %while.body.i.i.i ], [ 0, %do.body.i.i.i ]168  %I.0.in.i.i.i = phi i32 [ %I.0.i.i.i, %while.body.i.i.i ], [ %inc.i.i.i, %do.body.i.i.i ]169  %I.0.i.i.i = add i32 %I.0.in.i.i.i, -1170  %cmp.i.i.i = icmp sgt i32 %I.0.i.i.i, %J.0.i.i.i171  br i1 %cmp.i.i.i, label %while.body.i.i.i, label %enable.exit172 173while.body.i.i.i:                                 ; preds = %while.cond.i.i.i174  %idxprom.i52.i.i = sext i32 %I.0.i.i.i to i64175  %arrayidx.i53.i.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr.i, i64 %idxprom.i52.i.i176  %8 = load i8, ptr addrspace(4) %arrayidx.i53.i.i177  %idxprom1.i.i.i = zext nneg i32 %J.0.i.i.i to i64178  %arrayidx2.i.i.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr.i, i64 %idxprom1.i.i.i179  %9 = load i8, ptr addrspace(4) %arrayidx2.i.i.i180  store i8 %9, ptr addrspace(4) %arrayidx.i53.i.i181  store i8 %8, ptr addrspace(4) %arrayidx2.i.i.i182  %inc.i54.i.i = add nuw nsw i32 %J.0.i.i.i, 1183  br label %while.cond.i.i.i, !llvm.loop !5184 185enable.exit: ; preds = %while.cond.i.i.i186  %add.i = add i32 %Len.0.i47, %inc.i.i.i187  %cmp2.not.i = icmp eq i32 %I.0.i48, 2188  br i1 %cmp2.not.i, label %for.inc.i52, label %if.then.i189 190if.then.i:                                        ; preds = %enable.exit191  %idx.ext3.i = zext i32 %add.i to i64192  %add.ptr4.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr5, i64 %idx.ext3.i193  br label %for.cond.i.i194 195for.cond.i.i:                                     ; preds = %for.inc.i.i, %if.then.i196  %Len.0.i.i = phi i32 [ 0, %if.then.i ], [ %inc.i.i, %for.inc.i.i ]197  %idxprom.i24.i = zext i32 %Len.0.i.i to i64198  %arrayidx.i25.i = getelementptr inbounds i8, ptr addrspace(1) @.str.6, i64 %idxprom.i24.i199  %10 = load i8, ptr addrspace(1) %arrayidx.i25.i200  %cmp.not.i.i = icmp eq i8 %10, 0201  br i1 %cmp.not.i.i, label %for.cond1.i.i, label %for.inc.i.i202 203for.inc.i.i:                                      ; preds = %for.cond.i.i204  %inc.i.i = add i32 %Len.0.i.i, 1205  br label %for.cond.i.i, !llvm.loop !1206 207for.cond1.i.i:                                    ; preds = %for.body3.i.i, %for.cond.i.i208  %I.0.i.i = phi i32 [ %inc9.i.i, %for.body3.i.i ], [ 0, %for.cond.i.i ]209  %cmp2.i.i = icmp ult i32 %I.0.i.i, %Len.0.i.i210  br i1 %cmp2.i.i, label %for.body3.i.i, label %append.exit211 212for.body3.i.i:                                    ; preds = %for.cond1.i.i213  %idxprom4.i.i = zext i32 %I.0.i.i to i64214  %arrayidx5.i.i = getelementptr inbounds i8, ptr addrspace(1) @.str.6, i64 %idxprom4.i.i215  %11 = load i8, ptr addrspace(1) %arrayidx5.i.i216  %arrayidx7.i.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr4.i, i64 %idxprom4.i.i217  store i8 %11, ptr addrspace(4) %arrayidx7.i.i218  %inc9.i.i = add nuw i32 %I.0.i.i, 1219  br label %for.cond1.i.i, !llvm.loop !2220 221append.exit:          ; preds = %for.cond1.i.i222  %add6.i = add i32 %add.i, %Len.0.i.i223  br label %for.inc.i52224 225for.inc.i52:                                      ; preds = %append.exit, %enable.exit226  %Len.1.i = phi i32 [ %add6.i, %append.exit ], [ %add.i, %enable.exit ]227  %inc7.i = add nuw nsw i32 %I.0.i48, 1228  br label %for.cond.i46, !llvm.loop !6229 230exit: ; preds = %for.cond.i46231  %inc8.i = add i32 %Len.0.i47, 1232  %idxprom9.i = zext i32 %Len.0.i47 to i64233  %arrayidx10.i = getelementptr inbounds i8, ptr addrspace(4) %add.ptr5, i64 %idxprom9.i234  store i8 125, ptr addrspace(4) %arrayidx10.i235  %add9 = add i32 %add3, %inc8.i236  %inc = add nuw nsw i32 %I.0, 1237  br label %for.cond, !llvm.loop !7238}239 240declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)241declare void @llvm.memcpy.p0.p4.i64(ptr noalias nocapture writeonly, ptr addrspace(4) noalias nocapture readonly, i64, i1 immarg)242 243!0 = !{!"llvm.loop.mustprogress"}244!1 = distinct !{!1, !0}245!2 = distinct !{!2, !0}246!3 = distinct !{!3, !0}247!4 = distinct !{!4, !0}248!5 = distinct !{!5, !0}249!6 = distinct !{!6, !0}250!7 = distinct !{!7, !0}251