Command line options to enable and disable cost model

Is there a way to enable and disable the vectorization cost model (preferably through the command line) for the C compiler? (As of now, the community version is 19.10.)

This is useful since it allows us to evaluate a compiler’s cost model by seeing how often a program executes faster when the cost model is disabled. For this we need to compile the program both with the cost model enabled and disabled.

I found a similar thread here (, but it seems like I need to insert some code to “disable” the cost model. This means I would need two versions of the code, rather than having one version and different compiler options.

Hi amarinph,

No, there isn’t a way to completely disable the loop dependency analysis (which is what I believe you mean by “cost model”). The analysis does two main things: Can vectorization be applied and is it safe to do so.

For the safety aspect, you can use the the pragma’s to assert to the compiler that a particular loop is safe if there’s not enough information for the compiler to derive this itself. You can also use the flag “-Msafeptr” to assert to the compiler that there is no pointer aliasing in the code, which is often the reason why the compiler can’t vectorize loops.

There’s also “-Mvect=partial” which allows for some loops to be partially vectorized even if the whole loop can not.


Thanks Mat.

I’d like to clarify a bit more, although given your explanation on how the compiler works, the answer probably won’t change.

I don’t want to turn off loop dependency analysis. If the loop is not vectorizable, I don’t want to force it.

However, when the loop is vectorizable, the compiler has an option not to vectorize it if its cost model says it’s not profitable to do so. I’d like to be able to turn this off and always vectorize a loop when a loop is vectorizable.

Ah, yes, that’s a different question. Sorry for my misunderstanding.

There’s a few options that you can try.

“-Mvect=short” to enable short vector operations
“-Mvect=nosizelimit” or “-Mvect=sizelimit:” to adjust the maximum size in number of statements to enable vectorization in larger loops.

The “-Mvect” flag controls vectorization so you may also want to look over it’s documentation ( to see if there are other sub-options of interest.


Thanks again, Mat.

At a quick glance, it seems that those options are close to what we are looking for. I’ll ask more questions on this forum if anything else arises.