Issue 84266
Summary [clang] feature request: in for loops, optimize out strlen when we can check for NUL
Labels clang
Assignees
Reporter IAKOBVS
    Transform

```c
char *
f(const char *s, int c)
{
    for (size_t i = 0; i < strlen(s); ++i)
    	if (s[i] == (char)c)
		return s + i;
    return NULL;
}
```

into

```c
char *
f(const char *s, int c)
{
    for (size_t i = 0; s[i]; ++i)
    	if (s[i] == (char)c)
		return s + i;
    return NULL;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to