<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 31, 2019 at 8:50 AM kamlesh kumar via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Devs,<br>
Consider testcase here<br>
<a href="https://godbolt.org/z/qHZzqw" rel="noreferrer" target="_blank">https://godbolt.org/z/qHZzqw</a><br>
When optimization is O1 or above it produces unoptimized code<br>
because it calls __tls_get_address in loops.<br>
While with optimization disabled<br>
It produce single call to __tls_get_address outside of loop.<br>
is this a missed optimization by llvm?<br></blockquote><div><br></div><div dir="ltr">It's interesting to me that there's a big difference in -fpie and -fpic.<div><br></div><div><a href="https://godbolt.org/z/klX3q3">https://godbolt.org/z/klX3q3</a><br></div><div><br></div><div>In particular, with -fpie, no call to __tls_get_addr is needed, so the underlying considerations for optimization change. This feels like the optimizer isn't taking in to account the overhead of -fpic, when determining whether to hoist the address calculation out of the loop.</div></div><div><br></div><div dir="ltr" class="gmail_attr">On Thu, Oct 31, 2019 at 10:36 AM David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Looks pretty similar to the GCC generated code</blockquote><div><br></div><div>Challenge accepted => <a href="https://godbolt.org/z/8PX2La">https://godbolt.org/z/8PX2La</a></div><div><br></div><div>-- Jorg</div><div><br></div></div></div>