Skip to content

Commit 05af078

Browse files
authored
Merge pull request #809 from rust-lang/generic-checked-binop
Use generic builtin for checked binary operation
2 parents 55171cf + 364af52 commit 05af078

File tree

1 file changed

+3
-45
lines changed

1 file changed

+3
-45
lines changed

src/int.rs

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -287,51 +287,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
287287
// TODO(antoyo): remove duplication with intrinsic?
288288
let name = if self.is_native_int_type(lhs.get_type()) {
289289
match oop {
290-
OverflowOp::Add => match new_kind {
291-
Int(I8) => "__builtin_add_overflow",
292-
Int(I16) => "__builtin_add_overflow",
293-
Int(I32) => "__builtin_sadd_overflow",
294-
Int(I64) => "__builtin_saddll_overflow",
295-
Int(I128) => "__builtin_add_overflow",
296-
297-
Uint(U8) => "__builtin_add_overflow",
298-
Uint(U16) => "__builtin_add_overflow",
299-
Uint(U32) => "__builtin_uadd_overflow",
300-
Uint(U64) => "__builtin_uaddll_overflow",
301-
Uint(U128) => "__builtin_add_overflow",
302-
303-
_ => unreachable!(),
304-
},
305-
OverflowOp::Sub => match new_kind {
306-
Int(I8) => "__builtin_sub_overflow",
307-
Int(I16) => "__builtin_sub_overflow",
308-
Int(I32) => "__builtin_ssub_overflow",
309-
Int(I64) => "__builtin_ssubll_overflow",
310-
Int(I128) => "__builtin_sub_overflow",
311-
312-
Uint(U8) => "__builtin_sub_overflow",
313-
Uint(U16) => "__builtin_sub_overflow",
314-
Uint(U32) => "__builtin_usub_overflow",
315-
Uint(U64) => "__builtin_usubll_overflow",
316-
Uint(U128) => "__builtin_sub_overflow",
317-
318-
_ => unreachable!(),
319-
},
320-
OverflowOp::Mul => match new_kind {
321-
Int(I8) => "__builtin_mul_overflow",
322-
Int(I16) => "__builtin_mul_overflow",
323-
Int(I32) => "__builtin_smul_overflow",
324-
Int(I64) => "__builtin_smulll_overflow",
325-
Int(I128) => "__builtin_mul_overflow",
326-
327-
Uint(U8) => "__builtin_mul_overflow",
328-
Uint(U16) => "__builtin_mul_overflow",
329-
Uint(U32) => "__builtin_umul_overflow",
330-
Uint(U64) => "__builtin_umulll_overflow",
331-
Uint(U128) => "__builtin_mul_overflow",
332-
333-
_ => unreachable!(),
334-
},
290+
OverflowOp::Add => "__builtin_add_overflow",
291+
OverflowOp::Sub => "__builtin_sub_overflow",
292+
OverflowOp::Mul => "__builtin_mul_overflow",
335293
}
336294
} else {
337295
let (func_name, width) = match oop {

0 commit comments

Comments
 (0)