brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · f31a809 Raw
51 lines · plain
1! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s -check-prefixes=HONORINF,ALL2! RUN: %flang_fc1 -menable-no-infs -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s -check-prefixes=CHECK,ALL,%if flang-supports-f128-math %{F128%} %else %{F64%}3 4! ALL-LABEL: func @_QPmodulo_testr(5! ALL-SAME: %[[arg0:.*]]: !fir.ref<f64>{{.*}}, %[[arg1:.*]]: !fir.ref<f64>{{.*}}, %[[arg2:.*]]: !fir.ref<f64>{{.*}}) {6subroutine modulo_testr(r, a, p)7  real(8) :: r, a, p8  ! ALL-DAG: %[[a:.*]] = fir.load %[[arg1]] : !fir.ref<f64>9  ! ALL-DAG: %[[p:.*]] = fir.load %[[arg2]] : !fir.ref<f64>10  ! HONORINF: %[[res:.*]] = fir.call @_FortranAModuloReal8(%[[a]], %[[p]]11  ! CHECK-DAG: %[[rem:.*]] = arith.remf %[[a]], %[[p]] {{.*}}: f6412  ! CHECK-DAG: %[[zero:.*]] = arith.constant 0.000000e+00 : f6413  ! CHECK-DAG: %[[remNotZero:.*]] = arith.cmpf une, %[[rem]], %[[zero]] {{.*}} : f6414  ! CHECK-DAG: %[[aNeg:.*]] = arith.cmpf olt, %[[a]], %[[zero]] {{.*}} : f6415  ! CHECK-DAG: %[[pNeg:.*]] = arith.cmpf olt, %[[p]], %[[zero]] {{.*}} : f6416  ! CHECK-DAG: %[[signDifferent:.*]] = arith.xori %[[aNeg]], %[[pNeg]] : i117  ! CHECK-DAG: %[[mustAddP:.*]] = arith.andi %[[remNotZero]], %[[signDifferent]] : i118  ! CHECK-DAG: %[[remPlusP:.*]] = arith.addf %[[rem]], %[[p]] {{.*}}: f6419  ! CHECK: %[[res:.*]] = arith.select %[[mustAddP]], %[[remPlusP]], %[[rem]] : f6420  ! ALL: fir.store %[[res]] to %[[arg0]] : !fir.ref<f64>21  r = modulo(a, p)22end subroutine23 24! ALL-LABEL: func @_QPmodulo_testi(25! ALL-SAME: %[[arg0:.*]]: !fir.ref<i64>{{.*}}, %[[arg1:.*]]: !fir.ref<i64>{{.*}}, %[[arg2:.*]]: !fir.ref<i64>{{.*}}) {26subroutine modulo_testi(r, a, p)27  integer(8) :: r, a, p28  ! CHECK-DAG: %[[a:.*]] = fir.load %[[arg1]] : !fir.ref<i64>29  ! CHECK-DAG: %[[p:.*]] = fir.load %[[arg2]] : !fir.ref<i64>30  ! CHECK-DAG: %[[rem:.*]] = arith.remsi %[[a]], %[[p]] : i6431  ! CHECK-DAG: %[[argXor:.*]] = arith.xori %[[a]], %[[p]] : i6432  ! CHECK-DAG: %[[signDifferent:.*]] = arith.cmpi slt, %[[argXor]], %c0{{.*}} : i6433  ! CHECK-DAG: %[[remNotZero:.*]] = arith.cmpi ne, %[[rem]], %c0{{.*}} : i6434  ! CHECK-DAG: %[[mustAddP:.*]] = arith.andi %[[remNotZero]], %[[signDifferent]] : i135  ! CHECK-DAG: %[[remPlusP:.*]] = arith.addi %[[rem]], %[[p]] : i6436  ! CHECK: %[[res:.*]] = arith.select %[[mustAddP]], %[[remPlusP]], %[[rem]] : i6437  ! CHECK: fir.store %[[res]] to %[[arg0]] : !fir.ref<i64>38  r = modulo(a, p)39end subroutine40 41! CHECK-LABEL: func @_QPmodulo_testr16(42! F128-SAME: %[[arg0:.*]]: !fir.ref<f128>{{.*}}, %[[arg1:.*]]: !fir.ref<f128>{{.*}}, %[[arg2:.*]]: !fir.ref<f128>{{.*}}) {43! F64-SAME: %[[arg0:.*]]: !fir.ref<f64>{{.*}}, %[[arg1:.*]]: !fir.ref<f64>{{.*}}, %[[arg2:.*]]: !fir.ref<f64>{{.*}}) {44subroutine modulo_testr16(r, a, p)45  integer, parameter :: rk = merge(16, 8, selected_real_kind(33, 4931)==16)46  real(rk) :: r, a, p47  !F128: fir.call @_FortranAModuloReal16({{.*}}){{.*}}: (f128, f128, !fir.ref<i8>, i32) -> f12848  !F64: arith.remf %0, %1 fastmath<ninf,contract> : f6449  r = modulo(a, p)50end subroutine51