Replace math::LogOp with an approximations from the the Julien Pommier's SSE math library
|1,000 ms||x64 windows > MLIR.Examples/Toy/Ch6::jit.toy|
Script: -- : 'RUN: at line 1'; toyc-ch6 -emit=jit C:\ws\w16c2-1\llvm-project\premerge-checks\mlir\test\Examples\Toy\Ch6\jit.toy
|910 ms||x64 windows > MLIR.Examples/Toy/Ch7::jit.toy|
Script: -- : 'RUN: at line 1'; toyc-ch7 -emit=jit C:\ws\w16c2-1\llvm-project\premerge-checks\mlir\test\Examples\Toy\Ch7\jit.toy
LGTM, The log-approximation looks very similar to another implementation I am familiar with (https://github.com/halide/Halide/blob/master/src/IROperator.cpp#L1147)
Some (approximation precision - performance) trade off can be revisited later IMO.
The shift adds more operations and still uses same 8-order polynomial as https://github.com/boulos/syrah/blob/master/src/include/syrah/FixedVectorMath.h#L460, I wonder does it add more precision? if yes Can we reach same precision as syrah's implementation with lower polynomial order ?
abs isn't needed here if we are using a strictly positive frexp which is useful in the log(x), x > 0 we have below. This requires using a different cstInvMantMask see (https://github.com/boulos/syrah/blob/master/src/include/syrah/FixedVectorMath.h#L426)
Added a flag to disable abs, it saved ~5% of cpu time in benchmarks. Re mask: didn't quite get it, I think it is irrelevant, and 0x807FFFF is exactly the inverse of 0x7f800000.
Added a note to explore this option in the followup PRs.
Oh, yes, it looks like it's only for release build. Not sure about the guidelines for this case. We couldn't use #ifndef NDEBUG since asserts can also be enabled in release build. Could we introduce some dummy casting for them as we do for other variables that are only used inside asserts (https://llvm.org/docs/CodingStandards.html#id44)?