164 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 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:%.*]], 010; CHECK-NEXT: ret i1 [[CMP]]11;12 %neg_x = sub nsw i8 0, %x13 %cmp = icmp sgt i8 %neg_x, %x14 ret i1 %cmp15}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]], 021; CHECK-NEXT: ret i1 [[CMP]]22;23 %x = call i8 @gen8()24 %neg_x = sub nsw i8 0, %x25 %cmp = icmp slt i8 %x, %neg_x26 ret i1 %cmp27}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]], 034; CHECK-NEXT: ret i1 [[CMP]]35;36 %neg_x = sub nsw i8 0, %x37 call void @use8(i8 %neg_x)38 %cmp = icmp sgt i8 %neg_x, %x39 ret i1 %cmp40}41 42define i1 @t1(i8 %x) {43; CHECK-LABEL: @t1(44; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 145; CHECK-NEXT: ret i1 [[CMP]]46;47 %neg_x = sub nsw i8 0, %x48 %cmp = icmp sge i8 %neg_x, %x49 ret i1 %cmp50}51 52define i1 @t2(i8 %x) {53; CHECK-LABEL: @t2(54; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 055; CHECK-NEXT: ret i1 [[CMP]]56;57 %neg_x = sub nsw i8 0, %x58 %cmp = icmp slt i8 %neg_x, %x59 ret i1 %cmp60}61 62define i1 @t3(i8 %x) {63; CHECK-LABEL: @t3(64; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -165; CHECK-NEXT: ret i1 [[CMP]]66;67 %neg_x = sub nsw i8 0, %x68 %cmp = icmp sle i8 %neg_x, %x69 ret i1 %cmp70}71 72define i1 @t4(i8 %x) {73; CHECK-LABEL: @t4(74; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 075; CHECK-NEXT: ret i1 [[CMP]]76;77 %neg_x = sub nsw i8 0, %x78 %cmp = icmp ugt i8 %neg_x, %x79 ret i1 %cmp80}81 82define i1 @t5(i8 %x) {83; CHECK-LABEL: @t5(84; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -185; CHECK-NEXT: ret i1 [[CMP]]86;87 %neg_x = sub nsw i8 0, %x88 %cmp = icmp uge i8 %neg_x, %x89 ret i1 %cmp90}91 92define i1 @t6(i8 %x) {93; CHECK-LABEL: @t6(94; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 095; CHECK-NEXT: ret i1 [[CMP]]96;97 %neg_x = sub nsw i8 0, %x98 %cmp = icmp ult i8 %neg_x, %x99 ret i1 %cmp100}101 102define i1 @t7(i8 %x) {103; CHECK-LABEL: @t7(104; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1105; CHECK-NEXT: ret i1 [[CMP]]106;107 %neg_x = sub nsw i8 0, %x108 %cmp = icmp ule i8 %neg_x, %x109 ret i1 %cmp110}111 112define i1 @t8(i8 %x) {113; CHECK-LABEL: @t8(114; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0115; CHECK-NEXT: ret i1 [[CMP]]116;117 %neg_x = sub nsw i8 0, %x118 %cmp = icmp eq i8 %neg_x, %x119 ret i1 %cmp120}121 122define i1 @t9(i8 %x) {123; CHECK-LABEL: @t9(124; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 0125; CHECK-NEXT: ret i1 [[CMP]]126;127 %neg_x = sub nsw i8 0, %x128 %cmp = icmp ne i8 %neg_x, %x129 ret i1 %cmp130}131 132define i1 @n10(i8 %x) {133; CHECK-LABEL: @n10(134; CHECK-NEXT: [[NEG_X:%.*]] = sub i8 0, [[X:%.*]]135; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X]], [[NEG_X]]136; CHECK-NEXT: ret i1 [[CMP]]137;138 %neg_x = sub i8 0, %x ; not nsw139 %cmp = icmp sgt i8 %neg_x, %x140 ret i1 %cmp141}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 negation150 %cmp = icmp sgt i8 %neg_x, %x151 ret i1 %cmp152}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 slt i8 [[X2:%.*]], [[NEG_X]]158; CHECK-NEXT: ret i1 [[CMP]]159;160 %neg_x = sub nsw i8 0, %x1 ; not %x2161 %cmp = icmp sgt i8 %neg_x, %x2 ; not %x1162 ret i1 %cmp163}164