[GlobalISel] Introduce a G_FSQRT generic instruction

This introduces a generic instruction for computing the floating point
square root of a value.

Right now, we can't select @llvm.sqrt, so this is working towards fixing that.

llvm-svn: 352668
This commit is contained in:
Jessica Paquette 2019-01-30 20:49:50 +00:00
parent 5cdc91d003
commit 04a83a4cae
4 changed files with 17 additions and 0 deletions

View File

@ -526,6 +526,9 @@ HANDLE_TARGET_OPCODE(G_FCOS)
/// Floating point sine.
HANDLE_TARGET_OPCODE(G_FSIN)
/// Floating point square root.
HANDLE_TARGET_OPCODE(G_FSQRT)
/// Generic AddressSpaceCast.
HANDLE_TARGET_OPCODE(G_ADDRSPACE_CAST)

View File

@ -569,6 +569,16 @@ def G_FSIN : GenericInstruction {
let hasSideEffects = 0;
}
// Floating point square root of a value.
// This returns NaN for negative nonzero values.
// NOTE: Unlike libm sqrt(), this never sets errno. In all other respects it's
// libm-conformant.
def G_FSQRT : GenericInstruction {
let OutOperandList = (outs type0:$dst);
let InOperandList = (ins type0:$src1);
let hasSideEffects = 0;
}
//------------------------------------------------------------------------------
// Opcodes for LLVM Intrinsics
//------------------------------------------------------------------------------

View File

@ -91,6 +91,7 @@ def : GINodeEquiv<G_EXTRACT_VECTOR_ELT, vector_extract>;
def : GINodeEquiv<G_FCEIL, fceil>;
def : GINodeEquiv<G_FCOS, fcos>;
def : GINodeEquiv<G_FSIN, fsin>;
def : GINodeEquiv<G_FSQRT, fsqrt>;
// Broadly speaking G_LOAD is equivalent to ISD::LOAD but there are some
// complications that tablegen must take care of. For example, Predicates such

View File

@ -338,6 +338,9 @@
#
# DEBUG-NEXT: G_FSIN (opcode {{[0-9]+}}): 1 type index
# DEBUG: .. the first uncovered type index: 1, OK
#
# DEBUG-NEXT: G_FSQRT (opcode {{[0-9]+}}): 1 type index
# DEBUG: .. the first uncovered type index: 1, OK
# CHECK-NOT: ill-defined