Skip to content

Conversation

bruteforceboy
Copy link
Contributor

Closes #1816

char dst[20];
char src[20];
int _sz = 20, len = 20;
return (_sz ? ((_sz >= len) ? __builtin_bcopy(src, dst, len) : foo())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this conditional get simplified? Also, we may want some part of the conditional to be passed as an argument so that the test doesn't get overly optimized by constant folding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is actually from the OG. I can add an extra conditional test.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say keep this and add an extra one with the added complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bcardosolopes I added an extra conditional test.

float f8[8];
__builtin_bcopy(f4, f8, sizeof(float) * 4);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add at least one test with bcopy for completeness. That way if anyone tries to separate the handling of the builtin from the function it will show a regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also wanted to add a test with bcopy, but it requires <strings.h>, which I can't (or I'm not sure how to) use in the test directory.

Copy link
Member

Choose a reason for hiding this comment

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

with bcopy, but it requires <strings.h>,

Can you add a mock version that would still trigger codegen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bcardosolopes I wasn't able to. I need to somehow trigger memmove. I'm open to suggestions and can create a follow-up PR if I figure out a way.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

LGTM pending nits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CIR][CodeGen][Builtin] bcopy and __builtin_bcopy
3 participants