Home | History | Annotate | Download | only in GVN
      1 ; RUN: opt < %s -gvn -S | FileCheck %s
      2 ;
      3 
      4 %0 = type { i64, i1 }
      5 
      6 define i64 @test1(i64 %a, i64 %b) nounwind ssp {
      7 entry:
      8   %uadd = tail call %0 @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
      9   %uadd.0 = extractvalue %0 %uadd, 0
     10   %add1 = add i64 %a, %b
     11   ret i64 %add1
     12 }
     13 
     14 ; CHECK: @test1
     15 ; CHECK-NOT: add1
     16 ; CHECK: ret
     17 
     18 define i64 @test2(i64 %a, i64 %b) nounwind ssp {
     19 entry:
     20   %usub = tail call %0 @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
     21   %usub.0 = extractvalue %0 %usub, 0
     22   %sub1 = sub i64 %a, %b
     23   ret i64 %sub1
     24 }
     25 
     26 ; CHECK: @test2
     27 ; CHECK-NOT: sub1
     28 ; CHECK: ret
     29 
     30 define i64 @test3(i64 %a, i64 %b) nounwind ssp {
     31 entry:
     32   %umul = tail call %0 @llvm.umul.with.overflow.i64(i64 %a, i64 %b)
     33   %umul.0 = extractvalue %0 %umul, 0
     34   %mul1 = mul i64 %a, %b
     35   ret i64 %mul1
     36 }
     37 
     38 ; CHECK: @test3
     39 ; CHECK-NOT: mul1
     40 ; CHECK: ret
     41 
     42 define i64 @test4(i64 %a, i64 %b) nounwind ssp {
     43 entry:
     44   %sadd = tail call %0 @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)
     45   %sadd.0 = extractvalue %0 %sadd, 0
     46   %add1 = add i64 %a, %b
     47   ret i64 %add1
     48 }
     49 
     50 ; CHECK: @test4
     51 ; CHECK-NOT: add1
     52 ; CHECK: ret
     53 
     54 define i64 @test5(i64 %a, i64 %b) nounwind ssp {
     55 entry:
     56   %ssub = tail call %0 @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)
     57   %ssub.0 = extractvalue %0 %ssub, 0
     58   %sub1 = sub i64 %a, %b
     59   ret i64 %sub1
     60 }
     61 
     62 ; CHECK: @test5
     63 ; CHECK-NOT: sub1
     64 ; CHECK: ret
     65 
     66 define i64 @test6(i64 %a, i64 %b) nounwind ssp {
     67 entry:
     68   %smul = tail call %0 @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
     69   %smul.0 = extractvalue %0 %smul, 0
     70   %mul1 = mul i64 %a, %b
     71   ret i64 %mul1
     72 }
     73 
     74 ; CHECK: @test6
     75 ; CHECK-NOT: mul1
     76 ; CHECK: ret
     77 
     78 declare void @exit(i32) noreturn
     79 declare %0 @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
     80 declare %0 @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone
     81 declare %0 @llvm.umul.with.overflow.i64(i64, i64) nounwind readnone
     82 declare %0 @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
     83 declare %0 @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone
     84 declare %0 @llvm.smul.with.overflow.i64(i64, i64) nounwind readnone
     85 
     86