[llvm-commits] [llvm] r55021 - in /llvm/trunk: lib/CodeGen/SelectionDAG/FastISel.cpp test/CodeGen/X86/fast-isel.ll

Dan Gohman gohman at apple.com
Tue Aug 19 17:23:20 PDT 2008


Author: djg
Date: Tue Aug 19 19:23:20 2008
New Revision: 55021

URL: http://llvm.org/viewvc/llvm-project?rev=55021&view=rev
Log:
Add FastISel support for floating-point operations.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/trunk/test/CodeGen/X86/fast-isel.ll

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=55021&r1=55020&r2=55021&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Aug 19 19:23:20 2008
@@ -36,6 +36,7 @@
     // the given ISD opcode and type. Halt "fast" selection and bail.
     return false;
 
+  // We successfully emitted code for the given LLVM Instruction.
   ValueMap[I] = ResultReg;
   return true;
 }
@@ -53,12 +54,18 @@
 
   for (; I != End; ++I) {
     switch (I->getOpcode()) {
-    case Instruction::Add:
-      if (!SelectBinaryOp(I, ISD::ADD, ValueMap))  return I; break;
-    case Instruction::Sub:
-      if (!SelectBinaryOp(I, ISD::SUB, ValueMap))  return I; break;
-    case Instruction::Mul:
-      if (!SelectBinaryOp(I, ISD::MUL, ValueMap))  return I; break;
+    case Instruction::Add: {
+      ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FADD : ISD::ADD;
+      if (!SelectBinaryOp(I, Opc, ValueMap))  return I; break;
+    }
+    case Instruction::Sub: {
+      ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FSUB : ISD::SUB;
+      if (!SelectBinaryOp(I, Opc, ValueMap))  return I; break;
+    }
+    case Instruction::Mul: {
+      ISD::NodeType Opc = I->getType()->isFPOrFPVector() ? ISD::FMUL : ISD::MUL;
+      if (!SelectBinaryOp(I, Opc, ValueMap))  return I; break;
+    }
     case Instruction::SDiv:
       if (!SelectBinaryOp(I, ISD::SDIV, ValueMap)) return I; break;
     case Instruction::UDiv:

Modified: llvm/trunk/test/CodeGen/X86/fast-isel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=55021&r1=55020&r2=55021&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel.ll Tue Aug 19 19:23:20 2008
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc -fast-isel | grep add | count 1
+; RUN: llvm-as < %s | llc -fast-isel
 
 ; This tests very minimal fast-isel functionality.
 
@@ -21,3 +21,19 @@
   ret i32 %t5
 }
 
+define double @bar(double* %p, double* %q) {
+entry:
+  %r = load double* %p
+  %s = load double* %q
+  br label %fast
+
+fast:
+  %t0 = add double %r, %s
+  %t1 = mul double %t0, %s
+  %t2 = sub double %t1, %s
+  br label %exit
+
+exit:
+  ret double %t2
+}
+





More information about the llvm-commits mailing list