350 lines · plain
1; RUN: llc -verify-machineinstrs < %s | FileCheck %s2; ModuleID = 'new.bc'3target datalayout = "e-m:e-i64:64-n32:64"4target triple = "powerpc64le--linux-gnu"5 6@.str.87 = external hidden unnamed_addr constant [5 x i8], align 17@.str.1.88 = external hidden unnamed_addr constant [4 x i8], align 18@.str.2.89 = external hidden unnamed_addr constant [5 x i8], align 19@.str.3.90 = external hidden unnamed_addr constant [4 x i8], align 110@.str.4.91 = external hidden unnamed_addr constant [14 x i8], align 111@.str.5.92 = external hidden unnamed_addr constant [13 x i8], align 112@.str.6.93 = external hidden unnamed_addr constant [10 x i8], align 113@.str.7.94 = external hidden unnamed_addr constant [9 x i8], align 114@.str.8.95 = external hidden unnamed_addr constant [2 x i8], align 115@.str.9.96 = external hidden unnamed_addr constant [2 x i8], align 116@.str.10.97 = external hidden unnamed_addr constant [3 x i8], align 117@.str.11.98 = external hidden unnamed_addr constant [3 x i8], align 118 19; Function Attrs: nounwind20declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #021 22; Function Attrs: nounwind23declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #024 25; Function Attrs: nounwind26declare ptr @halide_string_to_string(ptr, ptr, ptr) #127 28; Function Attrs: nounwind29declare ptr @halide_int64_to_string(ptr, ptr, i64, i32) #130 31;; Hardware loop should not be generated in the loop that already has a user32;; defined hardware loop. Only one mtctr should be in the final assembly.33; CHECK-LABEL: halide_double_to_string34; CHECK-COUNT-1: mtctr35 36; Function Attrs: nounwind37define weak ptr @halide_double_to_string(ptr %dst, ptr %end, double %arg, i32 %scientific) #1 {38entry:39 %arg.addr = alloca double, align 840 %bits = alloca i64, align 841 %buf = alloca [512 x i8], align 142 store double %arg, ptr %arg.addr, align 8, !tbaa !443 call void @llvm.lifetime.start.p0(i64 8, ptr %bits) #044 store i64 0, ptr %bits, align 8, !tbaa !845 %call = call ptr @memcpy(ptr %bits, ptr %arg.addr, i64 8) #246 %0 = load i64, ptr %bits, align 8, !tbaa !847 %and = and i64 %0, 450359962737049548 %shr = lshr i64 %0, 5249 %shr.tr = trunc i64 %shr to i3250 %conv = and i32 %shr.tr, 204751 %shr2 = lshr i64 %0, 6352 %conv3 = trunc i64 %shr2 to i3253 %cmp = icmp eq i32 %conv, 204754 br i1 %cmp, label %if.then, label %if.else.1555 56if.then: ; preds = %entry57 %tobool = icmp eq i64 %and, 058 %tobool5 = icmp ne i32 %conv3, 059 br i1 %tobool, label %if.else.9, label %if.then.460 61if.then.4: ; preds = %if.then62 br i1 %tobool5, label %if.then.6, label %if.else63 64if.then.6: ; preds = %if.then.465 %call7 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.87) #366 br label %cleanup.14867 68if.else: ; preds = %if.then.469 %call8 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.1.88) #370 br label %cleanup.14871 72if.else.9: ; preds = %if.then73 br i1 %tobool5, label %if.then.11, label %if.else.1374 75if.then.11: ; preds = %if.else.976 %call12 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.2.89) #377 br label %cleanup.14878 79if.else.13: ; preds = %if.else.980 %call14 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.3.90) #381 br label %cleanup.14882 83if.else.15: ; preds = %entry84 %cmp16 = icmp eq i32 %conv, 085 %cmp17 = icmp eq i64 %and, 086 %or.cond = and i1 %cmp17, %cmp1687 br i1 %or.cond, label %if.then.18, label %if.end.3288 89if.then.18: ; preds = %if.else.1590 %tobool19 = icmp eq i32 %scientific, 091 %tobool21 = icmp ne i32 %conv3, 092 br i1 %tobool19, label %if.else.26, label %if.then.2093 94if.then.20: ; preds = %if.then.1895 br i1 %tobool21, label %if.then.22, label %if.else.2496 97if.then.22: ; preds = %if.then.2098 %call23 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.4.91) #399 br label %cleanup.148100 101if.else.24: ; preds = %if.then.20102 %call25 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.5.92) #3103 br label %cleanup.148104 105if.else.26: ; preds = %if.then.18106 br i1 %tobool21, label %if.then.28, label %if.else.30107 108if.then.28: ; preds = %if.else.26109 %call29 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.6.93) #3110 br label %cleanup.148111 112if.else.30: ; preds = %if.else.26113 %call31 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.7.94) #3114 br label %cleanup.148115 116if.end.32: ; preds = %if.else.15117 %tobool33 = icmp eq i32 %conv3, 0118 br i1 %tobool33, label %if.end.37, label %if.then.34119 120if.then.34: ; preds = %if.end.32121 %call35 = call ptr @halide_string_to_string(ptr %dst, ptr %end, ptr @.str.8.95) #3122 %sub36 = fsub double -0.000000e+00, %arg123 store double %sub36, ptr %arg.addr, align 8, !tbaa !4124 br label %if.end.37125 126if.end.37: ; preds = %if.then.34, %if.end.32127 %.pr = phi double [ %sub36, %if.then.34 ], [ %arg, %if.end.32 ]128 %dst.addr.0 = phi ptr [ %call35, %if.then.34 ], [ %dst, %if.end.32 ]129 %tobool38 = icmp eq i32 %scientific, 0130 br i1 %tobool38, label %if.else.62, label %while.condthread-pre-split131 132while.condthread-pre-split: ; preds = %if.end.37133 %cmp40.261 = fcmp olt double %.pr, 1.000000e+00134 br i1 %cmp40.261, label %while.body, label %while.cond.41thread-pre-split135 136while.body: ; preds = %while.body, %while.condthread-pre-split137 %exponent_base_10.0262 = phi i32 [ %dec, %while.body ], [ 0, %while.condthread-pre-split ]138 %1 = phi double [ %mul, %while.body ], [ %.pr, %while.condthread-pre-split ]139 %mul = fmul double %1, 1.000000e+01140 %dec = add nsw i32 %exponent_base_10.0262, -1141 %cmp40 = fcmp olt double %mul, 1.000000e+00142 br i1 %cmp40, label %while.body, label %while.cond.while.cond.41thread-pre-split_crit_edge143 144while.cond.while.cond.41thread-pre-split_crit_edge: ; preds = %while.body145 store double %mul, ptr %arg.addr, align 8, !tbaa !4146 br label %while.cond.41thread-pre-split147 148while.cond.41thread-pre-split: ; preds = %while.cond.while.cond.41thread-pre-split_crit_edge, %while.condthread-pre-split149 %.pr246 = phi double [ %mul, %while.cond.while.cond.41thread-pre-split_crit_edge ], [ %.pr, %while.condthread-pre-split ]150 %exponent_base_10.0.lcssa = phi i32 [ %dec, %while.cond.while.cond.41thread-pre-split_crit_edge ], [ 0, %while.condthread-pre-split ]151 %cmp42.257 = fcmp ult double %.pr246, 1.000000e+01152 br i1 %cmp42.257, label %while.end.44, label %while.body.43153 154while.body.43: ; preds = %while.body.43, %while.cond.41thread-pre-split155 %exponent_base_10.1258 = phi i32 [ %inc, %while.body.43 ], [ %exponent_base_10.0.lcssa, %while.cond.41thread-pre-split ]156 %2 = phi double [ %div, %while.body.43 ], [ %.pr246, %while.cond.41thread-pre-split ]157 %div = fdiv double %2, 1.000000e+01158 %inc = add nsw i32 %exponent_base_10.1258, 1159 %cmp42 = fcmp ult double %div, 1.000000e+01160 br i1 %cmp42, label %while.cond.41.while.end.44_crit_edge, label %while.body.43161 162while.cond.41.while.end.44_crit_edge: ; preds = %while.body.43163 store double %div, ptr %arg.addr, align 8, !tbaa !4164 br label %while.end.44165 166while.end.44: ; preds = %while.cond.41.while.end.44_crit_edge, %while.cond.41thread-pre-split167 %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 ]168 %.lcssa = phi double [ %div, %while.cond.41.while.end.44_crit_edge ], [ %.pr246, %while.cond.41thread-pre-split ]169 %mul45 = fmul double %.lcssa, 1.000000e+06170 %add = fadd double %mul45, 5.000000e-01171 %conv46 = fptoui double %add to i64172 %div47 = udiv i64 %conv46, 1000000173 %3 = mul i64 %div47, -1000000174 %sub49 = add i64 %conv46, %3175 %call50 = call ptr @halide_int64_to_string(ptr %dst.addr.0, ptr %end, i64 %div47, i32 1) #3176 %call51 = call ptr @halide_string_to_string(ptr %call50, ptr %end, ptr @.str.9.96) #3177 %call52 = call ptr @halide_int64_to_string(ptr %call51, ptr %end, i64 %sub49, i32 6) #3178 %cmp53 = icmp sgt i32 %exponent_base_10.1.lcssa, -1179 br i1 %cmp53, label %if.then.54, label %if.else.56180 181if.then.54: ; preds = %while.end.44182 %call55 = call ptr @halide_string_to_string(ptr %call52, ptr %end, ptr @.str.10.97) #3183 br label %if.end.59184 185if.else.56: ; preds = %while.end.44186 %call57 = call ptr @halide_string_to_string(ptr %call52, ptr %end, ptr @.str.11.98) #3187 %sub58 = sub nsw i32 0, %exponent_base_10.1.lcssa188 br label %if.end.59189 190if.end.59: ; preds = %if.else.56, %if.then.54191 %exponent_base_10.2 = phi i32 [ %exponent_base_10.1.lcssa, %if.then.54 ], [ %sub58, %if.else.56 ]192 %dst.addr.1 = phi ptr [ %call55, %if.then.54 ], [ %call57, %if.else.56 ]193 %conv60 = sext i32 %exponent_base_10.2 to i64194 %call61 = call ptr @halide_int64_to_string(ptr %dst.addr.1, ptr %end, i64 %conv60, i32 2) #3195 br label %cleanup.148196 197if.else.62: ; preds = %if.end.37198 br i1 %cmp16, label %if.then.64, label %if.end.66199 200if.then.64: ; preds = %if.else.62201 %call65 = call ptr @halide_double_to_string(ptr %dst.addr.0, ptr %end, double 0.000000e+00, i32 0) #3202 br label %cleanup.148203 204if.end.66: ; preds = %if.else.62205 %add68 = or i64 %and, 4503599627370496206 %sub70 = add nsw i32 %conv, -1075207 %cmp71 = icmp ult i32 %conv, 1075208 br i1 %cmp71, label %if.then.72, label %if.end.105209 210if.then.72: ; preds = %if.end.66211 %cmp73 = icmp slt i32 %sub70, -52212 br i1 %cmp73, label %if.end.84, label %if.else.76213 214if.else.76: ; preds = %if.then.72215 %sub77 = sub nsw i32 1075, %conv216 %sh_prom = zext i32 %sub77 to i64217 %shr78 = lshr i64 %add68, %sh_prom218 %shl81 = shl i64 %shr78, %sh_prom219 %sub82 = sub i64 %add68, %shl81220 br label %if.end.84221 222if.end.84: ; preds = %if.else.76, %if.then.72223 %integer_part.0 = phi i64 [ %shr78, %if.else.76 ], [ 0, %if.then.72 ]224 %f.0.in = phi i64 [ %sub82, %if.else.76 ], [ %add68, %if.then.72 ]225 %f.0 = uitofp i64 %f.0.in to double226 %conv85.244 = zext i32 %sub70 to i64227 %shl86 = shl i64 %conv85.244, 52228 %add88 = add i64 %shl86, 4696837146684686336229 %4 = bitcast i64 %add88 to double230 %mul90 = fmul double %4, %f.0231 %add91 = fadd double %mul90, 5.000000e-01232 %conv92 = fptoui double %add91 to i64233 %conv93 = uitofp i64 %conv92 to double234 %and96 = and i64 %conv92, 1235 %notlhs = fcmp oeq double %conv93, %add91236 %notrhs = icmp ne i64 %and96, 0237 %not.or.cond245 = and i1 %notrhs, %notlhs238 %dec99 = sext i1 %not.or.cond245 to i64239 %fractional_part.0 = add i64 %dec99, %conv92240 %cmp101 = icmp eq i64 %fractional_part.0, 1000000241 %inc103 = zext i1 %cmp101 to i64242 %inc103.integer_part.0 = add i64 %inc103, %integer_part.0243 %.fractional_part.0 = select i1 %cmp101, i64 0, i64 %fractional_part.0244 br label %if.end.105245 246if.end.105: ; preds = %if.end.84, %if.end.66247 %integer_part.2 = phi i64 [ %inc103.integer_part.0, %if.end.84 ], [ %add68, %if.end.66 ]248 %integer_exponent.0 = phi i32 [ 0, %if.end.84 ], [ %sub70, %if.end.66 ]249 %fractional_part.2 = phi i64 [ %.fractional_part.0, %if.end.84 ], [ 0, %if.end.66 ]250 call void @llvm.lifetime.start.p0(i64 512, ptr %buf) #0251 %add.ptr = getelementptr inbounds [512 x i8], ptr %buf, i64 0, i64 512252 %add.ptr106 = getelementptr inbounds [512 x i8], ptr %buf, i64 0, i64 480253 %call109 = call ptr @halide_int64_to_string(ptr %add.ptr106, ptr %add.ptr, i64 %integer_part.2, i32 1) #3254 %cmp110.252 = icmp sgt i32 %integer_exponent.0, 0255 br i1 %cmp110.252, label %for.cond.112.preheader, label %for.cond.cleanup256 257for.cond.112.preheader: ; preds = %if.end.138, %if.end.105258 %i.0255 = phi i32 [ %inc140, %if.end.138 ], [ 0, %if.end.105 ]259 %int_part_ptr.0253 = phi ptr [ %int_part_ptr.1, %if.end.138 ], [ %add.ptr106, %if.end.105 ]260 %int_part_ptr.02534 = ptrtoint ptr %int_part_ptr.0253 to i64261 %cmp114.249 = icmp eq ptr %call109, %int_part_ptr.0253262 br i1 %cmp114.249, label %if.end.138, label %for.body.116.preheader263 264for.body.116.preheader: ; preds = %for.cond.112.preheader265 %5 = sub i64 0, %int_part_ptr.02534266 %scevgep5 = getelementptr i8, ptr %call109, i64 %5267 %scevgep56 = ptrtoint ptr %scevgep5 to i64268 call void @llvm.set.loop.iterations.i64(i64 %scevgep56)269 br label %for.body.116270 271for.cond.cleanup: ; preds = %if.end.138, %if.end.105272 %int_part_ptr.0.lcssa = phi ptr [ %add.ptr106, %if.end.105 ], [ %int_part_ptr.1, %if.end.138 ]273 %call142 = call ptr @halide_string_to_string(ptr %dst.addr.0, ptr %end, ptr %int_part_ptr.0.lcssa) #3274 %call143 = call ptr @halide_string_to_string(ptr %call142, ptr %end, ptr @.str.9.96) #3275 %call144 = call ptr @halide_int64_to_string(ptr %call143, ptr %end, i64 %fractional_part.2, i32 6) #3276 call void @llvm.lifetime.end.p0(i64 512, ptr %buf) #0277 br label %cleanup.148278 279for.cond.cleanup.115: ; preds = %for.body.116280 br i1 %cmp125, label %if.then.136, label %if.end.138281 282for.body.116: ; preds = %for.body.116, %for.body.116.preheader283 %call109.pn = phi ptr [ %p.0251, %for.body.116 ], [ %call109, %for.body.116.preheader ]284 %carry.0250 = phi i32 [ %carry.1, %for.body.116 ], [ 0, %for.body.116.preheader ]285 %call109.pn2 = ptrtoint ptr %call109.pn to i64286 %p.0251 = getelementptr inbounds i8, ptr %call109.pn, i64 -1287 %scevgep3 = getelementptr i8, ptr inttoptr (i64 -1 to ptr), i64 %call109.pn2288 %6 = load i8, ptr %scevgep3, align 1, !tbaa !10289 %sub118 = add i8 %6, -48290 %conv120 = sext i8 %sub118 to i32291 %mul121 = shl nsw i32 %conv120, 1292 %add122 = or i32 %mul121, %carry.0250293 %7 = trunc i32 %add122 to i8294 %cmp125 = icmp sgt i8 %7, 9295 %sub128 = add nsw i32 %add122, 246296 %carry.1 = zext i1 %cmp125 to i32297 %new_digit.0.in = select i1 %cmp125, i32 %sub128, i32 %add122298 %add133 = add nsw i32 %new_digit.0.in, 48299 %conv134 = trunc i32 %add133 to i8300 %scevgep = getelementptr i8, ptr inttoptr (i64 -1 to ptr), i64 %call109.pn2301 store i8 %conv134, ptr %scevgep, align 1, !tbaa !10302 %8 = call i1 @llvm.loop.decrement(i64 1)303 br i1 %8, label %for.body.116, label %for.cond.cleanup.115304 305if.then.136: ; preds = %for.cond.cleanup.115306 %incdec.ptr137 = getelementptr inbounds i8, ptr %int_part_ptr.0253, i64 -1307 store i8 49, ptr %incdec.ptr137, align 1, !tbaa !10308 br label %if.end.138309 310if.end.138: ; preds = %if.then.136, %for.cond.cleanup.115, %for.cond.112.preheader311 %int_part_ptr.1 = phi ptr [ %incdec.ptr137, %if.then.136 ], [ %call109, %for.cond.112.preheader ], [ %int_part_ptr.0253, %for.cond.cleanup.115 ]312 %inc140 = add nuw nsw i32 %i.0255, 1313 %exitcond = icmp eq i32 %inc140, %integer_exponent.0314 br i1 %exitcond, label %for.cond.cleanup, label %for.cond.112.preheader315 316cleanup.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.6317 %retval.1 = phi ptr [ %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 ]318 call void @llvm.lifetime.end.p0(i64 8, ptr %bits) #0319 ret ptr %retval.1320}321 322; Function Attrs: nounwind323declare ptr @memcpy(ptr, ptr nocapture readonly, i64) #1324 325; Function Attrs: nounwind326declare void @llvm.set.loop.iterations.i64(i64) #0327 328; Function Attrs: nounwind329declare i1 @llvm.loop.decrement(i64) #0330 331attributes #0 = { nounwind }332attributes #1 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }333attributes #2 = { nounwind }334attributes #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