xref: /llvm-project/flang/test/Lower/Intrinsics/sign.f90 (revision f5759add702eb0b1243198d7f49b7a010b977f5d)
1! RUN: bbc %s -o - | FileCheck %s
2
3! CHECK-LABEL: sign_testi
4subroutine sign_testi(a, b, c)
5  integer a, b, c
6  ! CHECK: %[[VAL_1:.*]] = arith.shrsi %{{.*}}, %{{.*}} : i32
7  ! CHECK: %[[VAL_2:.*]] = arith.xori %{{.*}}, %[[VAL_1]] : i32
8  ! CHECK: %[[VAL_3:.*]] = arith.subi %[[VAL_2]], %[[VAL_1]] : i32
9  ! CHECK-DAG: %[[VAL_4:.*]] = arith.subi %{{.*}}, %[[VAL_3]] : i32
10  ! CHECK-DAG: %[[VAL_5:.*]] = arith.cmpi slt, %{{.*}}, %{{.*}} : i32
11  ! CHECK: select %[[VAL_5]], %[[VAL_4]], %[[VAL_3]] : i32
12  c = sign(a, b)
13end subroutine
14
15! CHECK-LABEL: sign_testr
16subroutine sign_testr(a, b, c)
17  real a, b, c
18  ! CHECK-NOT: fir.call @{{.*}}fabs
19  ! CHECK: math.copysign{{.*}} : f32
20  c = sign(a, b)
21end subroutine
22
23! CHECK-LABEL: sign_testr2
24subroutine sign_testr2(a, b, c)
25  real(KIND=16) a, b, c
26  ! CHECK-NOT: fir.call @{{.*}}fabs
27  ! CHECK: math.copysign{{.*}} : f128
28  c = sign(a, b)
29end subroutine
30