| 1 |
! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s -check-prefixes=HONORINF,ALL |
| 2 |
! RUN: flang-new -fc1 -menable-no-infs -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s -check-prefixes=CHECK,ALL |
| 3 |
|
| 4 |
! ALL-LABEL: func @_QPmodulo_testr( |
| 5 |
! ALL-SAME: %[[arg0:.*]]: !fir.ref<f64>{{.*}}, %[[arg1:.*]]: !fir.ref<f64>{{.*}}, %[[arg2:.*]]: !fir.ref<f64>{{.*}}) { |
| 6 |
subroutine modulo_testr(r, a, p) |
| 7 |
real(8) :: r, a, p |
| 8 |
! 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]] {{.*}}: f64 |
| 12 |
! CHECK-DAG: %[[zero:.*]] = arith.constant 0.000000e+00 : f64 |
| 13 |
! CHECK-DAG: %[[remNotZero:.*]] = arith.cmpf une, %[[rem]], %[[zero]] {{.*}} : f64 |
| 14 |
! CHECK-DAG: %[[aNeg:.*]] = arith.cmpf olt, %[[a]], %[[zero]] {{.*}} : f64 |
| 15 |
! CHECK-DAG: %[[pNeg:.*]] = arith.cmpf olt, %[[p]], %[[zero]] {{.*}} : f64 |
| 16 |
! CHECK-DAG: %[[signDifferent:.*]] = arith.xori %[[aNeg]], %[[pNeg]] : i1 |
| 17 |
! CHECK-DAG: %[[mustAddP:.*]] = arith.andi %[[remNotZero]], %[[signDifferent]] : i1 |
| 18 |
! CHECK-DAG: %[[remPlusP:.*]] = arith.addf %[[rem]], %[[p]] {{.*}}: f64 |
| 19 |
! CHECK: %[[res:.*]] = arith.select %[[mustAddP]], %[[remPlusP]], %[[rem]] : f64 |
| 20 |
! ALL: fir.store %[[res]] to %[[arg0]] : !fir.ref<f64> |
| 21 |
r = modulo(a, p) |
| 22 |
end subroutine |
| 23 |
|
| 24 |
! ALL-LABEL: func @_QPmodulo_testi( |
| 25 |
! ALL-SAME: %[[arg0:.*]]: !fir.ref<i64>{{.*}}, %[[arg1:.*]]: !fir.ref<i64>{{.*}}, %[[arg2:.*]]: !fir.ref<i64>{{.*}}) { |
| 26 |
subroutine modulo_testi(r, a, p) |
| 27 |
integer(8) :: r, a, p |
| 28 |
! 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]] : i64 |
| 31 |
! CHECK-DAG: %[[argXor:.*]] = arith.xori %[[a]], %[[p]] : i64 |
| 32 |
! CHECK-DAG: %[[signDifferent:.*]] = arith.cmpi slt, %[[argXor]], %c0{{.*}} : i64 |
| 33 |
! CHECK-DAG: %[[remNotZero:.*]] = arith.cmpi ne, %[[rem]], %c0{{.*}} : i64 |
| 34 |
! CHECK-DAG: %[[mustAddP:.*]] = arith.andi %[[remNotZero]], %[[signDifferent]] : i1 |
| 35 |
! CHECK-DAG: %[[remPlusP:.*]] = arith.addi %[[rem]], %[[p]] : i64 |
| 36 |
! CHECK: %[[res:.*]] = arith.select %[[mustAddP]], %[[remPlusP]], %[[rem]] : i64 |
| 37 |
! CHECK: fir.store %[[res]] to %[[arg0]] : !fir.ref<i64> |
| 38 |
r = modulo(a, p) |
| 39 |
end subroutine |
| 40 |
|
| 41 |
! CHECK-LABEL: func @_QPmodulo_testr16( |
| 42 |
! CHECK-SAME: %[[arg0:.*]]: !fir.ref<f128>{{.*}}, %[[arg1:.*]]: !fir.ref<f128>{{.*}}, %[[arg2:.*]]: !fir.ref<f128>{{.*}}) { |
| 43 |
subroutine modulo_testr16(r, a, p) |
| 44 |
real(16) :: r, a, p |
| 45 |
! CHECK: fir.call @_FortranAModuloReal16({{.*}}){{.*}}: (f128, f128, !fir.ref<i8>, i32) -> f128 |
| 46 |
r = modulo(a, p) |
| 47 |
end subroutine |