February 09, 2002 Re: array bounds checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | First. Not all cpu's have the ability to perform op(add(add(shift))) within a single instruction. Second, the fact that the CPU actually performs a shift rather than a multiply limits all such references to regular power of two byte boundaries. These restrictions are suitable for array references, but they do not lend themselves for pointer references. That is after all the reason pointers exist in C/C++ in addition to arrays. If arrays were sufficient, then pointers need not exist and would not be implemented. Clearly then if you believe that bounded arrays are a language requirement, you must logically conclude that bounded pointers are also a requirement since by including pointers in the first place you have admitted that arrays are not sufficient. Logic is not a pretty wreath of flowers that smell bad. > "Richard Krehbiel" <rich@kastle.com> wrote in message news:a40nur$1r5s$1@digitaldaemon.com... > > "Walter" <walter@digitalmars.com> wrote in message > > > In most cases, the multiply and add are done in hardware in the > addressing > > > mode calculation and do not add any execution time. > > Should I take this to mean that you believe applying the "strength reduction" optimization to array subscripting operations to be > unnecessary? > > I didn't think multiplies and adds were *that* free yet. Walter <walter@digitalmars.com> wrote in message news:a41ime$2pnk$4@digitaldaemon.com... > In my testing, doing such strength reduction for modern processors makes things worse, not better. The DMC optimizer has specific code in it to 'undo' optimizations that would otherwise fit in an addressing mode. |
Copyright © 1999-2021 by the D Language Foundation