Home | History | Annotate | Download | only in CodeGenPrepare
      1 ; RUN: opt -codegenprepare -S < %s | FileCheck %s
      2 
      3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
      4 target triple = "x86_64-apple-darwin10.0.0"
      5 
      6 ; CHECK-LABEL: @test1(
      7 ; CHECK: llvm.uadd.with.overflow
      8 ; CHECK: ret i64
      9 define i64 @test1(i64 %a, i64 %b) nounwind ssp {
     10 entry:
     11   %add = add i64 %b, %a
     12   %cmp = icmp ult i64 %add, %a
     13   %Q = select i1 %cmp, i64 %b, i64 42
     14   ret i64 %Q
     15 }
     16 
     17 ; CHECK-LABEL: @test2(
     18 ; CHECK: llvm.uadd.with.overflow
     19 ; CHECK: ret i64
     20 define i64 @test2(i64 %a, i64 %b) nounwind ssp {
     21 entry:
     22   %add = add i64 %b, %a
     23   %cmp = icmp ult i64 %add, %b
     24   %Q = select i1 %cmp, i64 %b, i64 42
     25   ret i64 %Q
     26 }
     27 
     28 ; CHECK-LABEL: @test3(
     29 ; CHECK: llvm.uadd.with.overflow
     30 ; CHECK: ret i64
     31 define i64 @test3(i64 %a, i64 %b) nounwind ssp {
     32 entry:
     33   %add = add i64 %b, %a
     34   %cmp = icmp ugt i64 %b, %add
     35   %Q = select i1 %cmp, i64 %b, i64 42
     36   ret i64 %Q
     37 }
     38 
     39 ; CHECK-LABEL: @test4(
     40 ; CHECK: llvm.uadd.with.overflow
     41 ; CHECK: extractvalue
     42 ; CHECK: extractvalue
     43 ; CHECK: select
     44 define i64 @test4(i64 %a, i64 %b, i1 %c) nounwind ssp {
     45 entry:
     46   %add = add i64 %b, %a
     47   %cmp = icmp ugt i64 %b, %add
     48   br i1 %c, label %next, label %exit
     49 
     50  next:
     51   %Q = select i1 %cmp, i64 %b, i64 42
     52   ret i64 %Q
     53 
     54  exit:
     55   ret i64 0
     56 }
     57 
     58 ; CHECK-LABEL: @test5(
     59 ; CHECK-NOT: llvm.uadd.with.overflow
     60 ; CHECK: next
     61 define i64 @test5(i64 %a, i64 %b, i64* %ptr, i1 %c) nounwind ssp {
     62 entry:
     63   %add = add i64 %b, %a
     64   store i64 %add, i64* %ptr
     65   %cmp = icmp ugt i64 %b, %add
     66   br i1 %c, label %next, label %exit
     67 
     68  next:
     69   %Q = select i1 %cmp, i64 %b, i64 42
     70   ret i64 %Q
     71 
     72  exit:
     73   ret i64 0
     74 }
     75