Re:Own Constant Folder in C/C++
by GrantMoyer on Saturday June 22, 2024 @09:32AM
(#40759024)
I wouldn't call this a performance bug in clang. It's an optimization working as intended.
[ Parent
| on HN ]
I would challenge you to find a processor on which the rsqrt plus two newton-raphson iterations is not slower than plain sqrt. (We don't know what mtune the author used)
Re:Own Constant Folder in C/C++
by GrantMoyer on Saturday June 22, 2024 @12:04PM
(#40760007)
According to Intel, any processor before Skylake (section 15.12 from [1]).
[1]: https://cdrdv2.intel.com/v1/dl/getContent/814198?fileName=24...
The author probably didn't use any mtune setting, which is likely the problem. If you look at older cores on Agner's instruction tables, SQRT has been getting steadily faster over time. This implementation is slightly faster on old Intel machines, for example.