This is an archive of the discontinued LLVM Phabricator instance.

[mlir] scf::ForOp: Drop iter arguments (and corresponding result) with no use
ClosedPublic

Authored by chelini on Mar 16 2021, 7:35 AM.

Details

Summary

'ForOpIterArgsFolder' can now remove iterator arguments (and corresponding
results) with no use.

Example:

%cst = constant 32 : i32

%0:2 = scf.for %arg1 = %lb to %ub step %step iter_args(%arg2 = %arg0, %arg3 = %cst)
  -> (i32, i32) {
  %1 = addu %arg2, %cst : i32
  scf.yield %1, %1 : i32, i32
}

use(%0#0)

%arg3 is not used in the block, and its corresponding result %0#1 has no use,
thus remove the iter argument.

Diff Detail

Event Timeline

chelini created this revision.Mar 16 2021, 7:35 AM
chelini requested review of this revision.Mar 16 2021, 7:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2021, 7:35 AM
chelini updated this revision to Diff 330985.Mar 16 2021, 7:46 AM

Minor update for test case.

nicolasvasilache accepted this revision.Mar 17 2021, 2:24 AM
This revision is now accepted and ready to land.Mar 17 2021, 2:24 AM

@nicolasvasilache thanks for landing it!