[llvm] [SeparateConstOffsetFromGEP] Preserve inbounds flag based on ValueTracking and NUW (PR #130617)
Fabian Ritter via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 10 05:55:40 PDT 2025
================
@@ -811,6 +780,30 @@ Value *ConstantOffsetExtractor::removeConstOffset(unsigned ChainIndex) {
return NewBO;
}
+/// A helper function to check if reassociating through an entry in the user
+/// chain would invalidate the GEP's nuw flag.
+static bool allowsPreservingNUW(User *U) {
+ assert(isa<BinaryOperator>(U) || isa<CastInst>(U) || isa<ConstantInt>(U));
----------------
ritter-x2a wrote:
> A ConstantInt can't be a user.
This statement sounds reasonable, but the inheritance diagram disagrees: https://llvm.org/doxygen/classllvm_1_1ConstantInt.html
The assertion does fail if the last disjunct is removed.
Anyway, I'll look into turning it into a conservative return instead.
https://github.com/llvm/llvm-project/pull/130617
More information about the llvm-commits
mailing list