-Rpass-missed vs -Rpass-analysis

Hello,

I am currently working on optimization remarks enhancement (e.g. in loop-vectorize pass). There are 3 options to enable such diagnostics: -Rpass, -Rpass-missed and -Rpass-analysis.

From help:

-Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression

-Rpass-missed= Report missed transformations by optimization passes whose name matches the given POSIX regular expression

-Rpass= Report transformations performed by optimization passes whose name matches the given POSIX regular expression

The question is when to generate “missed” remark and when an “analysis” one? In my opinion we should generate “missed” remarks with a short explanation why optimization did not succeed and “analysis” with additional data on optimization process (e.g. “cost of vector instructions here is X, cost of scalar version is Y” and so on).

Also, this is taken from https://reviews.llvm.org/D3683:
-Rpass-missed is used by optimizers to inform the user when they tried
to apply an optimization but couldn’t (or wouldn’t).
-Rpass-analysis is used by optimizers to report analysis results back
to the user (e.g., why the transformation could not be applied).

Now consider loop vectorization pass. We can’t vectorize a loop with a switching statement, so it will be informative to give a message like “loop not vectorized: loop contains switching statement”. But should this message refer to -Rpass-missed or -Rpass-analysis? In current version it goes to “analysis”, and if user is using -Rpass-missed instead it gives only “loop not vectorized”. What’s the point of doing it in that way? “Missed” remark becomes nearly useless for users.

In the end, should we consider replacing -Rpass-missed and -Rpass-analysis (and maybe -Rpass also) with a single option?

BR,

  • Vladimir Miloserdov

Not sure it’s useful to emit the cost of each individual instruction (any remark which includes LLVM IR instructions is going to be very difficult to understand for anyone who isn’t a compiler developer), but the intuition is correct, I think. That sounds like a bug. -Eli

Hi,

Hello,

I am currently working on optimization remarks enhancement (e.g. in loop-vectorize pass). There are 3 options to enable such diagnostics: -Rpass, -Rpass-missed and -Rpass-analysis.

From help:
-Rpass-analysis=<value> Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
-Rpass-missed=<value> Report missed transformations by optimization passes whose name matches the given POSIX regular expression
-Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression

The question is when to generate “missed” remark and when an “analysis” one? In my opinion we should generate “missed” remarks with a short explanation why optimization did not succeed and “analysis” with additional data on optimization process (e.g. “cost of vector instructions here is X, cost of scalar version is Y” and so on).

Also, this is taken from https://reviews.llvm.org/D3683:
-Rpass-missed is used by optimizers to inform the user when they tried
to apply an optimization but couldn't (or wouldn't).
-Rpass-analysis is used by optimizers to report analysis results back
to the user (e.g., why the transformation could not be applied).

Now consider loop vectorization pass. We can’t vectorize a loop with a switching statement, so it will be informative to give a message like “loop not vectorized: loop contains switching statement”. But should this message refer to -Rpass-missed or -Rpass-analysis? In current version it goes to “analysis”, and if user is using -Rpass-missed instead it gives only “loop not vectorized”. What’s the point of doing it in that way? “Missed” remark becomes nearly useless for users.

Yes, this was a mistake when remarks were implemented in the loop vectorizer and then it got carried over to other passes as well. For example, a fix to remedy the situation in the Inliner: https://reviews.llvm.org/rL293492.

It would be great to improve LV to only use analysis for things where we don’t know the outcome of the optimization yet but the intermediate analysis results would be interesting/actionable to the user. We also use analysis for neutral things like reporting the size of the generated function, size of the stack frame, etc.

In the end, should we consider replacing -Rpass-missed and -Rpass-analysis (and maybe -Rpass also) with a single option?

I think that there are valid use cases for asking for remarks for performed and missed optimization separately. For example, in order to better understand the generated assembly you only want -Rpass. On the other hand there is a new workflow to generate all remarks in external optimization record files with -fsave-optimization-record. (This can then be visualized with tools/opt-viewer/opt-viewer.py.)

Adam