1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=ipsccp < %s | FileCheck %s
4 ; Test that information about the true/false value of conditions themselves
5 ; is also used, not information implied by comparisions.
7 define i32 @switch(i32 %x) {
8 ; CHECK-LABEL: @switch(
9 ; CHECK-NEXT: switch i32 [[X:%.*]], label [[CASE_DEFAULT:%.*]] [
10 ; CHECK-NEXT: i32 0, label [[CASE_0:%.*]]
11 ; CHECK-NEXT: i32 2, label [[CASE_2:%.*]]
14 ; CHECK-NEXT: br label [[END:%.*]]
16 ; CHECK-NEXT: br label [[END]]
17 ; CHECK: case.default:
18 ; CHECK-NEXT: br label [[END]]
20 ; CHECK-NEXT: ret i32 1
22 switch i32 %x, label %case.default [
39 %phi = phi i32 [ %add, %case.0 ], [ %sub, %case.2 ], [ 1, %case.default]
43 define i1 @assume(i32 %x) {
44 ; CHECK-LABEL: @assume(
45 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
46 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
47 ; CHECK-NEXT: ret i1 true
49 %cmp = icmp sge i32 %x, 0
50 call void @llvm.assume(i1 %cmp)
54 define i32 @branch(i32 %x) {
55 ; CHECK-LABEL: @branch(
56 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
57 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN1:%.*]], label [[IF_THEN2:%.*]]
59 ; CHECK-NEXT: br label [[IF2_THEN1:%.*]]
61 ; CHECK-NEXT: br label [[IF2_END:%.*]]
63 ; CHECK-NEXT: ret i32 0
65 ; CHECK-NEXT: br label [[IF3_THEN2:%.*]]
67 ; CHECK-NEXT: br label [[IF3_END:%.*]]
69 ; CHECK-NEXT: ret i32 1
71 %cmp = icmp sge i32 %x, 0
72 br i1 %cmp, label %if.then1, label %if.then2
75 br i1 %cmp, label %if2.then1, label %if2.then2
84 %phi = phi i32 [ 0, %if2.then1 ], [ 1, %if2.then2 ]
88 br i1 %cmp, label %if3.then1, label %if3.then2
97 %phi2 = phi i32 [ 0, %if3.then1 ], [ 1, %if3.then2 ]
101 define void @pr46814(i32 %a) {
102 ; CHECK-LABEL: @pr46814(
103 ; CHECK-NEXT: [[C1:%.*]] = icmp uge i32 [[A:%.*]], 10
104 ; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[A]], 20
105 ; CHECK-NEXT: [[C3:%.*]] = and i1 [[C1]], [[C2]]
106 ; CHECK-NEXT: br i1 [[C3]], label [[IF_1:%.*]], label [[EXIT:%.*]]
108 ; CHECK-NEXT: br label [[IF_2:%.*]]
110 ; CHECK-NEXT: br i1 true, label [[EXIT]], label [[EXIT]]
112 ; CHECK-NEXT: ret void
114 %c1 = icmp uge i32 %a, 10
115 %c2 = icmp ult i32 %a, 20
116 %c3 = and i1 %c1, %c2
117 br i1 %c3, label %if.1, label %exit
120 br i1 %c3, label %if.2, label %exit
123 br i1 %c3, label %exit, label %exit
129 declare void @llvm.assume(i1)