1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
3 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
5 ; Check that we fold the condition of branches of the
6 ; form: br <condition> dest1, dest2, where dest1 == dest2.
7 define i32 @test(i32 %x) {
10 ; CHECK-NEXT: br i1 false, label [[MERGE:%.*]], label [[MERGE]]
12 ; CHECK-NEXT: ret i32 [[X:%.*]]
15 %cmp = icmp ult i32 %x, 7
16 br i1 %cmp, label %merge, label %merge
23 define i32 @pat(i32 %x) {
25 ; CHECK-NEXT: br i1 false, label [[PATATINO:%.*]], label [[PATATINO]]
27 ; CHECK-NEXT: ret i32 [[X:%.*]]
29 %y = icmp eq i32 27, ptrtoint(i8* @global to i32)
30 br i1 %y, label %patatino, label %patatino
35 define i1 @test01(i1 %cond) {
36 ; CHECK-LABEL: @test01(
38 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE_1:%.*]], label [[IF_FALSE_1:%.*]]
40 ; CHECK-NEXT: br label [[MERGE_1:%.*]]
42 ; CHECK-NEXT: br label [[MERGE_1]]
44 ; CHECK-NEXT: br i1 [[COND]], label [[IF_TRUE_2:%.*]], label [[IF_FALSE_2:%.*]]
46 ; CHECK-NEXT: br label [[MERGE_2:%.*]]
48 ; CHECK-NEXT: br label [[MERGE_2]]
50 ; CHECK-NEXT: ret i1 [[COND]]
53 br i1 %cond, label %if.true.1, label %if.false.1
62 %merge.cond.1 = phi i1 [true, %if.true.1], [false, %if.false.1]
63 br i1 %merge.cond.1, label %if.true.2, label %if.false.2
72 %merge.cond.2 = phi i1 [true, %if.true.2], [false, %if.false.2]
76 define i1 @test02(i1 %cond) {
77 ; CHECK-LABEL: @test02(
79 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE_1:%.*]], label [[IF_FALSE_1:%.*]]
81 ; CHECK-NEXT: br label [[MERGE_1:%.*]]
83 ; CHECK-NEXT: br label [[MERGE_1]]
85 ; CHECK-NEXT: br i1 [[COND]], label [[IF_FALSE_2:%.*]], label [[IF_TRUE_2:%.*]]
87 ; CHECK-NEXT: br label [[MERGE_2:%.*]]
89 ; CHECK-NEXT: br label [[MERGE_2]]
91 ; CHECK-NEXT: ret i1 [[COND]]
94 br i1 %cond, label %if.true.1, label %if.false.1
103 %merge.cond.1 = phi i1 [false, %if.true.1], [true, %if.false.1]
104 br i1 %merge.cond.1, label %if.true.2, label %if.false.2
113 %merge.cond.2 = phi i1 [false, %if.true.2], [true, %if.false.2]