|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt %s -instcombine -S | FileCheck %s |
| 3 | + |
| 4 | +declare i8 @gen8() |
| 5 | +declare void @use8(i8) |
| 6 | + |
| 7 | +define i1 @t0(i8 %x) { |
| 8 | +; CHECK-LABEL: @t0( |
| 9 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 10 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]] |
| 11 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 12 | +; |
| 13 | + %neg_x = sub nsw i8 0, %x |
| 14 | + %cmp = icmp sgt i8 %neg_x, %x |
| 15 | + ret i1 %cmp |
| 16 | +} |
| 17 | + |
| 18 | +define i1 @t0_commutative() { |
| 19 | +; CHECK-LABEL: @t0_commutative( |
| 20 | +; CHECK-NEXT: [[X:%.*]] = call i8 @gen8() |
| 21 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X]] |
| 22 | +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], [[NEG_X]] |
| 23 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 24 | +; |
| 25 | + %x = call i8 @gen8() |
| 26 | + %neg_x = sub nsw i8 0, %x |
| 27 | + %cmp = icmp slt i8 %x, %neg_x |
| 28 | + ret i1 %cmp |
| 29 | +} |
| 30 | + |
| 31 | +define i1 @t0_extrause(i8 %x) { |
| 32 | +; CHECK-LABEL: @t0_extrause( |
| 33 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 34 | +; CHECK-NEXT: call void @use8(i8 [[NEG_X]]) |
| 35 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]] |
| 36 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 37 | +; |
| 38 | + %neg_x = sub nsw i8 0, %x |
| 39 | + call void @use8(i8 %neg_x) |
| 40 | + %cmp = icmp sgt i8 %neg_x, %x |
| 41 | + ret i1 %cmp |
| 42 | +} |
| 43 | + |
| 44 | +define i1 @t1(i8 %x) { |
| 45 | +; CHECK-LABEL: @t1( |
| 46 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 47 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NEG_X]], [[X]] |
| 48 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 49 | +; |
| 50 | + %neg_x = sub nsw i8 0, %x |
| 51 | + %cmp = icmp sge i8 %neg_x, %x |
| 52 | + ret i1 %cmp |
| 53 | +} |
| 54 | + |
| 55 | +define i1 @t2(i8 %x) { |
| 56 | +; CHECK-LABEL: @t2( |
| 57 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 58 | +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[NEG_X]], [[X]] |
| 59 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 60 | +; |
| 61 | + %neg_x = sub nsw i8 0, %x |
| 62 | + %cmp = icmp slt i8 %neg_x, %x |
| 63 | + ret i1 %cmp |
| 64 | +} |
| 65 | + |
| 66 | +define i1 @t3(i8 %x) { |
| 67 | +; CHECK-LABEL: @t3( |
| 68 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 69 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NEG_X]], [[X]] |
| 70 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 71 | +; |
| 72 | + %neg_x = sub nsw i8 0, %x |
| 73 | + %cmp = icmp sle i8 %neg_x, %x |
| 74 | + ret i1 %cmp |
| 75 | +} |
| 76 | + |
| 77 | +define i1 @t4(i8 %x) { |
| 78 | +; CHECK-LABEL: @t4( |
| 79 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 80 | +; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NEG_X]], [[X]] |
| 81 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 82 | +; |
| 83 | + %neg_x = sub nsw i8 0, %x |
| 84 | + %cmp = icmp ugt i8 %neg_x, %x |
| 85 | + ret i1 %cmp |
| 86 | +} |
| 87 | + |
| 88 | +define i1 @t5(i8 %x) { |
| 89 | +; CHECK-LABEL: @t5( |
| 90 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 91 | +; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NEG_X]], [[X]] |
| 92 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 93 | +; |
| 94 | + %neg_x = sub nsw i8 0, %x |
| 95 | + %cmp = icmp uge i8 %neg_x, %x |
| 96 | + ret i1 %cmp |
| 97 | +} |
| 98 | + |
| 99 | +define i1 @t6(i8 %x) { |
| 100 | +; CHECK-LABEL: @t6( |
| 101 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 102 | +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NEG_X]], [[X]] |
| 103 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 104 | +; |
| 105 | + %neg_x = sub nsw i8 0, %x |
| 106 | + %cmp = icmp ult i8 %neg_x, %x |
| 107 | + ret i1 %cmp |
| 108 | +} |
| 109 | + |
| 110 | +define i1 @t7(i8 %x) { |
| 111 | +; CHECK-LABEL: @t7( |
| 112 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 113 | +; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[NEG_X]], [[X]] |
| 114 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 115 | +; |
| 116 | + %neg_x = sub nsw i8 0, %x |
| 117 | + %cmp = icmp ule i8 %neg_x, %x |
| 118 | + ret i1 %cmp |
| 119 | +} |
| 120 | + |
| 121 | +define i1 @t8(i8 %x) { |
| 122 | +; CHECK-LABEL: @t8( |
| 123 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 124 | +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[NEG_X]], [[X]] |
| 125 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 126 | +; |
| 127 | + %neg_x = sub nsw i8 0, %x |
| 128 | + %cmp = icmp eq i8 %neg_x, %x |
| 129 | + ret i1 %cmp |
| 130 | +} |
| 131 | + |
| 132 | +define i1 @t9(i8 %x) { |
| 133 | +; CHECK-LABEL: @t9( |
| 134 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]] |
| 135 | +; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[NEG_X]], [[X]] |
| 136 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 137 | +; |
| 138 | + %neg_x = sub nsw i8 0, %x |
| 139 | + %cmp = icmp ne i8 %neg_x, %x |
| 140 | + ret i1 %cmp |
| 141 | +} |
| 142 | + |
| 143 | +define i1 @n10(i8 %x) { |
| 144 | +; CHECK-LABEL: @n10( |
| 145 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub i8 0, [[X:%.*]] |
| 146 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]] |
| 147 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 148 | +; |
| 149 | + %neg_x = sub i8 0, %x ; not nsw |
| 150 | + %cmp = icmp sgt i8 %neg_x, %x |
| 151 | + ret i1 %cmp |
| 152 | +} |
| 153 | + |
| 154 | +define i1 @n11(i8 %x) { |
| 155 | +; CHECK-LABEL: @n11( |
| 156 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 1, [[X:%.*]] |
| 157 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X]] |
| 158 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 159 | +; |
| 160 | + %neg_x = sub nsw i8 1, %x ; not negation |
| 161 | + %cmp = icmp sgt i8 %neg_x, %x |
| 162 | + ret i1 %cmp |
| 163 | +} |
| 164 | + |
| 165 | +define i1 @n12(i8 %x1, i8 %x2) { |
| 166 | +; CHECK-LABEL: @n12( |
| 167 | +; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X1:%.*]] |
| 168 | +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NEG_X]], [[X2:%.*]] |
| 169 | +; CHECK-NEXT: ret i1 [[CMP]] |
| 170 | +; |
| 171 | + %neg_x = sub nsw i8 0, %x1 ; not %x2 |
| 172 | + %cmp = icmp sgt i8 %neg_x, %x2 ; not %x1 |
| 173 | + ret i1 %cmp |
| 174 | +} |
0 commit comments