<div dir="ltr">Yes. Thank You.</div><div class="gmail_extra"><br><div class="gmail_quote">On 18 March 2016 at 15:41, Stefan Gränitz <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi Ansar<span class=""><br>
<br>
<blockquote type="cite">
<div>But, If in case LLVM is reusing <b style="background-color:rgb(243,243,243)">%sub </b><span style="background-color:rgb(243,243,243)">in between
to hold some other computations, then there will be some
errors in my computation. So I want to make sure that LLVM
won't reuse any of these virtual registers. </span></div>
</blockquote></span>
The simple answer is: yes, you can be sure that %sub will not be
reassigned, it's immutable.<br>
Anyway, as Mehdi mentioned it's good to read the docs.<br>
<br>
Best,<br>
Stefan<br>
<br>
<div>Am 18.03.16 um 11:06 schrieb Mehdi
Amini via llvm-dev:<br>
</div><div><div class="h5">
<blockquote type="cite">
<div>Have you read the SSA link that David sent earlier?
(i.e. <a href="https://en.wikipedia.org/wiki/Static_single_assignment_form" target="_blank">https://en.wikipedia.org/wiki/Static_single_assignment_form</a>
)</div>
<div><br>
</div>
There is no such thing as a "LLVM register", or "variables".
<div>The main concepts are the memory, and *values*
(like %sub in your example). The latter are *immutable*.</div>
<div><br>
</div>
<div>-- </div>
<div>Mehdi</div>
<div><br>
<div>
<blockquote type="cite">
<div>On Mar 18, 2016, at 2:49 AM, Ansar K.A. via
llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>
wrote:</div>
<br>
<div>
<div dir="ltr">For eg:
<div><br>
</div>
<div>c=a-b is represented using the following
statements in IR:</div>
<div><br>
</div>
<div> %tmp = load i32, i32* %a, align 4</div>
<div> %tmp1 = load i32, i32* %b, align 4</div>
<div> %sub = sub nsw i32 %tmp, %tmp1 <br>
</div>
<div> store i32 %sub, i32* %c, align 4</div>
<div><br>
</div>
<div><br>
</div>
<div>whenever there is a redundant computation
of the same, say k=a-b (if the value of <b>a</b>
and <b>b</b> are not changed) the code will
be like this:</div>
<div><br>
</div>
<div> %tmp2 = load i32, i32* %a, align 4</div>
<div> %tmp3 = load i32, i32* %b, align 4</div>
<div> <span style="background-color:rgb(255,255,255)">%sub1
= sub nsw i32 %tmp2, %tmp3 </span><br>
</div>
<div> <span style="background-color:rgb(255,255,0)"> store
i32 %sub1, i32* %k, align 4</span></div>
<div><br>
</div>
<div>But this is not required, Since <b>a-b</b> is already there in that virtual
register <b>%sub. </b>So I can rewrite the
highlighted code ( eliminating redundancy ) as</div>
<div><br>
</div>
<div><b> store i32 <span style="background-color:rgb(255,255,0)">%sub</span>,
i32* %k, align 4</b></div>
<div><b><br>
</b></div>
<div>and can delete the statement <b>%sub1
= sub nsw i32 %tmp2, %tmp3 </b></div>
<div><b><br>
</b></div>
<div>But, If in case LLVM is reusing <b style="background-color:rgb(243,243,243)">%sub
</b><span style="background-color:rgb(243,243,243)">in between to hold some other computations,
then there will be some errors in my computation. So
I want to make sure that LLVM won't reuse any of
these virtual registers. </span></div>
<div><span style="background-color:rgb(243,243,243)"><br>
</span></div>
<div><span style="background-color:rgb(243,243,243)">I
hope it clarifies.</span></div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 18 March 2016 at 13:39, mats
petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank"></a><a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span>On 18
March 2016 at 06:31, Ansar K.A. via llvm-dev
<span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank"></a><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I meant LLVM
registers. Thanks for the correcting me.</div>
</blockquote>
<div><br>
</div>
</span>
<div>But registers in LLVM-IR are in
infinite supply, since the are virtual
registers. Real registers appear when the IR
is translated to machine instructions, and
this is based on the live-range of the
actual variables, so the same register will
be re-used within the machine code. Reusing
a virtual register is BAD because it will
confuse the IR into thinking that your code
is using the same thing for longer, and
thus, potentially, make it use the same
hardware register when two different ones
could have been used.<br>
<br>
</div>
<div>Can you please explain what it
is you want to achieve, as a bigger picture?
Ideally with some example of some source,
its generated IR and how you want it to be
different?<br>
<br>
--<br>
</div>
<div>Mats<br>
</div>
<span>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 18 March
2016 at 10:42, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank"></a><a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Question
is hard to understand - the
registers in LLVM are in <a href="https://en.wikipedia.org/wiki/Static_single_assignment_form" target="_blank">Static
Single Assignment form</a>,
they're not variables that can
be assigned and reassigned
values (so the answer to your
question is probably "no").
It's best to look at what
Clang does to see how IR can
be used to represent
constructs in C you may be
more familiar with.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span>On Thu, Mar 17,
2016 at 10:05 PM, Ansar
K.A. via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank"></a><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>
wrote:<br>
</span>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<div dir="ltr">
<div>In any
case, Is there any
chance for reusing <i>temporary
variable </i>used
in it's IR by LLVM ?<i> </i><br>
</div>
</div>
<br>
</span>_______________________________________________<br>
LLVM Developers mailing
list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</span></div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</div></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>