1 ; RUN: opt -S -jump-threading < %s | FileCheck %s 2 3 declare i8* @escape() 4 declare void @llvm.assume(i1) 5 6 define i1 @test1(i1 %cond) { 7 entry: 8 br i1 %cond, label %taken, label %not_taken 9 10 ; CHECK-LABEL: @test1 11 ; CHECK: br i1 %cond, label %no, label %yes 12 ; CHECK: ret i1 true 13 14 taken: 15 %res1 = call i8* @escape() 16 %a = icmp eq i8* %res1, null 17 tail call void @llvm.assume(i1 %a) 18 br label %done 19 not_taken: 20 %res2 = call i8* @escape() 21 %b = icmp ne i8* %res2, null 22 tail call void @llvm.assume(i1 %b) 23 br label %done 24 25 ; An assume that can be used to simplify this comparison dominates each 26 ; predecessor branch (although no assume dominates the cmp itself). Make sure 27 ; this still can be simplified. 28 29 done: 30 %res = phi i8* [ %res1, %taken ], [ %res2, %not_taken ] 31 %cnd = icmp ne i8* %res, null 32 br i1 %cnd, label %yes, label %no 33 34 yes: 35 ret i1 true 36 no: 37 ret i1 false 38 } 39 40