<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000">Hi Jason,<br>I'm using the "late" IfConverter.<br>Indeed I'm missing an implementation of ClobbersPredicate. However it seems this function assumes that the predicate is stored in a special system register (no surprise, the patch is arm oriented).<br>Our target stores predicates in general register. So I guess the only way out is to extend this method to accept the predicate conditions computed by analyzeBranch. I'll give it a go.<br>Many thanks for the pointer.<br><br><div id="c4fa0f84-565f-4fd6-8c3a-78234d07f65d" data-marker=""><div><br></div> <div style="font-size:9pt;font-family:'arial' , 'helvetica' , sans-serif"> <span style="color:#144444;font-size:9pt"><strong>Diogo Sampaio</strong></span><br> <span style="color:#144444;font-size:9pt"><strong>Senior Compiler Engineer • Kalray</strong></span><br> <span style="color:#144444;font-size:8pt">Phone: </span><br> <span style="color:#11588f;font-size:8pt"><u>dsampaio@kalrayinc.com</u> • <a href="https://www.kalrayinc.com" style="color:#11588f" target="_blank" rel="nofollow noopener noreferrer"><u>www.kalrayinc.com</u></a></span> </div> <br> <table cellpadding="0px" border="0px"><tbody><tr><td> <div> <a href="https://www.kalrayinc.com" target="_blank" rel="nofollow noopener noreferrer"> <img src="https://www.kalrayinc.com/IMG/png/Logo_Kalray_141x39.png" alt="Kalray logo"></a> </div> </td><td> <div style="padding-left:10px;border-left:1px solid #58585a"> <span style="color:#144444;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif;display:block;line-height:120%">Intelligent Data Processing<br>From Cloud to Edge</span></div> </td></tr></tbody></table> <br>   <span style="color:#7db621;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif"><strong> Please consider the environment before printing this e-mail.</strong></span> <div> <span style="color:#144444;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif;display:block;line-height:100%">This message contains information that may be privileged or confidential and is the property of Kalray S.A. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.</span></div> <br></div><br><div id="content_out_dsampaio_kalray.eu"></div><hr id="zwchr" data-marker=""><div data-marker=""><b>From: </b>"Jason Eckhardt" <jeckhardt@nvidia.com><br><b>To: </b>"llvm-dev" <llvm-dev@lists.llvm.org>, "Diogo Sampaio" <dsampaio@kalray.eu><br><b>Sent: </b>Friday, September 24, 2021 9:40:51 PM<br><b>Subject: </b>Re: If-converter breaking condition data dependency<br></div><br><div data-marker=""><style style="display:none">/*<![CDATA[*/P {
        margin-top: 0;
        margin-bottom: 0;
}
/*]]>*/</style>
>In none of the TargetInstructionInfo hooks we obtain both the basic block and
<div>>branch conditions to detect this break of data dependency, although I imagine</div>
<div>>the if-converter should be the one doing so.</div>
<div>></div>
<div>>At best, isProfitableToIfCvt should also receive the branch conditions, so it</div>
<div>>could detect this case.</div>
<div><br>
</div>
<div>Which if-converter pass are you using? There is the "late" IfConverter pass and</div>
<div>the "early" EarlyIfPredicator pass. In either case, the legality checks are not</div>
<div>performed by isProfitableToIfCvt.</div>
<div><br>
</div>
<div>Off the top of my head, I'd guess that if you are using the IfConverter, you</div>
<div>might double-check your implementation of TII::ClobbersPredicate or trace</div>
<div>through its callers on your example.  If you are using EarlyIfPredicator, you</div>
<div>might check SSAIfConv::canPredicateInstrs (and its helper SSAIfConv::InstrDependenciesAllowIfConv).</div>
<div><br>
</div>
<div id="appendonsend"></div>
<p id="fb_identificator"></p><p></p><hr style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Diogo Sampaio via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> Friday, September 24, 2021 10:53 AM<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [llvm-dev] If-converter breaking condition data dependency</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">External email: Use caution opening links or attachments<br>
<br>
<br>
Hi,<br>
I'm trying to use if-converter to generate conditional load instructions. However I'm acing a data-dependency issue such as this one:<br>
The original code would output as this:<br>
<br>
        compw.eq $r0 = $r1, $r0    <= condition is stored in r0<br>
        ;;<br>
        cb.even $r0 ? .LBB72_9     <= branch if r0 is even<br>
        ;;<br>
        ld $r0 = 16[$r20]          <= only loads if r0 is odd<br>
        ;;<br>
        ld $r20 = 8[$r0]           <= only loads if r0 is odd<br>
        ;;<br>
.LBB72_9:<br>
<br>
<br>
if-converter would change it to this:<br>
        compw.eq $r0 = $r1, $r0 <= same condition in same register<br>
        ;;<br>
        ld.odd $r0 ? $r0 = 16[$r20] <= ko. The condition is overwritten.<br>
        ;;<br>
        ld.odd $r0 ? $r20 = 8[$r0]  <= ko. Load occurs depending on the new loaded value.<br>
<br>
In none of the TargetInstructionInfo hooks we obtain both the basic block and branch conditions to detect this break of data dependency, although I imagine the if-converter should be the one doing so.<br>
At best, isProfitableToIfCvt should also receive the branch conditions, so it could detect this case.<br>
<br>
Am I missing something?<br>
Did anyone else face such issue?<br>
Btw, we're still using llvm 12.0.1.<br>
<br>
Thanks in advance.<br>
<br>
Diogo Sampaio<br>
Senior Compiler Engineer • Kalray<br>
dsampaio@kalrayinc.com • [ <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kalrayinc.com%2F&amp;data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=H1EyRiaE4sIHi5jGbOBIzPkaBmMQdCu%2B0%2FTU6o1V2eE%3D&amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer">
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kalrayinc.com%2F&amp;data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=H1EyRiaE4sIHi5jGbOBIzPkaBmMQdCu%2B0%2FTU6o1V2eE%3D&amp;reserved=0</a>
 | <a href="https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kalrayinc.com%2F&amp;data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=MvqpedZGdiKhXiQ4aM88wLhJ5Z1GtYMM7eTCx9QIRHQ%3D&amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer">
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kalrayinc.com%2F&amp;data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=MvqpedZGdiKhXiQ4aM88wLhJ5Z1GtYMM7eTCx9QIRHQ%3D&amp;reserved=0</a>
 ]<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
llvm-dev@lists.llvm.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&amp;data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=gkvPjtISQhONUYJMhiXCGhOVQv8diMTLxxL4dlnryVI%3D&amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&amp;data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=gkvPjtISQhONUYJMhiXCGhOVQv8diMTLxxL4dlnryVI%3D&amp;reserved=0</a><br>
</div>
</span></font></div><br></div></div></body></html>