@@ -230,7 +230,7 @@ struct LoadStoreConversionBase {
230230 };
231231
232232 SmallVector<Value> ptrElems (numElems);
233- SmallVector<Value> maskElems (numElems) ;
233+ SmallVector<Value> maskElems;
234234 for (unsigned i = 0 ; i < numElems; ++i) {
235235 auto index = indices[i];
236236 SmallVector<Value> indicesInTensor (rank);
@@ -251,15 +251,17 @@ struct LoadStoreConversionBase {
251251 ptrElems[i] = gep (ptr_ty (rewriter.getContext (), 1 /* global*/ ),
252252 valueElemTy, blockPtr[blockBase], offset);
253253
254- // Get the LLVM values for mask
255- maskElems[i] = linearize (
256- indicesInTensor,
257- {blockPtr.begin () + blockShape, blockPtr.begin () + blockStride},
258- int_val (1 , 1 ),
259- [&](const Value &index, const Value &shape, const Value &mask) {
260- // mask = mask && (index < shape)
261- return and_ (icmp_slt (index, trunc (i32_ty, shape)), mask);
262- });
254+ if (boundaryCheck.size () > 0 ) {
255+ // Get the LLVM values for mask
256+ maskElems.push_back (linearize (
257+ indicesInTensor,
258+ {blockPtr.begin () + blockShape, blockPtr.begin () + blockStride},
259+ int_val (1 , 1 ),
260+ [&](const Value &index, const Value &shape, const Value &mask) {
261+ // mask = mask && (index < shape)
262+ return and_ (icmp_slt (index, trunc (i32_ty, shape)), mask);
263+ }));
264+ }
263265 }
264266
265267 // Get the LLVM values for `other`
0 commit comments