infinite-loop.ll 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ; REQUIRES: asserts
  2. ; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s
  3. ; RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s
  4. ; PR5373
  5. ; Loop unswitching shouldn't trivially unswitch the true case of condition %a
  6. ; in the code here because it leads to an infinite loop. While this doesn't
  7. ; contain any instructions with side effects, it's still a kind of side effect.
  8. ; It can trivially unswitch on the false cas of condition %a though.
  9. ; STATS: 2 loop-unswitch - Number of branches unswitched
  10. ; STATS: 1 loop-unswitch - Number of unswitches that are trivial
  11. ; CHECK-LABEL: @func_16(
  12. ; CHECK-NEXT: entry:
  13. ; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split
  14. ; CHECK: entry.split:
  15. ; CHECK-NEXT: br i1 %b, label %cond.end.us, label %abort1
  16. ; CHECK: cond.end.us:
  17. ; CHECK-NEXT: br label %cond.end.us
  18. ; CHECK: abort0.split:
  19. ; CHECK-NEXT: call void @end0() [[NOR_NUW:#[0-9]+]]
  20. ; CHECK-NEXT: unreachable
  21. ; CHECK: abort1:
  22. ; CHECK-NEXT: call void @end1() [[NOR_NUW]]
  23. ; CHECK-NEXT: unreachable
  24. ; CHECK: }
  25. define void @func_16(i1 %a, i1 %b) nounwind {
  26. entry:
  27. br label %for.body
  28. for.body:
  29. br i1 %a, label %cond.end, label %abort0
  30. cond.end:
  31. br i1 %b, label %for.body, label %abort1
  32. abort0:
  33. call void @end0() noreturn nounwind
  34. unreachable
  35. abort1:
  36. call void @end1() noreturn nounwind
  37. unreachable
  38. }
  39. declare void @end0() noreturn
  40. declare void @end1() noreturn
  41. ; CHECK: attributes #0 = { nounwind }
  42. ; CHECK: attributes #1 = { noreturn }
  43. ; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind }