Missed optimization of empty for loop function into just ret #69833
Closed
Description
#include <unordered_map>
void foo(std::unordered_map<int, int> umap)
{
for (const auto& i : umap) {}
}foo(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >): # @foo(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >)
add rdi, 16
.LBB0_1: # =>This Inner Loop Header: Depth=1
mov rdi, qword ptr [rdi]
test rdi, rdi
jne .LBB0_1
rethttps://godbolt.org/z/cdavsPGq5
Tested on x86-64 clang (trunk), the above function get fully optimized to just ret on gcc (trunk).
Activity