2011-08-09-PhiUpdate.ll 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ; RUN: opt -S < %s -instcombine -inline -jump-threading -loop-unroll -unroll-count=4 | FileCheck %s
  2. ;
  3. ; This is a test case that required a number of setup passes because
  4. ; it depends on block order.
  5. 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"
  6. target triple = "x86_64-apple-macosx10.6.8"
  7. declare i1 @check() nounwind
  8. declare i32 @getval() nounwind
  9. ; Check that the loop exit merges values from all the iterations. This
  10. ; could be a tad fragile, but it's a good test.
  11. ;
  12. ; CHECK-LABEL: @foo(
  13. ; CHECK: return:
  14. ; CHECK: %retval.0 = phi i32 [ %tmp7.i, %land.lhs.true ], [ 0, %do.cond ], [ %tmp7.i.1, %land.lhs.true.1 ], [ 0, %do.cond.1 ], [ %tmp7.i.2, %land.lhs.true.2 ], [ 0, %do.cond.2 ], [ %tmp7.i.3, %land.lhs.true.3 ], [ 0, %do.cond.3 ]
  15. ; CHECK-NOT: @bar(
  16. ; CHECK: bar.exit.3
  17. define i32 @foo() uwtable ssp align 2 {
  18. entry:
  19. br i1 undef, label %return, label %if.end
  20. if.end: ; preds = %entry
  21. %call2 = call i32 @getval()
  22. br label %do.body
  23. do.body: ; preds = %do.cond, %if.end
  24. %call6 = call i32 @bar()
  25. %cmp = icmp ne i32 %call6, 0
  26. br i1 %cmp, label %land.lhs.true, label %do.cond
  27. land.lhs.true: ; preds = %do.body
  28. %call10 = call i32 @getval()
  29. %cmp11 = icmp eq i32 0, %call10
  30. br i1 %cmp11, label %return, label %do.cond
  31. do.cond: ; preds = %land.lhs.true, %do.body
  32. %cmp18 = icmp sle i32 0, %call2
  33. br i1 %cmp18, label %do.body, label %return
  34. return: ; preds = %do.cond, %land.lhs.true, %entry
  35. %retval.0 = phi i32 [ 0, %entry ], [ %call6, %land.lhs.true ], [ 0, %do.cond ]
  36. ret i32 %retval.0
  37. }
  38. define linkonce_odr i32 @bar() nounwind uwtable ssp align 2 {
  39. entry:
  40. br i1 undef, label %land.lhs.true, label %cond.end
  41. land.lhs.true: ; preds = %entry
  42. %cmp4 = call zeroext i1 @check()
  43. br i1 %cmp4, label %cond.true, label %cond.end
  44. cond.true: ; preds = %land.lhs.true
  45. %tmp7 = call i32 @getval()
  46. br label %cond.end
  47. cond.end: ; preds = %cond.true, %land.lhs.true, %entry
  48. %cond = phi i32 [ %tmp7, %cond.true ], [ 0, %land.lhs.true ], [ 0, %entry ]
  49. ret i32 %cond
  50. }