Skip to content

Commit f90fa0a

Browse files
author
Xiang Li
committed
Use min(offsetSize, gatherMaskDimValue) when gatherMaskDim is immediate.
1 parent 5569e53 commit f90fa0a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/Conversion/StructuredToMemref/StructuredToMemref.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ struct LoadConverter : public OpConversionPattern<tts::LoadOp> {
852852
// gatherMaskDim to guard the load.
853853
if (auto gatherMaskDimIndex = getIntAttr(gatherMaskDim)) {
854854
// If the gather mask dimension is a constant, we can use it directly.
855-
offsetSize = gatherMaskDimIndex.value();
855+
unsigned gatherMaskDimValue = gatherMaskDimIndex.value();
856+
offsetSize = std::min(offsetSize, gatherMaskDimValue);
856857
}
857858
}
858859
auto upperBound = rewriter.create<arith::ConstantIndexOp>(loc, offsetSize);
@@ -1006,7 +1007,8 @@ struct StoreConverter : public OpConversionPattern<tts::StoreOp> {
10061007
// gatherMaskDim to guard the load.
10071008
if (auto gatherMaskDimIndex = getIntAttr(gatherMaskDim)) {
10081009
// If the gather mask dimension is a constant, we can use it directly.
1009-
offsetSize = gatherMaskDimIndex.value();
1010+
unsigned gatherMaskDimValue = gatherMaskDimIndex.value();
1011+
offsetSize = std::min(offsetSize, gatherMaskDimValue);
10101012
}
10111013
}
10121014
auto upperBound = rewriter.create<arith::ConstantIndexOp>(loc, offsetSize);

0 commit comments

Comments
 (0)