Skip to content

[flang] Implement the lowering portion of the CSHIFT intrinsic #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2021

Conversation

psteinfeld
Copy link
Collaborator

This change implements the lowering runtime portion of the CSHIFT
intrinsic. The implementation of the runtime was done in revision
D106292.

This change implements the lowering runtime portion of the CSHIFT
intrinsic.  The implementation of the runtime was done in revision
D106292.
! CHECK-DAG: %[[cs19:.*]] = fir.convert %[[cs11]] : (!fir.box<!fir.array<3x3xi32>>) -> !fir.box<none>
! CHECK-DAG: %[[cs20:.*]] = fir.convert %[[cs13]] : (!fir.box<!fir.array<3xi32>>) -> !fir.box<none>
! CHECK-DAG: %[[cs21:.*]] = fir.convert %[[cs17]]
! CHECK: fir.call @_FortranACshift(%[[cs18]], %[[cs19]], %[[cs20]], %{{.*}}, %[[cs21]], %{{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32) -> none
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sourceline argument, you can just use %{{.*}} instead of %[[cs21]].

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Mark. I'll make that change.

! CHECK-DAG: %[[cs43:.*]] = fir.convert %[[cs37]] : (!fir.box<!fir.array<6xi32>>) -> !fir.box<none>
! CHECK-DAG: %[[cs44:.*]] = fir.convert %[[cs1]] : (!fir.ref<i32>) -> i64
! CHECK-DAG: %[[cs45:.*]] = fir.convert %[[cs41]]
! CHECK: fir.call @_FortranACshiftVector(%[[cs42]], %[[cs43]], %[[cs44]], %[[cs45]], %{{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i64, !fir.ref<i8>, i32) -> none
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above about the sourceline argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Mark. I'll make that change.

Comment on lines 1977 to 1978
auto array = builder.createBox(loc, args[0]);
fir::BoxValue arrayTmp = builder.createBox(loc, args[0]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer the pattern:

fir::BoxValue arrayBox= builder.createBox(loc, args[0]);
auto array = fir::getBase(arrayBox);

createBox generates IR each time it is called. The snippet above avoids generating the same IR twice just to get the rank. Most of this duplicated IR is pruned by dead code elimination before you see it, but here it is really easy to not do extra work in the first place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Jean. I'll fix it.

Copy link
Collaborator

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good !

…project into fir-dev

Getting ready to merge changes for the CSHIFT intrinsic.
This change implements the lowering runtime portion of the CSHIFT
intrinsic.  The implementation of the runtime was done in revision
D106292.
@psteinfeld psteinfeld merged commit 23d2f3e into fir-dev Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants