Skip to content

LLVM could avoid calling memcmp when the maximum lenght is 1 #157064

@philnik777

Description

@philnik777
auto test1(const char* str, unsigned len) {
  auto cmp_len = len == 0 ? 0 : 1;
  return __builtin_memcmp("a", str, cmp_len);
}

results in a memcmp call, even though it's almost certainly faster to inline the memcmp call, especially when the place where the result is used is available.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions