Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -march=x86 | FileCheck %s
      2 
      3 @ok = internal constant [4 x i8] c"%d\0A\00"
      4 @no = internal constant [4 x i8] c"no\0A\00"
      5 
      6 define i1 @func1(i32 %v1, i32 %v2) nounwind {
      7 entry:
      8   %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 %v2)
      9   %sum = extractvalue {i32, i1} %t, 0
     10   %obit = extractvalue {i32, i1} %t, 1
     11   br i1 %obit, label %overflow, label %normal
     12 
     13 normal:
     14   %t1 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x i8]* @ok, i32 0, i32 0), i32 %sum ) nounwind
     15   ret i1 true
     16 
     17 overflow:
     18   %t2 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x i8]* @no, i32 0, i32 0) ) nounwind
     19   ret i1 false
     20 
     21 ; CHECK: func1:
     22 ; CHECK: subl 20(%esp)
     23 ; CHECK-NEXT: jo
     24 }
     25 
     26 define i1 @func2(i32 %v1, i32 %v2) nounwind {
     27 entry:
     28   %t = call {i32, i1} @llvm.usub.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 %carry, label %normal
     32 
     33 normal:
     34   %t1 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x i8]* @ok, i32 0, i32 0), i32 %sum ) nounwind
     35   ret i1 true
     36 
     37 carry:
     38   %t2 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x i8]* @no, i32 0, i32 0) ) nounwind
     39   ret i1 false
     40 
     41 ; CHECK: func2:
     42 ; CHECK: subl 20(%esp)
     43 ; CHECK-NEXT: jb
     44 }
     45 
     46 declare i32 @printf(i8*, ...) nounwind
     47 declare {i32, i1} @llvm.ssub.with.overflow.i32(i32, i32)
     48 declare {i32, i1} @llvm.usub.with.overflow.i32(i32, i32)
     49 
     50 define i1 @func3(i32 %x) nounwind {
     51 entry:
     52   %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %x, i32 1)
     53   %obit = extractvalue {i32, i1} %t, 1
     54   ret i1 %obit
     55 
     56 ; CHECK: func3:
     57 ; CHECK: decl
     58 ; CHECK-NEXT: seto
     59 }
     60