@@ -2,7 +2,6 @@ use crate::abi::{Abi, FnAbi, LlvmType, PassMode};
2
2
use crate :: builder:: Builder ;
3
3
use crate :: context:: CodegenCx ;
4
4
use crate :: llvm;
5
- use crate :: llvm_util;
6
5
use crate :: type_:: Type ;
7
6
use crate :: type_of:: LayoutLlvmExt ;
8
7
use crate :: va_arg:: emit_va_arg;
@@ -11,7 +10,7 @@ use crate::value::Value;
11
10
use rustc_ast:: ast;
12
11
use rustc_codegen_ssa:: base:: { compare_simd_types, to_immediate, wants_msvc_seh} ;
13
12
use rustc_codegen_ssa:: common:: span_invalid_monomorphization_error;
14
- use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
13
+ use rustc_codegen_ssa:: common:: TypeKind ;
15
14
use rustc_codegen_ssa:: glue;
16
15
use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
17
16
use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
@@ -461,46 +460,14 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
461
460
let is_add = name == "saturating_add" ;
462
461
let lhs = args[ 0 ] . immediate ( ) ;
463
462
let rhs = args[ 1 ] . immediate ( ) ;
464
- if llvm_util:: get_major_version ( ) >= 8 {
465
- let llvm_name = & format ! (
466
- "llvm.{}{}.sat.i{}" ,
467
- if signed { 's' } else { 'u' } ,
468
- if is_add { "add" } else { "sub" } ,
469
- width
470
- ) ;
471
- let llfn = self . get_intrinsic ( llvm_name) ;
472
- self . call ( llfn, & [ lhs, rhs] , None )
473
- } else {
474
- let llvm_name = & format ! (
475
- "llvm.{}{}.with.overflow.i{}" ,
476
- if signed { 's' } else { 'u' } ,
477
- if is_add { "add" } else { "sub" } ,
478
- width
479
- ) ;
480
- let llfn = self . get_intrinsic ( llvm_name) ;
481
- let pair = self . call ( llfn, & [ lhs, rhs] , None ) ;
482
- let val = self . extract_value ( pair, 0 ) ;
483
- let overflow = self . extract_value ( pair, 1 ) ;
484
- let llty = self . type_ix ( width) ;
485
-
486
- let limit = if signed {
487
- let limit_lo = self
488
- . const_uint_big ( llty, ( i128:: MIN >> ( 128 - width) ) as u128 ) ;
489
- let limit_hi = self
490
- . const_uint_big ( llty, ( i128:: MAX >> ( 128 - width) ) as u128 ) ;
491
- let neg = self . icmp (
492
- IntPredicate :: IntSLT ,
493
- val,
494
- self . const_uint ( llty, 0 ) ,
495
- ) ;
496
- self . select ( neg, limit_hi, limit_lo)
497
- } else if is_add {
498
- self . const_uint_big ( llty, u128:: MAX >> ( 128 - width) )
499
- } else {
500
- self . const_uint ( llty, 0 )
501
- } ;
502
- self . select ( overflow, limit, val)
503
- }
463
+ let llvm_name = & format ! (
464
+ "llvm.{}{}.sat.i{}" ,
465
+ if signed { 's' } else { 'u' } ,
466
+ if is_add { "add" } else { "sub" } ,
467
+ width
468
+ ) ;
469
+ let llfn = self . get_intrinsic ( llvm_name) ;
470
+ self . call ( llfn, & [ lhs, rhs] , None )
504
471
}
505
472
_ => bug ! ( ) ,
506
473
} ,
0 commit comments