Skip to content

intrinsics: Add impl for fadd_fast, fsub_fast, fmul_fast, fdiv_fast and frem_fast - #4944

Open
CohenArthur wants to merge 2 commits into
Rust-GCC:masterfrom
CohenArthur:fop-fast-intrinsics
Open

CohenArthur wants to merge 2 commits into
Rust-GCC:masterfrom
CohenArthur:fop-fast-intrinsics

Conversation

@CohenArthur

Copy link
Copy Markdown
Member

Addresses #4926
Needs #4943 so only review last commit

Add an implementation for the aforementioned intrinsics. Note that this is a simple
implementation and does not actually implement fast mode for these operations, but
instead simply performs the operation. As far as I can tell, it is not possible to
turn on fast mode in GCC for just one operation instead of the whole program.

gcc/rust/ChangeLog:

* backend/rust-compile-intrinsic.cc: Reformat the table and add entries for
f<op>_fast intrinsics.
* backend/rust-intrinsic-handlers.cc (fop_fast): New handler for f<op>_fast
intrinsics.
* backend/rust-intrinsic-handlers.h (fop_fast): New declaration.
* typecheck/rust-hir-type-check-intrinsic.cc: Add typecheck info for f<op>_fast
intrinsics.
* util/rust-intrinsic-values.h: New intrinsics.

gcc/testsuite/ChangeLog:

* rust/compile/fop_fast_intrinsics.rs: New test.

@CohenArthur
CohenArthur force-pushed the fop-fast-intrinsics branch 2 times, most recently from 4924644 to 57a1279 Compare September 29, 2026 17:36
@Polygonalr

Copy link
Copy Markdown
Contributor

You can prolly try out the new stacked PR feature if the PR requires a prior PR to be merged first ツ

When performing the mod/remainder operation on floating point values, we cannot simply make a
fold_build2 binary op as this operation is not defined in later passes of GCC for f32 and f64.
We have to call the remainder{,f,l} builtins and store the result instead.

This was previously uncaught in our testsuite, and the associated testcase would simply ICE.

gcc/rust/ChangeLog:

	* rust-gcc.cc (builtin_remainder_float_call): New function.
	(maybe_extend_precision): Likewise.
	(arithmetic_or_logical_expression): Call them and adapt logic.

gcc/testsuite/ChangeLog:

	* rust/compile/float-rem.rs: New test.
…nd frem_fast

Add an implementation for the aforementioned intrinsics. Note that this is a simple
implementation and does not actually implement fast mode for these operations, but
instead simply performs the operation. As far as I can tell, it is not possible to
turn on fast mode in GCC for just one operation instead of the whole program.

gcc/rust/ChangeLog:

	* backend/rust-compile-intrinsic.cc: Reformat the table and add entries for
	f<op>_fast intrinsics.
	* backend/rust-intrinsic-handlers.cc (fop_fast): New handler for f<op>_fast
	intrinsics.
	* backend/rust-intrinsic-handlers.h (fop_fast): New declaration.
	* typecheck/rust-hir-type-check-intrinsic.cc: Add typecheck info for f<op>_fast
	intrinsics.
	* util/rust-intrinsic-values.h: New intrinsics.

gcc/testsuite/ChangeLog:

	* rust/compile/fop_fast_intrinsics.rs: New test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants