Ticket #5924 (new bug)

Opened 16 months ago

Last modified 9 months ago

Bad Cmm generated for updating one element in Array#

Reported by: tibbe Owned by:
Priority: normal Milestone: 7.6.2
Component: Compiler Version: 7.4.1
Keywords: Cc: johan.tibell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by tibbe) (diff)

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.

Attachments

Update.hs Download (1.5 KB) - added by tibbe 16 months ago.
Insert.hcr Download (21.9 KB) - added by tibbe 16 months ago.
Update.cmm Download (7.9 KB) - added by tibbe 16 months ago.

Change History

Changed 16 months ago by tibbe

Changed 16 months ago by tibbe

Changed 16 months ago by tibbe

Changed 16 months ago by tibbe

  • cc johan.tibell@… added

To follow my annotations, start at Update.test_info in Update.cmm.

Changed 16 months ago by tibbe

  • description modified (diff)
  • summary changed from Back Cmm generated for updating one element in Array# to Bad Cmm generated for updating one element in Array#

Changed 15 months ago by simonmar

  • difficulty set to Unknown
  • milestone set to 7.6.1

I think the memset can be omitted; we don't care about the card table when the array is in the young generation. The assignments you've marked as XXX will probably be removed by the coalescing optimisation in the register allocator - you might want to check the assembly.

Changed 9 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.