59 lines · plain
1; RUN: opt -passes=jump-threading -S %s | FileCheck %s2 3; Check that we thread arg2neg -> checkpos -> end.4;5; LazyValueInfo would previously fail to analyze the value of %arg in arg2neg6; because its predecessing blocks (checkneg) hadn't been processed yet (PR21238)7 8; CHECK-LABEL: @test_jump_threading9; CHECK: arg2neg:10; CHECK-NEXT: br i1 %arg1, label %end, label %checkpos.thread11; CHECK: checkpos.thread:12; CHECK-NEXT: br label %end13 14define i32 @test_jump_threading(i1 %arg1, i32 %arg2) {15checkneg:16 %cmp = icmp slt i32 %arg2, 017 br i1 %cmp, label %arg2neg, label %checkpos18 19arg2neg:20 br i1 %arg1, label %end, label %checkpos21 22checkpos:23 %cmp2 = icmp sgt i32 %arg2, 024 br i1 %cmp2, label %arg2pos, label %end25 26arg2pos:27 br label %end28 29end:30 %0 = phi i32 [ 1, %arg2neg ], [ 2, %checkpos ], [ 3, %arg2pos ]31 ret i32 %032}33 34 35; arg2neg has an edge back to itself. If LazyValueInfo is not careful when36; visiting predecessors, it could get into an infinite loop.37 38; CHECK-LABEL: test_infinite_loop39 40define i32 @test_infinite_loop(i1 %arg1, i32 %arg2) {41checkneg:42 %cmp = icmp slt i32 %arg2, 043 br i1 %cmp, label %arg2neg, label %checkpos44 45arg2neg:46 br i1 %arg1, label %arg2neg, label %checkpos47 48checkpos:49 %cmp2 = icmp sgt i32 %arg2, 050 br i1 %cmp2, label %arg2pos, label %end51 52arg2pos:53 br label %end54 55end:56 %0 = phi i32 [ 2, %checkpos ], [ 3, %arg2pos ]57 ret i32 %058}59