This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Add codegen for vector subscripted LHS
ClosedPublic

Authored by jeanPerier on Jun 26 2023, 5:06 AM.

Details

Summary

This patch adds support for vector subscripted assignment left-hand
side. It does not yet add support for the cases where the LHS must be
saved because its evaluation could be impacted by the assignment.

The implementation adds an hlfir::ElementalOpInterface to share the
elemental inlining utility and some other tools between
hlfir::ElementalOp and hlfir::ElelemntalAddrOp.

It adds generateYieldedLHS() to allow retrieving the LHS value
in lowering, whether or not it is vector subscripted. If it is vector
subscripted, this utility creates a loop nest iterating over the
elements and returns the address of an element.

Diff Detail

Event Timeline

jeanPerier created this revision.Jun 26 2023, 5:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2023, 5:06 AM
jeanPerier requested review of this revision.Jun 26 2023, 5:06 AM
jeanPerier edited the summary of this revision. (Show Details)Jun 26 2023, 5:13 AM
tblah accepted this revision.Jun 26 2023, 9:33 AM

One tiny nit. Otherwise this looks great to me :)

flang/test/HLFIR/order_assignments/vector-subscripts-codegen.fir
120

Should this be destroying VAL_16 (the result of the elemental)?

This revision is now accepted and ready to land.Jun 26 2023, 9:33 AM
jeanPerier added inline comments.Jun 27 2023, 2:49 AM
flang/test/HLFIR/order_assignments/vector-subscripts-codegen.fir
120

Thanks for the review! Yes, this is indeed destroying VAL_16, for some reason the generate-test-checks.py utility is not making the link and is creating a new capture here. I updated it manually.

Update LIT test to use the correct value instead of creating a new
capture with the hlfir.expr argument.

jeanPerier edited the summary of this revision. (Show Details)Jun 27 2023, 4:25 AM
This revision was automatically updated to reflect the committed changes.