https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121815

            Bug ID: 121815
           Summary: memcmp should expand inline when the len is [0,1]
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

I thought this was filed before but I can't find it (maybe it was for memcpy).

Basically if we know the len is [0,1] we should be able expand memcmp inline
always.
Take:
```
auto test1(const char* str, unsigned len) {
  auto cmp_len = len == 0 ? 0 : 1;
  return __builtin_memcmp("a", str, cmp_len);
}
```

This is from https://github.com/llvm/llvm-project/issues/157064 .

Reply via email to