[LLVMdev] Optimization of calls to functions without side effects (from Kaleidoscope example)
Rob Pieke
rob-p at moving-picture.com
Mon Nov 15 05:39:42 PST 2010
> You need to set attribute ReadOnly on the sin / cos functions, using
> Function::addFnAttr(Attribute) for example.
Hmm ... I tried setting that right after Function::Create but I still get the same result (though flagged with "readonly")
declare double @sin(double) readonly
declare double @cos(double) readonly
define double @foo(double %x) readonly {
entry:
%calltmp = call double @sin(double %x)
%calltmp1 = call double @sin(double %x)
%multmp = fmul double %calltmp, %calltmp1
%calltmp2 = call double @cos(double %x)
%calltmp3 = call double @cos(double %x)
%multmp4 = fmul double %calltmp2, %calltmp3
%addtmp = fadd double %multmp, %multmp4
ret double %addtmp
}
More information about the llvm-dev
mailing list