pr18223.ll 723 B

123456789101112131415161718192021222324252627282930
  1. ; RUN: opt -indvars -S < %s | FileCheck %s
  2. ; indvars should transform the phi node pair from the for-loop
  3. ; CHECK-LABEL: @main(
  4. ; CHECK: ret = phi i32 [ 0, %entry ], [ 0, {{.*}} ]
  5. @c = common global i32 0, align 4
  6. define i32 @main() #0 {
  7. entry:
  8. %0 = load i32, i32* @c, align 4
  9. %tobool = icmp eq i32 %0, 0
  10. br i1 %tobool, label %for.body, label %exit
  11. for.body:
  12. %inc2 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
  13. %sub = add i32 %inc2, -1
  14. %cmp1 = icmp uge i32 %sub, %inc2
  15. %conv = zext i1 %cmp1 to i32
  16. br label %for.inc
  17. for.inc:
  18. %inc = add nsw i32 %inc2, 1
  19. %cmp = icmp slt i32 %inc, 5
  20. br i1 %cmp, label %for.body, label %exit
  21. exit:
  22. %ret = phi i32 [ 0, %entry ], [ %conv, %for.inc ]
  23. ret i32 %ret
  24. }