@@ -2,7 +2,6 @@ use crate::abi::{Abi, FnAbi, LlvmType, PassMode};
22use crate :: builder:: Builder ;
33use crate :: context:: CodegenCx ;
44use crate :: llvm;
5- use crate :: llvm_util;
65use crate :: type_:: Type ;
76use crate :: type_of:: LayoutLlvmExt ;
87use crate :: va_arg:: emit_va_arg;
@@ -11,7 +10,7 @@ use crate::value::Value;
1110use rustc_ast:: ast;
1211use rustc_codegen_ssa:: base:: { compare_simd_types, to_immediate, wants_msvc_seh} ;
1312use rustc_codegen_ssa:: common:: span_invalid_monomorphization_error;
14- use rustc_codegen_ssa:: common:: { IntPredicate , TypeKind } ;
13+ use rustc_codegen_ssa:: common:: TypeKind ;
1514use rustc_codegen_ssa:: glue;
1615use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
1716use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
@@ -461,46 +460,14 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
461460 let is_add = name == "saturating_add" ;
462461 let lhs = args[ 0 ] . immediate ( ) ;
463462 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 )
504471 }
505472 _ => bug ! ( ) ,
506473 } ,
0 commit comments