-
Notifications
You must be signed in to change notification settings - Fork 16
[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
Conversation
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 |
There was a problem hiding this comment.
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]].
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
flang/lib/Lower/IntrinsicCall.cpp
Outdated
auto array = builder.createBox(loc, args[0]); | ||
fir::BoxValue arrayTmp = builder.createBox(loc, args[0]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
This change implements the lowering runtime portion of the CSHIFT
intrinsic. The implementation of the runtime was done in revision
D106292.