simple-loop.ll 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
  2. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  3. target triple = "x86_64-apple-macosx10.8.0"
  4. ;CHECK:rollable
  5. define i32 @rollable(i32* noalias nocapture %in, i32* noalias nocapture %out, i64 %n) {
  6. %1 = icmp eq i64 %n, 0
  7. br i1 %1, label %._crit_edge, label %.lr.ph
  8. .lr.ph: ; preds = %0, %.lr.ph
  9. %i.019 = phi i64 [ %26, %.lr.ph ], [ 0, %0 ]
  10. %2 = shl i64 %i.019, 2
  11. %3 = getelementptr inbounds i32, i32* %in, i64 %2
  12. ;CHECK:load <4 x i32>
  13. %4 = load i32, i32* %3, align 4
  14. %5 = or i64 %2, 1
  15. %6 = getelementptr inbounds i32, i32* %in, i64 %5
  16. %7 = load i32, i32* %6, align 4
  17. %8 = or i64 %2, 2
  18. %9 = getelementptr inbounds i32, i32* %in, i64 %8
  19. %10 = load i32, i32* %9, align 4
  20. %11 = or i64 %2, 3
  21. %12 = getelementptr inbounds i32, i32* %in, i64 %11
  22. %13 = load i32, i32* %12, align 4
  23. ;CHECK:mul <4 x i32>
  24. %14 = mul i32 %4, 7
  25. ;CHECK:add <4 x i32>
  26. %15 = add i32 %14, 7
  27. %16 = mul i32 %7, 7
  28. %17 = add i32 %16, 14
  29. %18 = mul i32 %10, 7
  30. %19 = add i32 %18, 21
  31. %20 = mul i32 %13, 7
  32. %21 = add i32 %20, 28
  33. %22 = getelementptr inbounds i32, i32* %out, i64 %2
  34. ;CHECK:store <4 x i32>
  35. store i32 %15, i32* %22, align 4
  36. %23 = getelementptr inbounds i32, i32* %out, i64 %5
  37. store i32 %17, i32* %23, align 4
  38. %24 = getelementptr inbounds i32, i32* %out, i64 %8
  39. store i32 %19, i32* %24, align 4
  40. %25 = getelementptr inbounds i32, i32* %out, i64 %11
  41. store i32 %21, i32* %25, align 4
  42. %26 = add i64 %i.019, 1
  43. %exitcond = icmp eq i64 %26, %n
  44. br i1 %exitcond, label %._crit_edge, label %.lr.ph
  45. ._crit_edge: ; preds = %.lr.ph, %0
  46. ;CHECK: ret
  47. ret i32 undef
  48. }
  49. ;CHECK:unrollable
  50. ;CHECK-NOT: <4 x i32>
  51. ;CHECK: ret
  52. define i32 @unrollable(i32* %in, i32* %out, i64 %n) nounwind ssp uwtable {
  53. %1 = icmp eq i64 %n, 0
  54. br i1 %1, label %._crit_edge, label %.lr.ph
  55. .lr.ph: ; preds = %0, %.lr.ph
  56. %i.019 = phi i64 [ %26, %.lr.ph ], [ 0, %0 ]
  57. %2 = shl i64 %i.019, 2
  58. %3 = getelementptr inbounds i32, i32* %in, i64 %2
  59. %4 = load i32, i32* %3, align 4
  60. %5 = or i64 %2, 1
  61. %6 = getelementptr inbounds i32, i32* %in, i64 %5
  62. %7 = load i32, i32* %6, align 4
  63. %8 = or i64 %2, 2
  64. %9 = getelementptr inbounds i32, i32* %in, i64 %8
  65. %10 = load i32, i32* %9, align 4
  66. %11 = or i64 %2, 3
  67. %12 = getelementptr inbounds i32, i32* %in, i64 %11
  68. %13 = load i32, i32* %12, align 4
  69. %14 = mul i32 %4, 7
  70. %15 = add i32 %14, 7
  71. %16 = mul i32 %7, 7
  72. %17 = add i32 %16, 14
  73. %18 = mul i32 %10, 7
  74. %19 = add i32 %18, 21
  75. %20 = mul i32 %13, 7
  76. %21 = add i32 %20, 28
  77. %22 = getelementptr inbounds i32, i32* %out, i64 %2
  78. store i32 %15, i32* %22, align 4
  79. %23 = getelementptr inbounds i32, i32* %out, i64 %5
  80. store i32 %17, i32* %23, align 4
  81. %barrier = call i32 @goo(i32 0) ; <---------------- memory barrier.
  82. %24 = getelementptr inbounds i32, i32* %out, i64 %8
  83. store i32 %19, i32* %24, align 4
  84. %25 = getelementptr inbounds i32, i32* %out, i64 %11
  85. store i32 %21, i32* %25, align 4
  86. %26 = add i64 %i.019, 1
  87. %exitcond = icmp eq i64 %26, %n
  88. br i1 %exitcond, label %._crit_edge, label %.lr.ph
  89. ._crit_edge: ; preds = %.lr.ph, %0
  90. ret i32 undef
  91. }
  92. declare i32 @goo(i32)