|
|
|
|
|
by zasdffaa
1388 days ago
|
|
An aside. > It will literally turn a "sum of i from 0 to N" into "n(n+1)/2", among others[1] Yeah, seen that on a godbolt youtube vid. Question is, should it do this? Or should it force you to use a library, by reporting what you're trying to do and telling you there's an easier way ( "sum of 1 to n is <formula>, instead of a loop use library function 'sum1toN()" ) I think getting too clever risks hurting the user by not letting them know there's a better way. [1] actually it seems to do a slightly different version of this to prevent risk of overflow, but same result. |
|
Generally I think some of LLVM's optimizations are trying too hard for the amount of complexity and compilation overhead they create. All that complexity comes at the risk of bugs. With optimizations around UB, it becomes downright mind-boggling what could go wrong. But I'm not an LLVM maintainer so what the heck do I know.