only-lower-check.ll 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ; RUN: opt -irce-print-range-checks -irce-print-changed-loops -irce < %s 2>&1 | FileCheck %s
  2. ; CHECK: irce: loop has 1 inductive range checks:
  3. ; CHECK-NEXT: InductiveRangeCheck:
  4. ; CHECK-NEXT: Kind: RANGE_CHECK_LOWER
  5. ; CHECK-NEXT: Offset: (-1 + %n) Scale: -1 Length: (null)
  6. ; CHECK-NEXT: Branch: br i1 %abc, label %in.bounds, label %out.of.bounds
  7. ; CHECK-NEXT: irce: in function only_lower_check: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
  8. define void @only_lower_check(i32 *%arr, i32 *%a_len_ptr, i32 %n) {
  9. entry:
  10. %len = load i32, i32* %a_len_ptr, !range !0
  11. %first.itr.check = icmp sgt i32 %n, 0
  12. %start = sub i32 %n, 1
  13. br i1 %first.itr.check, label %loop, label %exit
  14. loop:
  15. %idx = phi i32 [ %start, %entry ] , [ %idx.dec, %in.bounds ]
  16. %idx.dec = sub i32 %idx, 1
  17. %abc = icmp sge i32 %idx, 0
  18. br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
  19. in.bounds:
  20. %addr = getelementptr i32, i32* %arr, i32 %idx
  21. store i32 0, i32* %addr
  22. %next = icmp sgt i32 %idx.dec, -1
  23. br i1 %next, label %loop, label %exit
  24. out.of.bounds:
  25. ret void
  26. exit:
  27. ret void
  28. }
  29. !0 = !{i32 0, i32 2147483647}
  30. !1 = !{!"branch_weights", i32 64, i32 4}