Add support for FSQRT node, patch contributed by Morten Ofstad
authorChris Lattner <sabre@nondot.org>
Thu, 28 Apr 2005 22:07:18 +0000 (22:07 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 28 Apr 2005 22:07:18 +0000 (22:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21610 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelPattern.cpp

index bb9e901e1e71d076dc2862ef0724dd3dfadf0f74..d7ea0e3c8e6cb69f2f462ecf403ffa9a4b00e30d 100644 (file)
@@ -1830,12 +1830,16 @@ unsigned ISel::SelectExpr(SDOperand N) {
     return Result;
 
   case ISD::FABS:
-    Tmp1 = SelectExpr(Node->getOperand(0));
-    BuildMI(BB, X86::FABS, 1, Result).addReg(Tmp1);
-    return Result;
   case ISD::FNEG:
+  case ISD::FSQRT:
+    assert(N.getValueType()==MVT::f64 && "Illegal type for this operation");
     Tmp1 = SelectExpr(Node->getOperand(0));
-    BuildMI(BB, X86::FCHS, 1, Result).addReg(Tmp1);
+    switch (N.getOpcode()) {
+    default: assert(0 && "Unreachable!");
+    case ISD::FABS: BuildMI(BB, X86::FABS, 1, Result).addReg(Tmp1); break;
+    case ISD::FNEG: BuildMI(BB, X86::FCHS, 1, Result).addReg(Tmp1); break;
+    case ISD::FSQRT: BuildMI(BB, X86::FSQRT, 1, Result).addReg(Tmp1); break;
+    }
     return Result;
 
   case ISD::MULHU: