Skip to content

Commit e7c1ad4

Browse files
author
git apple-llvm automerger
committed
Merge commit '580f70e07042' from llvm.org/main into next
2 parents c1bccad + 580f70e commit e7c1ad4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
1313
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
1414
#include "mlir/IR/BuiltinAttributes.h"
15+
#include <limits>
1516

1617
namespace mlir {
1718
namespace gpu {
@@ -116,7 +117,9 @@ struct OpLowering : public ConvertOpToLLVMPattern<Op> {
116117

117118
if (upperBound && intrType != IntrType::None) {
118119
int32_t min = (intrType == IntrType::Dim ? 1 : 0);
119-
int32_t max = *upperBound + (intrType == IntrType::Id ? 0 : 1);
120+
int32_t max = *upperBound == std::numeric_limits<int32_t>::max()
121+
? *upperBound
122+
: *upperBound + (intrType == IntrType::Id ? 0 : 1);
120123
newOp->setAttr("range", LLVM::ConstantRangeAttr::get(
121124
rewriter.getContext(), 32, min, max));
122125
}

mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,3 +763,16 @@ gpu.module @test_module {
763763
gpu.module @test_custom_data_layout attributes {llvm.data_layout = "e"} {
764764

765765
}
766+
767+
// -----
768+
769+
gpu.module @test_module {
770+
// CHECK32-LABEL: func @gpu_dim_int_max_upper_bound()
771+
func.func @gpu_dim_int_max_upper_bound()
772+
-> (index) {
773+
774+
// CHECK32: rocdl.workgroup.dim.x range <i32, 1, 2147483647> : i32
775+
%bDimX = gpu.block_dim x upper_bound 2147483647
776+
func.return %bDimX : index
777+
}
778+
}

0 commit comments

Comments
 (0)