Bad Cmm generated for updating one element in Array#
I've attached a small standalone program that implements the following function:
-- | /O(n)/ Update the element at the given position in this array.
update16 :: Array e -> Int -> e -> Array e
which update one element (by copying the whole array) of an array of size 16. The attachment includes the optimized Cmm for a call to this function, together with a bunch of comments (inline with the Cmm) by me, pointing out inefficiencies in the generated Cmm.
My overall goal is to make this particular function fast. This might involve fixes to the code generator and/or adding primitives whether that makes sense. In any case this code might be a good source of ideas for improvements to the code generator.
To follow my annotations, start at Update.test_info
in Update.cmm
.