-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LoopInterchange] Interchange potentially breaks the program correctness #123920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think there are at least three ways to solve this issue.
|
Hi @kasuga-fj , thanks for the report and letting us know. I can look at this / pick this up on Monday. But please go ahead of course if you want to continue looking at this. |
Hi @sjoerdmeijer, thanks for the confirmation. I'll wait for you because I'd like to know your opinion. |
I did a quick check in llvm-test-suite and found only six loops that have |
Sounds like a good approach to me for now: let's make interchange correct first. |
LoopInterchange have converted `DVEntry::LE` and `DVEntry::GE` in direction vectors to '<' and '>' respectively. This handling is incorrect because the information about the '=' it lost. This leads to miscompilation in some cases. To resolve this issue, convert them to '*' instead. Resolve llvm#123920
In the following program, LoopInterchange incorrectly interchanges the innermost two loops.
See also: https://godbolt.org/z/rfev9drn7
Note that the current LoopInterchange interchanges these loops twice, therefore the order returns to the original one. So this case works fine.
The problem here is that the LoopInterchange regards
Dependence::DVEntry::LE
as '<'. As a result, the direction vector becomes[< < >]
. Swapping the innermost loops changes this to[< > <]
, which passes the legality check. In fact, we must also consider the direction vector such as[= < >]
.The text was updated successfully, but these errors were encountered: