← Back to context

Comment by fngjdflmdflg

1 year ago

I read somewhere that since floating point addition is not associative the compiler will not autovectorize because the order might change.

It’s somewhat more complicated than that (& presumed your hot path is floating point instead of integral), but that can be a consideration.

  • What are the other considerations? (assuming we are dealing with FP)

    • Disclaimer: not an expert here so could be very very wrong. This is just my understanding so happy to be corrected.

      Another would be that something like fused multiple add would have different (higher if I recall correctly) precision which violates IEE754 and thus vectorization since default options are standard compliant.

      Another is that some math intrinsics are documented to populate errno which would prevent using autovec in paths that have an intrinsic.

      There may be other nuances depending on float vs double.

      Basically most of the things that make up ffast-math i believe would prevent autovectorization.

      1 reply →