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

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 01:48:18 PDT 2024


================
@@ -552,17 +552,17 @@ struct BasicAAResult::DecomposedGEP {
   APInt Offset;
   // Scaled variable (non-constant) indices.
   SmallVector<VariableGEPIndex, 4> VarIndices;
-  // Are all operations inbounds GEPs or non-indexing operations?
+  // Nowrap flags common to all GEP operations involved in expression.
   // (std::nullopt iff expression doesn't involve any geps)
-  std::optional<bool> InBounds;
+  std::optional<GEPNoWrapFlags> NWFlags;
----------------
hazzlim wrote:

Good point - I've made this initialize with `GEPNoWrapFlags::none()`, with some logic in `DecomposeGEPExpression` so that we initialize on the first GEP we encounter - as this seemed to make sense to avoid ever having DecompGEP2 retain `GEPNoWrapFlags::all()` in the case where the decomposition of `V2` does not encounter any GEPs. 

This doesn't seem to be an issue at present, but seems cleaner to make sure the flags are always correct in this way? 

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


More information about the llvm-commits mailing list