summaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2025-11-20 15:44:58 -0800
committerFlorian Mayer <fmayer@google.com>2025-11-20 15:44:58 -0800
commitda1d82491dfa34c08534ea747f0ceedef0bd33be (patch)
tree2f4f18d335550ee1618612783a10ebdddf1febef /mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
parenta5fb057dd9a7cdc777f0ce940d3e28421dbb5a4a (diff)
parent49e46a57cc1575271179c8c9c6fec5639781e9c6 (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/fmayer/spr/main.ubsan-add-fsanitize-preserve-runtime-flag
Created using spr 1.3.7 [skip ci]
Diffstat (limited to 'mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp')
-rw-r--r--mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
index 76a822b05a65..309121f52081 100644
--- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
+++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
@@ -453,10 +453,24 @@ static LogicalResult processParallelLoop(
1, 2,
rewriter.getAffineDimExpr(0) * rewriter.getAffineSymbolExpr(0) +
rewriter.getAffineSymbolExpr(1));
+ // Map through cloningMap first so we use values valid at the launch
+ // scope, then ensure they are launch-independent (or cloned constants).
+ Value mappedStep = cloningMap.lookupOrDefault(step);
+ Value mappedLowerBound = cloningMap.lookupOrDefault(lowerBound);
+
+ mappedStep = ensureLaunchIndependent(mappedStep);
+ mappedLowerBound = ensureLaunchIndependent(mappedLowerBound);
+
+ // If either cannot be made available above the launch, fail gracefully.
+ if (!mappedStep || !mappedLowerBound) {
+ return rewriter.notifyMatchFailure(
+ parallelOp, "lower bound / step must be constant or defined above "
+ "the gpu.launch");
+ }
+
newIndex = AffineApplyOp::create(
rewriter, loc, annotation.getMap().compose(lowerAndStep),
- ValueRange{operand, ensureLaunchIndependent(step),
- ensureLaunchIndependent(lowerBound)});
+ ValueRange{operand, mappedStep, mappedLowerBound});
// If there was also a bound, insert that, too.
// TODO: Check that we do not assign bounds twice.
if (annotation.getBound()) {