Skip to content

Commit 071643f

Browse files
authored
[mlir][llvm] Add llvm.experimental.constrained.fpext operation (#129054)
Ref: #86260
1 parent 91140e6 commit 071643f

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,15 @@ def LLVM_ConstrainedFPTruncIntr
468468
}];
469469
}
470470

471+
def LLVM_ConstrainedFPExtIntr
472+
: LLVM_ConstrainedIntr<"fpext", /*numArgs=*/1,
473+
/*overloadedResult=*/1, /*overloadedOperands=*/[0],
474+
/*hasRoundingMode=*/0> {
475+
let assemblyFormat = [{
476+
$arg_0 $fpExceptionBehavior attr-dict `:` type($arg_0) `to` type(results)
477+
}];
478+
}
479+
471480
// Intrinsics with multiple returns.
472481

473482
class LLVM_ArithWithOverflowOp<string mnem>

mlir/test/Target/LLVMIR/Import/intrinsic.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,19 @@ define void @experimental_constrained_fptrunc(double %s, <4 x double> %v) {
10341034
ret void
10351035
}
10361036

1037+
; CHECK-LABEL: experimental_constrained_fpext
1038+
define void @experimental_constrained_fpext(float %s, <4 x float> %v) {
1039+
; CHECK: llvm.intr.experimental.constrained.fpext %{{.*}} ignore : f32 to f64
1040+
%1 = call double @llvm.experimental.constrained.fpext.f64.f32(float %s, metadata !"fpexcept.ignore")
1041+
; CHECK: llvm.intr.experimental.constrained.fpext %{{.*}} maytrap : f32 to f64
1042+
%2 = call double @llvm.experimental.constrained.fpext.f64.f32(float %s, metadata !"fpexcept.maytrap")
1043+
; CHECK: llvm.intr.experimental.constrained.fpext %{{.*}} strict : f32 to f64
1044+
%3 = call double @llvm.experimental.constrained.fpext.f64.f32(float %s, metadata !"fpexcept.strict")
1045+
; CHECK: llvm.intr.experimental.constrained.fpext %{{.*}} ignore : vector<4xf32> to vector<4xf64>
1046+
%6 = call <4 x double> @llvm.experimental.constrained.fpext.v4f64.v4f32(<4 x float> %v, metadata !"fpexcept.ignore")
1047+
ret void
1048+
}
1049+
10371050
declare float @llvm.fmuladd.f32(float, float, float)
10381051
declare <8 x float> @llvm.fmuladd.v8f32(<8 x float>, <8 x float>, <8 x float>)
10391052
declare float @llvm.fma.f32(float, float, float)
@@ -1278,3 +1291,5 @@ declare <vscale x 4 x float> @llvm.vector.insert.nxv4f32.v4f32(<vscale x 4 x flo
12781291
declare <4 x float> @llvm.vector.extract.v4f32.nxv4f32(<vscale x 4 x float>, i64)
12791292
declare <4 x half> @llvm.experimental.constrained.fptrunc.v4f16.v4f64(<4 x double>, metadata, metadata)
12801293
declare float @llvm.experimental.constrained.fptrunc.f32.f64(double, metadata, metadata)
1294+
declare <4 x double> @llvm.experimental.constrained.fpext.v4f64.v4f32(<4 x float>, metadata)
1295+
declare double @llvm.experimental.constrained.fpext.f64.f32(float, metadata)

mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,23 @@ llvm.func @experimental_constrained_fptrunc(%s: f64, %v: vector<4xf32>) {
11311131
llvm.return
11321132
}
11331133

1134+
// CHECK-LABEL: @experimental_constrained_fpext
1135+
llvm.func @experimental_constrained_fpext(%s: f32, %v: vector<4xf32>) {
1136+
// CHECK: call double @llvm.experimental.constrained.fpext.f64.f32(
1137+
// CHECK: metadata !"fpexcept.ignore"
1138+
%0 = llvm.intr.experimental.constrained.fpext %s ignore : f32 to f64
1139+
// CHECK: call double @llvm.experimental.constrained.fpext.f64.f32(
1140+
// CHECK: metadata !"fpexcept.maytrap"
1141+
%1 = llvm.intr.experimental.constrained.fpext %s maytrap : f32 to f64
1142+
// CHECK: call double @llvm.experimental.constrained.fpext.f64.f32(
1143+
// CHECK: metadata !"fpexcept.strict"
1144+
%2 = llvm.intr.experimental.constrained.fpext %s strict : f32 to f64
1145+
// CHECK: call <4 x double> @llvm.experimental.constrained.fpext.v4f64.v4f32(
1146+
// CHECK: metadata !"fpexcept.strict"
1147+
%5 = llvm.intr.experimental.constrained.fpext %v strict : vector<4xf32> to vector<4xf64>
1148+
llvm.return
1149+
}
1150+
11341151
// Check that intrinsics are declared with appropriate types.
11351152
// CHECK-DAG: declare float @llvm.fma.f32(float, float, float)
11361153
// CHECK-DAG: declare <8 x float> @llvm.fma.v8f32(<8 x float>, <8 x float>, <8 x float>) #0

0 commit comments

Comments
 (0)