[clang] [llvm] [Analysis] Enhance alignment propagation in computeKnownBits. (PR #166935)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 13 08:35:03 PST 2025


================
@@ -2367,9 +2368,29 @@ void computeKnownBits(const Value *V, const APInt &DemandedElts,
   }
 
   // Aligned pointers have trailing zeros - refine Known.Zero set
+  auto SameFunction = [](auto A, auto B) {
+    return A->getParent()->getParent() == B->getParent()->getParent();
+  };
   if (isa<PointerType>(V->getType())) {
     Align Alignment = V->getPointerAlignment(Q.DL);
     Known.Zero.setLowBits(Log2(Alignment));
+    for (auto *User : V->users()) {
----------------
dtcxzyw wrote:

```suggestion
    if (Q.CxtI) {
    Function *CxtFunc = Q.CxtI->getFunction();
    for (auto *User : V->users()) {
```
When CxtI is unavailable, we don't need to iterate the user list.

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


More information about the llvm-commits mailing list