-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LoopInterchange][DependenceAnalysis] Miscompilation on loops with anti-dependencies #116144
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 haven't looked into details here, but from your description I suspect that this is probably a duplicate of #54176. This reproducer is smaller and nicer, so thanks for that. I am planning to look at #54176 and this one very soon, so will assign this to myself but let me know if you want to pick this up. |
You may want to check for 'S' scalar dependences in the loop interchange legality.
|
No @mshockwave, the dependence on the inner loop is correctly computed as flow '<'. |
Should have been fixed with #119345. Please reopen if persists. |
Uh oh!
There was an error while loading. Please reload this page.
Consider this simple function:
LoopInterchange currently kicks in on this loop and turns it into:
Which is apparently wrong.
To further illustrate the problem, one can run the function with this
main
function:The
-O0
program (w/ argc = 1) prints out " 13 14 11 8 5" while the incorrectly interchanged program prints " 5 6 7 8 5", hence the miscompile.The culprit of this problem comes from DependenceAnalysis, which provides a direction vector (between
A[i]
&A[i + 1]
) of "[S <]" in this case, but I think it really should yield "[S >]" because we have an anti-dependency here. LoopInterchange should be able to stop doing any optimization when it sees "[S >]" as it violates the legality.CC @sjoerdmeijer @Meinersbur @bmahjour
The text was updated successfully, but these errors were encountered: