[LLVMdev] Assignment of large objects, optimization?
Patrik Hägglund H
patrik.h.hagglund at ericsson.com
Mon Mar 12 03:38:00 PDT 2012
Hi,
My fronted generates (bad) code, which I see that LLVM is unable to optimize. For example, code similar to:
%a = type [32 x i16]
declare void @set_obj(%a*)
declare void @use_obj(%a*)
define void @foo() {
entry:
%a1 = alloca %a
%a2 = alloca %a
call void @set_obj(%a* %a2)
%a3 = load %a* %a2
store %a %a3, %a* %a1
call void @use_obj(%a* %a1)
ret void
}
(Or with load/store replaced with memcpy).
In C pseudo-code this is similar to:
a a1;
a a2 = set_obj();
a1 = a2;
use_obj(a1);
and the corresponding LLVM IR in foo() can be simplified to:
%a1 = alloca %a
call void @set_obj(%a* %a1)
call void @use_obj(%a* %a1)
Is it unreasonable to expect LLVM to do this kind of simplifications?
On a side note: Why isn't there an assignment operator in the LLVM IR? Other compilers I have seen have some kind of assignment operator in the IR.
/Patrik Hägglund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120312/e3a795df/attachment.html>
More information about the llvm-dev
mailing list