This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][SCF] Remove unused arguments to whileop
ClosedPublic

Authored by wsmoses on Jan 11 2022, 3:45 PM.

Details

Summary

Canonicalize away unused arguments to the before region of a whileOp

Diff Detail

Event Timeline

wsmoses created this revision.Jan 11 2022, 3:45 PM
wsmoses requested review of this revision.Jan 11 2022, 3:45 PM
mehdi_amini added inline comments.Jan 11 2022, 3:55 PM
mlir/lib/Dialect/SCF/SCF.cpp
2476

This does not seem used right now?
I'm surprised the verifier is even passing...

wsmoses updated this revision to Diff 399107.Jan 11 2022, 3:57 PM

Remove unused vector

wsmoses marked an inline comment as done.Jan 11 2022, 4:00 PM
mehdi_amini accepted this revision.Jan 11 2022, 4:01 PM
This revision is now accepted and ready to land.Jan 11 2022, 4:01 PM
mehdi_amini added inline comments.Jan 11 2022, 4:05 PM
mlir/lib/Dialect/SCF/SCF.cpp
2461

I think it is worth having an early exit before doing any heavy work:

if (!llvm::any_of(op.getBeforeArguments(), [] (Value arg) { return arg.use_empty(); })
  return failure();
wsmoses updated this revision to Diff 399119.Jan 11 2022, 4:23 PM

Add early exit

wsmoses updated this revision to Diff 399127.Jan 11 2022, 4:56 PM

Fix error

This revision was automatically updated to reflect the committed changes.