<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font>On Thursday 19 February 2009 19:00:14 Jon Harrop wrote:<br><blockquote type="cite">I'm toying with benchmarks on my HLVM and am unable to get any performance<br></blockquote><blockquote type="cite">improvement from optimization passes...<br></blockquote><br>I just disassembled some of the IR before and after optimization. This example <br>function squares a complex number:<br></div></blockquote>Something is definitely wrong with the way you're using optimization passes.</div><div><br><blockquote type="cite"><div>The ideal result is probably:<br></div></blockquote>It is indeed so:</div><div><br></div><div><div> ./opt -std-compile-opts test.bc | ./llvm-dis</div><div>; ModuleID = '<stdin>'</div><div><br></div><div>define fastcc i32 @zsqr({ double, double }* nocapture, { double, double }) nounwind {</div><div>entry:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%2 = extractvalue { double, double } %1, 0<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%3 = extractvalue { double, double } %1, 0<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%4 = mul double %2, %3<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%5 = extractvalue { double, double } %1, 1<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%6 = extractvalue { double, double } %1, 1<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%7 = mul double %5, %6<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%8 = sub double %4, %7<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%9 = extractvalue { double, double } %1, 0<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%10 = mul double %9, 2.000000e+00<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%11 = extractvalue { double, double } %1, 1<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%12 = mul double %10, %11<span class="Apple-tab-span" style="white-space:pre"> </span>; <double> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%insert = insertvalue { double, double } undef, double %8, 0<span class="Apple-tab-span" style="white-space:pre"> </span>; <{ double, double }> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>%insert2 = insertvalue { double, double } %insert, double %12, 1<span class="Apple-tab-span" style="white-space:pre"> </span>; <{ double, double }> [#uses=1]</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>store { double, double } %insert2, { double, double }* %0</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>ret i32 0</div><div>}</div><div><br></div></div><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>---<br>With best regards, Anton Korobeynikov<br>Faculty of Mathematics and Mechanics, Saint Petersburg State University</div></div></span> </div><br></body></html>