<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 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@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:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
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 90.0pt 72.0pt 90.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="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Is this an RFC for (an expansion of) the patch you already have
</span></a><a href="https://reviews.llvm.org/D35014"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">https://reviews.llvm.org/D35014</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">? Or are you planning
on making a different design? <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">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Lama<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"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Jatin Bhateja [mailto:jatin.bhateja@gmail.com]
<br>
<b>Sent:</b> Sunday, July 9, 2017 9:21 AM<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Cc:</b> llvm-dev@redking.me.uk; Saba, Lama <lama.saba@intel.com><br>
<b>Subject:</b> RFC: Identification of LEA instructions with complex addressing mode<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"> Current state:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 1/ LEA with complex addressing mode are supported by Intel micro architectures after Nehalem.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 2/ LEA detection is being done during SelectionDAG based instruction selection through<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> addressing mode based complex pattern matching. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 3/ This does not identify LEA patterns beyond Scaling factor 1.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> e.g.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> T1 = A + B;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> T2 = T1 + B;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> T3 = T2 + B;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> T4 = T3 + 10;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> T5 = T4 + 20;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> T6 = T5 + B<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> Above sequence can be folded to <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LEA 30( A , 4 , B); <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> where BASE = A, SCALE = 4, INDEX = B and OFFSET = 30 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 4/ Control flow information is not present at SelectionDAG level, as SelectionDAG based selection<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> work over a single BasicBlock at a time. Which makes it difficult to avoid generation of<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> complex LEA with 3 operands (even with Scale=1) within Loops.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Proposal:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 1/ To have a pre-RA pass to identify LEAs with dense folding. By dense folding I mean scale factor greater than 1. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 2/ Since this pass will run over MachineInstrs so it will be usable for FastISel and Global ISel based flows also which <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> bypass SelectionDAG. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 3/ At MI level we have control flow Analysis info in the form of MachineDominatorTree and MachineLoopInfo<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> to avoid formation of LEAs in loops.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> 4/ Perform CSE over dense LEAs (which have Scale factor > 1) to factor out overlapping computations.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> When two LEAs share BASE , INDEX and OFFSET but have different SCALE we can<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> take out the common complex LEA and generate a simple LEA with legal Scale. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> e.g. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LEA1 : RES1 = LEA 10( A , 4 , B) <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LEA2 : RES2 = LEA 10( A , 8 , B)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> can be converted to <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LEA1 : RES1 = LEA 10( A , 4 , B)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LEA2 : RES2 = LEA (RES1 , 4 , B)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 5/ Disintegration of complex LEAs with Scale 1 to simple LEA + ADD which is already being handled during <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> FixupLEAPass.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Kindly drop your suggestions/comments. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Jatin Bhateja<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>