1; RUN: llc < %s 2; Verify codegen's don't crash on overflow intrinsics. 3 4;; SADD 5 6define zeroext i8 @sadd_i8(i8 signext %a, i8 signext %b) nounwind ssp { 7entry: 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 15declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8) nounwind readnone 16 17define zeroext i16 @sadd_i16(i16 signext %a, i16 signext %b) nounwind ssp { 18entry: 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 26declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone 27 28define zeroext i32 @sadd_i32(i32 signext %a, i32 signext %b) nounwind ssp { 29entry: 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 37declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone 38 39 40;; UADD 41 42define zeroext i8 @uadd_i8(i8 signext %a, i8 signext %b) nounwind ssp { 43entry: 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 51declare { i8, i1 } @llvm.uadd.with.overflow.i8(i8, i8) nounwind readnone 52 53define zeroext i16 @uadd_i16(i16 signext %a, i16 signext %b) nounwind ssp { 54entry: 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 62declare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone 63 64define zeroext i32 @uadd_i32(i32 signext %a, i32 signext %b) nounwind ssp { 65entry: 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 73declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone 74 75 76 77;; ssub 78 79define zeroext i8 @ssub_i8(i8 signext %a, i8 signext %b) nounwind ssp { 80entry: 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 88declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8) nounwind readnone 89 90define zeroext i16 @ssub_i16(i16 signext %a, i16 signext %b) nounwind ssp { 91entry: 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 99declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone 100 101define zeroext i32 @ssub_i32(i32 signext %a, i32 signext %b) nounwind ssp { 102entry: 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 110declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone 111 112 113;; usub 114 115define zeroext i8 @usub_i8(i8 signext %a, i8 signext %b) nounwind ssp { 116entry: 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 124declare { i8, i1 } @llvm.usub.with.overflow.i8(i8, i8) nounwind readnone 125 126define zeroext i16 @usub_i16(i16 signext %a, i16 signext %b) nounwind ssp { 127entry: 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 135declare { i16, i1 } @llvm.usub.with.overflow.i16(i16, i16) nounwind readnone 136 137define zeroext i32 @usub_i32(i32 signext %a, i32 signext %b) nounwind ssp { 138entry: 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 146declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone 147 148 149 150;; smul 151 152define zeroext i8 @smul_i8(i8 signext %a, i8 signext %b) nounwind ssp { 153entry: 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 161declare { i8, i1 } @llvm.smul.with.overflow.i8(i8, i8) nounwind readnone 162 163define zeroext i16 @smul_i16(i16 signext %a, i16 signext %b) nounwind ssp { 164entry: 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 172declare { i16, i1 } @llvm.smul.with.overflow.i16(i16, i16) nounwind readnone 173 174define zeroext i32 @smul_i32(i32 signext %a, i32 signext %b) nounwind ssp { 175entry: 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 183declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) nounwind readnone 184 185 186;; umul 187 188define zeroext i8 @umul_i8(i8 signext %a, i8 signext %b) nounwind ssp { 189entry: 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 197declare { i8, i1 } @llvm.umul.with.overflow.i8(i8, i8) nounwind readnone 198 199define zeroext i16 @umul_i16(i16 signext %a, i16 signext %b) nounwind ssp { 200entry: 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 208declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16) nounwind readnone 209 210define zeroext i32 @umul_i32(i32 signext %a, i32 signext %b) nounwind ssp { 211entry: 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 219declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32) nounwind readnone 220 221