[llvm] [Attributor] Propagate alignment through ptrmask (PR #150158)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 10 00:00:27 PDT 2025
================
@@ -5187,6 +5187,58 @@ 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),
+ DepClassTy::NONE);
+ if (ConstVals && ConstVals->isValidState() && ConstVals->isAtFixpoint()) {
+ unsigned ShiftValue =
+ std::min(ConstVals->getAssumedMinTrailingZeros(), (unsigned)63);
+ Align ConstAlign(UINT64_C(1) << ShiftValue);
+ if (ConstAlign >= AlignAA->getKnownAlign())
+ return Align(1);
----------------
arsenm wrote:
> So %p = llvm.ptrmask(%x, %mask) does not provide any information for required alignment for %x, and returning the minimum requirement.
This is the wrong way to view it. You should be trying to interpret the known range based on the known alignment and known possible values. It doesn't matter if it happens there's no refinement, you should be reporting the maximum assumable value
https://github.com/llvm/llvm-project/pull/150158
More information about the llvm-commits
mailing list