1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 define i64 @test0(i64 %x) {
7 ; CHECK-NEXT: [[A:%.*]] = icmp eq i64 [[X:%.*]], 0
8 ; CHECK-NEXT: br i1 [[A]], label [[EXIT:%.*]], label [[NON_ZERO:%.*]]
10 ; CHECK-NEXT: [[B:%.*]] = icmp eq i64 [[X]], 0
11 ; CHECK-NEXT: br i1 [[B]], label [[UNREACHABLE:%.*]], label [[EXIT]]
13 ; CHECK-NEXT: br label [[EXIT]]
15 ; CHECK-NEXT: [[C:%.*]] = phi i64 [ 0, [[START:%.*]] ], [ 1, [[NON_ZERO]] ], [ 2, [[UNREACHABLE]] ]
16 ; CHECK-NEXT: ret i64 [[C]]
19 %a = icmp eq i64 %x, 0
20 br i1 %a, label %exit, label %non_zero
23 %b = icmp eq i64 %x, 0
24 br i1 %b, label %unreachable, label %exit
30 %c = phi i64 [ 0, %start ], [ 1, %non_zero ], [ 2, %unreachable ]
34 define i64 @test1(i64 %x) {
35 ; CHECK-LABEL: @test1(
37 ; CHECK-NEXT: [[A:%.*]] = icmp eq i64 [[X:%.*]], 0
38 ; CHECK-NEXT: br i1 [[A]], label [[EXIT:%.*]], label [[NON_ZERO:%.*]]
40 ; CHECK-NEXT: [[B:%.*]] = icmp ugt i64 [[X]], 0
41 ; CHECK-NEXT: br i1 [[B]], label [[EXIT]], label [[UNREACHABLE:%.*]]
43 ; CHECK-NEXT: br label [[EXIT]]
45 ; CHECK-NEXT: [[C:%.*]] = phi i64 [ 0, [[START:%.*]] ], [ [[X]], [[NON_ZERO]] ], [ 0, [[UNREACHABLE]] ]
46 ; CHECK-NEXT: ret i64 [[C]]
49 %a = icmp eq i64 %x, 0
50 br i1 %a, label %exit, label %non_zero
53 %b = icmp ugt i64 %x, 0
54 br i1 %b, label %exit, label %unreachable
60 %c = phi i64 [ 0, %start ], [ %x, %non_zero ], [ 0, %unreachable ]
64 define i1 @test2(i64 %x, i1 %y) {
65 ; CHECK-LABEL: @test2(
67 ; CHECK-NEXT: [[A:%.*]] = icmp eq i64 [[X:%.*]], 0
68 ; CHECK-NEXT: br i1 [[A]], label [[EXIT:%.*]], label [[NON_ZERO:%.*]]
70 ; CHECK-NEXT: br i1 [[Y:%.*]], label [[ONE:%.*]], label [[TWO:%.*]]
72 ; CHECK-NEXT: br label [[MAINBLOCK:%.*]]
74 ; CHECK-NEXT: br label [[MAINBLOCK]]
76 ; CHECK-NEXT: [[P:%.*]] = phi i64 [ [[X]], [[ONE]] ], [ 42, [[TWO]] ]
77 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[P]], 0
78 ; CHECK-NEXT: br label [[EXIT]]
80 ; CHECK-NEXT: [[RES:%.*]] = phi i1 [ [[CMP]], [[MAINBLOCK]] ], [ true, [[START:%.*]] ]
81 ; CHECK-NEXT: ret i1 [[RES]]
84 %a = icmp eq i64 %x, 0
85 br i1 %a, label %exit, label %non_zero
88 br i1 %y, label %one, label %two
97 %p = phi i64 [ %x, %one ], [ 42, %two ]
98 %cmp = icmp eq i64 %p, 0
102 %res = phi i1 [ %cmp, %mainblock ], [ 1, %start ]