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