Skip to content

Commit 39d7a23

Browse files
authored
Merge pull request rust-lang#185 from rust-lang/feature/dummy-fast-math
Add dummy fast math implementation
2 parents 45e3a4a + 4dc0bbf commit 39d7a23

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

src/builder.rs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,31 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
530530
}
531531

532532
fn frem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
533+
// TODO(antoyo): add check in libgccjit since using the binary operator % causes the following error:
534+
// during RTL pass: expand
535+
// libgccjit.so: error: in expmed_mode_index, at expmed.h:240
536+
// 0x7f0101d58dc6 expmed_mode_index
537+
// ../../../gcc/gcc/expmed.h:240
538+
// 0x7f0101d58e35 expmed_op_cost_ptr
539+
// ../../../gcc/gcc/expmed.h:262
540+
// 0x7f0101d594a1 sdiv_cost_ptr
541+
// ../../../gcc/gcc/expmed.h:531
542+
// 0x7f0101d594f3 sdiv_cost
543+
// ../../../gcc/gcc/expmed.h:549
544+
// 0x7f0101d6af7e expand_divmod(int, tree_code, machine_mode, rtx_def*, rtx_def*, rtx_def*, int, optab_methods)
545+
// ../../../gcc/gcc/expmed.cc:4356
546+
// 0x7f0101d94f9e expand_expr_divmod
547+
// ../../../gcc/gcc/expr.cc:8929
548+
// 0x7f0101d97a26 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier)
549+
// ../../../gcc/gcc/expr.cc:9566
550+
// 0x7f0101bef6ef expand_gimple_stmt_1
551+
// ../../../gcc/gcc/cfgexpand.cc:3967
552+
// 0x7f0101bef910 expand_gimple_stmt
553+
// ../../../gcc/gcc/cfgexpand.cc:4028
554+
// 0x7f0101bf6ee7 expand_gimple_basic_block
555+
// ../../../gcc/gcc/cfgexpand.cc:6069
556+
// 0x7f0101bf9194 execute
557+
// ../../../gcc/gcc/cfgexpand.cc:6795
533558
if a.get_type().is_compatible_with(self.cx.float_type) {
534559
let fmodf = self.context.get_builtin_function("fmodf");
535560
// FIXME(antoyo): this seems to produce the wrong result.
@@ -604,24 +629,29 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
604629
a * b
605630
}
606631

607-
fn fadd_fast(&mut self, _lhs: RValue<'gcc>, _rhs: RValue<'gcc>) -> RValue<'gcc> {
608-
unimplemented!();
632+
fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
633+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
634+
lhs + rhs
609635
}
610636

611-
fn fsub_fast(&mut self, _lhs: RValue<'gcc>, _rhs: RValue<'gcc>) -> RValue<'gcc> {
612-
unimplemented!();
637+
fn fsub_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
638+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
639+
lhs - rhs
613640
}
614641

615-
fn fmul_fast(&mut self, _lhs: RValue<'gcc>, _rhs: RValue<'gcc>) -> RValue<'gcc> {
616-
unimplemented!();
642+
fn fmul_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
643+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
644+
lhs * rhs
617645
}
618646

619-
fn fdiv_fast(&mut self, _lhs: RValue<'gcc>, _rhs: RValue<'gcc>) -> RValue<'gcc> {
620-
unimplemented!();
647+
fn fdiv_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
648+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
649+
lhs / rhs
621650
}
622651

623-
fn frem_fast(&mut self, _lhs: RValue<'gcc>, _rhs: RValue<'gcc>) -> RValue<'gcc> {
624-
unimplemented!();
652+
fn frem_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
653+
// NOTE: it seems like we cannot enable fast-mode for a single operation in GCC.
654+
self.frem(lhs, rhs)
625655
}
626656

627657
fn checked_binop(&mut self, oop: OverflowOp, typ: Ty<'_>, lhs: Self::Value, rhs: Self::Value) -> (Self::Value, Self::Value) {

test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ EOF
265265
for test in $(rg --files-with-matches "catch_unwind|should_panic|thread|lto" src/test/ui); do
266266
rm $test
267267
done
268+
git checkout src/test/ui/lto/auxiliary/dylib.rs
268269
git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs
269270
git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs
270271

0 commit comments

Comments
 (0)