This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add InferTypeOpInterface to scf.if op
ClosedPublic

Authored by frgossen on Jan 18 2023, 11:18 AM.

Diff Detail

Event Timeline

frgossen created this revision.Jan 18 2023, 11:18 AM
frgossen requested review of this revision.Jan 18 2023, 11:18 AM
frgossen retitled this revision from BEGIN_PUBLIC [MLIR] Add InferTypeOpInterface to scf.if op END_PUBLIC to [MLIR] Add InferTypeOpInterface to scf.if op.Jan 18 2023, 11:18 AM
frgossen added a reviewer: jpienaar.
pifon2a accepted this revision.Jan 19 2023, 8:13 AM
pifon2a added inline comments.
mlir/lib/Dialect/SCF/IR/SCF.cpp
1483

can we use getTerminator here?

This revision is now accepted and ready to land.Jan 19 2023, 8:13 AM
frgossen updated this revision to Diff 490583.Jan 19 2023, 10:18 AM

Address comments

This revision was landed with ongoing or failed builds.Jan 19 2023, 10:20 AM
This revision was automatically updated to reflect the committed changes.
pifon2a added inline comments.Jan 19 2023, 10:31 AM
mlir/lib/Dialect/SCF/IR/SCF.cpp
1480

this should be either a llvm::cast, otherwise you need to check whether the dynamic cast actually happened.

Ah seems I never hit submit yesterday. Same comment as Alex on one and general question on verification part.

mlir/lib/Dialect/SCF/IR/SCF.cpp
1476

Is the op invalid in that case? So here we are duplicating a bit of verification? Remember for builder methods invalid input is UB while for verification there is an order in which these run and so we should have checked that there is at least 1 region and that it satisfies SizedRegion<1>, given that do we need to verify these?

1484

If you use result of dyn_cast without checking if null, then cast is preferred (you could move the the trait that says it should have yield before type inference one to have this verified before you get here).

Thanks!

mlir/lib/Dialect/SCF/IR/SCF.cpp
1476

For the builders, I agree. inferReturnTypes is used when the regions and blocks are fully set up.
For the verifiers, do we want to rely on the order in which they are called? That seems fragile to me and not worth avoiding the cheap checks here.
Addressed this in https://reviews.llvm.org/D142155

1480