Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intrinsics: Add copy_nonoverlapping<T> #1459

Merged
merged 1 commit into from Aug 16, 2022

Conversation

CohenArthur
Copy link
Member

@CohenArthur CohenArthur commented Aug 11, 2022

intrinsics: Add copy_nonoverlapping

This intrinsic is similar to C's memcpy (or in our case, GCC's
__builtin_memcpy) with the order of arguments swapped and knowledge
about the type of the operands. So we can desugar the following calls:

copy_nonoverlapping::<T>(src, dst, count)

can be converted to

__builtin_memcpy(dst, src, count * size_of::<T>())

Sadly, calling this intrinsic results in calls being optimized out for some reason. I'll open a separate issue to deal with that as I don't have the skills to resolve it. fixed by not marking the function's declaration as TREE_READONLY

Fixes #1450

@philberty
Copy link
Member

If you rebase this on top of #1462 you should be able to close the issue

@philberty philberty added this to In progress in Const generics and missing features sprint via automation Aug 11, 2022
@philberty philberty assigned CohenArthur and unassigned philberty Aug 11, 2022
@CohenArthur CohenArthur force-pushed the copy-nonoverlapping branch 4 times, most recently from 72b06c1 to 795f27f Compare August 12, 2022 08:55
Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Const generics and missing features sprint automation moved this from In progress to Reviewer approved Aug 12, 2022
@CohenArthur
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 12, 2022

Merge conflict.

@CohenArthur CohenArthur force-pushed the copy-nonoverlapping branch 2 times, most recently from c11732e to f68ecc7 Compare August 16, 2022 09:27
This intrinsic is similar to C's memcpy (or in our case, GCC's
__builtin_memcpy) with the order of arguments swapped and knowledge
about the type of the operands. So we can desugar the following calls:

`copy_nonoverlapping::<T>(src, dst, count)`

can be converted to

`__builtin_memcpy(dst, src, count * size_of::<T>())`

Finally, unlike most intrinsics, copy_nonoverlapping must be marked as impure

Co-authored-by: philbert <philip.herron@embecosm.com>
@CohenArthur
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 16, 2022

Build succeeded:

@bors bors bot merged commit 4665766 into Rust-GCC:master Aug 16, 2022
Const generics and missing features sprint automation moved this from Reviewer approved to Done Aug 16, 2022
@CohenArthur CohenArthur deleted the copy-nonoverlapping branch August 16, 2022 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Implement copy_nonoverlapping intrinsic
2 participants