97 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)5declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8)6 7define i1 @test_generic(i64 %a, i64 %b) {8; CHECK-LABEL: @test_generic(9; CHECK-NEXT: [[RES:%.*]] = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 [[A:%.*]], i64 [[B:%.*]])10; CHECK-NEXT: [[OVERFLOW:%.*]] = extractvalue { i64, i1 } [[RES]], 111; CHECK-NEXT: ret i1 [[OVERFLOW]]12;13 %res = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)14 %overflow = extractvalue { i64, i1 } %res, 115 ret i1 %overflow16}17 18define i1 @test_constant0(i8 %a) {19; CHECK-LABEL: @test_constant0(20; CHECK-NEXT: ret i1 false21;22 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 0)23 %overflow = extractvalue { i8, i1 } %res, 124 ret i1 %overflow25}26 27define i1 @test_constant1(i8 %a) {28; CHECK-LABEL: @test_constant1(29; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp eq i8 [[A:%.*]], 12730; CHECK-NEXT: ret i1 [[OVERFLOW]]31;32 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 1)33 %overflow = extractvalue { i8, i1 } %res, 134 ret i1 %overflow35}36 37define i1 @test_constant2(i8 %a) {38; CHECK-LABEL: @test_constant2(39; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp sgt i8 [[A:%.*]], 12540; CHECK-NEXT: ret i1 [[OVERFLOW]]41;42 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 2)43 %overflow = extractvalue { i8, i1 } %res, 144 ret i1 %overflow45}46 47define i1 @test_constant3(i8 %a) {48; CHECK-LABEL: @test_constant3(49; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp sgt i8 [[A:%.*]], 12450; CHECK-NEXT: ret i1 [[OVERFLOW]]51;52 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 3)53 %overflow = extractvalue { i8, i1 } %res, 154 ret i1 %overflow55}56 57define i1 @test_constant4(i8 %a) {58; CHECK-LABEL: @test_constant4(59; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp sgt i8 [[A:%.*]], 12360; CHECK-NEXT: ret i1 [[OVERFLOW]]61;62 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 4)63 %overflow = extractvalue { i8, i1 } %res, 164 ret i1 %overflow65}66 67define i1 @test_constant127(i8 %a) {68; CHECK-LABEL: @test_constant127(69; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp sgt i8 [[A:%.*]], 070; CHECK-NEXT: ret i1 [[OVERFLOW]]71;72 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 127)73 %overflow = extractvalue { i8, i1 } %res, 174 ret i1 %overflow75}76 77define i1 @test_constant128(i8 %a) {78; CHECK-LABEL: @test_constant128(79; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp slt i8 [[A:%.*]], 080; CHECK-NEXT: ret i1 [[OVERFLOW]]81;82 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 128)83 %overflow = extractvalue { i8, i1 } %res, 184 ret i1 %overflow85}86 87define i1 @test_constant255(i8 %a) {88; CHECK-LABEL: @test_constant255(89; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp eq i8 [[A:%.*]], -12890; CHECK-NEXT: ret i1 [[OVERFLOW]]91;92 %res = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 255)93 %overflow = extractvalue { i8, i1 } %res, 194 ret i1 %overflow95}96 97