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