[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 32) (PR #186730)

via flang-commits flang-commits at lists.llvm.org
Sun Mar 15 20:53:55 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Eugene Epshteyn (eugeneepshteyn)

<details>
<summary>Changes</summary>

Tests converted from test/Lower/Intrinsics: ibset.f90, ichar.f90, ieee_class.f90, ieee_copy_sign.f90, ieee_is_finite.f90

---

Patch is 28.05 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/186730.diff


5 Files Affected:

- (modified) flang/test/Lower/Intrinsics/ibset.f90 (+15-13) 
- (modified) flang/test/Lower/Intrinsics/ichar.f90 (+28-21) 
- (modified) flang/test/Lower/Intrinsics/ieee_class.f90 (+51-55) 
- (modified) flang/test/Lower/Intrinsics/ieee_copy_sign.f90 (+25-22) 
- (modified) flang/test/Lower/Intrinsics/ieee_is_finite.f90 (+38-34) 


``````````diff
diff --git a/flang/test/Lower/Intrinsics/ibset.f90 b/flang/test/Lower/Intrinsics/ibset.f90
index 254adf75216a1..24c0ce34a2cfa 100644
--- a/flang/test/Lower/Intrinsics/ibset.f90
+++ b/flang/test/Lower/Intrinsics/ibset.f90
@@ -1,17 +1,19 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
-! CHECK-LABEL: ibset_test
+! CHECK-LABEL: func.func @_QPibset_test(
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<i32> {{.*}}, %[[ARG1:.*]]: !fir.ref<i32> {{.*}})
 function ibset_test(i, j)
-  ! CHECK-DAG: %[[result:.*]] = fir.alloca i32 {bindc_name = "ibset_test"
-  ! CHECK-DAG: %[[i:.*]] = fir.load %arg0 : !fir.ref<i32>
-  ! CHECK-DAG: %[[j:.*]] = fir.load %arg1 : !fir.ref<i32>
-  ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : i32
-  ! CHECK: %[[VAL_6:.*]] = arith.shli %[[VAL_5]], %[[j]] : i32
-  ! CHECK: %[[VAL_7:.*]] = arith.ori %[[i]], %[[VAL_6]] : i32
-  ! CHECK: fir.store %[[VAL_7]] to %[[result]] : !fir.ref<i32>
-  ! CHECK: %[[VAL_8:.*]] = fir.load %[[result]] : !fir.ref<i32>
-  ! CHECK: return %[[VAL_8]] : i32
+  ! CHECK-DAG: %[[I:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %{{.*}} arg 1 {uniq_name = "_QFibset_testEi"}
+  ! CHECK-DAG: %[[J:.*]]:2 = hlfir.declare %[[ARG1]] dummy_scope %{{.*}} arg 2 {uniq_name = "_QFibset_testEj"}
+  ! CHECK-DAG: %[[RESULT_ALLOC:.*]] = fir.alloca i32 {bindc_name = "ibset_test", uniq_name = "_QFibset_testEibset_test"}
+  ! CHECK-DAG: %[[RESULT:.*]]:2 = hlfir.declare %[[RESULT_ALLOC]] {uniq_name = "_QFibset_testEibset_test"}
+  ! CHECK-DAG: %[[I_VAL:.*]] = fir.load %[[I]]#0 : !fir.ref<i32>
+  ! CHECK-DAG: %[[J_VAL:.*]] = fir.load %[[J]]#0 : !fir.ref<i32>
+  ! CHECK-DAG: %[[C1:.*]] = arith.constant 1 : i32
+  ! CHECK: %[[VAL_6:.*]] = arith.shli %[[C1]], %[[J_VAL]] : i32
+  ! CHECK: %[[VAL_7:.*]] = arith.ori %[[I_VAL]], %[[VAL_6]] : i32
+  ! CHECK: hlfir.assign %[[VAL_7]] to %[[RESULT]]#0 : i32, !fir.ref<i32>
+  ! CHECK: %[[RET_VAL:.*]] = fir.load %[[RESULT]]#0 : !fir.ref<i32>
+  ! CHECK: return %[[RET_VAL]] : i32
   ibset_test = ibset(i, j)
 end
-
diff --git a/flang/test/Lower/Intrinsics/ichar.f90 b/flang/test/Lower/Intrinsics/ichar.f90
index eb7e03873e6b7..e633a8c2b8d0b 100644
--- a/flang/test/Lower/Intrinsics/ichar.f90
+++ b/flang/test/Lower/Intrinsics/ichar.f90
@@ -1,43 +1,50 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
-! CHECK-LABEL: ichar_test
+! CHECK-LABEL: func.func @_QPichar_test(
+! CHECK-SAME: %[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
 subroutine ichar_test(c)
   character(1) :: c
   character :: str(10)
-  ! CHECK-DAG: %[[unbox:.*]]:2 = fir.unboxchar
-  ! CHECK-DAG: %[[BOX:.*]] = fir.convert %[[unbox]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1>>
-  ! CHECK-DAG: %[[J:.*]] = fir.alloca i32 {{{.*}}uniq_name = "{{.*}}Ej"}
-  ! CHECK-DAG: %[[STR:.*]] = fir.alloca !fir.array{{.*}} {{{.*}}uniq_name = "{{.*}}Estr"}
-  ! CHECK: %[[PTR:.*]] = fir.load %[[BOX]] : !fir.ref<!fir.char<1>>
-  ! CHECK: %[[CHAR:.*]] = fir.extract_value %[[PTR]], [0 : index] :
+  ! CHECK-DAG: %[[UNBOX:.*]]:2 = fir.unboxchar %[[ARG0]]
+  ! CHECK-DAG: %[[CONV:.*]] = fir.convert %[[UNBOX]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1>>
+  ! CHECK-DAG: %[[C_DECL:.*]]:2 = hlfir.declare %[[CONV]] typeparams {{.*}} dummy_scope %{{.*}} arg 1 {uniq_name = "_QFichar_testEc"}
+  ! CHECK-DAG: %[[J_ALLOC:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFichar_testEj"}
+  ! CHECK-DAG: %[[J_DECL:.*]]:2 = hlfir.declare %[[J_ALLOC]] {uniq_name = "_QFichar_testEj"}
+  ! CHECK-DAG: %[[STR_ALLOC:.*]] = fir.alloca !fir.array<10x!fir.char<1>> {bindc_name = "str", uniq_name = "_QFichar_testEstr"}
+  ! CHECK-DAG: %[[STR_DECL:.*]]:2 = hlfir.declare %[[STR_ALLOC]]({{.*}}) typeparams {{.*}} {uniq_name = "_QFichar_testEstr"}
+
+  ! CHECK: %[[C_VAL:.*]] = fir.load %[[C_DECL]]#0 : !fir.ref<!fir.char<1>>
+  ! CHECK: %[[CHAR:.*]] = fir.extract_value %[[C_VAL]], [0 : index] : (!fir.char<1>) -> i8
   ! CHECK: %[[ARG:.*]] = arith.extui %[[CHAR]] : i8 to i32
-  ! CHECK: fir.call @{{.*}}OutputInteger32{{.*}}%[[ARG]]
-  ! CHECK: fir.call @{{.*}}EndIoStatement
+  ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[ARG]])
+  ! CHECK: fir.call @_FortranAioEndIoStatement
   print *, ichar(c)
 
-  ! CHECK-DAG: %{{.*}} = fir.load %[[J]] : !fir.ref<i32>
-  ! CHECK: %[[PTR1:.*]] = fir.coordinate_of %[[STR]], %
-  ! CHECK: %[[PTR2:.*]] = fir.load %[[PTR1]] : !fir.ref<!fir.char<1>>
-  ! CHECK: %[[CHAR:.*]] = fir.extract_value %[[PTR2]], [0 : index] :
-  ! CHECK: %[[ARG:.*]] = arith.extui %[[CHAR]] : i8 to i32
-  ! CHECK: fir.call @{{.*}}OutputInteger32{{.*}}%[[ARG]]
-  ! CHECK: fir.call @{{.*}}EndIoStatement
+  ! CHECK: %[[J_VAL:.*]] = fir.load %[[J_DECL]]#0 : !fir.ref<i32>
+  ! CHECK: %[[J_IDX:.*]] = fir.convert %[[J_VAL]] : (i32) -> i64
+  ! CHECK: %[[STR_EL:.*]] = hlfir.designate %[[STR_DECL]]#0 (%[[J_IDX]])  typeparams {{.*}} : (!fir.ref<!fir.array<10x!fir.char<1>>>, i64, index) -> !fir.ref<!fir.char<1>>
+  ! CHECK: %[[STR_VAL:.*]] = fir.load %[[STR_EL]] : !fir.ref<!fir.char<1>>
+  ! CHECK: %[[CHAR2:.*]] = fir.extract_value %[[STR_VAL]], [0 : index] : (!fir.char<1>) -> i8
+  ! CHECK: %[[ARG2:.*]] = arith.extui %[[CHAR2]] : i8 to i32
+  ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[ARG2]])
+  ! CHECK: fir.call @_FortranAioEndIoStatement
   print *, ichar(str(J))
 
   ! "Magic" 88 below is the ASCII code for `X` and the value returned by IACHAR (’X’)
   ! CHECK: %[[c88:.*]] = arith.constant 88 : i32
-  ! CHECK-NEXT: fir.call @{{.*}}OutputInteger32({{.*}}, %[[c88]])
-  ! CHECK-NEXT: fir.call @{{.*}}EndIoStatement
+  ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[c88]])
+  ! CHECK: fir.call @_FortranAioEndIoStatement
   print *, iachar('X')
 end subroutine
 
 ! Check that 'arith.extui' op is not generated if type are matching.
- ! CHECK-LABEL: no_extui
+! CHECK-LABEL: func.func @_QPno_extui(
 subroutine no_extui(ch)
   integer, parameter :: kind = selected_char_kind('ISO_10646')
   character(*, kind), intent(in) :: ch(:)
   integer :: i, j
   ! CHECK-NOT: arith.extui
+  ! CHECK: %[[CHAR4:.*]] = fir.extract_value {{.*}}, [0 : index] : (!fir.char<4>) -> i32
+  ! CHECK: hlfir.assign %[[CHAR4]] to {{.*}} : i32, !fir.ref<i32>
   j = ichar(ch(i)(i:i))
 end subroutine
diff --git a/flang/test/Lower/Intrinsics/ieee_class.f90 b/flang/test/Lower/Intrinsics/ieee_class.f90
index acef959656539..ab177e40e0d0d 100644
--- a/flang/test/Lower/Intrinsics/ieee_class.f90
+++ b/flang/test/Lower/Intrinsics/ieee_class.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
 #ifndef RK
 #define RK 8
@@ -8,7 +8,7 @@ module m
   integer, parameter :: k = RK
   character(20) :: tag(11)
 contains
-  ! CHECK-LABEL: func @_QMmPinit
+  ! CHECK-LABEL: func.func @_QMmPinit()
   subroutine init
     tag( 1) = 'signaling_nan';      tag( 2) = 'quiet_nan'
     tag( 3) = 'negative_inf';       tag( 4) = 'negative_normal'
@@ -17,7 +17,8 @@ subroutine init
     tag( 9) = 'positive_normal';    tag(10) = 'positive_inf'
     tag(11) = 'other_value'
   end
-  ! CHECK-LABEL: func @_QMmPout
+  ! CHECK-LABEL: func.func @_QMmPout(
+  ! CHECK-SAME: %[[X_ARG:.*]]: !fir.ref<f64> {{.*}}, %[[V_ARG:.*]]: !fir.ref<i32> {{.*}})
   subroutine out(x,v)
     use ieee_arithmetic
     real(k) :: x
@@ -36,53 +37,53 @@ subroutine out(x,v)
   end
 end module m
 
-! CHECK-LABEL: func @_QPclassify
+! CHECK-LABEL: func.func @_QPclassify(
+! CHECK-SAME: %[[X_ARG:.*]]: !fir.ref<f64> {{.*}})
 subroutine classify(x)
   use m; use ieee_arithmetic
   real(k) :: x
-  ! CHECK-DAG: %[[V_0:[0-9]+]] = fir.alloca i32 {adapt.valuebyref}
-  ! CHECK-DAG: %[[V_1:[0-9]+]] = fir.alloca !fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>
-  ! CHECK-DAG: %[[V_2:[0-9]+]] = fir.alloca !fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}> {bindc_name = "r", uniq_name = "_QFclassifyEr"}
+  ! CHECK-DAG: %[[R_ALLOC:.*]] = fir.alloca !fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}> {bindc_name = "r", uniq_name = "_QFclassifyEr"}
+  ! CHECK-DAG: %[[R_DECL:.*]]:2 = hlfir.declare %[[R_ALLOC]] {uniq_name = "_QFclassifyEr"}
+  ! CHECK-DAG: %[[X_DECL:.*]]:2 = hlfir.declare %[[X_ARG]] {{.*}} {uniq_name = "_QFclassifyEx"}
   type(ieee_class_type) :: r
 
-  ! CHECK:     %[[V_8:[0-9]+]] = fir.load %arg0 : !fir.ref<f64>
-  ! CHECK:     %[[V_9:[0-9]+]] = arith.bitcast %[[V_8]] : f64 to i64
-  ! CHECK:     %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c59{{.*}} : i64
-  ! CHECK:     %[[V_11:[0-9]+]] = arith.andi %[[V_10]], %c16{{.*}} : i64
-  ! CHECK:     %[[V_12:[0-9]+]] = arith.andi %[[V_9]], %c9218868437227405312{{.*}} : i64
-  ! CHECK:     %[[V_13:[0-9]+]] = arith.cmpi ne, %[[V_12]], %c0{{.*}} : i64
-  ! CHECK:     %[[V_14:[0-9]+]] = arith.select %[[V_13]], %c8{{.*}}, %c0{{.*}} : i64
-  ! CHECK:     %[[V_15:[0-9]+]] = arith.ori %[[V_11]], %[[V_14]] : i64
-  ! CHECK:     %[[V_16:[0-9]+]] = arith.cmpi eq, %[[V_12]], %c9218868437227405312{{.*}} : i64
-  ! CHECK:     %[[V_17:[0-9]+]] = arith.select %[[V_16]], %c4{{.*}}, %c0{{.*}} : i64
-  ! CHECK:     %[[V_18:[0-9]+]] = arith.ori %[[V_15]], %[[V_17]] : i64
-  ! CHECK:     %[[V_19:[0-9]+]] = arith.andi %[[V_9]], %c2251799813685247{{.*}} : i64
-  ! CHECK:     %[[V_20:[0-9]+]] = arith.cmpi ne, %[[V_19]], %c0{{.*}} : i64
-  ! CHECK:     %[[V_21:[0-9]+]] = arith.select %[[V_20]], %c2{{.*}}, %c0{{.*}} : i64
-  ! CHECK:     %[[V_22:[0-9]+]] = arith.ori %[[V_18]], %[[V_21]] : i64
-  ! CHECK:     %[[V_23:[0-9]+]] = arith.shrui %[[V_9]], %c51{{.*}} : i64
-  ! CHECK:     %[[V_24:[0-9]+]] = arith.andi %[[V_23]], %c1{{.*}} : i64
-  ! CHECK:     %[[V_25:[0-9]+]] = arith.ori %[[V_22]], %[[V_24]] : i64
-  ! CHECK:     %[[V_26:[0-9]+]] = fir.address_of(@_FortranAIeeeClassTable) : !fir.ref<!fir.array<32xi8>>
-  ! CHECK:     %[[V_27:[0-9]+]] = fir.coordinate_of %[[V_26]], %[[V_25]] : (!fir.ref<!fir.array<32xi8>>, i64) -> !fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>
-  ! CHECK:     %[[V_29:[0-9]+]] = fir.coordinate_of %[[V_27]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     %[[V_31:[0-9]+]] = fir.coordinate_of %[[V_2]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     %[[V_32:[0-9]+]] = fir.load %[[V_29]] : !fir.ref<i8>
-  ! CHECK:     fir.store %[[V_32]] to %[[V_31]] : !fir.ref<i8>
+  ! CHECK:     %[[X_VAL:.*]] = fir.load %[[X_DECL]]#0 : !fir.ref<f64>
+  ! CHECK:     %[[BITCAST:.*]] = arith.bitcast %[[X_VAL]] : f64 to i64
+  ! CHECK:     %{{.*}} = arith.shrui %[[BITCAST]], %c59{{.*}} : i64
+  ! CHECK:     %[[V_11:.*]] = arith.andi %{{.*}}, %c16{{.*}} : i64
+  ! CHECK:     %[[EXP:.*]] = arith.andi %[[BITCAST]], %c{{-?[0-9]+}}{{.*}} : i64
+  ! CHECK:     %[[EXP_NZ:.*]] = arith.cmpi ne, %[[EXP]], %c0{{.*}} : i64
+  ! CHECK:     %[[V_14:.*]] = arith.select %[[EXP_NZ]], %c8{{.*}}, %c0{{.*}} : i64
+  ! CHECK:     %[[V_15:.*]] = arith.ori %[[V_11]], %[[V_14]] : i64
+  ! CHECK:     %[[EXP_INF:.*]] = arith.cmpi eq, %[[EXP]], %c{{-?[0-9]+}}{{.*}} : i64
+  ! CHECK:     %[[V_17:.*]] = arith.select %[[EXP_INF]], %c4{{.*}}, %c0{{.*}} : i64
+  ! CHECK:     %[[V_18:.*]] = arith.ori %[[V_15]], %[[V_17]] : i64
+  ! CHECK:     %[[FRAC:.*]] = arith.andi %[[BITCAST]], %c{{[0-9]+}}{{.*}} : i64
+  ! CHECK:     %[[FRAC_NZ:.*]] = arith.cmpi ne, %[[FRAC]], %c0{{.*}} : i64
+  ! CHECK:     %[[V_21:.*]] = arith.select %[[FRAC_NZ]], %c2{{.*}}, %c0{{.*}} : i64
+  ! CHECK:     %[[V_22:.*]] = arith.ori %[[V_18]], %[[V_21]] : i64
+  ! CHECK:     %[[V_23:.*]] = arith.shrui %[[BITCAST]], %c51{{.*}} : i64
+  ! CHECK:     %[[V_24:.*]] = arith.andi %[[V_23]], %c1{{.*}} : i64
+  ! CHECK:     %[[V_25:.*]] = arith.ori %[[V_22]], %[[V_24]] : i64
+  ! CHECK:     %[[TABLE:.*]] = fir.address_of(@_FortranAIeeeClassTable) : !fir.ref<!fir.array<32xi8>>
+  ! CHECK:     %[[COORD:.*]] = fir.coordinate_of %[[TABLE]], %[[V_25]] : (!fir.ref<!fir.array<32xi8>>, i64) -> !fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>
+  ! CHECK:     %[[TMP:.*]]:2 = hlfir.declare %[[COORD]] {uniq_name = ".tmp.intrinsic_result"}
+  ! CHECK:     %[[EXPR:.*]] = hlfir.as_expr %[[TMP]]#0 move {{.*}} : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>, i1) -> !hlfir.expr<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>
+  ! CHECK:     hlfir.assign %[[EXPR]] to %[[R_DECL]]#0 : !hlfir.expr<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>, !fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>
+  ! CHECK:     hlfir.destroy %[[EXPR]] : !hlfir.expr<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>
   r = ieee_class(x)
 
 ! if (r==ieee_signaling_nan)      call out(x, 1)
 ! if (r==ieee_quiet_nan)          call out(x, 2)
-  ! CHECK:     %[[V_39:[0-9]+]] = fir.coordinate_of %[[V_1]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     fir.store %c3{{.*}} to %[[V_39]] : !fir.ref<i8>
-  ! CHECK:     %[[V_41:[0-9]+]] = fir.coordinate_of %[[V_2]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     %[[V_43:[0-9]+]] = fir.coordinate_of %[[V_1]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     %[[V_44:[0-9]+]] = fir.load %[[V_41]] : !fir.ref<i8>
-  ! CHECK:     %[[V_45:[0-9]+]] = fir.load %[[V_43]] : !fir.ref<i8>
-  ! CHECK:     %[[V_46:[0-9]+]] = arith.cmpi eq, %[[V_44]], %[[V_45]] : i8
-  ! CHECK:     fir.if %[[V_46]] {
-  ! CHECK:       fir.store %c3{{.*}} to %[[V_0]] : !fir.ref<i32>
-  ! CHECK:       fir.call @_QMmPout(%arg0, %[[V_0]]) {{.*}} : (!fir.ref<f64>, !fir.ref<i32>) -> ()
+  ! CHECK:     %[[R_WHICH:.*]] = fir.coordinate_of %[[R_DECL]]#0, {{.*}}which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
+  ! CHECK:     %{{.*}} = fir.coordinate_of %{{.*}}, {{.*}}which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
+  ! CHECK:     %[[R_VAL:.*]] = fir.load %[[R_WHICH]] : !fir.ref<i8>
+  ! CHECK:     %[[CLASS_VAL:.*]] = fir.load %{{.*}} : !fir.ref<i8>
+  ! CHECK:     %[[EQ:.*]] = arith.cmpi eq, %[[R_VAL]], %[[CLASS_VAL]] : i8
+  ! CHECK:     fir.if %[[EQ]] {
+  ! CHECK:       %[[V_ASSOC:.*]]:3 = hlfir.associate %c3{{.*}} {adapt.valuebyref} : (i32) -> (!fir.ref<i32>, !fir.ref<i32>, i1)
+  ! CHECK:       fir.call @_QMmPout(%[[X_DECL]]#0, %[[V_ASSOC]]#0) {{.*}} : (!fir.ref<f64>, !fir.ref<i32>) -> ()
+  ! CHECK:       hlfir.end_associate %[[V_ASSOC]]#1, %[[V_ASSOC]]#2 : !fir.ref<i32>, i1
   ! CHECK:     }
   if (r==ieee_negative_inf)       call out(x, 3)
 ! if (r==ieee_negative_normal)    call out(x, 4)
@@ -95,7 +96,7 @@ subroutine classify(x)
 ! if (r==ieee_other_value)        call out(x,11)
 end
 
-! CHECK-LABEL: func @_QQmain
+! CHECK-LABEL: func.func @_QQmain()
 program p
   use m; use ieee_arithmetic
   real(k) :: x(10)
@@ -104,19 +105,14 @@ program p
 
 ! x(1)  = ieee_value(x(1), ieee_signaling_nan)
 ! x(2)  = ieee_value(x(1), ieee_quiet_nan)
-  ! CHECK:     %[[V_0:[0-9]+]] = fir.alloca !fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>
-  ! CHECK:     %[[V_2:[0-9]+]] = fir.address_of(@_QFEx) : !fir.ref<!fir.array<10xf64>>
-  ! CHECK:     %[[V_9:[0-9]+]] = fir.coordinate_of %[[V_0]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     fir.store %c3{{.*}} to %[[V_9]] : !fir.ref<i8>
-  ! CHECK:     %[[V_11:[0-9]+]] = fir.coordinate_of %[[V_0]], _QMieee_arithmeticTieee_class_type.which : (!fir.ref<!fir.type<_QMieee_arithmeticTieee_class_type{_QMieee_arithmeticTieee_class_type.which:i8}>>) -> !fir.ref<i8>
-  ! CHECK:     %[[V_12:[0-9]+]] = fir.load %[[V_11]] : !fir.ref<i8>
-  ! CHECK:     %[[V_13:[0-9]+]] = fir.address_of(@_FortranAIeeeValueTable_8) : !fir.ref<!fir.array<12xi64>>
-  ! CHECK:     %[[V_14:[0-9]+]] = fir.coordinate_of %[[V_13]], %[[V_12]] : (!fir.ref<!fir.array<12xi64>>, i8) -> !fir.ref<i64>
-  ! CHECK:     %[[V_15:[0-9]+]] = fir.load %[[V_14]] : !fir.ref<i64>
-  ! CHECK:     %[[V_16:[0-9]+]] = arith.bitcast %[[V_15]] : i64 to f64
-  ! CHECK:     %[[V_17:[0-9]+]] = arith.subi %c3{{.*}}, %c1{{.*}} : i64
-  ! CHECK:     %[[V_18:[0-9]+]] = fir.coordinate_of %[[V_2]], %[[V_17]] : (!fir.ref<!fir.array<10xf64>>, i64) -> !fir.ref<f64>
-  ! CHECK:     fir.store %[[V_16]] to %[[V_18]] : !fir.ref<f64>
+  ! CHECK:     %[[X_G_ALLOC:.*]] = fir.address_of(@_QFEx) : !fir.ref<!fir.array<10xf64>>
+  ! CHECK:     %[[X_G_DECL:.*]]:2 = hlfir.declare %[[X_G_ALLOC]]({{.*}}) {uniq_name = "_QFEx"}
+  ! CHECK:     %[[VAL_TABLE:.*]] = fir.address_of(@_FortranAIeeeValueTable_8) : !fir.ref<!fir.array<12xi64>>
+  ! CHECK:     %[[VAL_COORD:.*]] = fir.coordinate_of %[[VAL_TABLE]], %{{.*}} : (!fir.ref<!fir.array<12xi64>>, i8) -> !fir.ref<i64>
+  ! CHECK:     %[[VAL_I64:.*]] = fir.load %[[VAL_COORD]] : !fir.ref<i64>
+  ! CHECK:     %[[VAL_F64:.*]] = arith.bitcast %[[VAL_I64]] : i64 to f64
+  ! CHECK:     %[[X3_ADDR:.*]] = hlfir.designate %[[X_G_DECL]]#0 (%c3{{.*}})  : (!fir.ref<!fir.array<10xf64>>, index) -> !fir.ref<f64>
+  ! CHECK:     hlfir.assign %[[VAL_F64]] to %[[X3_ADDR]] : f64, !fir.ref<f64>
   x(3)  = ieee_value(x(1), ieee_negative_inf)
 ! x(4)  = ieee_value(x(1), ieee_negative_normal)
 ! x(5)  = ieee_value(x(1), ieee_negative_subnormal)
diff --git a/flang/test/Lower/Intrinsics/ieee_copy_sign.f90 b/flang/test/Lower/Intrinsics/ieee_copy_sign.f90
index 13e80bc5060b9..d354bc266adad 100644
--- a/flang/test/Lower/Intrinsics/ieee_copy_sign.f90
+++ b/flang/test/Lower/Intrinsics/ieee_copy_sign.f90
@@ -1,32 +1,35 @@
-! RUN: bbc -emit-fir -hlfir=false -o - %s | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
 
-! CHECK-LABEL: func @_QQmain
+! CHECK-LABEL: func.func @_QQmain()
 use ieee_arithmetic
 real(4) :: x = -2.0, y = huge(y)
 real(8) :: z = 2.0
 
-! CHECK-DAG: %[[V_0:[0-9]+]] = fir.address_of(@_QFEx) : !fir.ref<f32>
-! CHECK-DAG: %[[V_1:[0-9]+]] = fir.address_of(@_QFEy) : !fir.ref<f32>
-! CHECK-DAG: %[[V_2:[0-9]+]] = fir.address_of(@_QFEz) : !fir.ref<f64>
+! CHECK-DAG: %[[X_ADDR:.*]] = fir.address_of(@_QFEx) : !fir.ref<f32>
+! CHECK-DAG: %[[X_DECL:.*]]:2 = hlfir.declare %[[X_ADDR]] {uniq_name = "_QFEx"}
+! CHECK-DAG: %[[Y_ADDR:.*]] = fir.address_of(@_QFEy) : !fir.ref<f32>
+! CHECK-DAG: %[[Y_DECL:.*]]:2 = hlfir.declare %[[Y_ADDR]] {uniq_name = "_QFEy"}
+! CHECK-DAG: %[[Z_ADDR:.*]] = fir.address_of(@_QFEz) : !fir.ref<f64>
+! CHECK-DAG: %[[Z_DECL:.*]]:2 = hlfir.declare %[[Z_ADDR]] {uniq_name = "_QFEz"}
 
-! CHECK-DAG: %[[V_6:[0-9]+]] = fir.load %[[V_0]] : !fir.ref<f32>
-! CHECK-DAG: %[[V_7:[0-9]+]] = fir.load %[[V_1]] : !fir.ref<f32>
-! CHECK:     %[[V_8:[0-9]+]] = math.copysign %[[V_6]], %[[V_7]] fastmath<contract> : f32
-! CHECK:     %[[V_9:[0-9]+]] = fir.call @_FortranAioOutputReal32(%{{.*}}, %[[V_8]]) fastmath<contract> : (!fir.ref<i8>, f32) -> i1
+! CHECK-DAG: %[[X_VAL:.*]] = fir.load %[[X_DECL]]#0 : !fir.ref<f32>
+! CHECK-DAG: %[[Y_VAL:.*]] = fir.load %[[Y_DECL]]#0 : !fir.ref<f32>
+! CHECK:     %[[CS1:.*]] = math.copysign %[[X_VAL]], %[[Y_VAL]] fastmath<contract> : f32
+! CHECK:     fir.call @_FortranAioOutputReal32({{.*}}, %[[CS1]])
 
-! CHECK-DAG: %[[V_10:[0-9]+]] = fir.load %[[V_2]] : !fir.ref<f64>
-! CHECK-DAG: %[[V_11:[0-9]+]] = fir.load %[[V_1]] : !fir.ref<f32>
-! CHECK:     %[[V_12:...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/186730


More information about the flang-commits mailing list