Skip to content

Commit 35ae752

Browse files
committed
Disable LLVM's new fptoint intrinsics on riscv64
Looks like this platform still isn't quite working yet due to https://bugs.llvm.org/show_bug.cgi?id=50083
1 parent de2a460 commit 35ae752

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
670670
}
671671

672672
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() {
674674
let src_ty = self.cx.val_ty(val);
675675
let float_width = self.cx.float_width(src_ty);
676676
let int_width = self.cx.int_width(dest_ty);
@@ -683,7 +683,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
683683
}
684684

685685
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() {
687687
let src_ty = self.cx.val_ty(val);
688688
let float_width = self.cx.float_width(src_ty);
689689
let int_width = self.cx.int_width(dest_ty);
@@ -1387,4 +1387,12 @@ impl Builder<'a, 'll, 'tcx> {
13871387
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
13881388
}
13891389
}
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+
}
13901398
}

0 commit comments

Comments
 (0)