This is an archive of the discontinued LLVM Phabricator instance.

[flang]Avoid asking for operands when there are none

Authored by Leporacanthicus on Aug 11 2022, 5:31 AM.



Fix one encountered (issue #57072) and two potential scenarios where the
code would ask for an operand that isn't there.

Add test for the encountered case.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 11 2022, 5:31 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
Leporacanthicus requested review of this revision.Aug 11 2022, 5:31 AM

Thank you for the changes, but I think this is not enough in general, so it may still make sense to make this code "experimental" for the time being. I would like to enable the pass in the driver so that DOT_PRODUCT inlining kicks in, but I cannot do this because SUM inlining fails many tests. TBH, I also see issues with DOT_PRODUCT inlining currently, but I hope I will be able to resolve them soon and enable the pass in the driver.


I do not think the check above is enough. As I understand, the main goal of this code is to skip fir.convert, but we should expect that we can meet any instruction producing !, e.g. consider that previous passes generated of a ! in the middle for whatever reason. I think we should actually check for a set of expected operations in the chain and bail out otherwise.


Please remove.

My internal testing passed with this patch and the pass enabled in the driver, so it should probably be okay. At the same time, I am still uncomfortable with the wide range of operations that we pass through during the analysis. Can you please check explicitly for operations expected in the chain, i.e. check explicitly for fir.convert and return conservative results otherwise?

Updated check for expected operation (always fir::ConvertOp) instead of
checking for number of operands. Assert to capture should number of operands
be zero.

Remove spurious include of iostream.

Leporacanthicus marked 2 inline comments as done.Aug 16 2022, 1:00 PM
Leporacanthicus added inline comments.

I think I've done this correctly - I'm slightly worried it's TOO restrictive....

vzakhari accepted this revision.Aug 16 2022, 1:07 PM
vzakhari added inline comments.

I understand your concern. I guess we will have to see what critical cases we might be missing here by analyzing benchmarks.

I think you may keep the loop so that we skip multiple fir.convert operations in a raw (e.g. see getArgElementType below). This can be done in a separate commit, though.

This revision is now accepted and ready to land.Aug 16 2022, 1:07 PM