[llvm] [BasicAA] Use nuw attribute of GEPs (PR #98608)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 03:51:14 PDT 2024


================
@@ -1239,6 +1240,20 @@ AliasResult BasicAAResult::aliasGEP(
     }
   }
 
+  // If the difference between pointers is Offset +<nuw> Indices then we know
+  // that the addition does not wrap the pointer index type (add nuw) and the
+  // constant Offset is a lower bound on the distance between the pointers. We
+  // can then prove NoAlias via Offset u>= VLeftSize.
+  //    +                +                     +
+  //    | BaseOffset     |   +<nuw> Indices    |
+  //    ---------------->|-------------------->|
+  //    |-->VLeftSize    |                     |-------> VRightSize
----------------
nikic wrote:

```suggestion
  //    |-->V2Size    |                     |-------> V1Size
```
I think? WOuld be good to have the names here line up with the variable names.

https://github.com/llvm/llvm-project/pull/98608


More information about the llvm-commits mailing list