Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LLVM dialect: introduce fmuladd intrinsic as operation
This operation is important to achieve decent performance in computational kernels. In LLVM, it is implemented as an intrinsic (through function declaration and function call). Thanks to MLIR's extendable set of operations, it does not have to differentiate between built-ins and intrinsics, so fmuladd is introduced as a general type-polymorphic operation. Custom printing and parsing will be added later. PiperOrigin-RevId: 263106305
- Loading branch information
1 parent
88de8b2
commit 5f0a843
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
|
||
// CHECK-LABEL: @intrinsics | ||
func @intrinsics(%arg0: !llvm.float, %arg1: !llvm.float, %arg2: !llvm<"<8 x float>">) { | ||
// CHECK: call float @llvm.fmuladd.f32.f32.f32 | ||
"llvm.fmuladd"(%arg0, %arg1, %arg0) : (!llvm.float, !llvm.float, !llvm.float) -> !llvm.float | ||
// CHECK: call <8 x float> @llvm.fmuladd.v8f32.v8f32.v8f32 | ||
"llvm.fmuladd"(%arg2, %arg2, %arg2) : (!llvm<"<8 x float>">, !llvm<"<8 x float>">, !llvm<"<8 x float>">) -> !llvm<"<8 x float>"> | ||
llvm.return | ||
} | ||
|
||
// Check that intrinsics are declared with appropriate types. | ||
// CHECK: declare float @llvm.fmuladd.f32.f32.f32(float, float, float) | ||
// CHECK: declare <8 x float> @llvm.fmuladd.v8f32.v8f32.v8f32(<8 x float>, <8 x float>, <8 x float>) #0 | ||
|