1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=jump-threading -S < %s | FileCheck %s
8 ; trunc(and) should be simplified
9 define i32 @test(i1 %cond0) {
11 ; CHECK-NEXT: br i1 [[COND0:%.*]], label [[T1:%.*]], label [[F1:%.*]]
13 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
14 ; CHECK-NEXT: br label [[F2:%.*]]
16 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
17 ; CHECK-NEXT: br label [[F2]]
19 ; CHECK-NEXT: [[A:%.*]] = phi i32 [ 10, [[T1]] ], [ 0, [[F1]] ]
20 ; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[V1]], [[T1]] ], [ [[V2]], [[F1]] ]
21 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[A]], 1
22 ; CHECK-NEXT: ret i32 [[B]]
24 br i1 %cond0, label %T1, label %F1
34 %A = phi i32 [10, %T1], [0, %F1]
35 %B = phi i32 [%v1, %T1], [%v2, %F1]
37 %cond = trunc i32 %And to i1
38 br i1 %cond, label %T2, label %F2
48 ; trunc(select) should be simplified
49 define i32 @test2(i1 %cond0) {
50 ; CHECK-LABEL: @test2(
51 ; CHECK-NEXT: br i1 [[COND0:%.*]], label [[T1:%.*]], label [[F1:%.*]]
53 ; CHECK-NEXT: [[V1:%.*]] = call i32 @f1()
54 ; CHECK-NEXT: br label [[F2:%.*]]
56 ; CHECK-NEXT: [[V2:%.*]] = call i32 @f2()
57 ; CHECK-NEXT: br label [[F2]]
59 ; CHECK-NEXT: [[A:%.*]] = phi i1 [ true, [[T1]] ], [ false, [[F1]] ]
60 ; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[V1]], [[T1]] ], [ [[V2]], [[F1]] ]
61 ; CHECK-NEXT: [[A2:%.*]] = xor i1 [[A]], true
62 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[A2]], i32 10, i32 0
63 ; CHECK-NEXT: ret i32 [[B]]
65 br i1 %cond0, label %T1, label %F1
75 %A = phi i1 [1, %T1], [0, %F1]
76 %B = phi i32 [%v1, %T1], [%v2, %F1]
78 %sel = select i1 %A2, i32 10, i32 0
79 %cond = trunc i32 %sel to i1
80 br i1 %cond, label %T2, label %F2