Recent regression of sqrt optimization when the argument cannot be negative
Open
llvm:instcombine
missed-optimization
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
With LLVM 21, and until a few days ago with trunk, the following code would be optimized to not have a branch to a sqrt library call, as it is impossible for the square of a number to be invalid input for sqrt, therefore having to potentially set errno is not required.
The responsible transformation used to happen in AggressiveInstCombinePass.
See: https://godbolt.org/z/bqWedbKfd
But in the last few days something regressed this and AggressiveInstCombinePass misses this optimization.
Related but distinct issue: #174813
Contributor guide
Assessment
This issue has not been assessed yet.