[llvm] [LAA] Add initial support for non-power-of-2 store-load forwarding distance (PR #137873)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 03:43:28 PDT 2025
================
@@ -1731,24 +1732,61 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(uint64_t Distance,
break;
}
}
+ // RISCV VLA supports non-power-2 vector factor. So, we iterate in a
+ // backward order to find largest VF, which allows aligned stores-loads or
+ // the number of iterations between conflicting memory addresses is not less
+ // than 8 (NumItersForStoreLoadThroughMemory).
+ if (AllowNonPow2Deps) {
+ MaxVFWithoutSLForwardIssuesNonPowerOf2 =
+ std::min(8 * VectorizerParams::MaxVectorWidth / TypeByteSize,
+ MaxNonPowerOf2StoreLoadForwardSafeDistanceInBits);
+
+ for (uint64_t VF = MaxVFWithoutSLForwardIssuesNonPowerOf2;
----------------
fhahn wrote:
> Suggestions? Any preferences here?
Thanks for the extra info. I think it would be helpful to update the comment to. include a generalized variant of the extra info you shared regarding what VFs can be picked (highlighted below)
> Not necessary. We can use any whole divider of the MaxVFWithoutSLForwardIssuesNonPowerOf2. Say, if MaxVFWithoutSLForwardIssuesNonPowerOf2 is 9, then we can use 3 and 9. If it is 6, we can use 2, 3, 6. All these are safe.
I guess most RISCV HW with EVL support will support store-load forwarding with non-power-of-2 distances?
https://github.com/llvm/llvm-project/pull/137873
More information about the llvm-commits
mailing list