Tuesday, June 28, 2016

std::min/max prevent autovectorization in vs2015

a < b ? a : b;    <-- auto vectorizes
std::min(a,b)   <-- does not

Another bug report for VS: std::min/max break autovectorization

VS's autovectorizer requires massaging to get anything out of it.

Another quirk:  during type conversion, don't skip steps.
For example.

float->i8  //this is skipping the step of converting to i32
float->i32 //An instruction exists for this,

So if you convert float directly to i8, autovectorization fails.
Instead you must convert to i32, and then to i8, now autovectorization succeeds.

No comments:

Post a Comment