rgb_phi.ll 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
  2. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
  3. target triple = "i386-apple-macosx10.9.0"
  4. ; We disable the vectorization of <3 x float> for now
  5. ; float foo(float *A) {
  6. ;
  7. ; float R = A[0];
  8. ; float G = A[1];
  9. ; float B = A[2];
  10. ; for (int i=0; i < 121; i+=3) {
  11. ; R+=A[i+0]*7;
  12. ; G+=A[i+1]*8;
  13. ; B+=A[i+2]*9;
  14. ; }
  15. ;
  16. ; return R+G+B;
  17. ; }
  18. ;CHECK-LABEL: @foo(
  19. ;CHECK: br
  20. ;CHECK-NOT: phi <3 x float>
  21. ;CHECK-NOT: fmul <3 x float>
  22. ;CHECK-NOT: fadd <3 x float>
  23. ; At the moment we don't sink extractelements.
  24. ;CHECK: br
  25. ;CHECK-NOT: extractelement
  26. ;CHECK-NOT: extractelement
  27. ;CHECK-NOT: extractelement
  28. ;CHECK: ret
  29. define float @foo(float* nocapture readonly %A) {
  30. entry:
  31. %0 = load float, float* %A, align 4
  32. %arrayidx1 = getelementptr inbounds float, float* %A, i64 1
  33. %1 = load float, float* %arrayidx1, align 4
  34. %arrayidx2 = getelementptr inbounds float, float* %A, i64 2
  35. %2 = load float, float* %arrayidx2, align 4
  36. br label %for.body
  37. for.body: ; preds = %for.body.for.body_crit_edge, %entry
  38. %3 = phi float [ %0, %entry ], [ %.pre, %for.body.for.body_crit_edge ]
  39. %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body.for.body_crit_edge ]
  40. %B.032 = phi float [ %2, %entry ], [ %add14, %for.body.for.body_crit_edge ]
  41. %G.031 = phi float [ %1, %entry ], [ %add9, %for.body.for.body_crit_edge ]
  42. %R.030 = phi float [ %0, %entry ], [ %add4, %for.body.for.body_crit_edge ]
  43. %mul = fmul float %3, 7.000000e+00
  44. %add4 = fadd float %R.030, %mul
  45. %4 = add nsw i64 %indvars.iv, 1
  46. %arrayidx7 = getelementptr inbounds float, float* %A, i64 %4
  47. %5 = load float, float* %arrayidx7, align 4
  48. %mul8 = fmul float %5, 8.000000e+00
  49. %add9 = fadd float %G.031, %mul8
  50. %6 = add nsw i64 %indvars.iv, 2
  51. %arrayidx12 = getelementptr inbounds float, float* %A, i64 %6
  52. %7 = load float, float* %arrayidx12, align 4
  53. %mul13 = fmul float %7, 9.000000e+00
  54. %add14 = fadd float %B.032, %mul13
  55. %indvars.iv.next = add i64 %indvars.iv, 3
  56. %8 = trunc i64 %indvars.iv.next to i32
  57. %cmp = icmp slt i32 %8, 121
  58. br i1 %cmp, label %for.body.for.body_crit_edge, label %for.end
  59. for.body.for.body_crit_edge: ; preds = %for.body
  60. %arrayidx3.phi.trans.insert = getelementptr inbounds float, float* %A, i64 %indvars.iv.next
  61. %.pre = load float, float* %arrayidx3.phi.trans.insert, align 4
  62. br label %for.body
  63. for.end: ; preds = %for.body
  64. %add16 = fadd float %add4, %add9
  65. %add17 = fadd float %add16, %add14
  66. ret float %add17
  67. }