1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 define i1 @test_conds_single_use_in_different_blocks(i8 %x) {
5 ; CHECK-LABEL: @test_conds_single_use_in_different_blocks(
7 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
8 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[X]], 5
9 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[X]], 5
10 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
12 ; CHECK-NEXT: ret i1 [[T_1]]
14 ; CHECK-NEXT: ret i1 [[C_2]]
17 %c.1 = icmp ugt i8 %x, 10
18 %t.1 = icmp ugt i8 %x, 5
19 %c.2 = icmp ugt i8 %x, 5
20 br i1 %c.1, label %then, label %else
30 define i1 @test_conds_single_use_in_different_blocks_2(i8 %x, i8 %y) {
31 ; CHECK-LABEL: @test_conds_single_use_in_different_blocks_2(
33 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
34 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[Y:%.*]], 5
35 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[Y]], [[X]]
36 ; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i8 [[Y]], 5
37 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN_1:%.*]], label [[ELSE:%.*]]
39 ; CHECK-NEXT: br i1 [[C_2]], label [[THEN_2:%.*]], label [[ELSE]]
41 ; CHECK-NEXT: ret i1 [[T_1]]
43 ; CHECK-NEXT: ret i1 [[C_3]]
46 %c.1 = icmp ugt i8 %x, 10
47 %t.1 = icmp ugt i8 %y, 5
48 %c.2 = icmp ugt i8 %y, %x
49 %c.3 = icmp ugt i8 %y, 5
50 br i1 %c.1, label %then.1, label %else
53 br i1 %c.2, label %then.2, label %else
62 declare void @llvm.assume(i1)
64 ; Only the use of %t.1 in %then.2 could be simplified, but not the one in
66 define i1 @test_conds_multiple_uses_in_different_blocks_2(i8 %x, i8 %y) {
67 ; CHECK-LABEL: @test_conds_multiple_uses_in_different_blocks_2(
69 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
70 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[Y:%.*]], 5
71 ; CHECK-NEXT: call void @llvm.assume(i1 [[T_1]])
72 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[Y]], [[X]]
73 ; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i8 [[Y]], 5
74 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN_1:%.*]], label [[ELSE:%.*]]
76 ; CHECK-NEXT: br i1 [[C_2]], label [[THEN_2:%.*]], label [[ELSE]]
78 ; CHECK-NEXT: ret i1 true
80 ; CHECK-NEXT: ret i1 true
83 %c.1 = icmp ugt i8 %x, 10
84 %t.1 = icmp ugt i8 %y, 5
85 call void @llvm.assume(i1 %t.1)
86 %c.2 = icmp ugt i8 %y, %x
87 %c.3 = icmp ugt i8 %y, 5
88 br i1 %c.1, label %then.1, label %else
91 br i1 %c.2, label %then.2, label %else