<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:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-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.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:517038639;
mso-list-type:hybrid;
mso-list-template-ids:742455272 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></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>Hi All,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>In the target I am working, we comes cross a situation that the loop strength reduction<o:p></o:p></p><p class=MsoNormal>could deliver a better result but currently not, because <o:p></o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'> </span></span><![endif]>the algorithm narrows search space by winner registers without considering <o:p></o:p></p><p class=MsoListParagraph>the target preferred format. (NarrowSearchSpaceByPickingWinnerRegs)<o:p></o:p></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'> </span></span><![endif]>Cost comparison solely favors the number register without considering other<o:p></o:p></p><p class=MsoListParagraph>Impacts. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For the case one,<o:p></o:p></p><p class=MsoNormal>NarrowSearchSpaceByPickingWinnerRegs filters by most occurred registers.<o:p></o:p></p><p class=MsoNormal>ld(basereg, immediate) is a target preferred addressing mode. However, it may<o:p></o:p></p><p class=MsoNormal>be deleted because basereg is very likely not to be the most occurred register <o:p></o:p></p><p class=MsoNormal>because the less opportunity in a combination. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For the case two, by observing the cost comparison equation<o:p></o:p></p><p class=MsoNormal>bool Cost::operator<(const Cost &Other) const {<o:p></o:p></p><p class=MsoNormal> if (NumRegs != Other.NumRegs) return NumRegs < Other.NumRegs;<o:p></o:p></p><p class=MsoNormal> if (AddRecCost != Other.AddRecCost) return AddRecCost < Other.AddRecCost;<o:p></o:p></p><p class=MsoNormal> if (NumIVMuls != Other.NumIVMuls) return NumIVMuls < Other.NumIVMuls;<o:p></o:p></p><p class=MsoNormal> if (NumBaseAdds != Other.NumBaseAdds) return NumBaseAdds < Other.NumBaseAdds;<o:p></o:p></p><p class=MsoNormal> if (ImmCost != Other.ImmCost) return ImmCost < Other.ImmCost;<o:p></o:p></p><p class=MsoNormal> if (SetupCost != Other.SetupCost) return SetupCost < Other.SetupCost;<o:p></o:p></p><p class=MsoNormal> return false;<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If we have a case to compare<o:p></o:p></p><p class=MsoNormal>Cost at 5 regs, with addrec cost 1, plus 15 base adds, plus 1 imm cost, plus 4 setup cost.<o:p></o:p></p><p class=MsoNormal>Cost at 4 regs, with addrec cost 1, plus 28 base adds, plus 1 imm cost, plus 2 setup cost.<o:p></o:p></p><p class=MsoNormal>The current mode will select 4 regs case even there are 14 more base adds. And base<o:p></o:p></p><p class=MsoNormal>Adds matters in our targets.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So I think the current LSR should be pushing more decision into target dependent backend.<o:p></o:p></p><p class=MsoNormal>Like calling new functions in TargetTransformInfo. At least, in narrow search space and cost <o:p></o:p></p><p class=MsoNormal>comparison phase, or more in cost rating phase. LSR can be tightly cooped with the target<o:p></o:p></p><p class=MsoNormal>attributes in order to get the most beneficial result.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>How do you guys think?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Yin <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>