[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
; Test that floating-point instructions that set cc are *not* used to
|
|
|
|
; eliminate *strict* compares for load complement, load negative and load
|
|
|
|
; positive
|
|
|
|
;
|
|
|
|
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
|
|
|
|
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
|
|
|
|
|
|
|
|
; Load complement (sign-bit flipped).
|
|
|
|
; Test f32
|
|
|
|
define float @f1(float %a, float %b, float %f) #0 {
|
|
|
|
; CHECK-LABEL: f1:
|
|
|
|
; CHECK: ltebr
|
|
|
|
; CHECK-NEXT: ber %r14
|
|
|
|
%neg = fneg float %f
|
|
|
|
%cond = call i1 @llvm.experimental.constrained.fcmp.f32(
|
|
|
|
float %neg, float 0.0,
|
|
|
|
metadata !"oeq",
|
|
|
|
metadata !"fpexcept.strict") #0
|
|
|
|
%res = select i1 %cond, float %a, float %b
|
|
|
|
ret float %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f64
|
|
|
|
define double @f2(double %a, double %b, double %f) #0 {
|
|
|
|
; CHECK-LABEL: f2:
|
|
|
|
; CHECK: ltdbr
|
|
|
|
; CHECK-NEXT: ber %r14
|
|
|
|
%neg = fneg double %f
|
|
|
|
%cond = call i1 @llvm.experimental.constrained.fcmp.f64(
|
|
|
|
double %neg, double 0.0,
|
|
|
|
metadata !"oeq",
|
|
|
|
metadata !"fpexcept.strict") #0
|
|
|
|
%res = select i1 %cond, double %a, double %b
|
|
|
|
ret double %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Negation of floating-point absolute.
|
|
|
|
; Test f32
|
|
|
|
declare float @llvm.fabs.f32(float %f)
|
|
|
|
define float @f3(float %a, float %b, float %f) #0 {
|
|
|
|
; CHECK-LABEL: f3:
|
|
|
|
; CHECK: ltebr
|
|
|
|
; CHECK-NEXT: ber %r14
|
2020-05-30 00:17:23 +08:00
|
|
|
%abs = call float @llvm.fabs.f32(float %f) #0
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
%neg = fneg float %abs
|
|
|
|
%cond = call i1 @llvm.experimental.constrained.fcmp.f32(
|
|
|
|
float %neg, float 0.0,
|
|
|
|
metadata !"oeq",
|
|
|
|
metadata !"fpexcept.strict") #0
|
|
|
|
%res = select i1 %cond, float %a, float %b
|
|
|
|
ret float %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f64
|
|
|
|
declare double @llvm.fabs.f64(double %f)
|
|
|
|
define double @f4(double %a, double %b, double %f) #0 {
|
|
|
|
; CHECK-LABEL: f4:
|
|
|
|
; CHECK: ltdbr
|
|
|
|
; CHECK-NEXT: ber %r14
|
2020-05-30 00:17:23 +08:00
|
|
|
%abs = call double @llvm.fabs.f64(double %f) #0
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
%neg = fneg double %abs
|
|
|
|
%cond = call i1 @llvm.experimental.constrained.fcmp.f64(
|
|
|
|
double %neg, double 0.0,
|
|
|
|
metadata !"oeq",
|
|
|
|
metadata !"fpexcept.strict") #0
|
|
|
|
%res = select i1 %cond, double %a, double %b
|
|
|
|
ret double %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Absolute floating-point value.
|
|
|
|
; Test f32
|
|
|
|
define float @f5(float %a, float %b, float %f) #0 {
|
|
|
|
; CHECK-LABEL: f5:
|
|
|
|
; CHECK: ltebr
|
|
|
|
; CHECK-NEXT: ber %r14
|
2020-05-30 00:17:23 +08:00
|
|
|
%abs = call float @llvm.fabs.f32(float %f) #0
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
%cond = call i1 @llvm.experimental.constrained.fcmp.f32(
|
|
|
|
float %abs, float 0.0,
|
|
|
|
metadata !"oeq",
|
|
|
|
metadata !"fpexcept.strict") #0
|
|
|
|
%res = select i1 %cond, float %a, float %b
|
|
|
|
ret float %res
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test f64
|
|
|
|
define double @f6(double %a, double %b, double %f) #0 {
|
|
|
|
; CHECK-LABEL: f6:
|
|
|
|
; CHECK: ltdbr
|
|
|
|
; CHECK-NEXT: ber %r14
|
2020-05-30 00:17:23 +08:00
|
|
|
%abs = call double @llvm.fabs.f64(double %f) #0
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
%cond = call i1 @llvm.experimental.constrained.fcmp.f64(
|
|
|
|
double %abs, double 0.0,
|
|
|
|
metadata !"oeq",
|
|
|
|
metadata !"fpexcept.strict") #0
|
|
|
|
%res = select i1 %cond, double %a, double %b
|
|
|
|
ret double %res
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { strictfp }
|
|
|
|
|
|
|
|
declare i1 @llvm.experimental.constrained.fcmp.f32(float, float, metadata, metadata)
|
|
|
|
declare i1 @llvm.experimental.constrained.fcmp.f64(double, double, metadata, metadata)
|
|
|
|
|