Skip to content

Commit 6f05d07

Browse files
committed
Adds some comments.
1 parent eb8661a commit 6f05d07

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/Analysis/MaskAnalysis.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,26 @@ LogicalResult MaskState::addStates(const MaskState &lhsState,
219219
LogicalResult MaskState::minStateScalar(const MaskState &lhsState,
220220
const MaskState &rhsState, Location loc,
221221
OpBuilder &builder) {
222+
// Conjunction where both sides are scalar should not be done after splats. We
223+
// should ensure that code generation pushes the splat as late as possible.
222224
if (lhsState.scalar && rhsState.scalar) {
223225
InFlightDiagnostic diag =
224226
emitError(loc) << "Unexpected case where both lhs and rhs are scalars";
225227
return failure();
226228
}
229+
230+
// Caller should ensure that at least one side is scalar.
227231
if (!lhsState.scalar && !rhsState.scalar) {
228232
InFlightDiagnostic diag =
229233
emitError(loc)
230234
<< "Unexpected case where both lhs and rhs are not scalars";
231235
return failure();
232236
}
233237

238+
// If we see a scalar condition in a conjunction with a mask, this means we
239+
// are either going to take the mask dimension or take nothing at all. To do
240+
// that we use a select on the scalar value with the mask dimension in the
241+
// true case and zero in the false case.
234242
auto &scalarState = lhsState.scalar ? lhsState : rhsState;
235243
auto &nonScalarState = lhsState.scalar ? rhsState : lhsState;
236244
for (uint32_t i = 0; i < nonScalarState.getRank(); i++) {

lib/Analysis/OpFoldResultUtils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ OpFoldResult selectOFRs(const OpFoldResult condOFR, const OpFoldResult trueOFR,
346346
auto falseValue = ofrToIndexValue(falseOFR, loc, b);
347347
auto condValue = ofrToIndexValue(condOFR, loc, b);
348348

349+
// Ideally we should not be passing around everything as index type since mask
350+
// analysis can come across i1 values, but that improvement is being left for
351+
// future work. For now we just unwrap an index back into it's i1 value if
352+
// necessary.
349353
if (!condValue.getType().isInteger(1)) {
350354
assert(condValue.getDefiningOp<arith::IndexCastOp>());
351355
condValue = condValue.getDefiningOp<arith::IndexCastOp>().getOperand();

0 commit comments

Comments
 (0)