[llvm] [Attributor] Propagate alignment through ptrmask (PR #150158)
Krzysztof Drewniak via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 3 11:52:34 PST 2025
================
@@ -5200,6 +5201,28 @@ static unsigned getKnownAlignForUse(Attributor &A, AAAlign &QueryingAA,
TrackUse = true;
return 0;
}
+ if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::ptrmask: {
+ // Is it appropriate to pull attribute in initialization?
+ 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(),
+ Value::MaxAlignmentExponent);
+ Align ConstAlign(UINT64_C(1) << ShiftValue);
+ if (ConstAlign >= AlignAA->getKnownAlign())
----------------
krzysz00 wrote:
I might just not be understanding the attributor very well, but it seems weird that we're setting align 1 here. I assume it's because there's some handling later that fixes this case?
I can tell from the tests that all this code is doing what I'd intuitively expect, so I'll just let myself be confused.
https://github.com/llvm/llvm-project/pull/150158
More information about the llvm-commits
mailing list