-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Miscompile with opt -passes="loop-unroll,loop-mssa(licm,indvars)" -unroll-count=4 #91957
Comments
This starts happening with #67736 , commit 2dd5204
|
Without looking into this in detail, it's possible that the way the LICM code modifies instructions in place results incorrect cached SCEV results. |
I added some printouts and see that when IndVarSimplify run rewriteLoopExitValues we do
for Inst being
and then we get the SCEV
which looks wrong. If I split up the pipeline in several opt runs we instead get the SCEV
which looks more reasonable (and then we also get the correct result).
to
so yeah, it should perhaps do something (more) about SCEV. |
After reassociating expressions, LICM is required to invalidate SCEV results, as otherwise it could lead subsequent passes in the pipeline (e.g., IndVars) to miscompile. Fixes: llvm#91957.
@antoniofrighetto : nice that you work on this! But oh it's annoying that I don't get any emails from github about that there was activity here with a linked PR with a fix etc even if I wrote this issue. :( I do get emails when there are comments but not when the issue was assigned or the PR was created. :( |
While reassociating expressions, LICM is required to invalidate SCEV results, as otherwise subsequent passes in the pipeline (e.g., IndVars) may reason on invalid results, thus miscompiling. This is achieved by rewriting the reassociable instruction from scratch. Fixes: llvm#91957.
While reassociating expressions, LICM is required to invalidate SCEV results, as otherwise subsequent passes in the pipeline, that leverage LICM foldings (e.g. IndVars), may reason on invalid expressions; thus miscompiling. This is achieved by rewriting the reassociable instruction from scratch. Fixes: llvm#91957.
@mikaelholmen This is a bit inconvenient indeed, GH doesn’t seem to send notifications wrt that :( Closed this, thanks for reporting! |
Thank you! |
While reassociating expressions, LICM is required to invalidate SCEV results, as otherwise subsequent passes in the pipeline that leverage LICM foldings (e.g. IndVars), may reason on invalid expressions; thus miscompiling. This is achieved by rewriting the reassociable instruction from scratch. Fixes: llvm#91957.
llvm commit: e76b257
Reproduce with:
opt -passes="loop-unroll,loop-mssa(licm,indvars)" -unroll-count=4 bbi-95405.ll -S -o -
The input function returns 32768, but after running the passes as above we get
So now the function returns 8192 instead.
If I extract the IR after loop-unroll or licm and run the rest of the passes instead I get the correct result.
bbi-95405.ll.gz
The text was updated successfully, but these errors were encountered: