This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Add hlfir.count intrinsic
ClosedPublic

Authored by tblah on Jun 9 2023, 4:28 AM.

Details

Summary

Adds a new HLFIR operation for the COUNT intrinsic according to
the design set out in flang/docs/HighLevel.md. This patch includes all
the necessary changes to create a new HLFIR operation and lower it into
the fir runtime call.

Patch by @jacob-crawley

Diff Detail

Event Timeline

jacob-crawley created this revision.Jun 9 2023, 4:28 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 9 2023, 4:28 AM
jacob-crawley requested review of this revision.Jun 9 2023, 4:28 AM
tblah added inline comments.Jun 10 2023, 9:42 AM
flang/test/HLFIR/count-lowering.fir
149

This doesn't look right. In flang/runtime/reduction.cpp I find

void RTName(CountDim(Descriptor &result, const Descriptor &x, int dim, int kind, const char *source, int line)

So there should be 6 arguments (the missing one is for the kind value).

158

What is this elemental for?

tblah commandeered this revision.Jun 12 2023, 7:22 AM
tblah edited reviewers, added: jacob-crawley; removed: tblah.

I'm commandeering this revision because Jacob will not be working on this anymore.

tblah updated this revision to Diff 530504.Jun 12 2023, 7:37 AM

Update test not to miss out checking an argument to the runtime call

tblah edited the summary of this revision. (Show Details)Jun 12 2023, 7:39 AM

Other than my comment about the fast math interface, looks good.

flang/include/flang/Optimizer/HLFIR/HLFIROps.td
372–373

Is the fast math attribute really relevant here (the operation is not dealing with fp arithmetic)?

tblah updated this revision to Diff 530922.Jun 13 2023, 8:39 AM
tblah edited the summary of this revision. (Show Details)

Nice spot! I've removed the fastmath interface.

tblah marked an inline comment as done.Jun 13 2023, 8:40 AM
jeanPerier accepted this revision.Jun 15 2023, 8:26 AM

Looks great

This revision is now accepted and ready to land.Jun 15 2023, 8:26 AM
This revision was automatically updated to reflect the committed changes.