1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 ; The first comparison (a != b) should not be dropped
5 define i1 @test1(i8* %a, i8* %b) {
7 ; CHECK-NEXT: [[COND1:%.*]] = icmp ne i8* [[A:%.*]], [[B:%.*]]
8 ; CHECK-NEXT: [[A2:%.*]] = getelementptr inbounds i8, i8* [[A]], i64 -1
9 ; CHECK-NEXT: [[COND2:%.*]] = icmp ugt i8* [[A2]], [[B]]
10 ; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND1]], i1 [[COND2]], i1 false
11 ; CHECK-NEXT: ret i1 [[RES]]
13 %cond1 = icmp ne i8* %a, %b
14 %a2 = getelementptr inbounds i8, i8* %a, i64 -1
15 %cond2 = icmp ugt i8* %a2, %b
16 %res = select i1 %cond1, i1 %cond2, i1 false
20 ; The first comparison (a != b) should not be dropped
21 define i1 @test2(i32 %a, i32 %b) {
22 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: [[COND1:%.*]] = icmp ne i32 [[A:%.*]], [[B:%.*]]
24 ; CHECK-NEXT: [[A2:%.*]] = add nuw i32 [[A]], 1
25 ; CHECK-NEXT: [[COND2:%.*]] = icmp ult i32 [[A2]], [[B]]
26 ; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND1]], i1 [[COND2]], i1 false
27 ; CHECK-NEXT: ret i1 [[RES]]
29 %cond1 = icmp ne i32 %a, %b
30 %a2 = add nuw i32 %a, 1
31 %cond2 = icmp ult i32 %a2, %b
32 %res = select i1 %cond1, i1 %cond2, i1 false