Index: include/llvm/Support/TargetOpcodes.def =================================================================== --- include/llvm/Support/TargetOpcodes.def +++ include/llvm/Support/TargetOpcodes.def @@ -526,6 +526,9 @@ /// 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) Index: include/llvm/Target/GenericOpcodes.td =================================================================== --- include/llvm/Target/GenericOpcodes.td +++ include/llvm/Target/GenericOpcodes.td @@ -569,6 +569,16 @@ 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 //------------------------------------------------------------------------------ Index: include/llvm/Target/GlobalISel/SelectionDAGCompat.td =================================================================== --- include/llvm/Target/GlobalISel/SelectionDAGCompat.td +++ include/llvm/Target/GlobalISel/SelectionDAGCompat.td @@ -91,6 +91,7 @@ def : GINodeEquiv; def : GINodeEquiv; def : GINodeEquiv; +def : GINodeEquiv; // Broadly speaking G_LOAD is equivalent to ISD::LOAD but there are some // complications that tablegen must take care of. For example, Predicates such Index: test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir =================================================================== --- test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir +++ test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir @@ -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