conservative-lvi.ll 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ; RUN: opt -jump-threading -S %s | FileCheck %s
  2. ; Check that we thread arg2neg -> checkpos -> end.
  3. ;
  4. ; LazyValueInfo would previously fail to analyze the value of %arg in arg2neg
  5. ; because its predecessing blocks (checkneg) hadn't been processed yet (PR21238)
  6. ; CHECK-LABEL: @test_jump_threading
  7. ; CHECK: arg2neg:
  8. ; CHECK-NEXT: br i1 %arg1, label %end, label %checkpos.thread
  9. ; CHECK: checkpos.thread:
  10. ; CHECK-NEXT: br label %end
  11. define i32 @test_jump_threading(i1 %arg1, i32 %arg2) {
  12. checkneg:
  13. %cmp = icmp slt i32 %arg2, 0
  14. br i1 %cmp, label %arg2neg, label %checkpos
  15. arg2neg:
  16. br i1 %arg1, label %end, label %checkpos
  17. checkpos:
  18. %cmp2 = icmp sgt i32 %arg2, 0
  19. br i1 %cmp2, label %arg2pos, label %end
  20. arg2pos:
  21. br label %end
  22. end:
  23. %0 = phi i32 [ 1, %arg2neg ], [ 2, %checkpos ], [ 3, %arg2pos ]
  24. ret i32 %0
  25. }
  26. ; arg2neg has an edge back to itself. If LazyValueInfo is not careful when
  27. ; visiting predecessors, it could get into an infinite loop.
  28. ; CHECK-LABEL: test_infinite_loop
  29. define i32 @test_infinite_loop(i1 %arg1, i32 %arg2) {
  30. checkneg:
  31. %cmp = icmp slt i32 %arg2, 0
  32. br i1 %cmp, label %arg2neg, label %checkpos
  33. arg2neg:
  34. br i1 %arg1, label %arg2neg, label %checkpos
  35. checkpos:
  36. %cmp2 = icmp sgt i32 %arg2, 0
  37. br i1 %cmp2, label %arg2pos, label %end
  38. arg2pos:
  39. br label %end
  40. end:
  41. %0 = phi i32 [ 2, %checkpos ], [ 3, %arg2pos ]
  42. ret i32 %0
  43. }