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: [[C_2:%.*]] = icmp ugt i8 [[X]], 5
9 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
11 ; CHECK-NEXT: ret i1 true
13 ; CHECK-NEXT: ret i1 [[C_2]]
16 %c.1 = icmp ugt i8 %x, 10
17 %t.1 = icmp ugt i8 %x, 5
18 %c.2 = icmp ugt i8 %x, 5
19 br i1 %c.1, label %then, label %else
29 define i1 @test_conds_single_use_in_different_blocks_2(i8 %x, i8 %y) {
30 ; CHECK-LABEL: @test_conds_single_use_in_different_blocks_2(
32 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
33 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[Y:%.*]], [[X]]
34 ; CHECK-NEXT: [[C_3:%.*]] = icmp ugt i8 [[Y]], 5
35 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN_1:%.*]], label [[ELSE:%.*]]
37 ; CHECK-NEXT: br i1 [[C_2]], label [[THEN_2:%.*]], label [[ELSE]]
39 ; CHECK-NEXT: ret i1 true
41 ; CHECK-NEXT: ret i1 [[C_3]]
44 %c.1 = icmp ugt i8 %x, 10
45 %t.1 = icmp ugt i8 %y, 5
46 %c.2 = icmp ugt i8 %y, %x
47 %c.3 = icmp ugt i8 %y, 5
48 br i1 %c.1, label %then.1, label %else
51 br i1 %c.2, label %then.2, label %else
60 declare void @llvm.assume(i1)
62 ; Only the use of %t.1 in %then.2 could be simplified, but not the one in
64 define i1 @test_conds_multiple_uses_in_different_blocks_2(i8 %x, i8 %y) {
65 ; CHECK-LABEL: @test_conds_multiple_uses_in_different_blocks_2(
67 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[X:%.*]], 10
68 ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[Y:%.*]], 5
69 ; CHECK-NEXT: call void @llvm.assume(i1 [[T_1]])
70 ; CHECK-NEXT: [[C_2:%.*]] = icmp ugt i8 [[Y]], [[X]]
71 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN_1:%.*]], label [[ELSE:%.*]]
73 ; CHECK-NEXT: br i1 [[C_2]], label [[THEN_2:%.*]], label [[ELSE]]
75 ; CHECK-NEXT: ret i1 true
77 ; CHECK-NEXT: ret i1 true
80 %c.1 = icmp ugt i8 %x, 10
81 %t.1 = icmp ugt i8 %y, 5
82 call void @llvm.assume(i1 %t.1)
83 %c.2 = icmp ugt i8 %y, %x
84 %c.3 = icmp ugt i8 %y, 5
85 br i1 %c.1, label %then.1, label %else
88 br i1 %c.2, label %then.2, label %else