-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][hlfir] get extents from hlfir.shape_of
If the extents were known, this should have been canonicalised into a fir.shape operation. Therefore, the extents at this point are not known at compile time. Use hlfir.get_extents to delay resolving the real extent until after the expression is bufferized. Depends On: D146831 Differential Revision: https://reviews.llvm.org/D146832
- Loading branch information
Showing
2 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
! RUN: bbc -emit-fir -hlfir %s -o - | FileCheck %s | ||
subroutine foo(a, b) | ||
real :: a(:, :), b(:, :) | ||
interface | ||
elemental subroutine elem_sub(x) | ||
real, intent(in) :: x | ||
end subroutine | ||
end interface | ||
call elem_sub(matmul(a, b)) | ||
end subroutine | ||
! CHECK-LABEL: func.func @_QPfoo | ||
! CHECK: %[[A_ARG:.*]]: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "a"} | ||
! CHECK: %[[B_ARG:.*]]: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "b"} | ||
! CHECK-DAG: %[[A_VAR:.*]]:2 = hlfir.declare %[[A_ARG]] | ||
! CHECK-DAG: %[[B_VAR:.*]]:2 = hlfir.declare %[[B_ARG]] | ||
! CHECK-NEXT: %[[MUL:.*]] = hlfir.matmul %[[A_VAR]]#0 %[[B_VAR]]#0 | ||
! CHECK-NEXT: %[[SHAPE:.*]] = hlfir.shape_of %[[MUL]] : (!hlfir.expr<?x?xf32>) -> !fir.shape<2> | ||
! CHECK-NEXT: %[[EXT0:.*]] = hlfir.get_extent %[[SHAPE]] {dim = 0 : index} : (!fir.shape<2>) -> index | ||
! CHECK-NEXT: %[[EXT1:.*]] = hlfir.get_extent %[[SHAPE]] {dim = 1 : index} : (!fir.shape<2>) -> index | ||
! CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index | ||
! CHECK-NEXT: fir.do_loop %[[ARG2:.*]] = %[[C1]] to %[[EXT1]] step %[[C1]] { | ||
! CHECK-NEXT: fir.do_loop %[[ARG3:.*]] = %[[C1]] to %[[EXT0]] step %[[C1]] { | ||
! CHECK-NEXT: %[[ELE:.*]] = hlfir.apply %[[MUL]], %[[ARG3]], %[[ARG2]] : (!hlfir.expr<?x?xf32>, index, index) -> f32 | ||
! CHECK-NEXT: %[[ASSOC:.*]]:3 = hlfir.associate %[[ELE]] {uniq_name = "adapt.valuebyref"} : (f32) -> (!fir.ref<f32>, !fir.ref<f32>, i1) | ||
! CHECK-NEXT: fir.call | ||
! CHECK-NEXT: hlfir.end_associate | ||
! CHECK-NEXT: } | ||
! CHECK-NEXT: } | ||
! CHECK-NEXT: hlfir.destroy %[[MUL]] | ||
! CHECK-NEXT: return | ||
! CHECK-NEXT: } |