[llvm] [Attributor] Propagate alignment through ptrmask (PR #150158)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Oct 10 18:42:36 PDT 2025
    
    
  
================
@@ -5187,6 +5187,59 @@ struct AADereferenceableCallSiteReturned final
 // ------------------------ Align Argument Attribute ------------------------
 
 namespace {
+
+Align getKnownAlignForIntrinsic(Attributor &A, AAAlign &QueryingAA,
+                                const IntrinsicInst &II) {
+  switch (II.getIntrinsicID()) {
+  case Intrinsic::ptrmask: {
+    const auto *ConstVals = A.getAAFor<AAPotentialConstantValues>(
+        QueryingAA, IRPosition::value(*(II.getOperand(1))), DepClassTy::NONE);
+    const auto *AlignAA = A.getAAFor<AAAlign>(QueryingAA, IRPosition::value(II),
----------------
Shoreshen wrote:
Hi @shiltian , assume we have `%p = llvm.ptrmask(%x, %mask)` and we are initializing `AAAlign` for `%x`.
When coming to the call of `getKnownAlignForUse` it need to return an known alignment right after the function end. In order to do that, we need to compare the known alignment for `%x` and the value of `%mask`.
Setting the `TrackUse` to `true` will only take effect after returning of `getKnownAlignForUse`
https://github.com/llvm/llvm-project/pull/150158
    
    
More information about the llvm-commits
mailing list