Array optimizations
Very frequently I use array operations such as:
-
maxval(abs(a-b))for finding maximum error betweenaandb. -
sqrt(dot_product(array,array))or evensqrt(sum(x**2))to compute a norm. There is now anorm2intrinsic for this.
I think the compiler optimizer should be able to recognize such common expressions and generate optimal code for those.
Implementation: this could be an ASR pass that recognized such expressions and replaces them with internal functions. Alternatively, once we have some general framework for simplifying such array operations (perhaps using Mathematics of Arrays), it could handle such a case.