[PATCH] D25464: [NFC] Loop Versioning for LICM code clean up

Evgeny Astigeevich via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 02:34:23 PDT 2016


eastig added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopVersioningLICM.cpp:305
-    DEBUG(dbgs() << "    Alias tracker type safety failed!\n");
-    return false;
   }
----------------
ashutosh.nema wrote:
> eastig wrote:
> > sbaranga wrote:
> > > eastig wrote:
> > > > It's strange checking. It was questioned in https://reviews.llvm.org/D9151. An answer was: 
> > > > 
> > > > > Actually this is a pre-condition in LICM’s “promoteLoopAccessesToScalars” where it expects all pointers in alias should have same type.
> > > > > To confirm same behaviour we added this check.
> > > > 
> > > > Yes, type checking is needed for AliasSet when all pointers must alias. This is done by LICM. In case of AliasSet whose pointers may alias we can have aliased pointers of different types, e.g. char * and char ** which might be aliased and they have different types.
> > > I agree, this does look strange (and it might not be a NFC), I think either Ashutosh or Adam should comment on this.
> > I'll revert for this review.
> Type check is required for LICM, it expects pointers in the alias set should have the same type.
Yes, it is required but LICM does it for alias sets with must-alias pointers. Here an alias set with may-alias pointers is checked. The goal of the LoopVersioningLICM pass is to create a version of a loop where all alias sets with may-alias pointers are converted either into sets with must-alias pointers or single-element sets. The checking is similar to what LICM does but it has different meaning. It restricts may-alias pointers used in a loop to have the same type. It excludes a case when 'char *' pointer can be aliased with everything. For example the following loop is not versioned because of this checking:
```
void f(int *a, int *b, char *c, int n) {
  for (int i = 0; i < n; ++i) {
    a[i] = b[i] + *c;
    *c = (char)a[i];
  }
}
```
In this case an alias set consists of 'a', 'b' and 'c'. We can calculate bounds of all pointers used in the loop. So we can create RT checks and move memory accesses to 'c' out of the loop.



https://reviews.llvm.org/D25464





More information about the llvm-commits mailing list