This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
totally folding string operations
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 30 Sep 2004 04:48:13 +0200
- Subject: totally folding string operations
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