<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0mm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","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-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Vaivaswatha, Dmitry,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Some more analysis of what goes wrong (both in missed optimizations and wrong code) in the current tbaa representation can be found in following thread:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><a href="http://lists.llvm.org/pipermail/cfe-dev/2015-March/042015.html">http://lists.llvm.org/pipermail/cfe-dev/2015-March/042015.html</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">unfortunately, there is (as far as I am aware) no solution yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">(I still want to dive deeper into this, but this is currently not on the top of my stack :( )<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Greetings,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Jeroen Dobbealere<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0mm 0mm 0mm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0mm 0mm 0mm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org]
<b>On Behalf Of </b>Dmitry Polukhin via llvm-dev<br>
<b>Sent:</b> Monday, December 07, 2015 4:13 PM<br>
<b>To:</b> Vaivaswatha Nagaraj<br>
<b>Cc:</b> LLVM Dev<br>
<b>Subject:</b> Re: [llvm-dev] Field sensitive alias analysis?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">BTW, I have found why it doesn't work for arrays. TBAA information propagation is not implemented in CodeGenFunction::EmitArraySubscriptExpr with "TODO: Preserve/extend path TBAA metadata?".<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Fri, Dec 4, 2015 at 1:38 PM, Dmitry Polukhin <<a href="mailto:dmitry.polukhin@gmail.com" target="_blank">dmitry.polukhin@gmail.com</a>> wrote:<o:p></o:p></p>
<div>
<p class="MsoNormal">As far as I can see it is specifics of arrays inside structs. Current TBAA does distinguish non-array members with path sensitive TBAA (see !1 and !6 in my example below, TBAA has reference to struct !2 and offset). As for arrays information
that it was member of some struct get lost completely (!7 has nothing about struct !2).<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">struct S {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> int a;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> int b;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> int c[3];<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">};<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">void foo(struct S* p) {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> p->a = 1;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> p->b = 2;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> p->c[0] = 3;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> p->c[1] = 4;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">define void @foo(%struct.S* nocapture %p) #0 {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">entry:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> %a = getelementptr inbounds %struct.S, %struct.S* %p, i64 0, i32 0<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> store i32 1, i32* %a, align 4, !tbaa !1<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> %b = getelementptr inbounds %struct.S, %struct.S* %p, i64 0, i32 1<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> store i32 2, i32* %b, align 4, !tbaa !6<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> %arrayidx = getelementptr inbounds %struct.S, %struct.S* %p, i64 0, i32 2, i64 0<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> store i32 3, i32* %arrayidx, align 4, !tbaa !7<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> %arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %p, i64 0, i32 2, i64 1<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> store i32 4, i32* %arrayidx2, align 4, !tbaa !7<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> ret void<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">!0 = !{!"clang version 3.8.0 "}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!1 = !{!2, !3, i64 0}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!2 = !{!"S", !3, i64 0, !3, i64 4, !4, i64 8}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!3 = !{!"int", !4, i64 0}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!4 = !{!"omnipotent char", !5, i64 0}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!5 = !{!"Simple C/C++ TBAA"}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!6 = !{!2, !3, i64 4}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">!7 = !{!3, !3, i64 0}<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm just start learning how TBAA in clang works so I don't know why it was implemented this way.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On Fri, Dec 4, 2015 at 11:06 AM, Vaivaswatha Nagaraj via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0mm 0mm 0mm 6.0pt;margin-left:4.8pt;margin-right:0mm">
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi, <o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I'm trying to optimize a simple C code and came across a situation where invariant code is not being moved out:<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">On an -O3 compilation, I noticed that the "load" for the loop bounds (which remain invariant throughout) happens on each iteration of both the loops, even though it is not modified anywhere in the function "bigLoop".
It seems that alias analysis is not able to say that the writes to one field in the structure does not impact the other field, leading to LICM being ineffective.<o:p></o:p></p>
</div>
<p class="MsoNormal">Do any of the alias analyses currently have some kind of field sensitivity that can help in this case?<o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">------------------------- test case ------------------------------------<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">#include <stdlib.h><br>
#include <stdio.h><br>
<br>
#define SIZE 100<br>
<br>
struct AS {<br>
int a[SIZE+4];<br>
int size;<br>
} A;<br>
<br>
void bigLoop(void)<br>
{<br>
unsigned i, j;<br>
<br>
for (i = 0; i < A.size; i++) {<br>
A.a[i+2] += A.a[i];<br>
}<br>
for (i = 0; i < A.size; i++) {<br>
A.a[i+2] *= A.a[i];<br>
}<br>
}<br>
<br>
int main()<br>
{<br>
A.size = random()%SIZE;<br>
for (unsigned i = 0; i < A.size; i++) {<br>
A.a[i] = random()%23;<br>
}<br>
bigLoop();<br>
return 0;<br>
}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"> - Vaivaswatha<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">_______________________________________________<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><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>