Skip to content

Commit

Permalink
MLIR: fix result positions to shadow (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Oct 8, 2024
1 parent 2f92df3 commit 152441a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,20 @@ LogicalResult mlir::enzyme::detail::controlFlowForwardHandler(
// table.
SmallVector<Value> reps;
size_t idx = 0;
for (Value r : op->getResults()) {
for (OpResult r : op->getResults()) {
// TODO only if used
reps.push_back(replacement->getResult(idx));
idx++;
if (!gutils->isConstantValue(r)) {
assert(resultPositionsToShadow.count(r.getResultNumber()));
auto inverted = gutils->invertedPointers.lookupOrNull(r);
assert(inverted);
gutils->invertedPointers.map(r, replacement->getResult(idx));
inverted.replaceAllUsesWith(replacement->getResult(idx));
gutils->erase(inverted.getDefiningOp());
idx++;
} else if (resultPositionsToShadow.count(r.getResultNumber())) {
idx++;
}
}

Expand Down

0 comments on commit 152441a

Please sign in to comment.