You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inlining already handles array slices, but it only allows a step-size of size 1 (mentioned in #1646). E,g,, a call like:
call test1(a(1:3, 2:5:3, 1:2:2), result)
cannot be inlined:
Transformation Error: Cannot inline routine 'test1' because one of its arguments is an array slice with a non-unit stride: 'a(:3,2:5:3,:2:2)' (TODO #1646)
The TODO is technically wrong (#1646 is about "dotproducttrans does not work if arguments are not plain arrays ", the non-unit stride is only mentioned there), so I decided to open a new issue to properly track this.
A suggested solution is to introduce a new pointer variable when inlining, e.g.:
a_p =>a(1:3, 2:5:3, 1:2:2)
And then use this pointer variable in the inlined routine.The F2003 standard allows that a dummy argument has the target attribute, even if the actual argument doesn't. Page 270 (12.4.1.2 Actual arguments associated with dummy data objects) lines 20-22:
20 If the dummy argument has the TARGET attribute and the corresponding actual argument does not
21 have the TARGET attribute or is an array section with a vector subscript, any pointers associated with
22 the dummy argument become undefined when execution of the procedure completes.
So any pointer set will become undefined when the subroutine exit, but as long as the inlined routine is executed, the pointer will be fine.
So during inline we could just add a target attribute to the dummy argument, introduce the pointer and the assignment, then in the inlined routine replace the original array with the pointer.
The text was updated successfully, but these errors were encountered:
hiker
changed the title
Support inlining with array slices and step size not 1
Support inlining with array slices and non-unit strides
Jan 25, 2025
Inlining already handles array slices, but it only allows a step-size of size 1 (mentioned in #1646). E,g,, a call like:
cannot be inlined:
The TODO is technically wrong (#1646 is about "dotproducttrans does not work if arguments are not plain arrays ", the non-unit stride is only mentioned there), so I decided to open a new issue to properly track this.
A suggested solution is to introduce a new pointer variable when inlining, e.g.:
And then use this pointer variable in the inlined routine.The F2003 standard allows that a dummy argument has the
target
attribute, even if the actual argument doesn't. Page 270 (12.4.1.2 Actual arguments associated with dummy data objects) lines 20-22:So any pointer set will become undefined when the subroutine exit, but as long as the inlined routine is executed, the pointer will be fine.
So during inline we could just add a
target
attribute to the dummy argument, introduce the pointer and the assignment, then in the inlined routine replace the original array with the pointer.The text was updated successfully, but these errors were encountered: