Make Value::isDereferenceablePointer handle offsets to pointer types with dereference...
authorHal Finkel <hfinkel@anl.gov>
Sat, 19 Jul 2014 03:25:16 +0000 (03:25 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sat, 19 Jul 2014 03:25:16 +0000 (03:25 +0000)
commit9e440c08a961eea1bc4c2a3faa5d6ce87b3c4554
tree23bce32e6906e374295fe60aa305a4fe097f06dc
parent16e394a36ce184e0312dd9ecebaee3bf36b2cacd
Make Value::isDereferenceablePointer handle offsets to pointer types with dereferenceable attributes

When we have a parameter (or call site return) with a dereferenceable
attribute, it can specify the size of an array pointed to by that parameter. If
we have a value for which we can accumulate a constant offset to such a
parameter, then we can use that offset in a direct comparison with the size
specified by the dereferenceable attribute.

This enables us to handle cases like this:

  int foo(int a[static 3]) {
    return a[2]; /* this is always dereferenceable */
  }

llvm-svn: 213447
llvm/lib/IR/Value.cpp
llvm/test/Transforms/LICM/hoist-deref-load.ll