no-if-convert.ll 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ; RUN: opt -basicaa -loop-distribute -verify-loop-info -verify-dom-info -S < %s \
  2. ; RUN: | FileCheck %s
  3. ; We should distribute this loop along === but not along ---. The last
  4. ; partition won't be vectorized due to conditional stores so it's better to
  5. ; keep it with the second partition which has a dependence cycle.
  6. ; (1st statement):
  7. ; for (i = 0; i < n; i++) {
  8. ; C[i] = D[i] * E[i];
  9. ;=============================
  10. ; A[i + 1] = A[i] * B[i];
  11. ;-----------------------------
  12. ; if (F[i])
  13. ; G[i] = H[i] * J[i];
  14. ; }
  15. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  16. target triple = "x86_64-apple-macosx10.10.0"
  17. define void @f(i32* noalias %a,
  18. i32* noalias %b,
  19. i32* noalias %c,
  20. i32* noalias %d,
  21. i32* noalias %e,
  22. i32* noalias %g,
  23. i32* noalias %h,
  24. i32* noalias %j,
  25. i64 %x) {
  26. entry:
  27. br label %for.body
  28. ; Ensure that we have only two partitions, the first with one multiplication
  29. ; and the second with two.
  30. ; CHECK: for.body.ldist1:
  31. ; CHECK: %mulC.ldist1 = mul i32 %loadD.ldist1, %loadE.ldist1
  32. ; CHECK: br i1 %exitcond.ldist1, label %entry.split, label %for.body.ldist1
  33. ; CHECK: entry.split:
  34. ; CHECK: br label %for.body
  35. ; CHECK: for.body:
  36. ; CHECK: %mulA = mul i32 %loadB, %loadA
  37. ; CHECK: %mulG = mul i32 %loadH, %loadJ
  38. ; CHECK: for.end:
  39. for.body: ; preds = %for.body, %entry
  40. %ind = phi i64 [ 0, %entry ], [ %add, %if.end ]
  41. %arrayidxD = getelementptr inbounds i32, i32* %d, i64 %ind
  42. %loadD = load i32, i32* %arrayidxD, align 4
  43. %arrayidxE = getelementptr inbounds i32, i32* %e, i64 %ind
  44. %loadE = load i32, i32* %arrayidxE, align 4
  45. %mulC = mul i32 %loadD, %loadE
  46. %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %ind
  47. store i32 %mulC, i32* %arrayidxC, align 4
  48. %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %ind
  49. %loadA = load i32, i32* %arrayidxA, align 4
  50. %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %ind
  51. %loadB = load i32, i32* %arrayidxB, align 4
  52. %mulA = mul i32 %loadB, %loadA
  53. %add = add nuw nsw i64 %ind, 1
  54. %arrayidxA_plus_4 = getelementptr inbounds i32, i32* %a, i64 %add
  55. store i32 %mulA, i32* %arrayidxA_plus_4, align 4
  56. %if.cond = icmp eq i64 %ind, %x
  57. br i1 %if.cond, label %if.then, label %if.end
  58. if.then:
  59. %arrayidxH = getelementptr inbounds i32, i32* %h, i64 %ind
  60. %loadH = load i32, i32* %arrayidxH, align 4
  61. %arrayidxJ = getelementptr inbounds i32, i32* %j, i64 %ind
  62. %loadJ = load i32, i32* %arrayidxJ, align 4
  63. %mulG = mul i32 %loadH, %loadJ
  64. %arrayidxG = getelementptr inbounds i32, i32* %g, i64 %ind
  65. store i32 %mulG, i32* %arrayidxG, align 4
  66. br label %if.end
  67. if.end:
  68. %exitcond = icmp eq i64 %add, 20
  69. br i1 %exitcond, label %for.end, label %for.body
  70. for.end: ; preds = %for.body
  71. ret void
  72. }