<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=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@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;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* 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:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {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="ZH-CN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">When I do a spill, I directly construct a physical register, see below:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">spill->src(0) =GenRegister(GEN_GENERAL_REGISTER_FILE, dstStart + dstID, 0,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">                                              selReg.type, selReg.vstride, selReg.width, selReg.hstride);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">and also allocate one physical register from reserved register pool, change the spilled virtual register to physical register:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">dst.physical =1; dst.nr = dstStart+dstID; dst.subnr = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">so, in later emit code, when they call ra->genReg(), I will directly return the physical register; see GenRegAllocator::Opaque::genReg()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> beignet-bounces+ruiling.song=intel.com@lists.freedesktop.org
 [mailto:beignet-bounces+ruiling.song=intel.com@lists.freedesktop.org] <b>On Behalf Of
</b>zhigang gong<br>
<b>Sent:</b> Friday, August 09, 2013 4:29 PM<br>
<b>To:</b> Song, Ruiling<br>
<b>Cc:</b> beignet@lists.freedesktop.org<br>
<b>Subject:</b> Re: [Beignet] [PATCH 2/2] Skip spill/unspill instruction when trying to do spill.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Could you tell something more about how could a spilledReg be a physical register?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">This is not very clear for me. If a virtual register is to be spilled, then it will<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">always be a virtual register, and will be unspilled when it is used. When it may<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">become a physical register?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">On Fri, Aug 9, 2013 at 1:23 PM, Ruiling Song <<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>> wrote:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">We can only spill virtual registers, should skip physical register.<br>
This fix random failure of compiler_box_blur when do spilling.<br>
<br>
Signed-off-by: Ruiling Song <<a href="mailto:ruiling.song@intel.com">ruiling.song@intel.com</a>><br>
---<br>
 backend/src/backend/gen_insn_selection.cpp |    7 +++++--<br>
 1 file changed, 5 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp<br>
index 3610051..5cafa98 100644<br>
--- a/backend/src/backend/gen_insn_selection.cpp<br>
+++ b/backend/src/backend/gen_insn_selection.cpp<br>
@@ -628,12 +628,15 @@ namespace gbe<br>
<br>
     for (auto &block : blockList)<br>
       for (auto &insn : block.insnList) {<br>
+        // spill / unspill insn should be skipped when do spilling<br>
+        if(insn.opcode == SEL_OP_SPILL_REG || insn.opcode == SEL_OP_UNSPILL_REG) continue;<br>
+<br>
         const uint32_t srcNum = insn.srcNum, dstNum = insn.dstNum;<br>
<br>
         for (uint32_t srcID = 0; srcID < srcNum; ++srcID) {<br>
           const GenRegister selReg = insn.src(srcID);<br>
           const ir::Register reg = selReg.reg();<br>
-          if(selReg.file == GEN_GENERAL_REGISTER_FILE && reg == spilledReg) {<br>
+          if(reg == spilledReg && selReg.file == GEN_GENERAL_REGISTER_FILE && selReg.physical == 0) {<br>
             GBE_ASSERT(srcID < 5);<br>
             SelectionInstruction *unspill = this->create(SEL_OP_UNSPILL_REG, 1, 0);<br>
             unspill->state  = GenInstructionState(simdWidth);<br>
@@ -652,7 +655,7 @@ namespace gbe<br>
         for (uint32_t dstID = 0; dstID < dstNum; ++dstID) {<br>
           const GenRegister selReg = insn.dst(dstID);<br>
           const ir::Register reg = selReg.reg();<br>
-          if(selReg.file == GEN_GENERAL_REGISTER_FILE && reg == spilledReg) {<br>
+          if(reg == spilledReg && selReg.file == GEN_GENERAL_REGISTER_FILE && selReg.physical == 0) {<br>
             GBE_ASSERT(dstID < 5);<br>
             SelectionInstruction *spill = this->create(SEL_OP_SPILL_REG, 0, 1);<br>
             spill->state  = GenInstructionState(simdWidth);<br>
<span class="hoenzb"><span style="color:#888888">--</span></span><span style="color:#888888"><br>
<span class="hoenzb">1.7.9.5</span><br>
<br>
<span class="hoenzb">_______________________________________________</span><br>
<span class="hoenzb">Beignet mailing list</span><br>
<span class="hoenzb"><a href="mailto:Beignet@lists.freedesktop.org">Beignet@lists.freedesktop.org</a></span><br>
<span class="hoenzb"><a href="http://lists.freedesktop.org/mailman/listinfo/beignet" target="_blank">http://lists.freedesktop.org/mailman/listinfo/beignet</a></span></span><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>