From 9c66417569c0a368aae565e9ead33d21f541f55a Mon Sep 17 00:00:00 2001 From: MLIR Team Date: Fri, 3 May 2019 03:08:56 -0700 Subject: [PATCH] Fix bug in LoopTiling where a loop with trip count of 1 caused a division by zero -- PiperOrigin-RevId: 246480710 --- mlir/lib/Transforms/LoopTiling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 64d1839fd660..11f2468b1a91 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -293,7 +293,7 @@ static void adjustToDivisorsOfTripCounts(ArrayRef band, // Adjust the tile size to largest factor of the trip count less than // tSize. uint64_t constTripCount = mayConst.getValue(); - if (tSizeAdjusted > constTripCount / 2) + if (constTripCount > 1 && tSizeAdjusted > constTripCount / 2) tSizeAdjusted = constTripCount / 2; while (constTripCount % tSizeAdjusted != 0) tSizeAdjusted--;