[llvm-dev] If-converter breaking condition data dependency
Diogo Sampaio via llvm-dev
llvm-dev at lists.llvm.org
Mon Sep 27 02:27:58 PDT 2021
Hi Jason,
I'm using the "late" IfConverter.
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).
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.
Many thanks for the pointer.
Diogo Sampaio
Senior Compiler Engineer • Kalray
Phone:
dsampaio at kalrayinc.com • [ https://www.kalrayinc.com/ | www.kalrayinc.com ]
[ https://www.kalrayinc.com/ | ]
Intelligent Data Processing
>From Cloud to Edge
Please consider the environment before printing this e-mail.
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.
From: "Jason Eckhardt" <jeckhardt at nvidia.com>
To: "llvm-dev" <llvm-dev at lists.llvm.org>, "Diogo Sampaio" <dsampaio at kalray.eu>
Sent: Friday, September 24, 2021 9:40:51 PM
Subject: Re: If-converter breaking condition data dependency
>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.
>
>At best, isProfitableToIfCvt should also receive the branch conditions, so it
>could detect this case.
Which if-converter pass are you using? There is the "late" IfConverter pass and
the "early" EarlyIfPredicator pass. In either case, the legality checks are not
performed by isProfitableToIfCvt.
Off the top of my head, I'd guess that if you are using the IfConverter, you
might double-check your implementation of TII::ClobbersPredicate or trace
through its callers on your example. If you are using EarlyIfPredicator, you
might check SSAIfConv::canPredicateInstrs (and its helper SSAIfConv::InstrDependenciesAllowIfConv).
To declare a filtering error, please use the following [ https://www.security-mail.net/reporter.php?mid=fa85.614e29c5.eae3b.0&r=dsampaio%40kalray.eu&s=jeckhardt%40nvidia.com&o=Re%3A+If-converter+breaking+condition+data+dependency&verdict=C&c=27a962f615fcd8698d819d42f4c9c9904f7f90d1 | link ]
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Diogo Sampaio via llvm-dev <llvm-dev at lists.llvm.org>
Sent: Friday, September 24, 2021 10:53 AM
To: llvm-dev <llvm-dev at lists.llvm.org>
Subject: [llvm-dev] If-converter breaking condition data dependency
External email: Use caution opening links or attachments
Hi,
I'm trying to use if-converter to generate conditional load instructions. However I'm acing a data-dependency issue such as this one:
The original code would output as this:
compw.eq $r0 = $r1, $r0 <= condition is stored in r0
;;
cb.even $r0 ? .LBB72_9 <= branch if r0 is even
;;
ld $r0 = 16[$r20] <= only loads if r0 is odd
;;
ld $r20 = 8[$r0] <= only loads if r0 is odd
;;
.LBB72_9:
if-converter would change it to this:
compw.eq $r0 = $r1, $r0 <= same condition in same register
;;
ld.odd $r0 ? $r0 = 16[$r20] <= ko. The condition is overwritten.
;;
ld.odd $r0 ? $r20 = 8[$r0] <= ko. Load occurs depending on the new loaded value.
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.
At best, isProfitableToIfCvt should also receive the branch conditions, so it could detect this case.
Am I missing something?
Did anyone else face such issue?
Btw, we're still using llvm 12.0.1.
Thanks in advance.
Diogo Sampaio
Senior Compiler Engineer • Kalray
dsampaio at kalrayinc.com • [ [ https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kalrayinc.com%2F&data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=H1EyRiaE4sIHi5jGbOBIzPkaBmMQdCu%2B0%2FTU6o1V2eE%3D&reserved=0 |
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kalrayinc.com%2F&data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=H1EyRiaE4sIHi5jGbOBIzPkaBmMQdCu%2B0%2FTU6o1V2eE%3D&reserved=0 ] | [ https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kalrayinc.com%2F&data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=MvqpedZGdiKhXiQ4aM88wLhJ5Z1GtYMM7eTCx9QIRHQ%3D&reserved=0 |
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kalrayinc.com%2F&data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=MvqpedZGdiKhXiQ4aM88wLhJ5Z1GtYMM7eTCx9QIRHQ%3D&reserved=0 ] ]
_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org
[ https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=gkvPjtISQhONUYJMhiXCGhOVQv8diMTLxxL4dlnryVI%3D&reserved=0 | https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=04%7C01%7Cjeckhardt%40nvidia.com%7C4d6e38fe8f8c4bb36fd308d97f7381f1%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637680957074749887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=gkvPjtISQhONUYJMhiXCGhOVQv8diMTLxxL4dlnryVI%3D&reserved=0 ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210927/4ce31051/attachment.html>
More information about the llvm-dev
mailing list