1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define i1 @test_nuw_and_unsigned_pred(i64 %x) {
5 ; CHECK-LABEL: @test_nuw_and_unsigned_pred(
6 ; CHECK-NEXT: [[Z:%.*]] = icmp ugt i64 [[X:%.*]], 7
7 ; CHECK-NEXT: ret i1 [[Z]]
9 %y = sub nuw i64 10, %x
10 %z = icmp ult i64 %y, 3
14 define i1 @test_nsw_and_signed_pred(i64 %x) {
15 ; CHECK-LABEL: @test_nsw_and_signed_pred(
16 ; CHECK-NEXT: [[Z:%.*]] = icmp slt i64 [[X:%.*]], -7
17 ; CHECK-NEXT: ret i1 [[Z]]
19 %y = sub nsw i64 3, %x
20 %z = icmp sgt i64 %y, 10
24 define i1 @test_nuw_nsw_and_unsigned_pred(i64 %x) {
25 ; CHECK-LABEL: @test_nuw_nsw_and_unsigned_pred(
26 ; CHECK-NEXT: [[Z:%.*]] = icmp ugt i64 [[X:%.*]], 6
27 ; CHECK-NEXT: ret i1 [[Z]]
29 %y = sub nuw nsw i64 10, %x
30 %z = icmp ule i64 %y, 3
34 define i1 @test_nuw_nsw_and_signed_pred(i64 %x) {
35 ; CHECK-LABEL: @test_nuw_nsw_and_signed_pred(
36 ; CHECK-NEXT: [[Z:%.*]] = icmp sgt i64 [[X:%.*]], 7
37 ; CHECK-NEXT: ret i1 [[Z]]
39 %y = sub nuw nsw i64 10, %x
40 %z = icmp slt i64 %y, 3
44 define i1 @test_negative_nuw_and_signed_pred(i64 %x) {
45 ; CHECK-LABEL: @test_negative_nuw_and_signed_pred(
46 ; CHECK-NEXT: [[Y:%.*]] = sub nuw i64 10, [[X:%.*]]
47 ; CHECK-NEXT: [[Z:%.*]] = icmp slt i64 [[Y]], 3
48 ; CHECK-NEXT: ret i1 [[Z]]
50 %y = sub nuw i64 10, %x
51 %z = icmp slt i64 %y, 3
55 define i1 @test_negative_nsw_and_unsigned_pred(i64 %x) {
56 ; CHECK-LABEL: @test_negative_nsw_and_unsigned_pred(
57 ; CHECK-NEXT: [[Y:%.*]] = sub nsw i64 10, [[X:%.*]]
58 ; CHECK-NEXT: [[Z:%.*]] = icmp ult i64 [[Y]], 3
59 ; CHECK-NEXT: ret i1 [[Z]]
61 %y = sub nsw i64 10, %x
62 %z = icmp ult i64 %y, 3
66 define i1 @test_negative_combined_sub_unsigned_overflow(i64 %x) {
67 ; CHECK-LABEL: @test_negative_combined_sub_unsigned_overflow(
68 ; CHECK-NEXT: [[Y:%.*]] = sub nuw i64 10, [[X:%.*]]
69 ; CHECK-NEXT: [[Z:%.*]] = icmp ult i64 [[Y]], 11
70 ; CHECK-NEXT: ret i1 [[Z]]
72 %y = sub nuw i64 10, %x
73 %z = icmp ult i64 %y, 11
77 define i1 @test_negative_combined_sub_signed_overflow(i8 %x) {
78 ; CHECK-LABEL: @test_negative_combined_sub_signed_overflow(
79 ; CHECK-NEXT: [[Y:%.*]] = sub nsw i8 127, [[X:%.*]]
80 ; CHECK-NEXT: [[Z:%.*]] = icmp slt i8 [[Y]], -1
81 ; CHECK-NEXT: ret i1 [[Z]]
83 %y = sub nsw i8 127, %x
84 %z = icmp slt i8 %y, -1