[llvm] [NVPTX] Constant fold blockDim when reqntid is specified (PR #191575)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 20:11:48 PDT 2026
================
@@ -90,23 +100,44 @@ static bool runNVVMIntrRange(Function &F) {
std::min(0xffffu, FunctionClusterRank),
std::min(0xffffu, FunctionClusterRank)};
- const auto ProccessIntrinsic = [&](IntrinsicInst *II) -> bool {
+ // When reqntid is specified, ntid (blockDim) values are exact compile-time
+ // constants. Get per-dimension values for constant folding.
+ const Vector3 ReqBlockDim =
+ !ReqNTID.empty()
+ ? Vector3{ReqNTID[0], ReqNTID.size() > 1 ? ReqNTID[1] : 1,
+ ReqNTID.size() > 2 ? ReqNTID[2] : 1}
+ : Vector3{};
+ // Only fold when reqntid values are within hardware limits.
----------------
AlexMaclean wrote:
I think my personal preference would be that we just treat this as a garbage-in garbage-out scenario and don't add any special logic to handle it (I assume that an invalid range would be converted to poison at some point?). Separately it would be good to add logic to the Verifier or somewhere else that checks the values are in the proper range.
https://github.com/llvm/llvm-project/pull/191575
More information about the llvm-commits
mailing list