<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I don't believe that anyone has
explored using assumes for modeling memory. Doing so seems
reasonable, but would require some careful thought. The place to
start looking would be the GVN pass. Specifically, look at the
handling for full redundancy cases. Looking at what we do for
known functions (i.e. malloc, calloc) might be a reasonable place
to start reading.<br>
<br>
Philip<br>
<br>
On 07/03/2015 03:55 AM, Tom Aernoudt wrote:<br>
</div>
<blockquote
cite="mid:67EA03F2E1E794459A297734CB9285F464F7E38A@de02wembxa.internal.synopsys.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is it possible to use __builtin_assume (or
something similar like __builtin_unreachable) to eliminate
stores?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Eg I would expect that I if I write
something as follows the optimizer could optimize away the
store to the variable a:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">void foo(int* a)<o:p></o:p></p>
<p class="MsoNormal">{<o:p></o:p></p>
<p class="MsoNormal"> __builtin_assume(*a == 0);<o:p></o:p></p>
<p class="MsoNormal"> *a = 0;<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">But the generated code still writes to the
variable:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">; Function Attrs: nounwind uwtable<o:p></o:p></p>
<p class="MsoNormal">define void @_Z3fooPi(i32* nocapture %a) #0
{<o:p></o:p></p>
<p class="MsoNormal"> %1 = load i32, i32* %a, align 4, !tbaa !8<o:p></o:p></p>
<p class="MsoNormal"> %2 = icmp eq i32 %1, 0<o:p></o:p></p>
<p class="MsoNormal"> tail call void @llvm.assume(i1 %2)<o:p></o:p></p>
<p class="MsoNormal"> store i32 0, i32* %a, align 4, !tbaa !8<o:p></o:p></p>
<p class="MsoNormal"> ret void<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">00000000000000a0 <_Z3fooPi>:<o:p></o:p></p>
<p class="MsoNormal"> a0: c7 07 00 00 00 00 movl
$0x0,(%rdi)<o:p></o:p></p>
<p class="MsoNormal"> a6: c3 retq <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Why this store not optimized away?<o:p></o:p></p>
<p class="MsoNormal">Is there another way to tell the optimizer
that the store can be eliminated?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Tom<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>