diff options
author | Razvan Lupusoru <rlupusoru@nvidia.com> | 2023-05-11 10:42:37 -0700 |
---|---|---|
committer | Razvan Lupusoru <rlupusoru@nvidia.com> | 2023-05-11 14:50:43 -0700 |
commit | 036549fc6c7cb9ecddd82c1401a2b50882a219f7 (patch) | |
tree | 52c79b849825ae863687a929ba86ace95ec39e05 /flang/test | |
parent | e19387e6936c9ccc6200b32f3affea7b1020664c (diff) | |
download | llvm-036549fc6c7cb9ecddd82c1401a2b50882a219f7.tar.gz |
[flang] Inline array size call when dim is compile time constant
Instead of calling _FortranASizeDim, we can instead load extent
directly from descriptor. Add this support for cases where dim
is a known constant at compile time.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D150385
Diffstat (limited to 'flang/test')
-rw-r--r-- | flang/test/Lower/Intrinsics/ubound.f90 | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/flang/test/Lower/Intrinsics/ubound.f90 b/flang/test/Lower/Intrinsics/ubound.f90 index 1883d5bf7523..8210ff38994b 100644 --- a/flang/test/Lower/Intrinsics/ubound.f90 +++ b/flang/test/Lower/Intrinsics/ubound.f90 @@ -69,3 +69,15 @@ subroutine ubound_test_3(a, dim, res) ! CHECK: fir.store %[[VAL_16]] to %{{.*}} : !fir.ref<i64> res = ubound(a, dim, 8) end subroutine + + +! CHECK-LABEL: func @_QPubound_test_const_dim( +subroutine ubound_test_const_dim(array) + real :: array(11:) + integer :: res +! Should not call _FortranASizeDim when dim is compile time constant. But instead load from descriptor directly. +! CHECK: %[[C0:.*]] = arith.constant 0 : index +! CHECK: %[[DIMS:.*]]:3 = fir.box_dims %arg0, %[[C0]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index) +! CHECK: %{{.*}} = fir.convert %[[DIMS]]#1 : (index) -> i32 + res = ubound(array, 1) +end subroutine |