1 ; RUN: llc < %s 2 ; ModuleID = 'new.bc' 3 target datalayout = "e-m:e-i64:64-n32:64" 4 target triple = "powerpc64le--linux-gnu" 5 6 @.str.87 = external hidden unnamed_addr constant [5 x i8], align 1 7 @.str.1.88 = external hidden unnamed_addr constant [4 x i8], align 1 8 @.str.2.89 = external hidden unnamed_addr constant [5 x i8], align 1 9 @.str.3.90 = external hidden unnamed_addr constant [4 x i8], align 1 10 @.str.4.91 = external hidden unnamed_addr constant [14 x i8], align 1 11 @.str.5.92 = external hidden unnamed_addr constant [13 x i8], align 1 12 @.str.6.93 = external hidden unnamed_addr constant [10 x i8], align 1 13 @.str.7.94 = external hidden unnamed_addr constant [9 x i8], align 1 14 @.str.8.95 = external hidden unnamed_addr constant [2 x i8], align 1 15 @.str.9.96 = external hidden unnamed_addr constant [2 x i8], align 1 16 @.str.10.97 = external hidden unnamed_addr constant [3 x i8], align 1 17 @.str.11.98 = external hidden unnamed_addr constant [3 x i8], align 1 18 19 ; Function Attrs: nounwind 20 declare void @llvm.lifetime.start(i64, i8* nocapture) #0 21 22 ; Function Attrs: nounwind 23 declare void @llvm.lifetime.end(i64, i8* nocapture) #0 24 25 ; Function Attrs: nounwind 26 declare i8* @halide_string_to_string(i8*, i8*, i8*) #1 27 28 ; Function Attrs: nounwind 29 declare i8* @halide_int64_to_string(i8*, i8*, i64, i32) #1 30 31 ; Function Attrs: nounwind 32 define weak i8* @halide_double_to_string(i8* %dst, i8* %end, double %arg, i32 %scientific) #1 { 33 entry: 34 %arg.addr = alloca double, align 8 35 %bits = alloca i64, align 8 36 %buf = alloca [512 x i8], align 1 37 store double %arg, double* %arg.addr, align 8, !tbaa !4 38 %0 = bitcast i64* %bits to i8* 39 call void @llvm.lifetime.start(i64 8, i8* %0) #0 40 store i64 0, i64* %bits, align 8, !tbaa !8 41 %1 = bitcast double* %arg.addr to i8* 42 %call = call i8* @memcpy(i8* %0, i8* %1, i64 8) #2 43 %2 = load i64, i64* %bits, align 8, !tbaa !8 44 %and = and i64 %2, 4503599627370495 45 %shr = lshr i64 %2, 52 46 %shr.tr = trunc i64 %shr to i32 47 %conv = and i32 %shr.tr, 2047 48 %shr2 = lshr i64 %2, 63 49 %conv3 = trunc i64 %shr2 to i32 50 %cmp = icmp eq i32 %conv, 2047 51 br i1 %cmp, label %if.then, label %if.else.15 52 53 if.then: ; preds = %entry 54 %tobool = icmp eq i64 %and, 0 55 %tobool5 = icmp ne i32 %conv3, 0 56 br i1 %tobool, label %if.else.9, label %if.then.4 57 58 if.then.4: ; preds = %if.then 59 br i1 %tobool5, label %if.then.6, label %if.else 60 61 if.then.6: ; preds = %if.then.4 62 %call7 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.87, i64 0, i64 0)) #3 63 br label %cleanup.148 64 65 if.else: ; preds = %if.then.4 66 %call8 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1.88, i64 0, i64 0)) #3 67 br label %cleanup.148 68 69 if.else.9: ; preds = %if.then 70 br i1 %tobool5, label %if.then.11, label %if.else.13 71 72 if.then.11: ; preds = %if.else.9 73 %call12 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2.89, i64 0, i64 0)) #3 74 br label %cleanup.148 75 76 if.else.13: ; preds = %if.else.9 77 %call14 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3.90, i64 0, i64 0)) #3 78 br label %cleanup.148 79 80 if.else.15: ; preds = %entry 81 %cmp16 = icmp eq i32 %conv, 0 82 %cmp17 = icmp eq i64 %and, 0 83 %or.cond = and i1 %cmp17, %cmp16 84 br i1 %or.cond, label %if.then.18, label %if.end.32 85 86 if.then.18: ; preds = %if.else.15 87 %tobool19 = icmp eq i32 %scientific, 0 88 %tobool21 = icmp ne i32 %conv3, 0 89 br i1 %tobool19, label %if.else.26, label %if.then.20 90 91 if.then.20: ; preds = %if.then.18 92 br i1 %tobool21, label %if.then.22, label %if.else.24 93 94 if.then.22: ; preds = %if.then.20 95 %call23 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4.91, i64 0, i64 0)) #3 96 br label %cleanup.148 97 98 if.else.24: ; preds = %if.then.20 99 %call25 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5.92, i64 0, i64 0)) #3 100 br label %cleanup.148 101 102 if.else.26: ; preds = %if.then.18 103 br i1 %tobool21, label %if.then.28, label %if.else.30 104 105 if.then.28: ; preds = %if.else.26 106 %call29 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6.93, i64 0, i64 0)) #3 107 br label %cleanup.148 108 109 if.else.30: ; preds = %if.else.26 110 %call31 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7.94, i64 0, i64 0)) #3 111 br label %cleanup.148 112 113 if.end.32: ; preds = %if.else.15 114 %tobool33 = icmp eq i32 %conv3, 0 115 br i1 %tobool33, label %if.end.37, label %if.then.34 116 117 if.then.34: ; preds = %if.end.32 118 %call35 = call i8* @halide_string_to_string(i8* %dst, i8* %end, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8.95, i64 0, i64 0)) #3 119 %sub36 = fsub double -0.000000e+00, %arg 120 store double %sub36, double* %arg.addr, align 8, !tbaa !4 121 br label %if.end.37 122 123 if.end.37: ; preds = %if.then.34, %if.end.32 124 %.pr = phi double [ %sub36, %if.then.34 ], [ %arg, %if.end.32 ] 125 %dst.addr.0 = phi i8* [ %call35, %if.then.34 ], [ %dst, %if.end.32 ] 126 %tobool38 = icmp eq i32 %scientific, 0 127 br i1 %tobool38, label %if.else.62, label %while.condthread-pre-split 128 129 while.condthread-pre-split: ; preds = %if.end.37 130 %cmp40.261 = fcmp olt double %.pr, 1.000000e+00 131 br i1 %cmp40.261, label %while.body, label %while.cond.41thread-pre-split 132 133 while.body: ; preds = %while.body, %while.condthread-pre-split 134 %exponent_base_10.0262 = phi i32 [ %dec, %while.body ], [ 0, %while.condthread-pre-split ] 135 %3 = phi double [ %mul, %while.body ], [ %.pr, %while.condthread-pre-split ] 136 %mul = fmul double %3, 1.000000e+01 137 %dec = add nsw i32 %exponent_base_10.0262, -1 138 %cmp40 = fcmp olt double %mul, 1.000000e+00 139 br i1 %cmp40, label %while.body, label %while.cond.while.cond.41thread-pre-split_crit_edge 140 141 while.cond.while.cond.41thread-pre-split_crit_edge: ; preds = %while.body 142 store double %mul, double* %arg.addr, align 8, !tbaa !4 143 br label %while.cond.41thread-pre-split 144 145 while.cond.41thread-pre-split: ; preds = %while.cond.while.cond.41thread-pre-split_crit_edge, %while.condthread-pre-split 146 %.pr246 = phi double [ %mul, %while.cond.while.cond.41thread-pre-split_crit_edge ], [ %.pr, %while.condthread-pre-split ] 147 %exponent_base_10.0.lcssa = phi i32 [ %dec, %while.cond.while.cond.41thread-pre-split_crit_edge ], [ 0, %while.condthread-pre-split ] 148 %cmp42.257 = fcmp ult double %.pr246, 1.000000e+01 149 br i1 %cmp42.257, label %while.end.44, label %while.body.43 150 151 while.body.43: ; preds = %while.body.43, %while.cond.41thread-pre-split 152 %exponent_base_10.1258 = phi i32 [ %inc, %while.body.43 ], [ %exponent_base_10.0.lcssa, %while.cond.41thread-pre-split ] 153 %4 = phi double [ %div, %while.body.43 ], [ %.pr246, %while.cond.41thread-pre-split ] 154 %div = fdiv double %4, 1.000000e+01 155 %inc = add nsw i32 %exponent_base_10.1258, 1 156 %cmp42 = fcmp ult double %div, 1.000000e+01 157 br i1 %cmp42, label %while.cond.41.while.end.44_crit_edge, label %while.body.43 158 159 while.cond.41.while.end.44_crit_edge: ; preds = %while.body.43 160 store double %div, double* %arg.addr, align 8, !tbaa !4 161 br label %while.end.44 162 163 while.end.44: ; preds = %while.cond.41.while.end.44_crit_edge, %while.cond.41thread-pre-split 164 %exponent_base_10.1.lcssa = phi i32 [ %inc, %while.cond.41.while.end.44_crit_edge ], [ %exponent_base_10.0.lcssa, %while.cond.41thread-pre-split ] 165 %.lcssa = phi double [ %div, %while.cond.41.while.end.44_crit_edge ], [ %.pr246, %while.cond.41thread-pre-split ] 166 %mul45 = fmul double %.lcssa, 1.000000e+06 167 %add = fadd double %mul45, 5.000000e-01 168 %conv46 = fptoui double %add to i64 169 %div47 = udiv i64 %conv46, 1000000 170 %5 = mul i64 %div47, -1000000 171 %sub49 = add i64 %conv46, %5 172 %call50 = call i8* @halide_int64_to_string(i8* %dst.addr.0, i8* %end, i64 %div47, i32 1) #3 173 %call51 = call i8* @halide_string_to_string(i8* %call50, i8* %end, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9.96, i64 0, i64 0)) #3 174 %call52 = call i8* @halide_int64_to_string(i8* %call51, i8* %end, i64 %sub49, i32 6) #3 175 %cmp53 = icmp sgt i32 %exponent_base_10.1.lcssa, -1 176 br i1 %cmp53, label %if.then.54, label %if.else.56 177 178 if.then.54: ; preds = %while.end.44 179 %call55 = call i8* @halide_string_to_string(i8* %call52, i8* %end, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10.97, i64 0, i64 0)) #3 180 br label %if.end.59 181 182 if.else.56: ; preds = %while.end.44 183 %call57 = call i8* @halide_string_to_string(i8* %call52, i8* %end, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11.98, i64 0, i64 0)) #3 184 %sub58 = sub nsw i32 0, %exponent_base_10.1.lcssa 185 br label %if.end.59 186 187 if.end.59: ; preds = %if.else.56, %if.then.54 188 %exponent_base_10.2 = phi i32 [ %exponent_base_10.1.lcssa, %if.then.54 ], [ %sub58, %if.else.56 ] 189 %dst.addr.1 = phi i8* [ %call55, %if.then.54 ], [ %call57, %if.else.56 ] 190 %conv60 = sext i32 %exponent_base_10.2 to i64 191 %call61 = call i8* @halide_int64_to_string(i8* %dst.addr.1, i8* %end, i64 %conv60, i32 2) #3 192 br label %cleanup.148 193 194 if.else.62: ; preds = %if.end.37 195 br i1 %cmp16, label %if.then.64, label %if.end.66 196 197 if.then.64: ; preds = %if.else.62 198 %call65 = call i8* @halide_double_to_string(i8* %dst.addr.0, i8* %end, double 0.000000e+00, i32 0) #3 199 br label %cleanup.148 200 201 if.end.66: ; preds = %if.else.62 202 %add68 = or i64 %and, 4503599627370496 203 %sub70 = add nsw i32 %conv, -1075 204 %cmp71 = icmp ult i32 %conv, 1075 205 br i1 %cmp71, label %if.then.72, label %if.end.105 206 207 if.then.72: ; preds = %if.end.66 208 %cmp73 = icmp slt i32 %sub70, -52 209 br i1 %cmp73, label %if.end.84, label %if.else.76 210 211 if.else.76: ; preds = %if.then.72 212 %sub77 = sub nsw i32 1075, %conv 213 %sh_prom = zext i32 %sub77 to i64 214 %shr78 = lshr i64 %add68, %sh_prom 215 %shl81 = shl i64 %shr78, %sh_prom 216 %sub82 = sub i64 %add68, %shl81 217 br label %if.end.84 218 219 if.end.84: ; preds = %if.else.76, %if.then.72 220 %integer_part.0 = phi i64 [ %shr78, %if.else.76 ], [ 0, %if.then.72 ] 221 %f.0.in = phi i64 [ %sub82, %if.else.76 ], [ %add68, %if.then.72 ] 222 %f.0 = uitofp i64 %f.0.in to double 223 %conv85.244 = zext i32 %sub70 to i64 224 %shl86 = shl i64 %conv85.244, 52 225 %add88 = add i64 %shl86, 4696837146684686336 226 %6 = bitcast i64 %add88 to double 227 %mul90 = fmul double %6, %f.0 228 %add91 = fadd double %mul90, 5.000000e-01 229 %conv92 = fptoui double %add91 to i64 230 %conv93 = uitofp i64 %conv92 to double 231 %and96 = and i64 %conv92, 1 232 %notlhs = fcmp oeq double %conv93, %add91 233 %notrhs = icmp ne i64 %and96, 0 234 %not.or.cond245 = and i1 %notrhs, %notlhs 235 %dec99 = sext i1 %not.or.cond245 to i64 236 %fractional_part.0 = add i64 %dec99, %conv92 237 %cmp101 = icmp eq i64 %fractional_part.0, 1000000 238 %inc103 = zext i1 %cmp101 to i64 239 %inc103.integer_part.0 = add i64 %inc103, %integer_part.0 240 %.fractional_part.0 = select i1 %cmp101, i64 0, i64 %fractional_part.0 241 br label %if.end.105 242 243 if.end.105: ; preds = %if.end.84, %if.end.66 244 %integer_part.2 = phi i64 [ %inc103.integer_part.0, %if.end.84 ], [ %add68, %if.end.66 ] 245 %integer_exponent.0 = phi i32 [ 0, %if.end.84 ], [ %sub70, %if.end.66 ] 246 %fractional_part.2 = phi i64 [ %.fractional_part.0, %if.end.84 ], [ 0, %if.end.66 ] 247 %7 = bitcast [512 x i8]* %buf to i8* 248 call void @llvm.lifetime.start(i64 512, i8* %7) #0 249 %add.ptr = getelementptr inbounds [512 x i8], [512 x i8]* %buf, i64 0, i64 512 250 %add.ptr106 = getelementptr inbounds [512 x i8], [512 x i8]* %buf, i64 0, i64 480 251 %call109 = call i8* @halide_int64_to_string(i8* %add.ptr106, i8* %add.ptr, i64 %integer_part.2, i32 1) #3 252 %cmp110.252 = icmp sgt i32 %integer_exponent.0, 0 253 br i1 %cmp110.252, label %for.cond.112.preheader, label %for.cond.cleanup 254 255 for.cond.112.preheader: ; preds = %if.end.138, %if.end.105 256 %i.0255 = phi i32 [ %inc140, %if.end.138 ], [ 0, %if.end.105 ] 257 %int_part_ptr.0253 = phi i8* [ %int_part_ptr.1, %if.end.138 ], [ %add.ptr106, %if.end.105 ] 258 %int_part_ptr.02534 = ptrtoint i8* %int_part_ptr.0253 to i64 259 %cmp114.249 = icmp eq i8* %call109, %int_part_ptr.0253 260 br i1 %cmp114.249, label %if.end.138, label %for.body.116.preheader 261 262 for.body.116.preheader: ; preds = %for.cond.112.preheader 263 %8 = sub i64 0, %int_part_ptr.02534 264 %scevgep5 = getelementptr i8, i8* %call109, i64 %8 265 %scevgep56 = ptrtoint i8* %scevgep5 to i64 266 call void @llvm.ppc.mtctr.i64(i64 %scevgep56) 267 br label %for.body.116 268 269 for.cond.cleanup: ; preds = %if.end.138, %if.end.105 270 %int_part_ptr.0.lcssa = phi i8* [ %add.ptr106, %if.end.105 ], [ %int_part_ptr.1, %if.end.138 ] 271 %9 = bitcast [512 x i8]* %buf to i8* 272 %call142 = call i8* @halide_string_to_string(i8* %dst.addr.0, i8* %end, i8* %int_part_ptr.0.lcssa) #3 273 %call143 = call i8* @halide_string_to_string(i8* %call142, i8* %end, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9.96, i64 0, i64 0)) #3 274 %call144 = call i8* @halide_int64_to_string(i8* %call143, i8* %end, i64 %fractional_part.2, i32 6) #3 275 call void @llvm.lifetime.end(i64 512, i8* %9) #0 276 br label %cleanup.148 277 278 for.cond.cleanup.115: ; preds = %for.body.116 279 br i1 %cmp125, label %if.then.136, label %if.end.138 280 281 for.body.116: ; preds = %for.body.116, %for.body.116.preheader 282 %call109.pn = phi i8* [ %p.0251, %for.body.116 ], [ %call109, %for.body.116.preheader ] 283 %carry.0250 = phi i32 [ %carry.1, %for.body.116 ], [ 0, %for.body.116.preheader ] 284 %call109.pn2 = ptrtoint i8* %call109.pn to i64 285 %p.0251 = getelementptr inbounds i8, i8* %call109.pn, i64 -1 286 %scevgep3 = getelementptr i8, i8* inttoptr (i64 -1 to i8*), i64 %call109.pn2 287 %10 = load i8, i8* %scevgep3, align 1, !tbaa !10 288 %sub118 = add i8 %10, -48 289 %conv120 = sext i8 %sub118 to i32 290 %mul121 = shl nsw i32 %conv120, 1 291 %add122 = or i32 %mul121, %carry.0250 292 %11 = trunc i32 %add122 to i8 293 %cmp125 = icmp sgt i8 %11, 9 294 %sub128 = add nsw i32 %add122, 246 295 %carry.1 = zext i1 %cmp125 to i32 296 %new_digit.0.in = select i1 %cmp125, i32 %sub128, i32 %add122 297 %add133 = add nsw i32 %new_digit.0.in, 48 298 %conv134 = trunc i32 %add133 to i8 299 %scevgep = getelementptr i8, i8* inttoptr (i64 -1 to i8*), i64 %call109.pn2 300 store i8 %conv134, i8* %scevgep, align 1, !tbaa !10 301 %12 = call i1 @llvm.ppc.is.decremented.ctr.nonzero() 302 br i1 %12, label %for.body.116, label %for.cond.cleanup.115 303 304 if.then.136: ; preds = %for.cond.cleanup.115 305 %incdec.ptr137 = getelementptr inbounds i8, i8* %int_part_ptr.0253, i64 -1 306 store i8 49, i8* %incdec.ptr137, align 1, !tbaa !10 307 br label %if.end.138 308 309 if.end.138: ; preds = %if.then.136, %for.cond.cleanup.115, %for.cond.112.preheader 310 %int_part_ptr.1 = phi i8* [ %incdec.ptr137, %if.then.136 ], [ %call109, %for.cond.112.preheader ], [ %int_part_ptr.0253, %for.cond.cleanup.115 ] 311 %inc140 = add nuw nsw i32 %i.0255, 1 312 %exitcond = icmp eq i32 %inc140, %integer_exponent.0 313 br i1 %exitcond, label %for.cond.cleanup, label %for.cond.112.preheader 314 315 cleanup.148: ; preds = %for.cond.cleanup, %if.then.64, %if.end.59, %if.else.30, %if.then.28, %if.else.24, %if.then.22, %if.else.13, %if.then.11, %if.else, %if.then.6 316 %retval.1 = phi i8* [ %call7, %if.then.6 ], [ %call8, %if.else ], [ %call12, %if.then.11 ], [ %call14, %if.else.13 ], [ %call23, %if.then.22 ], [ %call25, %if.else.24 ], [ %call29, %if.then.28 ], [ %call31, %if.else.30 ], [ %call65, %if.then.64 ], [ %call61, %if.end.59 ], [ %call144, %for.cond.cleanup ] 317 %13 = bitcast i64* %bits to i8* 318 call void @llvm.lifetime.end(i64 8, i8* %13) #0 319 ret i8* %retval.1 320 } 321 322 ; Function Attrs: nounwind 323 declare i8* @memcpy(i8*, i8* nocapture readonly, i64) #1 324 325 ; Function Attrs: nounwind 326 declare void @llvm.ppc.mtctr.i64(i64) #0 327 328 ; Function Attrs: nounwind 329 declare i1 @llvm.ppc.is.decremented.ctr.nonzero() #0 330 331 attributes #0 = { nounwind } 332 attributes #1 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 333 attributes #2 = { nounwind } 334 attributes #3 = { nounwind } 335 336 !llvm.ident = !{!0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0} 337 !llvm.module.flags = !{!1, !2, !3} 338 339 !0 = !{!"clang version 3.7.0 (branches/release_37 246867) (llvm/branches/release_37 246866)"} 340 !1 = !{i32 2, !"halide_use_soft_float_abi", i32 0} 341 !2 = !{i32 2, !"halide_mcpu", !"pwr8"} 342 !3 = !{i32 2, !"halide_mattrs", !"+altivec,+vsx,+power8-altivec,+direct-move"} 343 !4 = !{!5, !5, i64 0} 344 !5 = !{!"double", !6, i64 0} 345 !6 = !{!"omnipotent char", !7, i64 0} 346 !7 = !{!"Simple C/C++ TBAA"} 347 !8 = !{!9, !9, i64 0} 348 !9 = !{!"long long", !6, i64 0} 349 !10 = !{!6, !6, i64 0} 350