<div>Hello,<br></div><div><br></div><div>I have attached an example file to show you how i'm doing string concatenation. (This is the result after opt -O3 from llvm3.0)</div><div>There are two strings (a and b) allocated and filled with malloc and llvm.memcpy (from an internal constant). Then, a third string (c) is created. The new length is correctly constant folded, and llvm.memcpy copies the memory from the first two strings into the new one.</div>
<div>If LLVM would change the memcpy from a and b to c to a memcpy from the internal constant to c, it would be much better optimizable:</div><div> - Filling c could be made of one big memcpy</div><div> - The data filled into a and b would not longer be used</div>
<div> - So dead code elimination could remove two memcpy calls</div><div> - Then no calls are done on a and b, all other store's could be removed by dead store elimination</div><div> - From a and b, a malloc/free pair would be remain which will be removed then</div>
<div><br></div><div>I hope you can implement some optimization rules to achieve that improvement ;)</div>