<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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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:"Malgun Gothic";
        panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
        {font-family:"\@Malgun Gothic";
        panose-1:2 11 5 3 2 0 0 2 0 4;}
/* 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;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        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:1315182151;
        mso-list-type:hybrid;
        mso-list-template-ids:-131940256 1134840030 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;
        mso-fareast-font-family:"Malgun Gothic";
        mso-bidi-font-family:Calibri;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
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><o:p> </o:p></p><p class=MsoNormal>> I don't think there is a  need to hook up inline cost model for this. I consider this an pre-IPA enabler pass. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Do you mean that we can clone a call site whenever we detect opportunities? <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> After inlining, if the mergeable callsites remain, the later cfg simplification pass should kick in and merge them.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>  If the call sites we split before inliner are not inlined, later passes may have an opportunity to merge them back. However, if we split an inlinable call site, then we might increase the code size by inlining two call sites.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b>From:</b> Xinliang David Li [mailto:davidxl@google.com] <br><b>Sent:</b> Friday, October 13, 2017 6:18 PM<br><b>To:</b> Jun Lim <junbuml@codeaurora.org><br><b>Cc:</b> reviews+D38641+public+6e61ff737b781fa2@reviews.llvm.org; Chandler Carruth <chandlerc@gmail.com>; Easwaran Raman <eraman@google.com>; Chad Rosier <mcrosier@codeaurora.org>; aemerson@apple.com; llvm-commits <llvm-commits@lists.llvm.org>; kristof.beyls@arm.com<br><b>Subject:</b> Re: [PATCH] D38641: [Inline][WIP] Expose more inlining opportunities by further constraining call site arguments based on splitting an OR condition.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>I don't think there is a  need to hook up inline cost model for this. I consider this an pre-IPA enabler pass.   After inlining, if the mergeable callsites remain, the later cfg simplification pass should kick in and merge them.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>David<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Fri, Oct 13, 2017 at 3:14 PM, Jun Lim <<a href="mailto:junbuml@codeaurora.org" target="_blank">junbuml@codeaurora.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><p class=MsoNormal><br>Thanks David for the detail. I can also see many other opportunities for splitting/cloning call site not just for OR condition. We may be able to handle those step by step in a separate pass before inliner.  Don't you think we need to rely on the inline cost model to estimate the profitability before making decision for cloning a call site?<o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br><br>-----Original Message-----<br>From: David Li via Phabricator [mailto:<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>]<br>Sent: Friday, October 13, 2017 5:05 PM<br>To: <a href="mailto:junbuml@codeaurora.org">junbuml@codeaurora.org</a>; <a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>; <a href="mailto:eraman@google.com">eraman@google.com</a>; <a href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a><br>Cc: <a href="mailto:davidxl@google.com">davidxl@google.com</a>; <a href="mailto:aemerson@apple.com">aemerson@apple.com</a>; <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>; <a href="mailto:kristof.beyls@arm.com">kristof.beyls@arm.com</a><br>Subject: [PATCH] D38641: [Inline][WIP] Expose more inlining opportunities by further constraining call site arguments based on splitting an OR condition.<br><br>davidxl added a comment.<br><br>I see a lot of potential to make this more general. As I mentioned, this is similar to constant propagation based function cloning -- exposing specialization opportunities seems not limited to inliner though inlining could be the biggest customer.<br><br>Consider this:<br><br>define void @foo(i32) local_unnamed_addr #0 {<br><br>  %2 = icmp eq i32 %0, 10<br>  %3 = select i1 %2, i32 1, i32 2<br>  tail call void @bar(i32 %3) #2<br>  ret void<br><br>}<br><br>Converting Select into control flow and expose the constant propagation opportunity should be done in the same pass.<br><br>Consider another example:<br><br>define void @foo(i32) local_unnamed_addr #0 {<br><br>  %2 = icmp eq i32 %0, 10<br>  br i1 %2, label %3, label %4<br><br>; <label>:3:                                      ; preds = %1<br><br>  tail call void @bar(i32 1) #2<br>  br label %4<br><br>; <label>:4:                                      ; preds = %1, %3<br><br>  %5 = phi i32 [ 1, %3 ], [ 2, %1 ]<br>  tail call void @bar(i32 %5) #2<br>  ret void<br><br>}<br><br>Hoisting 'bar' call into incoming block of the phi can also expose opportunity.<br><br>Note that simplifyCFG pass in LLVM currently aggressively sink common code into the merge point -- which may lead to missing opportunities here.    Chandler has a patch to undo that to reduce the damage done by the sinking but that pass is pretty late in the pipeline and won't help for inlining/cloning purpose.<br><br><br><a href="https://reviews.llvm.org/D38641" target="_blank">https://reviews.llvm.org/D38641</a><br><br><br><br><o:p></o:p></p></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>