1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s 3 4define i1 @test_conds_single_use_in_different_blocks(i8 %x) { 5; CHECK-LABEL: @test_conds_single_use_in_different_blocks( 6; CHECK-NEXT: entry: 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:%.*]] 10; CHECK: then: 11; CHECK-NEXT: ret i1 true 12; CHECK: else: 13; CHECK-NEXT: ret i1 [[C_2]] 14; 15entry: 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 20 21then: 22 ret i1 %t.1 23 24else: 25 ret i1 %c.2 26} 27 28 29define i1 @test_conds_single_use_in_different_blocks_2(i8 %x, i8 %y) { 30; CHECK-LABEL: @test_conds_single_use_in_different_blocks_2( 31; CHECK-NEXT: entry: 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:%.*]] 36; CHECK: then.1: 37; CHECK-NEXT: br i1 [[C_2]], label [[THEN_2:%.*]], label [[ELSE]] 38; CHECK: then.2: 39; CHECK-NEXT: ret i1 true 40; CHECK: else: 41; CHECK-NEXT: ret i1 [[C_3]] 42; 43entry: 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 49 50then.1: 51 br i1 %c.2, label %then.2, label %else 52 53then.2: 54 ret i1 %t.1 55 56else: 57 ret i1 %c.3 58} 59 60declare void @llvm.assume(i1) 61 62; Only the use of %t.1 in %then.2 could be simplified, but not the one in 63; %entry. 64define i1 @test_conds_multiple_uses_in_different_blocks_2(i8 %x, i8 %y) { 65; CHECK-LABEL: @test_conds_multiple_uses_in_different_blocks_2( 66; CHECK-NEXT: entry: 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:%.*]] 72; CHECK: then.1: 73; CHECK-NEXT: br i1 [[C_2]], label [[THEN_2:%.*]], label [[ELSE]] 74; CHECK: then.2: 75; CHECK-NEXT: ret i1 true 76; CHECK: else: 77; CHECK-NEXT: ret i1 true 78; 79entry: 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 86 87then.1: 88 br i1 %c.2, label %then.2, label %else 89 90then.2: 91 ret i1 %t.1 92 93else: 94 ret i1 %c.3 95} 96