Skip to content

LLVM cannot constant fold memchr with constant size #120913

@philnik777

Description

@philnik777
void* test1(char* first, char val) {
  return __builtin_memchr(first, val, 2);
}

always generates a call to memchr, even though it could just check the two chars. I can't really see a case where calling memchr is faster than just checking the two chars. For larger N it would also be interesting to use vector comparisons for this instead of calling a function.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions