|
| 1 | +// Case 1: All floating-point arithmetics is lowered through APFloat. |
1 | 2 | // 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 |
4 | 12 |
|
5 | 13 | // 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 |
9 | 18 | } |
10 | 19 |
|
11 | 20 | 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 |
15 | 26 |
|
16 | 27 | // CHECK: 3.5 |
17 | | - vector.print %c : f8E4M3FN |
| 28 | + vector.print %c1 : f8E4M3FN |
| 29 | + |
| 30 | + // CHECK: 3.6 |
| 31 | + vector.print %c2 : f32 |
| 32 | + |
18 | 33 | return |
19 | 34 | } |
0 commit comments