[LLVMdev] Memmove vs Dead Code Elimination

Carl-Philip Hänsch cphaensch at googlemail.com
Sat Sep 17 00:43:35 PDT 2011


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)
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.
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:
 - Filling c could be made of one big memcpy
 - The data filled into a and b would not longer be used
 - So dead code elimination could remove two memcpy calls
 - Then no calls are done on a and b, all other store's could be removed by
dead store elimination
 - From a and b, a malloc/free pair would be remain which will be removed

I hope you can implement some optimization rules to achieve that improvement
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110917/9b1cabe6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stringref.ll
Type: application/octet-stream
Size: 13929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110917/9b1cabe6/attachment.obj>

More information about the llvm-dev mailing list