if-pred-stores.ll 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ; RUN: opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -loop-vectorize < %s | FileCheck %s --check-prefix=UNROLL
  2. ; RUN: opt -S -vectorize-num-stores-pred=1 -force-vector-width=2 -force-vector-interleave=1 -loop-vectorize -enable-cond-stores-vec < %s | FileCheck %s --check-prefix=VEC
  3. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  4. target triple = "x86_64-apple-macosx10.9.0"
  5. ; Test predication of stores.
  6. define i32 @test(i32* nocapture %f) #0 {
  7. entry:
  8. br label %for.body
  9. ; VEC-LABEL: test
  10. ; VEC: %[[v8:.+]] = icmp sgt <2 x i32> %{{.*}}, <i32 100, i32 100>
  11. ; VEC: %[[v9:.+]] = add nsw <2 x i32> %{{.*}}, <i32 20, i32 20>
  12. ; VEC: %[[v10:.+]] = and <2 x i1> %[[v8]], <i1 true, i1 true>
  13. ; VEC: %[[v11:.+]] = extractelement <2 x i1> %[[v10]], i32 0
  14. ; VEC: %[[v12:.+]] = icmp eq i1 %[[v11]], true
  15. ; VEC: br i1 %[[v12]], label %[[cond:.+]], label %[[else:.+]]
  16. ;
  17. ; VEC: [[cond]]:
  18. ; VEC: %[[v13:.+]] = extractelement <2 x i32> %[[v9]], i32 0
  19. ; VEC: %[[v14:.+]] = extractelement <2 x i32*> %{{.*}}, i32 0
  20. ; VEC: store i32 %[[v13]], i32* %[[v14]], align 4
  21. ; VEC: br label %[[else:.+]]
  22. ;
  23. ; VEC: [[else]]:
  24. ; VEC: %[[v15:.+]] = extractelement <2 x i1> %[[v10]], i32 1
  25. ; VEC: %[[v16:.+]] = icmp eq i1 %[[v15]], true
  26. ; VEC: br i1 %[[v16]], label %[[cond2:.+]], label %[[else2:.+]]
  27. ;
  28. ; VEC: [[cond2]]:
  29. ; VEC: %[[v17:.+]] = extractelement <2 x i32> %[[v9]], i32 1
  30. ; VEC: %[[v18:.+]] = extractelement <2 x i32*> %{{.+}} i32 1
  31. ; VEC: store i32 %[[v17]], i32* %[[v18]], align 4
  32. ; VEC: br label %[[else2:.+]]
  33. ;
  34. ; VEC: [[else2]]:
  35. ; UNROLL-LABEL: test
  36. ; UNROLL: vector.body:
  37. ; UNROLL: %[[IND:[a-zA-Z0-9]+]] = add i64 %{{.*}}, 0
  38. ; UNROLL: %[[IND1:[a-zA-Z0-9]+]] = add i64 %{{.*}}, 1
  39. ; UNROLL: %[[v0:[a-zA-Z0-9]+]] = getelementptr inbounds i32, i32* %f, i64 %[[IND]]
  40. ; UNROLL: %[[v1:[a-zA-Z0-9]+]] = getelementptr inbounds i32, i32* %f, i64 %[[IND1]]
  41. ; UNROLL: %[[v2:[a-zA-Z0-9]+]] = load i32, i32* %[[v0]], align 4
  42. ; UNROLL: %[[v3:[a-zA-Z0-9]+]] = load i32, i32* %[[v1]], align 4
  43. ; UNROLL: %[[v4:[a-zA-Z0-9]+]] = icmp sgt i32 %[[v2]], 100
  44. ; UNROLL: %[[v5:[a-zA-Z0-9]+]] = icmp sgt i32 %[[v3]], 100
  45. ; UNROLL: %[[v6:[a-zA-Z0-9]+]] = add nsw i32 %[[v2]], 20
  46. ; UNROLL: %[[v7:[a-zA-Z0-9]+]] = add nsw i32 %[[v3]], 20
  47. ; UNROLL: %[[v8:[a-zA-Z0-9]+]] = icmp eq i1 %[[v4]], true
  48. ; UNROLL: br i1 %[[v8]], label %[[cond:[a-zA-Z0-9.]+]], label %[[else:[a-zA-Z0-9.]+]]
  49. ;
  50. ; UNROLL: [[cond]]:
  51. ; UNROLL: store i32 %[[v6]], i32* %[[v0]], align 4
  52. ; UNROLL: br label %[[else]]
  53. ;
  54. ; UNROLL: [[else]]:
  55. ; UNROLL: %[[v9:[a-zA-Z0-9]+]] = icmp eq i1 %[[v5]], true
  56. ; UNROLL: br i1 %[[v9]], label %[[cond2:[a-zA-Z0-9.]+]], label %[[else2:[a-zA-Z0-9.]+]]
  57. ;
  58. ; UNROLL: [[cond2]]:
  59. ; UNROLL: store i32 %[[v7]], i32* %[[v1]], align 4
  60. ; UNROLL: br label %[[else2]]
  61. ;
  62. ; UNROLL: [[else2]]:
  63. for.body:
  64. %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
  65. %arrayidx = getelementptr inbounds i32, i32* %f, i64 %indvars.iv
  66. %0 = load i32, i32* %arrayidx, align 4
  67. %cmp1 = icmp sgt i32 %0, 100
  68. br i1 %cmp1, label %if.then, label %for.inc
  69. if.then:
  70. %add = add nsw i32 %0, 20
  71. store i32 %add, i32* %arrayidx, align 4
  72. br label %for.inc
  73. for.inc:
  74. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  75. %exitcond = icmp eq i64 %indvars.iv.next, 128
  76. br i1 %exitcond, label %for.end, label %for.body
  77. for.end:
  78. ret i32 0
  79. }
  80. ; Track basic blocks when unrolling conditional blocks. This code used to assert
  81. ; because we did not update the phi nodes with the proper predecessor in the
  82. ; vectorized loop body.
  83. ; PR18724
  84. ; UNROLL-LABEL: bug18724
  85. ; UNROLL: store i32
  86. ; UNROLL: store i32
  87. define void @bug18724() {
  88. entry:
  89. br label %for.body9
  90. for.body9:
  91. br i1 undef, label %for.inc26, label %for.body14
  92. for.body14:
  93. %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc23 ], [ undef, %for.body9 ]
  94. %iNewChunks.120 = phi i32 [ %iNewChunks.2, %for.inc23 ], [ undef, %for.body9 ]
  95. %arrayidx16 = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 %indvars.iv3
  96. %tmp = load i32, i32* %arrayidx16, align 4
  97. br i1 undef, label %if.then18, label %for.inc23
  98. if.then18:
  99. store i32 2, i32* %arrayidx16, align 4
  100. %inc21 = add nsw i32 %iNewChunks.120, 1
  101. br label %for.inc23
  102. for.inc23:
  103. %iNewChunks.2 = phi i32 [ %inc21, %if.then18 ], [ %iNewChunks.120, %for.body14 ]
  104. %indvars.iv.next4 = add nsw i64 %indvars.iv3, 1
  105. %tmp1 = trunc i64 %indvars.iv3 to i32
  106. %cmp13 = icmp slt i32 %tmp1, 0
  107. br i1 %cmp13, label %for.body14, label %for.inc26
  108. for.inc26:
  109. %iNewChunks.1.lcssa = phi i32 [ undef, %for.body9 ], [ %iNewChunks.2, %for.inc23 ]
  110. unreachable
  111. }