<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<div dir="ltr">
<div></div>
<div>
<div><span style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">I am trying to figure what is the best way to do the following in LLVM. Specifically wonder if MemorySSA can be used here…any pointers to existing code that does something similar will be
 useful.<span></span></span>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><br>
</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">Consider this code:</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><br>
</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">%foo = load i256, i256* @G</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">…</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">possible uses of %foo</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">…</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">%bar = call i32 @Bar(i256 %foo)</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><br>
</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">Now if I know that there are no writes to @G between the load and the call, I would like to convert the call to @Bar to a call to @BarP which accepts a pointer to i256:</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><br>
</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important">%bar = call i32 @BarP(i256* @G)</span><br>
</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important">How can I check if there are no clobbers of @G between the load and the call? @G does not alias with any other
 memory but there can be writes to @G between the above load and the call and if so, the safe thing to do is:<span></span></span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important">%foop = alloca i256</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important">store i256 %foo, i256* %foop</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)">…</div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important"><span style="background-color:rgb(255, 255, 255);display:inline !important">%bar<span> </span><span style="background-color:rgb(255, 255, 255);display:inline !important">=
 call i32 @BarP(i256* %foop)</span></span><br>
</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important">Note that I am trying to avoid creating a copy of %foo on the stack when possible.</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></div>
<div dir="ltr" style="caret-color:rgb(33, 33, 33);color:rgb(33, 33, 33)"><span style="background-color:rgb(255, 255, 255);display:inline !important">The goal here is to keep the wide integer in SSA form (there is performance benefit in doing this) but when
 I have to pass the wide vector to a library function, I want to pass its address. Since @G may be a copy of %foo, I would like to pass @G instead of creating a temp with alloca whenever it is safe to do so. The question is how to check if @G still has the
 same value as %foo.<span></span></span></div>
<br style="caret-color:rgb(0, 0, 0)">
<br>
</div>
<div id="ms-outlook-mobile-signature">
<div><br>
</div>
<div style="color:rgb(33, 33, 33);background-color:rgb(255, 255, 255)" dir="auto">
/Riyaz</div>
</div>
</div>
</div>
</body>
</html>