Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005345OCaml~DO NOT USE (was: OCaml general)public2011-08-20 17:412012-09-25 20:07
Assigned To 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version 
Summary0005345: Optimize bounds checking
DescriptionHere is a sequence of patches to improve the code selection for Ccheckbound. The first patch avoids the separate right shifting for block headers in most cases. The second and third patches further improve the code selection for amd64 and i386. Ccheckbound is now a sequence of cmp,jbe instead of mov,shr,cmp,jbe for the common memory/immediate case.
TagsNo tags attached.
Attached Filespatch file icon 0001-Optimize-Ccheckbound-during-cmmgen.patch [^] (5,912 bytes) 2011-08-20 17:41 [Show Content]
patch file icon 0002-Optimize-common-case-of-Ccheckbound-for-amd64.patch [^] (3,978 bytes) 2011-08-20 17:41 [Show Content]
patch file icon 0003-Also-optimize-common-case-of-Ccheckbound-for-i386.patch [^] (3,579 bytes) 2011-08-20 17:41 [Show Content]

- Relationships
related to 0005360closed For 64-bit targets, array bound checking assembly code could be more compact 

-  Notes
protz (manager)
2011-12-21 15:05


Can you provide benchmarks for real-world situations where this is useful? Also, there's a compile flag that allows one to disable array bounds checking (-unsafe). Can you provide a rationale for optimizing this? I would tend to think that people who want performance disable array bounds checking.


hcarty (reporter)
2011-12-21 15:15

A speed increase with bounds checking enabled would certainly be welcome. I would rather not give up the safety of bounds checking to gain speed when possible.

This assumes that the complexity of the patch is acceptable to the OCaml maintainers and that benchmarks show this patch provides a speed increase.
xleroy (administrator)
2011-12-22 10:44

Applied patch 0001 (the processor-independent part) in SVN trunk, commit 11934.

Even though array indexing with constant indices isn't that common, the patch is short, sweet, clever, and applies to all targets, so, let's go!

I prefer not to add x86-specific operations for this purpose, though. The "op mem, cst" form used to be a win over "mov reg, mem; op reg, cst" for early processors like the Pentium, but I doubt it makes much of a difference with contemporary x86 processors.

- Issue History
Date Modified Username Field Change
2011-08-20 17:41 meurer New Issue
2011-08-20 17:41 meurer File Added: 0001-Optimize-Ccheckbound-during-cmmgen.patch
2011-08-20 17:41 meurer File Added: 0002-Optimize-common-case-of-Ccheckbound-for-amd64.patch
2011-08-20 17:41 meurer File Added: 0003-Also-optimize-common-case-of-Ccheckbound-for-i386.patch
2011-12-21 15:05 protz Note Added: 0006457
2011-12-21 15:15 hcarty Note Added: 0006458
2011-12-22 09:40 protz Relationship added related to 0005360
2011-12-22 10:44 xleroy Note Added: 0006489
2011-12-22 10:44 xleroy Status new => resolved
2011-12-22 10:44 xleroy Resolution open => fixed
2012-09-25 20:07 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker