Skip to content

Commit 930a664

Browse files
improve test case
1 parent 1180064 commit 930a664

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed
Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1+
// Case 1: All floating-point arithmetics is lowered through APFloat.
12
// RUN: mlir-opt %s --convert-arith-to-apfloat --convert-to-llvm | \
2-
// RUN: mlir-runner -e entry --entry-point-result=void \
3-
// RUN: --shared-libs=%mlir_c_runner_utils | FileCheck %s
3+
// RUN: mlir-runner -e entry --entry-point-result=void \
4+
// RUN: --shared-libs=%mlir_c_runner_utils | FileCheck %s
5+
6+
// Case 2: Only unsupported arithmetics (f8E4M3FN) is lowered through APFloat.
7+
// Arithmetics on f32 is lowered directly to LLVM.
8+
// RUN: mlir-opt %s --convert-to-llvm --convert-arith-to-apfloat \
9+
// RUN: --convert-to-llvm --reconcile-unrealized-casts | \
10+
// RUN: mlir-runner -e entry --entry-point-result=void \
11+
// RUN: --shared-libs=%mlir_c_runner_utils | FileCheck %s
412

513
// Put rhs into separate function so that it won't be constant-folded.
6-
func.func @foo() -> f8E4M3FN {
7-
%cst = arith.constant 2.2 : f8E4M3FN
8-
return %cst : f8E4M3FN
14+
func.func @foo() -> (f8E4M3FN, f32) {
15+
%cst1 = arith.constant 2.2 : f8E4M3FN
16+
%cst2 = arith.constant 2.2 : f32
17+
return %cst1, %cst2 : f8E4M3FN, f32
918
}
1019

1120
func.func @entry() {
12-
%a = arith.constant 1.4 : f8E4M3FN
13-
%b = func.call @foo() : () -> (f8E4M3FN)
14-
%c = arith.addf %a, %b : f8E4M3FN
21+
%a1 = arith.constant 1.4 : f8E4M3FN
22+
%a2 = arith.constant 1.4 : f32
23+
%b1, %b2 = func.call @foo() : () -> (f8E4M3FN, f32)
24+
%c1 = arith.addf %a1, %b1 : f8E4M3FN // not supported by LLVM
25+
%c2 = arith.addf %a2, %b2 : f32 // supported by LLVM
1526

1627
// CHECK: 3.5
17-
vector.print %c : f8E4M3FN
28+
vector.print %c1 : f8E4M3FN
29+
30+
// CHECK: 3.6
31+
vector.print %c2 : f32
32+
1833
return
1934
}

0 commit comments

Comments
 (0)