logoalt Hacker News

woadwarrior01yesterday at 5:50 PM1 replyview on HN

The common subexpression elimination (CSE) pass in compilers takes care of that.


Replies

cmovqyesterday at 6:04 PM

Compilers cannot do this optimization for floating point [1] unless you're compiling with -ffast-math. In general, don't rely on compilers to optimize floating point sub-expressions.

[1]: https://godbolt.org/z/8bEjE9Wxx

show 1 reply