1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686-linux | FileCheck %s 3 4@ok = internal constant [4 x i8] c"%d\0A\00" 5@no = internal constant [4 x i8] c"no\0A\00" 6 7define i1 @func1(i32 %v1, i32 %v2) nounwind { 8; CHECK-LABEL: func1: 9; CHECK: # %bb.0: # %entry 10; CHECK-NEXT: subl $12, %esp 11; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax 12; CHECK-NEXT: subl {{[0-9]+}}(%esp), %eax 13; CHECK-NEXT: jno .LBB0_1 14; CHECK-NEXT: # %bb.2: # %overflow 15; CHECK-NEXT: movl $no, (%esp) 16; CHECK-NEXT: calll printf 17; CHECK-NEXT: xorl %eax, %eax 18; CHECK-NEXT: addl $12, %esp 19; CHECK-NEXT: retl 20; CHECK-NEXT: .LBB0_1: # %normal 21; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp) 22; CHECK-NEXT: movl $ok, (%esp) 23; CHECK-NEXT: calll printf 24; CHECK-NEXT: movb $1, %al 25; CHECK-NEXT: addl $12, %esp 26; CHECK-NEXT: retl 27entry: 28 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2) 29 %sum = extractvalue {i32, i1} %t, 0 30 %obit = extractvalue {i32, i1} %t, 1 31 br i1 %obit, label %overflow, label %normal 32 33normal: 34 %t1 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @ok, i32 0, i32 0), i32 %sum ) nounwind 35 ret i1 true 36 37overflow: 38 %t2 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @no, i32 0, i32 0) ) nounwind 39 ret i1 false 40 41} 42 43define i1 @func2(i32 %v1, i32 %v2) nounwind { 44; CHECK-LABEL: func2: 45; CHECK: # %bb.0: # %entry 46; CHECK-NEXT: subl $12, %esp 47; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax 48; CHECK-NEXT: subl {{[0-9]+}}(%esp), %eax 49; CHECK-NEXT: jae .LBB1_1 50; CHECK-NEXT: # %bb.2: # %carry 51; CHECK-NEXT: movl $no, (%esp) 52; CHECK-NEXT: calll printf 53; CHECK-NEXT: xorl %eax, %eax 54; CHECK-NEXT: addl $12, %esp 55; CHECK-NEXT: retl 56; CHECK-NEXT: .LBB1_1: # %normal 57; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp) 58; CHECK-NEXT: movl $ok, (%esp) 59; CHECK-NEXT: calll printf 60; CHECK-NEXT: movb $1, %al 61; CHECK-NEXT: addl $12, %esp 62; CHECK-NEXT: retl 63entry: 64 %t = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %v1, i32 %v2) 65 %sum = extractvalue {i32, i1} %t, 0 66 %obit = extractvalue {i32, i1} %t, 1 67 br i1 %obit, label %carry, label %normal 68 69normal: 70 %t1 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @ok, i32 0, i32 0), i32 %sum ) nounwind 71 ret i1 true 72 73carry: 74 %t2 = tail call i32 (i8*, ...) @printf( i8* getelementptr ([4 x i8], [4 x i8]* @no, i32 0, i32 0) ) nounwind 75 ret i1 false 76 77} 78 79declare i32 @printf(i8*, ...) nounwind 80declare {i32, i1} @llvm.ssub.with.overflow.i32(i32, i32) 81declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32) 82 83define i1 @func3(i32 %x) nounwind { 84; CHECK-LABEL: func3: 85; CHECK: # %bb.0: # %entry 86; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax 87; CHECK-NEXT: decl %eax 88; CHECK-NEXT: seto %al 89; CHECK-NEXT: retl 90entry: 91 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %x, i32 1) 92 %obit = extractvalue {i32, i1} %t, 1 93 ret i1 %obit 94 95} 96