| Issue |
173326
|
| Summary |
strchr should be optimize to equal check on boolean _expression_
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
rockeet
|
```c++
#include <string.h>
bool is_abchijopqxyz123(char ch) {
return strchr("abchijopqxyz123", ch) != NULL;
}
bool fast_is_abcdhijopqxyz123(char ch) {
return 'a' == ch ||
'b' == ch ||
'c' == ch ||
'h' == ch ||
'i' == ch ||
'j' == ch ||
'o' == ch ||
'p' == ch ||
'q' == ch ||
'x' == ch ||
'y' == ch ||
'z' == ch ||
'1' == ch ||
'2' == ch ||
'3' == ch;
}
```
It should be better strchr in is_abchijopqxyz123 can be opitimizied to fast_is_abcdhijopqxyz123, but it is not, see https://godbolt.org/z/qjr9rj1f4
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs