Home | History | Annotate | Download | only in ConstProp
      1 ; RUN: opt < %s -constprop -S | FileCheck %s
      2 
      3 
      4 declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)
      5 declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8)
      6 declare {i8, i1} @llvm.umul.with.overflow.i8(i8, i8)
      7 
      8 declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8)
      9 declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8)
     10 declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8)
     11 
     12 ;;-----------------------------
     13 ;; uadd
     14 ;;-----------------------------
     15 
     16 define {i8, i1} @uadd_1() nounwind {
     17 entry:
     18   %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100)
     19   ret {i8, i1} %t
     20 
     21 ; CHECK-LABEL: @uadd_1(
     22 ; CHECK: ret { i8, i1 } { i8 -114, i1 false }
     23 }
     24 
     25 define {i8, i1} @uadd_2() nounwind {
     26 entry:
     27   %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120)
     28   ret {i8, i1} %t
     29 
     30 ; CHECK-LABEL: @uadd_2(
     31 ; CHECK: ret { i8, i1 } { i8 6, i1 true }
     32 }
     33 
     34 ;;-----------------------------
     35 ;; usub
     36 ;;-----------------------------
     37 
     38 define {i8, i1} @usub_1() nounwind {
     39 entry:
     40   %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2)
     41   ret {i8, i1} %t
     42 
     43 ; CHECK-LABEL: @usub_1(
     44 ; CHECK: ret { i8, i1 } { i8 2, i1 false }
     45 }
     46 
     47 define {i8, i1} @usub_2() nounwind {
     48 entry:
     49   %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6)
     50   ret {i8, i1} %t
     51 
     52 ; CHECK-LABEL: @usub_2(
     53 ; CHECK: ret { i8, i1 } { i8 -2, i1 true }
     54 }
     55 
     56 ;;-----------------------------
     57 ;; umul
     58 ;;-----------------------------
     59 
     60 define {i8, i1} @umul_1() nounwind {
     61 entry:
     62   %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3)
     63   ret {i8, i1} %t
     64 
     65 ; CHECK-LABEL: @umul_1(
     66 ; CHECK: ret { i8, i1 } { i8 44, i1 true }
     67 }
     68 
     69 define {i8, i1} @umul_2() nounwind {
     70 entry:
     71   %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2)
     72   ret {i8, i1} %t
     73 
     74 ; CHECK-LABEL: @umul_2(
     75 ; CHECK: ret { i8, i1 } { i8 -56, i1 false }
     76 }
     77 
     78 ;;-----------------------------
     79 ;; sadd
     80 ;;-----------------------------
     81 
     82 define {i8, i1} @sadd_1() nounwind {
     83 entry:
     84   %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 42, i8 2)
     85   ret {i8, i1} %t
     86 
     87 ; CHECK-LABEL: @sadd_1(
     88 ; CHECK: ret { i8, i1 } { i8 44, i1 false }
     89 }
     90 
     91 define {i8, i1} @sadd_2() nounwind {
     92 entry:
     93   %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 120, i8 10)
     94   ret {i8, i1} %t
     95 
     96 ; CHECK-LABEL: @sadd_2(
     97 ; CHECK: ret { i8, i1 } { i8 -126, i1 true }
     98 }
     99 
    100 define {i8, i1} @sadd_3() nounwind {
    101 entry:
    102   %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 10)
    103   ret {i8, i1} %t
    104 
    105 ; CHECK-LABEL: @sadd_3(
    106 ; CHECK: ret { i8, i1 } { i8 -110, i1 false }
    107 }
    108 
    109 define {i8, i1} @sadd_4() nounwind {
    110 entry:
    111   %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 -10)
    112   ret {i8, i1} %t
    113 
    114 ; CHECK-LABEL: @sadd_4(
    115 ; CHECK: ret { i8, i1 } { i8 126, i1 true }
    116 }
    117 
    118 define {i8, i1} @sadd_5() nounwind {
    119 entry:
    120   %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 2, i8 -10)
    121   ret {i8, i1} %t
    122 
    123 ; CHECK-LABEL: @sadd_5(
    124 ; CHECK: ret { i8, i1 } { i8 -8, i1 false }
    125 }
    126 
    127 
    128 ;;-----------------------------
    129 ;; ssub
    130 ;;-----------------------------
    131 
    132 define {i8, i1} @ssub_1() nounwind {
    133 entry:
    134   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 2)
    135   ret {i8, i1} %t
    136 
    137 ; CHECK-LABEL: @ssub_1(
    138 ; CHECK: ret { i8, i1 } { i8 2, i1 false }
    139 }
    140 
    141 define {i8, i1} @ssub_2() nounwind {
    142 entry:
    143   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 6)
    144   ret {i8, i1} %t
    145 
    146 ; CHECK-LABEL: @ssub_2(
    147 ; CHECK: ret { i8, i1 } { i8 -2, i1 false }
    148 }
    149 
    150 define {i8, i1} @ssub_3() nounwind {
    151 entry:
    152   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 120)
    153   ret {i8, i1} %t
    154 
    155 ; CHECK-LABEL: @ssub_3(
    156 ; CHECK: ret { i8, i1 } { i8 126, i1 true }
    157 }
    158 
    159 define {i8, i1} @ssub_3b() nounwind {
    160 entry:
    161   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 10)
    162   ret {i8, i1} %t
    163 
    164 ; CHECK-LABEL: @ssub_3b(
    165 ; CHECK: ret { i8, i1 } { i8 -20, i1 false }
    166 }
    167 
    168 define {i8, i1} @ssub_4() nounwind {
    169 entry:
    170   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 120, i8 -10)
    171   ret {i8, i1} %t
    172 
    173 ; CHECK-LABEL: @ssub_4(
    174 ; CHECK: ret { i8, i1 } { i8 -126, i1 true }
    175 }
    176 
    177 define {i8, i1} @ssub_4b() nounwind {
    178 entry:
    179   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 20, i8 -10)
    180   ret {i8, i1} %t
    181 
    182 ; CHECK-LABEL: @ssub_4b(
    183 ; CHECK: ret { i8, i1 } { i8 30, i1 false }
    184 }
    185 
    186 define {i8, i1} @ssub_5() nounwind {
    187 entry:
    188   %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -20, i8 -10)
    189   ret {i8, i1} %t
    190 
    191 ; CHECK-LABEL: @ssub_5(
    192 ; CHECK: ret { i8, i1 } { i8 -10, i1 false }
    193 }
    194 
    195 ;;-----------------------------
    196 ;; smul
    197 ;;-----------------------------
    198 
    199 ; rdar://8501501
    200 define {i8, i1} @smul_1() nounwind {
    201 entry:
    202   %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10)
    203   ret {i8, i1} %t
    204 
    205 ; CHECK-LABEL: @smul_1(
    206 ; CHECK: ret { i8, i1 } { i8 -56, i1 true }
    207 }
    208