]> granicus.if.org Git - llvm/commitdiff
[GlobalISel] Introduce a G_FSQRT generic instruction
authorJessica Paquette <jpaquette@apple.com>
Wed, 30 Jan 2019 20:49:50 +0000 (20:49 +0000)
committerJessica Paquette <jpaquette@apple.com>
Wed, 30 Jan 2019 20:49:50 +0000 (20:49 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352668 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/TargetOpcodes.def
include/llvm/Target/GenericOpcodes.td
include/llvm/Target/GlobalISel/SelectionDAGCompat.td
test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir

index 553db2e4c208ef53b049e00767925ac29dd73983..23d008a0147282bd7123d2f19de3cc60805cfc5a 100644 (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)
 
index 639ca1b8a09efd054d6592591bddfdec547dc7d1..24ea886c2d987da87fa82485f56c7091d237fbd1 100644 (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
 //------------------------------------------------------------------------------
index f5179b6c91588b538445119279130817fbb62e79..64915da4e9150bf94b3a620d4c169941dc7f7156 100644 (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
index cf4842caeb23dfa3db67fbb2401a19b647703f29..aea743ba611c3d6f51588bffece7161b2ab20744 100644 (file)
 #
 # 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