<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" > </div>
<div dir="ltr" ><font face="Arial" size="3" style="outline: none;" >Hello,</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" > </font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" >In the discussion on bugzilla 30729, it is mentioned that the <span style="outline: none; font-family: "Courier New", Courier, monospace;" >'</span></font><span style="outline: none; font-family: "Courier New", Courier, monospace;" ><font size="3" style="outline: none;" >this'</font></span><font face="Arial" size="3" style="outline: none;" > pointer needs to be valid upon entry to a non-static method. Does the standard guarantee </font><font face="Courier" size="3" style="outline: none;" >this</font><font face="Arial" size="3" style="outline: none;" > is non-null on entry? If so, is there a reason we can't use that fact to mark '</font><font face="Courier New" size="3" style="outline: none;" >this'</font><font face="Arial" size="3" style="outline: none;" > as '</font><font face="Courier New" size="3" style="outline: none;" >dereferenceable(sizeof(*this))'</font><font face="Arial" size="3" style="outline: none;" >?</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" > </font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" >There are LICM optimizations we can do based on the knowledge that '</font><font face="Courier New" size="3" style="outline: none;" >this' </font><font face="Arial" size="3" style="outline: none;" >is non-null on entry to a non-static member function. </font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" > </font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" >eg. For the following IR, the two highlighted loads are not being hoisted out of the for loop because we are not able to guarantee that the pointer is non-null. If the '</font><font face="Courier New" size="3" style="outline: none;" >this</font><font face="Arial" size="3" style="outline: none;" >' pointer is guaranteed to be non-null on entry and we mark it thus, then the 2 loads within the for-loop body can then be hoisted out into the loop preheader.</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" > </font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" >This is of course just one example of an optimization we could perform based on this knowledge, but there are probably a number of others (i.e. anything that relies on a pointer being '</font><font face="Courier New" size="3" style="outline: none;" >dereferenceable(N)'</font><font face="Arial" size="3" style="outline: none;" >).</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" > </font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><b style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >$ cat a.ll</font></b><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >target datalayout = "e-m:e-i64:64-n32:64"<br style="outline: none;" >target triple = "powerpc64le-unknown-linux-gnu"</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >%struct.S = type { <4 x i32>, <4 x i32> }</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >; Function Attrs: norecurse nounwind readonly<br style="outline: none;" >define <4 x i32> @_ZNK1S20constShouldBeHoistedEmDv4_i(%struct.S* nocapture readonly %this, i64 %n, <4 x<br style="outline: none;" >i32> %x) align 2 {<br style="outline: none;" >entry:<br style="outline: none;" > %tobool9 = icmp eq i64 %n, 0<br style="outline: none;" > br i1 %tobool9, label %for.end, label %for.body.lr.ph</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >for.body.lr.ph: ; preds = %entry<br style="outline: none;" > %k1 = getelementptr inbounds %struct.S, %struct.S* %this, i64 0, i32 0<br style="outline: none;" > %k2 = getelementptr inbounds %struct.S, %struct.S* %this, i64 0, i32 1<br style="outline: none;" > br label %for.body</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >for.body: ; preds = %for.body.lr.ph, %if.end<br style="outline: none;" > %n.addr.011 = phi i64 [ %n, %for.body.lr.ph ], [ %div, %if.end ]<br style="outline: none;" > %x.addr.010 = phi <4 x i32> [ %x, %for.body.lr.ph ], [ %x.addr.1, %if.end ]<br style="outline: none;" > %rem = and i64 %n.addr.011, 15<br style="outline: none;" > %cmp = icmp eq i64 %rem, 0<br style="outline: none;" > br i1 %cmp, label %if.end, label %if.then</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >if.then: ; preds = %for.body<br style="outline: none;" > </font><b style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >%0 = load <4 x i32>, <4 x i32>* %k1, align 16</font></b><br style="outline: none;" ><font face="Courier New" size="3" style="outline: none;" > %add = add <4 x i32> %0, %x.addr.010<br style="outline: none;" > </font><b style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >%1 = load <4 x i32>, <4 x i32>* %k2, align 16</font></b><br style="outline: none;" ><font face="Courier New" size="3" style="outline: none;" > %xor = xor <4 x i32> %add, %1<br style="outline: none;" > br label %if.end</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >if.end: ; preds = %for.body, %if.then<br style="outline: none;" > %x.addr.1 = phi <4 x i32> [ %xor, %if.then ], [ %x.addr.010, %for.body ]<br style="outline: none;" > %div = lshr i64 %n.addr.011, 4<br style="outline: none;" > %tobool = icmp eq i64 %div, 0<br style="outline: none;" > br i1 %tobool, label %for.end, label %for.body</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Courier New" size="3" style="outline: none;" >for.end: ; preds = %if.end, %entry<br style="outline: none;" > %x.addr.0.lcssa = phi <4 x i32> [ %x, %entry ], [ %x.addr.1, %if.end ]<br style="outline: none;" > ret <4 x i32> %x.addr.0.lcssa<br style="outline: none;" >}</font><br style="outline: none; font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size: 12px;" ><font face="Arial" size="3" style="outline: none;" > </font></div>
<div dir="ltr" > </div>
<div dir="ltr" ><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" ><br>Regards,<br>Lei Huang</div>
<div dir="ltr" > </div>
<div dir="ltr" > </div>
<div dir="ltr" >LLVM Development on POWER</div>
<div dir="ltr" >Internal mail: C2/YGK/8200/MKM<br>Phone: (905) 413-4419<br>TieLine: 969-4419<br>E-mail: lei@ca.ibm.com</div></div></div></div></div></div></div><BR>