totally folding string operations
Giovanni Bajo
giovannibajo@libero.it
Thu Sep 30 02:47:00 GMT 2004
Hello,
I am investigating the fesability of totally folding constant string operations
at compile time. For instance, given:
void foo(void)
{
std::string a("123");
std::string b("345");
std::cout << a+b << "\n";
}
I would like my compiler to be able to generate the equivalent of:
void foo(void)
{
std::cout << "123456" << "\n";
}
By looking at the optimized tree dump of this example, there are two major
blockers here: the first is that the std::string methods involved are not
inlined, prolly because they are defined elsewhere (right?). The second problem
(for later) is that we do heap allocations even if we could not do that. An
idea here would be to construct a new optimizer pass which transforms closed
pairs of new/delete calls of constant size into alloca().
Comments?
--
Giovanni Bajo
More information about the Libstdc++
mailing list