1*f561713dSJuneyoung Lee; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2*f561713dSJuneyoung Lee; RUN: opt -jump-threading -S < %s | FileCheck %s 3*f561713dSJuneyoung Lee 4*f561713dSJuneyoung Lee@x = global i32 0 5*f561713dSJuneyoung Lee@y = global i32 0 6*f561713dSJuneyoung Lee 7*f561713dSJuneyoung Leedeclare void @f() 8*f561713dSJuneyoung Leedeclare void @g() 9*f561713dSJuneyoung Lee 10*f561713dSJuneyoung Leedefine i32 @pre(i1 %cond, i32 %n) { 11*f561713dSJuneyoung Lee; CHECK-LABEL: @pre( 12*f561713dSJuneyoung Lee; CHECK-NEXT: br i1 [[COND:%.*]], label [[C_THREAD:%.*]], label [[C:%.*]] 13*f561713dSJuneyoung Lee; CHECK: C.thread: 14*f561713dSJuneyoung Lee; CHECK-NEXT: store i32 0, i32* @x, align 4 15*f561713dSJuneyoung Lee; CHECK-NEXT: br label [[YES:%.*]] 16*f561713dSJuneyoung Lee; CHECK: C: 17*f561713dSJuneyoung Lee; CHECK-NEXT: [[A_PR:%.*]] = load i32, i32* @y, align 4 18*f561713dSJuneyoung Lee; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[A_PR]], 0 19*f561713dSJuneyoung Lee; CHECK-NEXT: br i1 [[COND2]], label [[YES]], label [[NO:%.*]] 20*f561713dSJuneyoung Lee; CHECK: YES: 21*f561713dSJuneyoung Lee; CHECK-NEXT: [[A4:%.*]] = phi i32 [ 0, [[C_THREAD]] ], [ [[A_PR]], [[C]] ] 22*f561713dSJuneyoung Lee; CHECK-NEXT: call void @f() 23*f561713dSJuneyoung Lee; CHECK-NEXT: ret i32 [[A4]] 24*f561713dSJuneyoung Lee; CHECK: NO: 25*f561713dSJuneyoung Lee; CHECK-NEXT: call void @g() 26*f561713dSJuneyoung Lee; CHECK-NEXT: ret i32 1 27*f561713dSJuneyoung Lee; 28*f561713dSJuneyoung Lee br i1 %cond, label %A, label %B 29*f561713dSJuneyoung LeeA: 30*f561713dSJuneyoung Lee store i32 0, i32* @x 31*f561713dSJuneyoung Lee br label %C 32*f561713dSJuneyoung LeeB: 33*f561713dSJuneyoung Lee br label %C 34*f561713dSJuneyoung LeeC: 35*f561713dSJuneyoung Lee %ptr = phi i32* [@x, %A], [@y, %B] 36*f561713dSJuneyoung Lee %a = load i32, i32* %ptr 37*f561713dSJuneyoung Lee %cond2 = icmp eq i32 %a, 0 38*f561713dSJuneyoung Lee br i1 %cond2, label %YES, label %NO 39*f561713dSJuneyoung LeeYES: 40*f561713dSJuneyoung Lee call void @f() 41*f561713dSJuneyoung Lee ret i32 %a 42*f561713dSJuneyoung LeeNO: 43*f561713dSJuneyoung Lee call void @g() 44*f561713dSJuneyoung Lee ret i32 1 45*f561713dSJuneyoung Lee} 46*f561713dSJuneyoung Lee 47*f561713dSJuneyoung Leedefine i32 @pre_freeze(i1 %cond, i32 %n) { 48*f561713dSJuneyoung Lee; CHECK-LABEL: @pre_freeze( 49*f561713dSJuneyoung Lee; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[C:%.*]] 50*f561713dSJuneyoung Lee; CHECK: A: 51*f561713dSJuneyoung Lee; CHECK-NEXT: store i32 0, i32* @x, align 4 52*f561713dSJuneyoung Lee; CHECK-NEXT: br label [[C]] 53*f561713dSJuneyoung Lee; CHECK: C: 54*f561713dSJuneyoung Lee; CHECK-NEXT: [[PTR:%.*]] = phi i32* [ @x, [[A]] ], [ @y, [[TMP0:%.*]] ] 55*f561713dSJuneyoung Lee; CHECK-NEXT: [[A:%.*]] = load i32, i32* [[PTR]], align 4 56*f561713dSJuneyoung Lee; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[A]], 0 57*f561713dSJuneyoung Lee; CHECK-NEXT: [[COND2_FR:%.*]] = freeze i1 [[COND2]] 58*f561713dSJuneyoung Lee; CHECK-NEXT: br i1 [[COND2_FR]], label [[YES:%.*]], label [[NO:%.*]] 59*f561713dSJuneyoung Lee; CHECK: YES: 60*f561713dSJuneyoung Lee; CHECK-NEXT: call void @f() 61*f561713dSJuneyoung Lee; CHECK-NEXT: ret i32 [[A]] 62*f561713dSJuneyoung Lee; CHECK: NO: 63*f561713dSJuneyoung Lee; CHECK-NEXT: call void @g() 64*f561713dSJuneyoung Lee; CHECK-NEXT: ret i32 1 65*f561713dSJuneyoung Lee; 66*f561713dSJuneyoung Lee br i1 %cond, label %A, label %B 67*f561713dSJuneyoung LeeA: 68*f561713dSJuneyoung Lee store i32 0, i32* @x 69*f561713dSJuneyoung Lee br label %C 70*f561713dSJuneyoung LeeB: 71*f561713dSJuneyoung Lee br label %C 72*f561713dSJuneyoung LeeC: 73*f561713dSJuneyoung Lee %ptr = phi i32* [@x, %A], [@y, %B] 74*f561713dSJuneyoung Lee %a = load i32, i32* %ptr 75*f561713dSJuneyoung Lee %cond2 = icmp eq i32 %a, 0 76*f561713dSJuneyoung Lee %cond2.fr = freeze i1 %cond2 77*f561713dSJuneyoung Lee br i1 %cond2.fr, label %YES, label %NO 78*f561713dSJuneyoung LeeYES: 79*f561713dSJuneyoung Lee call void @f() 80*f561713dSJuneyoung Lee ret i32 %a 81*f561713dSJuneyoung LeeNO: 82*f561713dSJuneyoung Lee call void @g() 83*f561713dSJuneyoung Lee ret i32 1 84*f561713dSJuneyoung Lee} 85