[Mlir-commits] [mlir] [mlir][OpenACC] Normalize loop bounds in convertACCLoopToSCFFor for negative steps (PR #184935)

Razvan Lupusoru llvmlistbot at llvm.org
Fri Mar 6 10:02:09 PST 2026


================
@@ -353,12 +350,44 @@ TEST_F(OpenACCUtilsLoopTest, ConvertLoopToSCFForExclusiveUpperBound) {
 
   ASSERT_TRUE(forOp);
 
-  // With exclusive upper bound, ub should remain 10 (no +1 adjustment)
+  // Positive step: bounds passed through directly (no normalization)
   EXPECT_EQ(forOp.getLowerBound(), c0);
   EXPECT_EQ(forOp.getUpperBound(), c10);
   EXPECT_EQ(forOp.getStep(), c1);
 }
 
+TEST_F(OpenACCUtilsLoopTest, ConvertLoopToSCFForNegativeStep) {
+  auto [module, funcOp] = createModuleWithFunc();
+
+  Value c10 = createIndexConstant(10);
+  Value c1 = createIndexConstant(1);
+  Value cNeg1 = createIndexConstant(-1);
+
+  // acc.loop from 10 to 1 step -1 (inclusive), like Fortran DO k = 10, 1, -1
----------------
razvanlupusoru wrote:

No need to capture source language example here.

https://github.com/llvm/llvm-project/pull/184935


More information about the Mlir-commits mailing list