[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
================
@@ -1843,6 +1858,11 @@ bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,
void BasicAAResult::subtractDecomposedGEPs(DecomposedGEP &DestGEP,
const DecomposedGEP &SrcGEP,
const AAQueryInfo &AAQI) {
+ // Drop nuw flag from GEP if subtraction of constant offsets overflows in an
+ // unsigned sense.
+ if (DestGEP.Offset.ult(SrcGEP.Offset))
+ DestGEP.NWFlags = DestGEP.NWFlags->withoutNoUnsignedWrap();
----------------
nikic wrote:
(Another reason to drop the std::optional: It's not really clear that this code here can't access nullopt).
https://github.com/llvm/llvm-project/pull/98608
More information about the llvm-commits
mailing list