llvm-project/flang/test/Lower/complex-real.f90
Kiran Chandramohan b9aa3eb28c [Flang] Add a missing case for bfloat
A case was missed for the bfloat type in the getRealType function
in FIRBuilder. This can cause a crash in some situations like in
the provided test. The patch adds the missing case.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D149469
2023-04-28 18:38:14 +00:00

16 lines
730 B
Fortran

! RUN: bbc -emit-fir %s -o - | FileCheck %s
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
! CHECK-LABEL: @_QPsb_complex_bfloat
! CHECK: %[[C_REF:.*]] = fir.alloca !fir.complex<3> {bindc_name = "c", uniq_name = "_QFsb_complex_bfloatEc"}
! CHECK: %[[R_REF:.*]] = fir.alloca bf16 {bindc_name = "r", uniq_name = "_QFsb_complex_bfloatEr"}
! CHECK: %[[R_VAL:.*]] = fir.load %[[R_REF]] : !fir.ref<bf16>
! CHECK: %[[C0:.*]] = arith.constant 0 : i32
! CHECK: %[[CREAL_REF:.*]] = fir.coordinate_of %[[C_REF]], %[[C0]] : (!fir.ref<!fir.complex<3>>, i32) -> !fir.ref<bf16>
! CHECK: fir.store %[[R_VAL]] to %[[CREAL_REF]] : !fir.ref<bf16>
subroutine sb_complex_bfloat
complex(kind=3) :: c
real(kind=3) :: r
c%re = r
end subroutine