1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
5 define void @f(i8* %x) nounwind {
8 ; CHECK-NEXT: br label [[BB:%.*]]
10 ; CHECK-NEXT: [[L1:%.*]] = load i8, i8* [[X:%.*]], align 1
11 ; CHECK-NEXT: [[S1:%.*]] = add i8 [[L1]], -6
12 ; CHECK-NEXT: [[C1:%.*]] = icmp ugt i8 [[S1]], 2
13 ; CHECK-NEXT: [[S2:%.*]] = add i8 [[L1]], -10
14 ; CHECK-NEXT: [[C2:%.*]] = icmp ugt i8 [[S2]], 2
15 ; CHECK-NEXT: [[A1:%.*]] = and i1 [[C1]], [[C2]]
16 ; CHECK-NEXT: br i1 [[A1]], label [[INCOMPATIBLE:%.*]], label [[OKAY:%.*]]
18 ; CHECK-NEXT: ret void
19 ; CHECK: incompatible:
20 ; CHECK-NEXT: ret void
26 %g1 = getelementptr i8, i8* %x, i32 0
27 %l1 = load i8, i8* %g1, align 1
29 %c1 = icmp ugt i8 %s1, 2
31 %c2 = icmp ugt i8 %s2, 2
33 br i1 %a1, label %incompatible, label %okay
42 define void @f_logical(i8* %x) nounwind {
43 ; CHECK-LABEL: @f_logical(
45 ; CHECK-NEXT: br label [[BB:%.*]]
47 ; CHECK-NEXT: [[L1:%.*]] = load i8, i8* [[X:%.*]], align 1
48 ; CHECK-NEXT: [[S1:%.*]] = add i8 [[L1]], -6
49 ; CHECK-NEXT: [[C1:%.*]] = icmp ugt i8 [[S1]], 2
50 ; CHECK-NEXT: [[S2:%.*]] = add i8 [[L1]], -10
51 ; CHECK-NEXT: [[C2:%.*]] = icmp ugt i8 [[S2]], 2
52 ; CHECK-NEXT: [[A1:%.*]] = and i1 [[C1]], [[C2]]
53 ; CHECK-NEXT: br i1 [[A1]], label [[INCOMPATIBLE:%.*]], label [[OKAY:%.*]]
55 ; CHECK-NEXT: ret void
56 ; CHECK: incompatible:
57 ; CHECK-NEXT: ret void
63 %g1 = getelementptr i8, i8* %x, i32 0
64 %l1 = load i8, i8* %g1, align 1
66 %c1 = icmp ugt i8 %s1, 2
68 %c2 = icmp ugt i8 %s2, 2
69 %a1 = select i1 %c1, i1 %c2, i1 false
70 br i1 %a1, label %incompatible, label %okay