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
The snipped on the left works well; the abstracted function compiles down to the same code as the goal function. The snipped on the right has the Vec usage replaced by an array. The assembler for the abstracted function is now more complicated than goal function.
Note that if one removes the Enum::Single variant, it does work.
I attempted to make the above example minimal. A more elaborate example is here.
The assembly doesn't really seem much worse. No extra loops, jumps or function calls. No memory accesses at all, it's all in registers. The code also seems pretty artificial, why have an empty variant that wraps an iter::Empty if that variant could just return None directly.
Imo a better example that demonstrates significant performance issues is needed.
I found a situation where creation, conversion into an iterator and consuming the iterator gets optimized for a
Vec
, but not for an array.Compiler explorer
The snipped on the left works well; the
abstracted
function compiles down to the same code as thegoal
function. The snipped on the right has theVec
usage replaced by an array. The assembler for theabstracted
function is now more complicated thangoal
function.Note that if one removes the
Enum::Single
variant, it does work.I attempted to make the above example minimal. A more elaborate example is here.
Should this be mentioned in #84513?
The text was updated successfully, but these errors were encountered: