@@ -3,7 +3,6 @@ use crate::common::Funclet;
33use crate :: context:: CodegenCx ;
44use crate :: llvm:: { self , BasicBlock , False } ;
55use crate :: llvm:: { AtomicOrdering , AtomicRmwBinOp , SynchronizationScope } ;
6- use crate :: llvm_util;
76use crate :: type_:: Type ;
87use crate :: type_of:: LayoutLlvmExt ;
98use crate :: value:: Value ;
@@ -1038,25 +1037,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10381037 dst : & ' ll Value ,
10391038 cmp : & ' ll Value ,
10401039 src : & ' ll Value ,
1041- mut order : rustc_codegen_ssa:: common:: AtomicOrdering ,
1040+ order : rustc_codegen_ssa:: common:: AtomicOrdering ,
10421041 failure_order : rustc_codegen_ssa:: common:: AtomicOrdering ,
10431042 weak : bool ,
10441043 ) -> & ' ll Value {
10451044 let weak = if weak { llvm:: True } else { llvm:: False } ;
1046- if llvm_util:: get_version ( ) < ( 13 , 0 , 0 ) {
1047- use rustc_codegen_ssa:: common:: AtomicOrdering :: * ;
1048- // Older llvm has the pre-C++17 restriction on
1049- // success and failure memory ordering,
1050- // requiring the former to be at least as strong as the latter.
1051- // So, for llvm 12, we upgrade the success ordering to a stronger
1052- // one if necessary.
1053- match ( order, failure_order) {
1054- ( Relaxed , Acquire ) => order = Acquire ,
1055- ( Release , Acquire ) => order = AcquireRelease ,
1056- ( _, SequentiallyConsistent ) => order = SequentiallyConsistent ,
1057- _ => { }
1058- }
1059- }
10601045 unsafe {
10611046 llvm:: LLVMRustBuildAtomicCmpXchg (
10621047 self . llbuilder ,
@@ -1444,51 +1429,37 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14441429 }
14451430 }
14461431
1447- fn fptoint_sat_broken_in_llvm ( & self ) -> bool {
1448- match self . tcx . sess . target . arch . as_ref ( ) {
1449- // FIXME - https://bugs.llvm.org/show_bug.cgi?id=50083
1450- "riscv64" => llvm_util:: get_version ( ) < ( 13 , 0 , 0 ) ,
1451- _ => false ,
1452- }
1453- }
1454-
14551432 fn fptoint_sat (
14561433 & mut self ,
14571434 signed : bool ,
14581435 val : & ' ll Value ,
14591436 dest_ty : & ' ll Type ,
14601437 ) -> Option < & ' ll Value > {
1461- if !self . fptoint_sat_broken_in_llvm ( ) {
1462- let src_ty = self . cx . val_ty ( val) ;
1463- let ( float_ty, int_ty, vector_length) = if self . cx . type_kind ( src_ty) == TypeKind :: Vector
1464- {
1465- assert_eq ! ( self . cx. vector_length( src_ty) , self . cx. vector_length( dest_ty) ) ;
1466- (
1467- self . cx . element_type ( src_ty) ,
1468- self . cx . element_type ( dest_ty) ,
1469- Some ( self . cx . vector_length ( src_ty) ) ,
1470- )
1471- } else {
1472- ( src_ty, dest_ty, None )
1473- } ;
1474- let float_width = self . cx . float_width ( float_ty) ;
1475- let int_width = self . cx . int_width ( int_ty) ;
1476-
1477- let instr = if signed { "fptosi" } else { "fptoui" } ;
1478- let name = if let Some ( vector_length) = vector_length {
1479- format ! (
1480- "llvm.{}.sat.v{}i{}.v{}f{}" ,
1481- instr, vector_length, int_width, vector_length, float_width
1482- )
1483- } else {
1484- format ! ( "llvm.{}.sat.i{}.f{}" , instr, int_width, float_width)
1485- } ;
1486- let f =
1487- self . declare_cfn ( & name, llvm:: UnnamedAddr :: No , self . type_func ( & [ src_ty] , dest_ty) ) ;
1488- Some ( self . call ( self . type_func ( & [ src_ty] , dest_ty) , f, & [ val] , None ) )
1438+ let src_ty = self . cx . val_ty ( val) ;
1439+ let ( float_ty, int_ty, vector_length) = if self . cx . type_kind ( src_ty) == TypeKind :: Vector {
1440+ assert_eq ! ( self . cx. vector_length( src_ty) , self . cx. vector_length( dest_ty) ) ;
1441+ (
1442+ self . cx . element_type ( src_ty) ,
1443+ self . cx . element_type ( dest_ty) ,
1444+ Some ( self . cx . vector_length ( src_ty) ) ,
1445+ )
14891446 } else {
1490- None
1491- }
1447+ ( src_ty, dest_ty, None )
1448+ } ;
1449+ let float_width = self . cx . float_width ( float_ty) ;
1450+ let int_width = self . cx . int_width ( int_ty) ;
1451+
1452+ let instr = if signed { "fptosi" } else { "fptoui" } ;
1453+ let name = if let Some ( vector_length) = vector_length {
1454+ format ! (
1455+ "llvm.{}.sat.v{}i{}.v{}f{}" ,
1456+ instr, vector_length, int_width, vector_length, float_width
1457+ )
1458+ } else {
1459+ format ! ( "llvm.{}.sat.i{}.f{}" , instr, int_width, float_width)
1460+ } ;
1461+ let f = self . declare_cfn ( & name, llvm:: UnnamedAddr :: No , self . type_func ( & [ src_ty] , dest_ty) ) ;
1462+ Some ( self . call ( self . type_func ( & [ src_ty] , dest_ty) , f, & [ val] , None ) )
14921463 }
14931464
14941465 pub ( crate ) fn landing_pad (
0 commit comments