2011-10-06-ReusePhi.ll 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ; RUN: opt -loop-reduce -S < %s | FileCheck %s
  2. ;
  3. ; Test LSR's intelligence regarding phi reuse.
  4. ; Verify that scaled GEPs are not reused. rdar://5064068
  5. target triple = "x86-apple-darwin"
  6. ; Provide legal integer types.
  7. target datalayout = "n8:16:32:64"
  8. ; CHECK-LABEL: @test(
  9. ; multiplies are hoisted out of the loop
  10. ; CHECK: while.body.lr.ph:
  11. ; CHECK: shl i64
  12. ; CHECK: shl i64
  13. ; GEPs are ugly
  14. ; CHECK: while.body:
  15. ; CHECK: phi
  16. ; CHECK: phi
  17. ; CHECK: phi
  18. ; CHECK: phi
  19. ; CHECK-NOT: phi
  20. ; CHECK: bitcast float* {{.*}} to i1*
  21. ; CHECK: bitcast float* {{.*}} to i1*
  22. ; CHECK: getelementptr i1, i1*
  23. ; CHECK: getelementptr i1, i1*
  24. define float @test(float* nocapture %A, float* nocapture %B, i32 %N, i32 %IA, i32 %IB) nounwind uwtable readonly ssp {
  25. entry:
  26. %cmp1 = icmp sgt i32 %N, 0
  27. br i1 %cmp1, label %while.body.lr.ph, label %while.end
  28. while.body.lr.ph: ; preds = %entry
  29. %idx.ext = sext i32 %IA to i64
  30. %idx.ext2 = sext i32 %IB to i64
  31. br label %while.body
  32. while.body: ; preds = %while.body.lr.ph, %while.body
  33. %A.addr.05 = phi float* [ %A, %while.body.lr.ph ], [ %add.ptr, %while.body ]
  34. %B.addr.04 = phi float* [ %B, %while.body.lr.ph ], [ %add.ptr3, %while.body ]
  35. %N.addr.03 = phi i32 [ %N, %while.body.lr.ph ], [ %sub, %while.body ]
  36. %Sum0.02 = phi float [ 0.000000e+00, %while.body.lr.ph ], [ %add, %while.body ]
  37. %0 = load float, float* %A.addr.05, align 4
  38. %1 = load float, float* %B.addr.04, align 4
  39. %mul = fmul float %0, %1
  40. %add = fadd float %Sum0.02, %mul
  41. %add.ptr = getelementptr inbounds float, float* %A.addr.05, i64 %idx.ext
  42. %add.ptr3 = getelementptr inbounds float, float* %B.addr.04, i64 %idx.ext2
  43. %sub = add nsw i32 %N.addr.03, -1
  44. %cmp = icmp sgt i32 %sub, 0
  45. br i1 %cmp, label %while.body, label %while.end
  46. while.end: ; preds = %while.body, %entry
  47. %Sum0.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add, %while.body ]
  48. ret float %Sum0.0.lcssa
  49. }