www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19310] New: VRP for array casts


          Issue ID: 19310
           Summary: VRP for array casts
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: performance
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dfj1esp02 sneakemail.com

long[] f(byte[] a)
    return cast(long[])a[0..a.length/8*8];

Here the compiler can see that the array length is multiple of 8 and simply
divide the length by 8 for the cast.

Oct 18 2018