[llvm] [Attributor] Propagate alignment through ptrmask (PR #150158)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 27 20:57:16 PDT 2025


================
@@ -5203,6 +5203,32 @@ static unsigned getKnownAlignForUse(Attributor &A, AAAlign &QueryingAA,
       TrackUse = true;
     return 0;
   }
+  if (auto *II = dyn_cast<IntrinsicInst>(I)) {
+    if (II->getIntrinsicID() == Intrinsic::ptrmask) {
+      auto *ConstVals = A.getAAFor<AAPotentialConstantValues>(
+          QueryingAA, IRPosition::value(*(II->getOperand(1))),
+          DepClassTy::NONE);
+      const AAAlign *AlignAA = A.getAAFor<AAAlign>(
+          QueryingAA, IRPosition::value(*(II)), DepClassTy::NONE);
+      if (ConstVals && ConstVals->isValidState()) {
+        if (ConstVals->isAtFixpoint()) {
+          uint64_t TrailingZeros = 64;
+          for (const auto &It : ConstVals->getAssumedSet())
+            if (It.countTrailingZeros() < TrailingZeros)
+              TrailingZeros = It.countTrailingZeros();
+          if (TrailingZeros < 64) {
----------------
arsenm wrote:

There's no reason to have a limit of 64 or hardcode it, just directly use the size from the pointer 

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


More information about the llvm-commits mailing list