<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
>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><span>might check SSAIfConv::canPredicateInstrs (and its helper SSAIfConv::InstrDependenciesAllowIfConv).</span></div>
<div><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" 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">
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">
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">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>
</body>
</html>