Nicolas Geoffray wrote:> Hi Andrew, > > Andrew Haley wrote: >> Also, if you can make the capability generic enough to use in Shark >> (more at http://gbenson.net/) that would be very useful.>> Agree. > >> The key, I suspect, is to allow the Java front end mark an array.length >> field in such a way that LLVM knows that field doesn't alias anything else >> and is constant, so it can be hoisted out of loops. > > For that matter, VMKit already has this optimization. Instead of > emitting an LLVM load of the size field, VMKit emits a GetArrayLength > call, flagged readnone. The GVN pass will merge all GetArrayLength of a > same array and the LICM pass will hoist the call. Once theses passes are > complete, VMKit lowers the call to > the actual load.Right, so that part should be trivial. So, does the array bounds check elimination already work? If it does, that will considerably reduce the work that Andre needs to do. To say the least... Andrew.
Andrew Haley wrote:> > Right, so that part should be trivial. So, does the array bounds check > elimination already work? If it does, that will considerably reduce > the work that Andre needs to do. To say the least... > >Trivial bounds check elimination already work, such as tab[2] = 1; tab[1] = 2 (the second affectation won't have a bounds checks). Although I don't know the details, I believe Andre also targets less trivial eliminations. Nicolas> Andrew. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Nicolas Geoffray wrote:> Andrew Haley wrote: >> Right, so that part should be trivial. So, does the array bounds check >> elimination already work? If it does, that will considerably reduce >> the work that Andre needs to do. To say the least... >> >> > > Trivial bounds check elimination already work, such as tab[2] = 1; > tab[1] = 2 (the second affectation won't have a bounds checks). Although > I don't know the details, I believe Andre also targets less trivial > eliminations.I should have asked a better question. By "does it work" I meant something like for (int i = 0; i < a.length; i++) System.out.println(a[i]); in which the autogenerated check should trivially be removed, but only if LLVM knows that a.length is invariant. Andrew.