Home | History | Annotate | Download | only in Generic
      1 ; RUN: llc < %s
      2 ; Verify codegen's don't crash on overflow intrinsics.
      3 
      4 ;; SADD
      5 
      6 define zeroext i8 @sadd_i8(i8 signext %a, i8 signext %b) nounwind ssp {
      7 entry:
      8   %sadd = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 %b)
      9   %cmp = extractvalue { i8, i1 } %sadd, 1
     10   %sadd.result = extractvalue { i8, i1 } %sadd, 0
     11   %X = select i1 %cmp, i8 %sadd.result, i8 42
     12   ret i8 %X
     13 }
     14 
     15 declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8) nounwind readnone
     16 
     17 define zeroext i16 @sadd_i16(i16 signext %a, i16 signext %b) nounwind ssp {
     18 entry:
     19   %sadd = tail call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
     20   %cmp = extractvalue { i16, i1 } %sadd, 1
     21   %sadd.result = extractvalue { i16, i1 } %sadd, 0
     22   %X = select i1 %cmp, i16 %sadd.result, i16 42
     23   ret i16 %X
     24 }
     25 
     26 declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
     27 
     28 define zeroext i32 @sadd_i32(i32 signext %a, i32 signext %b) nounwind ssp {
     29 entry:
     30   %sadd = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
     31   %cmp = extractvalue { i32, i1 } %sadd, 1
     32   %sadd.result = extractvalue { i32, i1 } %sadd, 0
     33   %X = select i1 %cmp, i32 %sadd.result, i32 42
     34   ret i32 %X
     35 }
     36 
     37 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
     38 
     39 
     40 ;; UADD
     41 
     42 define zeroext i8 @uadd_i8(i8 signext %a, i8 signext %b) nounwind ssp {
     43 entry:
     44   %uadd = tail call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %a, i8 %b)
     45   %cmp = extractvalue { i8, i1 } %uadd, 1
     46   %uadd.result = extractvalue { i8, i1 } %uadd, 0
     47   %X = select i1 %cmp, i8 %uadd.result, i8 42
     48   ret i8 %X
     49 }
     50 
     51 declare { i8, i1 } @llvm.uadd.with.overflow.i8(i8, i8) nounwind readnone
     52 
     53 define zeroext i16 @uadd_i16(i16 signext %a, i16 signext %b) nounwind ssp {
     54 entry:
     55   %uadd = tail call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
     56   %cmp = extractvalue { i16, i1 } %uadd, 1
     57   %uadd.result = extractvalue { i16, i1 } %uadd, 0
     58   %X = select i1 %cmp, i16 %uadd.result, i16 42
     59   ret i16 %X
     60 }
     61 
     62 declare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone
     63 
     64 define zeroext i32 @uadd_i32(i32 signext %a, i32 signext %b) nounwind ssp {
     65 entry:
     66   %uadd = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
     67   %cmp = extractvalue { i32, i1 } %uadd, 1
     68   %uadd.result = extractvalue { i32, i1 } %uadd, 0
     69   %X = select i1 %cmp, i32 %uadd.result, i32 42
     70   ret i32 %X
     71 }
     72 
     73 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
     74 
     75 
     76 
     77 ;; ssub
     78 
     79 define zeroext i8 @ssub_i8(i8 signext %a, i8 signext %b) nounwind ssp {
     80 entry:
     81   %ssub = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 %b)
     82   %cmp = extractvalue { i8, i1 } %ssub, 1
     83   %ssub.result = extractvalue { i8, i1 } %ssub, 0
     84   %X = select i1 %cmp, i8 %ssub.result, i8 42
     85   ret i8 %X
     86 }
     87 
     88 declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8) nounwind readnone
     89 
     90 define zeroext i16 @ssub_i16(i16 signext %a, i16 signext %b) nounwind ssp {
     91 entry:
     92   %ssub = tail call { i16, i1 } @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
     93   %cmp = extractvalue { i16, i1 } %ssub, 1
     94   %ssub.result = extractvalue { i16, i1 } %ssub, 0
     95   %X = select i1 %cmp, i16 %ssub.result, i16 42
     96   ret i16 %X
     97 }
     98 
     99 declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone
    100 
    101 define zeroext i32 @ssub_i32(i32 signext %a, i32 signext %b) nounwind ssp {
    102 entry:
    103   %ssub = tail call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
    104   %cmp = extractvalue { i32, i1 } %ssub, 1
    105   %ssub.result = extractvalue { i32, i1 } %ssub, 0
    106   %X = select i1 %cmp, i32 %ssub.result, i32 42
    107   ret i32 %X
    108 }
    109 
    110 declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone
    111 
    112 
    113 ;; usub
    114 
    115 define zeroext i8 @usub_i8(i8 signext %a, i8 signext %b) nounwind ssp {
    116 entry:
    117   %usub = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 %b)
    118   %cmp = extractvalue { i8, i1 } %usub, 1
    119   %usub.result = extractvalue { i8, i1 } %usub, 0
    120   %X = select i1 %cmp, i8 %usub.result, i8 42
    121   ret i8 %X
    122 }
    123 
    124 declare { i8, i1 } @llvm.usub.with.overflow.i8(i8, i8) nounwind readnone
    125 
    126 define zeroext i16 @usub_i16(i16 signext %a, i16 signext %b) nounwind ssp {
    127 entry:
    128   %usub = tail call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
    129   %cmp = extractvalue { i16, i1 } %usub, 1
    130   %usub.result = extractvalue { i16, i1 } %usub, 0
    131   %X = select i1 %cmp, i16 %usub.result, i16 42
    132   ret i16 %X
    133 }
    134 
    135 declare { i16, i1 } @llvm.usub.with.overflow.i16(i16, i16) nounwind readnone
    136 
    137 define zeroext i32 @usub_i32(i32 signext %a, i32 signext %b) nounwind ssp {
    138 entry:
    139   %usub = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
    140   %cmp = extractvalue { i32, i1 } %usub, 1
    141   %usub.result = extractvalue { i32, i1 } %usub, 0
    142   %X = select i1 %cmp, i32 %usub.result, i32 42
    143   ret i32 %X
    144 }
    145 
    146 declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone
    147 
    148 
    149 
    150 ;; smul
    151 
    152 define zeroext i8 @smul_i8(i8 signext %a, i8 signext %b) nounwind ssp {
    153 entry:
    154   %smul = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 %b)
    155   %cmp = extractvalue { i8, i1 } %smul, 1
    156   %smul.result = extractvalue { i8, i1 } %smul, 0
    157   %X = select i1 %cmp, i8 %smul.result, i8 42
    158   ret i8 %X
    159 }
    160 
    161 declare { i8, i1 } @llvm.smul.with.overflow.i8(i8, i8) nounwind readnone
    162 
    163 define zeroext i16 @smul_i16(i16 signext %a, i16 signext %b) nounwind ssp {
    164 entry:
    165   %smul = tail call { i16, i1 } @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
    166   %cmp = extractvalue { i16, i1 } %smul, 1
    167   %smul.result = extractvalue { i16, i1 } %smul, 0
    168   %X = select i1 %cmp, i16 %smul.result, i16 42
    169   ret i16 %X
    170 }
    171 
    172 declare { i16, i1 } @llvm.smul.with.overflow.i16(i16, i16) nounwind readnone
    173 
    174 define zeroext i32 @smul_i32(i32 signext %a, i32 signext %b) nounwind ssp {
    175 entry:
    176   %smul = tail call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
    177   %cmp = extractvalue { i32, i1 } %smul, 1
    178   %smul.result = extractvalue { i32, i1 } %smul, 0
    179   %X = select i1 %cmp, i32 %smul.result, i32 42
    180   ret i32 %X
    181 }
    182 
    183 declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) nounwind readnone
    184 
    185 
    186 ;; umul
    187 
    188 define zeroext i8 @umul_i8(i8 signext %a, i8 signext %b) nounwind ssp {
    189 entry:
    190   %umul = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 %b)
    191   %cmp = extractvalue { i8, i1 } %umul, 1
    192   %umul.result = extractvalue { i8, i1 } %umul, 0
    193   %X = select i1 %cmp, i8 %umul.result, i8 42
    194   ret i8 %X
    195 }
    196 
    197 declare { i8, i1 } @llvm.umul.with.overflow.i8(i8, i8) nounwind readnone
    198 
    199 define zeroext i16 @umul_i16(i16 signext %a, i16 signext %b) nounwind ssp {
    200 entry:
    201   %umul = tail call { i16, i1 } @llvm.umul.with.overflow.i16(i16 %a, i16 %b)
    202   %cmp = extractvalue { i16, i1 } %umul, 1
    203   %umul.result = extractvalue { i16, i1 } %umul, 0
    204   %X = select i1 %cmp, i16 %umul.result, i16 42
    205   ret i16 %X
    206 }
    207 
    208 declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16) nounwind readnone
    209 
    210 define zeroext i32 @umul_i32(i32 signext %a, i32 signext %b) nounwind ssp {
    211 entry:
    212   %umul = tail call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
    213   %cmp = extractvalue { i32, i1 } %umul, 1
    214   %umul.result = extractvalue { i32, i1 } %umul, 0
    215   %X = select i1 %cmp, i32 %umul.result, i32 42
    216   ret i32 %X
    217 }
    218 
    219 declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32) nounwind readnone
    220 
    221