@@ -670,7 +670,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
670
670
}
671
671
672
672
fn fptoui_sat ( & mut self , val : & ' ll Value , dest_ty : & ' ll Type ) -> Option < & ' ll Value > {
673
- if llvm_util:: get_version ( ) >= ( 12 , 0 , 0 ) {
673
+ if llvm_util:: get_version ( ) >= ( 12 , 0 , 0 ) && ! self . fptoint_sat_broken_in_llvm ( ) {
674
674
let src_ty = self . cx . val_ty ( val) ;
675
675
let float_width = self . cx . float_width ( src_ty) ;
676
676
let int_width = self . cx . int_width ( dest_ty) ;
@@ -683,7 +683,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
683
683
}
684
684
685
685
fn fptosi_sat ( & mut self , val : & ' ll Value , dest_ty : & ' ll Type ) -> Option < & ' ll Value > {
686
- if llvm_util:: get_version ( ) >= ( 12 , 0 , 0 ) {
686
+ if llvm_util:: get_version ( ) >= ( 12 , 0 , 0 ) && ! self . fptoint_sat_broken_in_llvm ( ) {
687
687
let src_ty = self . cx . val_ty ( val) ;
688
688
let float_width = self . cx . float_width ( src_ty) ;
689
689
let int_width = self . cx . int_width ( dest_ty) ;
@@ -1387,4 +1387,12 @@ impl Builder<'a, 'll, 'tcx> {
1387
1387
llvm:: LLVMAddIncoming ( phi, & val, & bb, 1 as c_uint ) ;
1388
1388
}
1389
1389
}
1390
+
1391
+ fn fptoint_sat_broken_in_llvm ( & self ) -> bool {
1392
+ match self . tcx . sess . target . arch . as_str ( ) {
1393
+ // FIXME - https://bugs.llvm.org/show_bug.cgi?id=50083
1394
+ "riscv64" => llvm_util:: get_version ( ) < ( 13 , 0 , 0 ) ,
1395
+ _ => false ,
1396
+ }
1397
+ }
1390
1398
}
0 commit comments