licm.ll 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ; RUN: opt -tbaa -licm -S < %s | FileCheck %s
  2. ; LICM should be able to hoist the address load out of the loop
  3. ; by using TBAA information.
  4. ; CHECK: @foo
  5. ; CHECK: entry:
  6. ; CHECK-NEXT: %tmp3 = load double*, double** @P, !tbaa !0
  7. ; CHECK-NEXT: br label %for.body
  8. @P = common global double* null
  9. define void @foo(i64 %n) nounwind {
  10. entry:
  11. br label %for.body
  12. for.body: ; preds = %entry, %for.body
  13. %i.07 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
  14. %tmp3 = load double*, double** @P, !tbaa !1
  15. %scevgep = getelementptr double, double* %tmp3, i64 %i.07
  16. %tmp4 = load double, double* %scevgep, !tbaa !2
  17. %mul = fmul double %tmp4, 2.300000e+00
  18. store double %mul, double* %scevgep, !tbaa !2
  19. %inc = add i64 %i.07, 1
  20. %exitcond = icmp eq i64 %inc, %n
  21. br i1 %exitcond, label %for.end, label %for.body
  22. for.end: ; preds = %for.body, %entry
  23. ret void
  24. }
  25. !0 = !{!"root", null}
  26. !1 = !{!6, !6, i64 0}
  27. !2 = !{!7, !7, i64 0}
  28. ; LICM shouldn't hoist anything here.
  29. ; CHECK: @bar
  30. ; CHECK: loop:
  31. ; CHECK: load
  32. ; CHECK: store
  33. ; CHECK: load
  34. ; CHECK: store
  35. ; CHECK: br label %loop
  36. define void @bar(i8** %p) nounwind {
  37. entry:
  38. %q = bitcast i8** %p to i8*
  39. br label %loop
  40. loop:
  41. %tmp51 = load i8*, i8** %p, !tbaa !4
  42. store i8* %tmp51, i8** %p
  43. %tmp40 = load i8, i8* %q, !tbaa !5
  44. store i8 %tmp40, i8* %q
  45. br label %loop
  46. }
  47. !3 = !{!"pointer", !8}
  48. !4 = !{!8, !8, i64 0}
  49. !5 = !{!9, !9, i64 0}
  50. !6 = !{!"pointer", !0}
  51. !7 = !{!"double", !0}
  52. !8 = !{!"char", !9}
  53. !9 = !{!"root", null}