https://bugs.llvm.org/show_bug.cgi?id=46965
Bug ID: 46965
Summary: Miss optimization for consecutive character equality
testing
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: zufu...@163.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
For following code (online at https://godbolt.org/z/3oxx69)
```
template <typename T, typename... Args>
constexpr bool AnyOf(T t, Args... args) noexcept {
return ((t == args) || ...);
}
bool Escape1(int ch) noexcept {
return AnyOf(ch, '\\', '\'', '\"', 'a', 'b', 'e',
'f', 'n', 'r', 't', 'x', 'u', 'U');
}
bool Escape2(int ch) noexcept {
return ch == '\\' || ch == '\'' || ch == '\"'
|| ch == 'a' || ch == 'b' || ch == 'e'
|| ch == 'f' || ch == 'n' || ch == 'r' || ch == 't'
|| ch == 'x' || ch == 'u' || ch == 'U';
}
```
Clang (and GCC, ICC) generates different code for Escape1 and Escape2, while
MSVC generates identical code. Clang also generates different code when
parameter `int ch` is changed to `char ch`.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs