Reikriam

manualy-daxpy-llvm-ir

Mar 17th, 2021
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.56 KB | None | 0 0
  1. ; ModuleID = 'hand-daxpy.c'
  2. source_filename = "hand-daxpy.c"
  3. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  4. target triple = "x86_64-unknown-linux-gnu"
  5.  
  6. @main.m = private unnamed_addr constant [3 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00], align 16
  7. @main.n = private unnamed_addr constant [3 x double] [double 4.000000e+00, double 5.000000e+00, double 6.000000e+00], align 16
  8. @.str = private unnamed_addr constant [4 x i8] c"%f\0A\00", align 1
  9.  
  10. ; Function Attrs: norecurse nounwind uwtable
  11. define dso_local i32 @daxpy_(i32 %nn, double %ssa, double* nocapture readonly %sx, i32 %iincx, double* nocapture %sy, i32 %iincy) local_unnamed_addr #0 {
  12. entry:
  13. %cmp = icmp sgt i32 %nn, 0
  14. %cmp1 = fcmp une double %ssa, 0.000000e+00
  15. %or.cond = and i1 %cmp, %cmp1
  16. br i1 %or.cond, label %if.then, label %if.end69
  17.  
  18. if.then: ; preds = %entry
  19. %cmp2 = icmp eq i32 %iincx, 1
  20. %cmp4 = icmp eq i32 %iincy, 1
  21. %or.cond70 = and i1 %cmp2, %cmp4
  22. br i1 %or.cond70, label %if.then5, label %if.else
  23.  
  24. if.then5: ; preds = %if.then
  25. %sub = add nsw i32 %nn, -3
  26. %conv = sext i32 %sub to i64
  27. %cmp6123 = icmp sgt i32 %nn, 3
  28. br i1 %cmp6123, label %for.body.preheader, label %for.cond28.preheader
  29.  
  30. for.body.preheader: ; preds = %if.then5
  31. %0 = icmp sgt i64 %conv, 4
  32. %smax = select i1 %0, i64 %conv, i64 4
  33. br label %for.body
  34.  
  35. for.cond28.preheader.loopexit: ; preds = %for.body
  36. %1 = add nuw nsw i64 %smax, 3
  37. %2 = and i64 %1, 9223372036854775804
  38. br label %for.cond28.preheader
  39.  
  40. for.cond28.preheader: ; preds = %for.cond28.preheader.loopexit, %if.then5
  41. %i.0.lcssa = phi i64 [ 0, %if.then5 ], [ %2, %for.cond28.preheader.loopexit ]
  42. %conv29 = sext i32 %nn to i64
  43. %cmp30121 = icmp slt i64 %i.0.lcssa, %conv29
  44. br i1 %cmp30121, label %for.body32, label %if.end69
  45.  
  46. for.body: ; preds = %for.body.preheader, %for.body
  47. %i.0124 = phi i64 [ %add27, %for.body ], [ 0, %for.body.preheader ]
  48. %arrayidx = getelementptr inbounds double, double* %sx, i64 %i.0124
  49. %3 = load double, double* %arrayidx, align 8, !tbaa !2
  50. %mul = fmul double %3, %ssa
  51. %arrayidx8 = getelementptr inbounds double, double* %sy, i64 %i.0124
  52. %4 = load double, double* %arrayidx8, align 8, !tbaa !2
  53. %add = fadd double %4, %mul
  54. store double %add, double* %arrayidx8, align 8, !tbaa !2
  55. %add9 = or i64 %i.0124, 1
  56. %arrayidx10 = getelementptr inbounds double, double* %sx, i64 %add9
  57. %5 = load double, double* %arrayidx10, align 8, !tbaa !2
  58. %mul11 = fmul double %5, %ssa
  59. %arrayidx13 = getelementptr inbounds double, double* %sy, i64 %add9
  60. %6 = load double, double* %arrayidx13, align 8, !tbaa !2
  61. %add14 = fadd double %6, %mul11
  62. store double %add14, double* %arrayidx13, align 8, !tbaa !2
  63. %add15 = or i64 %i.0124, 2
  64. %arrayidx16 = getelementptr inbounds double, double* %sx, i64 %add15
  65. %7 = load double, double* %arrayidx16, align 8, !tbaa !2
  66. %mul17 = fmul double %7, %ssa
  67. %arrayidx19 = getelementptr inbounds double, double* %sy, i64 %add15
  68. %8 = load double, double* %arrayidx19, align 8, !tbaa !2
  69. %add20 = fadd double %8, %mul17
  70. store double %add20, double* %arrayidx19, align 8, !tbaa !2
  71. %add21 = or i64 %i.0124, 3
  72. %arrayidx22 = getelementptr inbounds double, double* %sx, i64 %add21
  73. %9 = load double, double* %arrayidx22, align 8, !tbaa !2
  74. %mul23 = fmul double %9, %ssa
  75. %arrayidx25 = getelementptr inbounds double, double* %sy, i64 %add21
  76. %10 = load double, double* %arrayidx25, align 8, !tbaa !2
  77. %add26 = fadd double %10, %mul23
  78. store double %add26, double* %arrayidx25, align 8, !tbaa !2
  79. %add27 = add nuw nsw i64 %i.0124, 4
  80. %cmp6 = icmp slt i64 %add27, %conv
  81. br i1 %cmp6, label %for.body, label %for.cond28.preheader.loopexit
  82.  
  83. for.body32: ; preds = %for.cond28.preheader, %for.body32
  84. %i.1122 = phi i64 [ %inc, %for.body32 ], [ %i.0.lcssa, %for.cond28.preheader ]
  85. %arrayidx33 = getelementptr inbounds double, double* %sx, i64 %i.1122
  86. %11 = load double, double* %arrayidx33, align 8, !tbaa !2
  87. %mul34 = fmul double %11, %ssa
  88. %arrayidx35 = getelementptr inbounds double, double* %sy, i64 %i.1122
  89. %12 = load double, double* %arrayidx35, align 8, !tbaa !2
  90. %add36 = fadd double %12, %mul34
  91. store double %add36, double* %arrayidx35, align 8, !tbaa !2
  92. %inc = add nuw nsw i64 %i.1122, 1
  93. %exitcond = icmp eq i64 %inc, %conv29
  94. br i1 %exitcond, label %if.end69, label %for.body32
  95.  
  96. if.else: ; preds = %if.then
  97. %cmp39 = icmp sgt i32 %iincx, -1
  98. br i1 %cmp39, label %cond.end, label %cond.false
  99.  
  100. cond.false: ; preds = %if.else
  101. %sub41 = sub nsw i32 1, %nn
  102. %mul42 = mul nsw i32 %sub41, %iincx
  103. %phitmp = sext i32 %mul42 to i64
  104. br label %cond.end
  105.  
  106. cond.end: ; preds = %if.else, %cond.false
  107. %cond = phi i64 [ %phitmp, %cond.false ], [ 0, %if.else ]
  108. %cmp44 = icmp sgt i32 %iincy, -1
  109. br i1 %cmp44, label %for.body57.lr.ph, label %cond.false47
  110.  
  111. cond.false47: ; preds = %cond.end
  112. %sub48 = sub nsw i32 1, %nn
  113. %mul49 = mul nsw i32 %sub48, %iincy
  114. %phitmp119 = sext i32 %mul49 to i64
  115. br label %for.body57.lr.ph
  116.  
  117. for.body57.lr.ph: ; preds = %cond.false47, %cond.end
  118. %cond51 = phi i64 [ %phitmp119, %cond.false47 ], [ 0, %cond.end ]
  119. %conv54 = sext i32 %nn to i64
  120. %conv62 = sext i32 %iincx to i64
  121. %conv64 = sext i32 %iincy to i64
  122. br label %for.body57
  123.  
  124. for.body57: ; preds = %for.body57, %for.body57.lr.ph
  125. %iy.0128 = phi i64 [ %cond51, %for.body57.lr.ph ], [ %add65, %for.body57 ]
  126. %ix.0127 = phi i64 [ %cond, %for.body57.lr.ph ], [ %add63, %for.body57 ]
  127. %i.2126 = phi i64 [ 0, %for.body57.lr.ph ], [ %inc67, %for.body57 ]
  128. %arrayidx58 = getelementptr inbounds double, double* %sx, i64 %ix.0127
  129. %13 = load double, double* %arrayidx58, align 8, !tbaa !2
  130. %mul59 = fmul double %13, %ssa
  131. %arrayidx60 = getelementptr inbounds double, double* %sy, i64 %iy.0128
  132. %14 = load double, double* %arrayidx60, align 8, !tbaa !2
  133. %add61 = fadd double %14, %mul59
  134. store double %add61, double* %arrayidx60, align 8, !tbaa !2
  135. %add63 = add nsw i64 %ix.0127, %conv62
  136. %add65 = add nsw i64 %iy.0128, %conv64
  137. %inc67 = add nuw nsw i64 %i.2126, 1
  138. %exitcond130 = icmp eq i64 %inc67, %conv54
  139. br i1 %exitcond130, label %if.end69, label %for.body57
  140.  
  141. if.end69: ; preds = %for.body57, %for.body32, %for.cond28.preheader, %entry
  142. ret i32 0
  143. }
  144.  
  145. ; Function Attrs: argmemonly nounwind
  146. declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
  147.  
  148. ; Function Attrs: argmemonly nounwind
  149. declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
  150.  
  151. ; Function Attrs: nounwind uwtable
  152. define dso_local i32 @main() local_unnamed_addr #2 {
  153. entry:
  154. %m = alloca [3 x double], align 16
  155. %n = alloca [3 x double], align 16
  156. %0 = bitcast [3 x double]* %m to i8*
  157. call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %0) #4
  158. call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 16 %0, i8* align 16 bitcast ([3 x double]* @main.m to i8*), i64 24, i1 false)
  159. %1 = bitcast [3 x double]* %n to i8*
  160. call void @llvm.lifetime.start.p0i8(i64 24, i8* nonnull %1) #4
  161. call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 16 %1, i8* align 16 bitcast ([3 x double]* @main.n to i8*), i64 24, i1 false)
  162. %arraydecay = getelementptr inbounds [3 x double], [3 x double]* %m, i64 0, i64 0
  163. %arraydecay1 = getelementptr inbounds [3 x double], [3 x double]* %n, i64 0, i64 0
  164. %call = call i32 @daxpy_(i32 3, double 1.000000e+00, double* nonnull %arraydecay, i32 1, double* nonnull %arraydecay1, i32 1)
  165. br label %for.body
  166.  
  167. for.cond.cleanup: ; preds = %for.body
  168. call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %1) #4
  169. call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %0) #4
  170. ret i32 0
  171.  
  172. for.body: ; preds = %for.body, %entry
  173. %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
  174. %arrayidx = getelementptr inbounds [3 x double], [3 x double]* %n, i64 0, i64 %indvars.iv
  175. %2 = load double, double* %arrayidx, align 8, !tbaa !2
  176. %call2 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %2)
  177. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  178. %exitcond = icmp eq i64 %indvars.iv.next, 3
  179. br i1 %exitcond, label %for.cond.cleanup, label %for.body
  180. }
  181.  
  182. ; Function Attrs: argmemonly nounwind
  183. declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) #1
  184.  
  185. ; Function Attrs: nounwind
  186. declare dso_local i32 @printf(i8* nocapture readonly, ...) local_unnamed_addr #3
  187.  
  188. attributes #0 = { norecurse nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
  189. attributes #1 = { argmemonly nounwind }
  190. attributes #2 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
  191. attributes #3 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
  192. attributes #4 = { nounwind }
  193.  
  194. !llvm.module.flags = !{!0}
  195. !llvm.ident = !{!1}
  196.  
  197. !0 = !{i32 1, !"wchar_size", i32 4}
  198. !1 = !{!"clang version 7.1.0 "}
  199. !2 = !{!3, !3, i64 0}
  200. !3 = !{!"double", !4, i64 0}
  201. !4 = !{!"omnipotent char", !5, i64 0}
  202. !5 = !{!"Simple C/C++ TBAA"}
Advertisement
Add Comment
Please, Sign In to add comment