<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=Windows-1252">
<meta name="Generator" content="Microsoft Word 12 (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;}
@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:0in;
        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;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@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]-->
</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">This is the new patch. All my comments/answers bellow.<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">Thank you for the review.<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><i><span style="color:teal">- Elena</span></i></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<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""> Craig Topper [mailto:craig.topper@gmail.com]
<br>
<b>Sent:</b> Monday, June 25, 2012 00:24<br>
<b>To:</b> Rotem, Nadav<br>
<b>Cc:</b> Demikhovsky, Elena; llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [llvm-commits] Please review - One more shuffle optimization for AVX<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Sun, Jun 24, 2012 at 7:10 AM, Rotem, Nadav <<a href="mailto:nadav.rotem@intel.com" target="_blank">nadav.rotem@intel.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">CHECK: test18<br>
+; CHECK: vshufps<br>
+; CHECK: vshufps<br>
+; CHECK: vunpcklps<br>
<br>
Check for 'ret' at the end of the test.<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
<br>
                                   DebugLoc dl) {<br>
-  SDValue V = Insert128BitVector(DAG.getUNDEF(VT), V1, 0, DAG, dl);<br>
-  return Insert128BitVector(V, V2, NumElems/2, DAG, dl);<br>
+  SDValue V = DAG.getNode(ISD::UNDEF, dl, VT);<br>
+<br>
+  if (V1.getOpcode() != ISD::UNDEF)<br>
+    V = Insert128BitVector(V, V1, 0, DAG, dl);<br>
+<br>
+  if (V2.getOpcode() != ISD::UNDEF)<br>
+    V = Insert128BitVector(V, V2, NumElems/2, DAG, dl);<br>
+<br>
+  return V;<br>
 }<br>
<br>
No need to do this. Craig changed Insert128BitVector so that it checks for undef values.<br>
<br>
<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
+//<br>
+// Some special combinations that can be optimized<br>
+//<br>
<br>
What is special about these combinations ? <span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] These combinations are frequently seen in many benchmarks. This optimization gives 10-20% on many WOLF benchmarks.<o:p></o:p></span></i></b></p>
<p class="MsoNormal">Period at the end of the sentence.  <span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done<o:p></o:p></span></i></b></p>
<p class="MsoNormal">Why is this function called Compact8x32ShuffleNode ?<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] You can suggest another name.<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
<br>
+  if (VT.is256BitVector() && (NumElts == 8)) {<br>
<br>
You can check that VT = v8i32;<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] I changed to (VT==v8i32 || VT==v8f32)<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
<br>
+    ArrayRef<int> Mask = SVOp->getMask();<br>
+    if (isUndefOrEqual(Mask[0], 0) &&<br>
+        isUndefOrEqual(Mask[1], 8) &&<br>
+        isUndefOrEqual(Mask[2], 2) &&<br>
+        isUndefOrEqual(Mask[3], 10) &&<br>
+        isUndefOrEqual(Mask[4], 4) &&<br>
+        isUndefOrEqual(Mask[5], 12) &&<br>
+        isUndefOrEqual(Mask[6], 6) &&<br>
+        isUndefOrEqual(Mask[7], 14)) {<br>
<br>
Please create a local array and iterate over it in a loop. Calling a function 16 times bloats the code.<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
<br>
+      int CompactionMask[] = {0, 2, -1, -1, 4, 6, -1, -1};<br>
+      SDValue Op0 = DAG.getVectorShuffle(VT, dl, SVOp->getOperand(0),<br>
+        DAG.getNode(ISD::UNDEF, dl, VT), CompactionMask);<br>
+      SDValue Op1 = DAG.getVectorShuffle(VT, dl, SVOp->getOperand(1),<br>
+        DAG.getNode(ISD::UNDEF, dl, VT), CompactionMask);<br>
+      int UnpackMask[] = {0, 8, 1, 9, 4, 12, 5, 13};<br>
<br>
Undef can be created once, not 4 times.<o:p></o:p></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done</span></i></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><br>
Also mark those arrays as static const.<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
 <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
<br>
+}<br>
+<br>
+<br>
<br>
Remove the extra line breaks.<o:p></o:p></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Demikhovsky, Elena] Done</span></i></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
-----Original Message-----<br>
From: <a href="mailto:llvm-commits-bounces@cs.uiuc.edu">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-bounces@cs.uiuc.edu">llvm-commits-bounces@cs.uiuc.edu</a>] On Behalf Of Demikhovsky, Elena<br>
Sent: Sunday, June 24, 2012 15:30<br>
To: <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
Subject: [llvm-commits] Please review - One more shuffle optimization for AVX<br>
<br>
Hi,<br>
<br>
I have a bunch of optimizations for AVX and AVX2 code that I recently did. Most of them show significant performance speedup on real workloads.<br>
I'll send it to review one by one accompanied with appropriate tests.<br>
<br>
The current patch optimizes frequently used shuffle patterns and gives these instruction sequence reduction.<br>
Before:<br>
      vshufps $-35, %xmm1, %xmm0, %xmm2 ## xmm2 = xmm0[1,3],xmm1[1,3]<br>
       vpermilps       $-40, %xmm2, %xmm2 ## xmm2 = xmm2[0,2,1,3]<br>
       vextractf128    $1, %ymm1, %xmm1<br>
       vextractf128    $1, %ymm0, %xmm0<br>
       vshufps $-35, %xmm1, %xmm0, %xmm0 ## xmm0 = xmm0[1,3],xmm1[1,3]<br>
       vpermilps       $-40, %xmm0, %xmm0 ## xmm0 = xmm0[0,2,1,3]<br>
       vinsertf128     $1, %xmm0, %ymm2, %ymm0<br>
After:<br>
      vshufps $13, %ymm0, %ymm1, %ymm1 ## ymm1 = ymm1[1,3],ymm0[0,0],ymm1[5,7],ymm0[4,4]<br>
      vshufps $13, %ymm0, %ymm0, %ymm0 ## ymm0 = ymm0[1,3,0,0,5,7,4,4]<br>
      vunpcklps       %ymm1, %ymm0, %ymm0 ## ymm0 = ymm0[0],ymm1[0],ymm0[1],ymm1[1],ymm0[4],ymm1[4],ymm0[5],ymm1[5]<br>
<br>
 Thank you<br>
<br>
- Elena<br>
<br>
<br>
---------------------------------------------------------------------<br>
Intel Israel (74) Limited<br>
<br>
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.<br>
---------------------------------------------------------------------<br>
Intel Israel (74) Limited<br>
<br>
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.<br>
<br>
<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<br>
-- <br>
~Craig<o:p></o:p></p>
</div>
<font face="monospace">---------------------------------------------------------------------<br>
Intel Israel (74) Limited<br>
<br>
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.</font></body>
</html>