Pete Cooper | 451755d | 2015-04-30 23:14:14 +0000 | [diff] [blame] | 1 | ; RUN: llc %s -o - -verify-machineinstrs | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32" |
| 4 | target triple = "thumbv7s-apple-ios8.0.0" |
| 5 | |
| 6 | %struct.cells = type { i32, i32, %struct.cells* } |
| 7 | |
| 8 | @reg_len = external global i32, align 4 |
| 9 | |
| 10 | ; The thumb2 size reduction pass commutes arguments to make the first src of an add the same as the dest. |
| 11 | ; It needs to also move the internal flag when commuting arguments. |
| 12 | |
| 13 | ; CHECK-LABEL: @simulate |
| 14 | |
| 15 | ; Function Attrs: nounwind optsize ssp |
| 16 | define i32 @simulate(i32 %iterations, %struct.cells* nocapture %present, double %prob, i8* nocapture readonly %structure) { |
| 17 | entry: |
| 18 | %0 = load i32, i32* @reg_len, align 4, !tbaa !3 |
| 19 | %sub = add nsw i32 %0, -1 |
| 20 | %div = sdiv i32 %sub, 31 |
| 21 | %rem2 = srem i32 %sub, 31 |
| 22 | %cmp35202 = icmp sgt i32 %rem2, 0 |
| 23 | br label %for.cond3.preheader |
| 24 | |
| 25 | for.cond3.preheader: ; preds = %if.end85, %entry |
| 26 | %call192 = tail call i32 @lrand48() #2 |
| 27 | br label %for.cond6.preheader |
| 28 | |
| 29 | for.cond34.preheader: ; preds = %for.inc30 |
| 30 | br i1 %cmp35202, label %for.body37, label %for.end73 |
| 31 | |
| 32 | for.cond6.preheader: ; preds = %for.inc30, %for.cond3.preheader |
| 33 | %call197 = phi i32 [ %call, %for.inc30 ], [ %call192, %for.cond3.preheader ] |
| 34 | %i.0196 = phi i32 [ %inc31, %for.inc30 ], [ 0, %for.cond3.preheader ] |
| 35 | %temp.1195 = phi %struct.cells* [ %5, %for.inc30 ], [ %present, %for.cond3.preheader ] |
| 36 | %savefaulty.0194 = phi i32 [ %add12, %for.inc30 ], [ 0, %for.cond3.preheader ] |
| 37 | %savef_free.0193 = phi i32 [ %add11, %for.inc30 ], [ 0, %for.cond3.preheader ] |
| 38 | br label %for.body8 |
| 39 | |
| 40 | for.body8: ; preds = %for.body8, %for.cond6.preheader |
| 41 | %randv.0190 = phi i32 [ %call197, %for.cond6.preheader ], [ %shr, %for.body8 ] |
| 42 | %j.0189 = phi i32 [ 0, %for.cond6.preheader ], [ %inc, %for.body8 ] |
| 43 | %temp.2188 = phi %struct.cells* [ %temp.1195, %for.cond6.preheader ], [ %5, %for.body8 ] |
| 44 | %savefaulty.1187 = phi i32 [ %savefaulty.0194, %for.cond6.preheader ], [ %add12, %for.body8 ] |
| 45 | %savef_free.1186 = phi i32 [ %savef_free.0193, %for.cond6.preheader ], [ %add11, %for.body8 ] |
| 46 | %f_free = getelementptr inbounds %struct.cells, %struct.cells* %temp.2188, i32 0, i32 0 |
| 47 | %1 = load i32, i32* %f_free, align 4, !tbaa !7 |
| 48 | %add11 = add nsw i32 %1, %savef_free.1186 |
| 49 | %faulty = getelementptr inbounds %struct.cells, %struct.cells* %temp.2188, i32 0, i32 1 |
| 50 | %2 = load i32, i32* %faulty, align 4, !tbaa !10 |
| 51 | %add12 = add nsw i32 %2, %savefaulty.1187 |
| 52 | %next = getelementptr inbounds %struct.cells, %struct.cells* %temp.2188, i32 0, i32 2 |
| 53 | %3 = load %struct.cells*, %struct.cells** %next, align 4, !tbaa !11 |
| 54 | %f_free13 = getelementptr inbounds %struct.cells, %struct.cells* %3, i32 0, i32 0 |
| 55 | %4 = load i32, i32* %f_free13, align 4, !tbaa !7 |
| 56 | %add14 = add nsw i32 %4, %randv.0190 |
| 57 | %and = and i32 %add14, 1 |
| 58 | store i32 %and, i32* %f_free, align 4, !tbaa !7 |
| 59 | %call16 = tail call i32 @lrand48() #2 |
| 60 | %rem17 = srem i32 %call16, 1000 |
| 61 | %conv18 = sitofp i32 %rem17 to double |
| 62 | %div19 = fdiv double %conv18, 1.000000e+03 |
| 63 | %cmp20 = fcmp olt double %div19, %prob |
| 64 | %xor = zext i1 %cmp20 to i32 |
| 65 | %randv.1 = xor i32 %xor, %randv.0190 |
| 66 | %5 = load %struct.cells*, %struct.cells** %next, align 4, !tbaa !11 |
| 67 | %faulty25 = getelementptr inbounds %struct.cells, %struct.cells* %5, i32 0, i32 1 |
| 68 | %6 = load i32, i32* %faulty25, align 4, !tbaa !10 |
| 69 | %add26 = add nsw i32 %randv.1, %6 |
| 70 | %and27 = and i32 %add26, 1 |
| 71 | store i32 %and27, i32* %faulty, align 4, !tbaa !10 |
| 72 | %shr = ashr i32 %randv.0190, 1 |
| 73 | %inc = add nuw nsw i32 %j.0189, 1 |
| 74 | %exitcond = icmp eq i32 %inc, 31 |
| 75 | br i1 %exitcond, label %for.inc30, label %for.body8 |
| 76 | |
| 77 | for.inc30: ; preds = %for.body8 |
| 78 | %inc31 = add nuw nsw i32 %i.0196, 1 |
| 79 | %cmp4 = icmp slt i32 %inc31, %div |
| 80 | %call = tail call i32 @lrand48() #2 |
| 81 | br i1 %cmp4, label %for.cond6.preheader, label %for.cond34.preheader |
| 82 | |
| 83 | for.body37: ; preds = %for.body37, %for.cond34.preheader |
| 84 | %randv.2207 = phi i32 [ %shr70, %for.body37 ], [ %call, %for.cond34.preheader ] |
| 85 | %temp.3205 = phi %struct.cells* [ %9, %for.body37 ], [ %5, %for.cond34.preheader ] |
| 86 | %f_free45 = getelementptr inbounds %struct.cells, %struct.cells* %temp.3205, i32 0, i32 0 |
| 87 | %.pre220 = getelementptr inbounds %struct.cells, %struct.cells* %temp.3205, i32 0, i32 1 |
| 88 | %next50 = getelementptr inbounds %struct.cells, %struct.cells* %temp.3205, i32 0, i32 2 |
| 89 | %7 = load %struct.cells*, %struct.cells** %next50, align 4, !tbaa !11 |
| 90 | %f_free51 = getelementptr inbounds %struct.cells, %struct.cells* %7, i32 0, i32 0 |
| 91 | %8 = load i32, i32* %f_free51, align 4, !tbaa !7 |
| 92 | %add52 = add nsw i32 %8, %randv.2207 |
| 93 | %and53 = and i32 %add52, 1 |
| 94 | store i32 %and53, i32* %f_free45, align 4, !tbaa !7 |
| 95 | %call55 = tail call i32 @lrand48() #2 |
| 96 | %rem56 = srem i32 %call55, 1000 |
| 97 | %conv57 = sitofp i32 %rem56 to double |
| 98 | %div58 = fdiv double %conv57, 1.000000e+03 |
| 99 | %cmp59 = fcmp olt double %div58, %prob |
| 100 | %xor62 = zext i1 %cmp59 to i32 |
| 101 | %randv.3 = xor i32 %xor62, %randv.2207 |
| 102 | %9 = load %struct.cells*, %struct.cells** %next50, align 4, !tbaa !11 |
| 103 | %faulty65 = getelementptr inbounds %struct.cells, %struct.cells* %9, i32 0, i32 1 |
| 104 | %10 = load i32, i32* %faulty65, align 4, !tbaa !10 |
| 105 | %add66 = add nsw i32 %randv.3, %10 |
| 106 | %and67 = and i32 %add66, 1 |
| 107 | store i32 %and67, i32* %.pre220, align 4, !tbaa !10 |
| 108 | %shr70 = ashr i32 %randv.2207, 1 |
| 109 | br label %for.body37 |
| 110 | |
| 111 | for.end73: ; preds = %for.cond34.preheader |
| 112 | %call74 = tail call i32 @lrand48() #2 |
| 113 | %11 = load i32, i32* @reg_len, align 4, !tbaa !3 |
| 114 | %sub75 = add nsw i32 %11, -1 |
| 115 | %arrayidx76 = getelementptr inbounds i8, i8* %structure, i32 %sub75 |
| 116 | %12 = load i8, i8* %arrayidx76, align 1, !tbaa !12 |
| 117 | %cmp78 = icmp eq i8 %12, 49 |
| 118 | %f_free81 = getelementptr inbounds %struct.cells, %struct.cells* %5, i32 0, i32 0 |
| 119 | br i1 %cmp78, label %if.then80, label %for.end73.if.end85_crit_edge |
| 120 | |
| 121 | for.end73.if.end85_crit_edge: ; preds = %for.end73 |
| 122 | %.pre222 = getelementptr inbounds %struct.cells, %struct.cells* %5, i32 0, i32 1 |
| 123 | br label %if.end85 |
| 124 | |
| 125 | if.then80: ; preds = %for.end73 |
| 126 | %13 = load i32, i32* %f_free81, align 4, !tbaa !7 |
| 127 | %add82 = add nsw i32 %13, %add11 |
| 128 | %faulty83 = getelementptr inbounds %struct.cells, %struct.cells* %5, i32 0, i32 1 |
| 129 | %14 = load i32, i32* %faulty83, align 4, !tbaa !10 |
| 130 | %add84 = add nsw i32 %14, %add12 |
| 131 | br label %if.end85 |
| 132 | |
| 133 | if.end85: ; preds = %if.then80, %for.end73.if.end85_crit_edge |
| 134 | %faulty100.pre-phi = phi i32* [ %.pre222, %for.end73.if.end85_crit_edge ], [ %faulty83, %if.then80 ] |
| 135 | %savef_free.5 = phi i32 [ %add11, %for.end73.if.end85_crit_edge ], [ %add82, %if.then80 ] |
| 136 | %savefaulty.5 = phi i32 [ %add12, %for.end73.if.end85_crit_edge ], [ %add84, %if.then80 ] |
| 137 | %add86 = add nsw i32 %savef_free.5, %call74 |
| 138 | %and87 = and i32 %add86, 1 |
| 139 | store i32 %and87, i32* %f_free81, align 4, !tbaa !7 |
| 140 | %call89 = tail call i32 @lrand48() #2 |
| 141 | %rem90 = srem i32 %call89, 10000 |
| 142 | %conv91 = sitofp i32 %rem90 to double |
| 143 | %div92 = fdiv double %conv91, 1.000000e+04 |
| 144 | %cmp93 = fcmp olt double %div92, %prob |
| 145 | %xor96 = zext i1 %cmp93 to i32 |
| 146 | %randv.4 = xor i32 %xor96, %call74 |
| 147 | %add98 = add nsw i32 %randv.4, %savefaulty.5 |
| 148 | %and99 = and i32 %add98, 1 |
| 149 | store i32 %and99, i32* %faulty100.pre-phi, align 4, !tbaa !10 |
| 150 | br label %for.cond3.preheader |
| 151 | } |
| 152 | |
| 153 | ; Function Attrs: optsize |
| 154 | declare i32 @lrand48() |
| 155 | |
| 156 | attributes #2 = { nounwind optsize } |
| 157 | |
| 158 | !llvm.module.flags = !{!0, !1} |
| 159 | !llvm.ident = !{!2} |
| 160 | |
| 161 | !0 = !{i32 1, !"wchar_size", i32 4} |
| 162 | !1 = !{i32 1, !"min_enum_size", i32 4} |
| 163 | !2 = !{!"clang version 3.7.0 (trunk 236243)"} |
| 164 | !3 = !{!4, !4, i64 0} |
| 165 | !4 = !{!"int", !5, i64 0} |
| 166 | !5 = !{!"omnipotent char", !6, i64 0} |
| 167 | !6 = !{!"Simple C/C++ TBAA"} |
| 168 | !7 = !{!8, !4, i64 0} |
| 169 | !8 = !{!"cells", !4, i64 0, !4, i64 4, !9, i64 8} |
| 170 | !9 = !{!"any pointer", !5, i64 0} |
| 171 | !10 = !{!8, !4, i64 4} |
| 172 | !11 = !{!8, !9, i64 8} |
| 173 | !12 = !{!5, !5, i64 0} |