[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / integer-operations.f90
blob76ec658695a71af3816b6f70eb6a680c8e1b4318
1 ! RUN: bbc %s -o "-" | FileCheck %s
3 ! Test integer intrinsic operation lowering to fir.
5 ! CHECK-LABEL:eq0_test
6 LOGICAL FUNCTION eq0_test(x0, x1)
7 INTEGER(4) :: x0
8 INTEGER(4) :: x1
9 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
10 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
11 ! CHECK:[[reg3:%[0-9]+]] = arith.cmpi eq, [[reg1]], [[reg2]] : i32
12 ! CHECK:fir.convert [[reg3]] {{.*}} -> !fir.logical<4>
13 eq0_test = x0 .EQ. x1
14 END FUNCTION
16 ! CHECK-LABEL:ne1_test
17 LOGICAL FUNCTION ne1_test(x0, x1)
18 INTEGER(4) :: x0
19 INTEGER(4) :: x1
20 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
21 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
22 ! CHECK:[[reg3:%[0-9]+]] = arith.cmpi ne, [[reg1]], [[reg2]] : i32
23 ! CHECK:fir.convert [[reg3]] {{.*}} -> !fir.logical<4>
24 ne1_test = x0 .NE. x1
25 END FUNCTION
27 ! CHECK-LABEL:lt2_test
28 LOGICAL FUNCTION lt2_test(x0, x1)
29 INTEGER(4) :: x0
30 INTEGER(4) :: x1
31 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
32 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
33 ! CHECK:[[reg3:%[0-9]+]] = arith.cmpi slt, [[reg1]], [[reg2]] : i32
34 ! CHECK:fir.convert [[reg3]] {{.*}} -> !fir.logical<4>
35 lt2_test = x0 .LT. x1
36 END FUNCTION
38 ! CHECK-LABEL:le3_test
39 LOGICAL FUNCTION le3_test(x0, x1)
40 INTEGER(4) :: x0
41 INTEGER(4) :: x1
42 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
43 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
44 ! CHECK:[[reg3:%[0-9]+]] = arith.cmpi sle, [[reg1]], [[reg2]] : i32
45 ! CHECK:fir.convert [[reg3]] {{.*}} -> !fir.logical<4>
46 le3_test = x0 .LE. x1
47 END FUNCTION
49 ! CHECK-LABEL:gt4_test
50 LOGICAL FUNCTION gt4_test(x0, x1)
51 INTEGER(4) :: x0
52 INTEGER(4) :: x1
53 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
54 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
55 ! CHECK:[[reg3:%[0-9]+]] = arith.cmpi sgt, [[reg1]], [[reg2]] : i32
56 ! CHECK:fir.convert [[reg3]] {{.*}} -> !fir.logical<4>
57 gt4_test = x0 .GT. x1
58 END FUNCTION
60 ! CHECK-LABEL:ge5_test
61 LOGICAL FUNCTION ge5_test(x0, x1)
62 INTEGER(4) :: x0
63 INTEGER(4) :: x1
64 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
65 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
66 ! CHECK:[[reg3:%[0-9]+]] = arith.cmpi sge, [[reg1]], [[reg2]] : i32
67 ! CHECK:fir.convert [[reg3]] {{.*}} -> !fir.logical<4>
68 ge5_test = x0 .GE. x1
69 END FUNCTION
71 ! CHECK-LABEL:add6_test
72 INTEGER(4) FUNCTION add6_test(x0, x1)
73 INTEGER(4) :: x0
74 INTEGER(4) :: x1
75 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
76 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
77 ! CHECK:addi [[reg1]], [[reg2]] : i32
78 add6_test = x0 + x1
79 END FUNCTION
81 ! CHECK-LABEL:sub7_test
82 INTEGER(4) FUNCTION sub7_test(x0, x1)
83 INTEGER(4) :: x0
84 INTEGER(4) :: x1
85 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
86 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
87 ! CHECK:subi [[reg1]], [[reg2]] : i32
88 sub7_test = x0 - x1
89 END FUNCTION
91 ! CHECK-LABEL:mult8_test
92 INTEGER(4) FUNCTION mult8_test(x0, x1)
93 INTEGER(4) :: x0
94 INTEGER(4) :: x1
95 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
96 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
97 ! CHECK:muli [[reg1]], [[reg2]] : i32
98 mult8_test = x0 * x1
99 END FUNCTION
101 ! CHECK-LABEL:div9_test
102 INTEGER(4) FUNCTION div9_test(x0, x1)
103 INTEGER(4) :: x0
104 INTEGER(4) :: x1
105 ! CHECK-DAG:[[reg1:%[0-9]+]] = fir.load %arg0
106 ! CHECK-DAG:[[reg2:%[0-9]+]] = fir.load %arg1
107 ! CHECK:arith.divsi [[reg1]], [[reg2]] : i32
108 div9_test = x0 / x1
109 END FUNCTION