[llvm] AlignmentFromAssumptions should only track pointer operand users (PR #73370)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 05:43:44 PST 2023


================
@@ -266,22 +262,27 @@ bool AlignmentFromAssumptionsPass::processAssumption(CallInst *ACall,
 
     // Now that we've updated that use of the pointer, look for other uses of
     // the pointer to update.
-    Visited.insert(J);
-    for (User *UJ : J->users()) {
-      Instruction *K = cast<Instruction>(UJ);
-      if (!Visited.count(K))
-        WorkList.push_back(K);
-    }
+    if (auto UJ = dyn_cast<User>(J))
+      for (auto &U : UJ->uses()) {
+        if (U->getType()->isPointerTy()) {
+          if (AA->alias(U, AAPtr)) {
----------------
nikic wrote:

> Could you please explain you opinion? Why using AA "not appropriate"?

It's semantically incorrect. You are interested in following instructions that are based-on the original pointer in a way that SCEV understands. MayAlias results include much more than that, e.g. a `load` result will MayAlias with the load operand if the pointer has escaped, which goes contrary to your original motivation.

> Also, isa does not make any sense at all. See my explanation above. So, given all the above my initial fix looks the easiest one. Nothing except the load really need to be taken into account.

Sorry, which comment does this refer to? Why does the isa check not make sense?

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


More information about the llvm-commits mailing list