I have seen the "__assume()" statement used in Intel examples, such as "__assume(n1%16==0)" used in the recommendations in the article at https://software.intel.com/en-us/articles/data-alignment-to-assist-vectorization
I have not been able to find any discussion of this function in the compiler documentation. I can find a description of "__assume_aligned()", but not for "__assume()". This may be because the search function for the compiler documentation ignores leading punctuation. So searching for "assume_aligned" returns useful results, while searching for "__assume" returns any page that contains the word "assume" -- 71 matches in the Intel version 16 compiler docs. The web-browser-based documentation portal is too slow to look through that many results one at a time, so if anyone knows if there is documentation for this statement, I would appreciate a pointer!
This is a Microsoft invention (although we support it on Linux too):
See documentation at:
The Microsoft web page just says that the argument to the __assume() statement can be "any statement that is assumed to evaluate to true". The only example provided -- "__assume(0)" means that the compiler can assume that this code will never be reached.
The Intel web page gives only one example -- "__assume (n1%16==0)", and uses it as a way to provide information about the alignment of array references with constant offsets.
I guess I was hoping for some documentation of what types of statements the compiler might be likely to take advantage of. Since there does not appear to be any such documentation, I will __assume() that this is not a feature of the compiler that is likely to be useful....