You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiler creates branches with allocs that can never be hit, or it may create superfluous allocs that are never really used, the JIT will not be able to figure that out though.
let inlinemapOption mapper option =match option with| Some x -> Some(mapper x)| None -> None
letalmostErasedOption()=lety()=3match Some(y())|> mapOption (fun x -> x +2)with| Some x ->5| None ->4letunnecessaryOption()=lety()=3match Some(y())|> mapOption (fun x -> x +2)with| Some x -> x
| None ->4
The compiler is doing a pretty good job at constant folding but it really falls short by such a tiny margin to remove all the useless code.
These examples are contrived but in real cases cause inline code to not have the desired performance increase. Forcing people to write unidiomatic nullable reference returns or tricks with byref out vars.
ValueOption is worse at inlining, especially without #8970
https://sharplab.io/#v2:DYLgZgzgPsCmAuACAlgO2G2iC2BDADgPL7zID2qOB+sATomSeZQLyICwAUIj1fAMYALBkwqIA7snjCuvRFEQA1XMACusAMplsWAB6IAtAD4lK9Vp0AKPPhr1dASlm8FytbAByFLMdPuvqLBcXHBIKthkEPAAorS4ELAAJsSkFJYOiCzOPKGIAJ6I6ZmIAMzZHNy8eALCbubasJZ56RlQJjYpzIVgqpT6vvoA1IgATBmS0hVyrmaaDYj9JgCs5TP+3oYmACzlIQiIvYH8sBAQuLR5nWkZWZU5+wVFbGV3U1W4NX71Vs0Ore0EK6USw9PqbBaIYZjCRSGSvNbfPTg3SrL6eDa+LZAA
The text was updated successfully, but these errors were encountered:
I'll relabel this to feature improvement as there's specific thing that says we'll definitely remove all such bindings, especially when optimizations interact.
Compiler creates branches with allocs that can never be hit, or it may create superfluous allocs that are never really used, the JIT will not be able to figure that out though.
https://sharplab.io/#v2:DYLgZgzgPsCmAuACAlgO2G2iC2BDADgPL7zID2qOB+sATomSeZQLyICwAUIj1fAMYALBkwqIA7snjCuvRFEQBlMtiwAPRAFoAfEpWwAFHnw16agJSzeCgHIUsOxHdSwuXOElzBsZCPACitLgQsAAmxKQUBuaILFY8HogAnojRsYgAzPEc3Lx4AsLKqgZJ0TFQusYRzKlgAK6UGo4aANSIAEwxktI5cgpF6lq6AKzZtvZDiAAs2e4IiA0u/LAQELi0SdVRMXG5CfMpaWxZe715uAV6xaXm5ZUEW5QG9Y2TrR1dUjKn/fqITbo1GMnBNHFMgA=
Decompiled:
The compiler is doing a pretty good job at constant folding but it really falls short by such a tiny margin to remove all the useless code.
These examples are contrived but in real cases cause inline code to not have the desired performance increase. Forcing people to write unidiomatic nullable reference returns or tricks with byref out vars.
Related:
athas/raytracers#29
dotnet/coreclr#21950 (comment)
#8953
ValueOption is worse at inlining, especially without #8970
https://sharplab.io/#v2:DYLgZgzgPsCmAuACAlgO2G2iC2BDADgPL7zID2qOB+sATomSeZQLyICwAUIj1fAMYALBkwqIA7snjCuvRFEQA1XMACusAMplsWAB6IAtAD4lK9Vp0AKPPhr1dASlm8FytbAByFLMdPuvqLBcXHBIKthkEPAAorS4ELAAJsSkFJYOiCzOPKGIAJ6I6ZmIAMzZHNy8eALCbubasJZ56RlQJjYpzIVgqpT6vvoA1IgATBmS0hVyrmaaDYj9JgCs5TP+3oYmACzlIQiIvYH8sBAQuLR5nWkZWZU5+wVFbGV3U1W4NX71Vs0Ore0EK6USw9PqbBaIYZjCRSGSvNbfPTg3SrL6eDa+LZAAThe text was updated successfully, but these errors were encountered: