[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelSimple.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Apr 29 21:12:57 PDT 2005
Changes in directory llvm/lib/Target/X86:
X86ISelSimple.cpp updated: 1.315 -> 1.316
---
Log message:
Add support for llvm.sqrt and sin/cos if unsafe math optimizations are enabled.
---
Diffs of the changes: (+27 -0)
X86ISelSimple.cpp | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+)
Index: llvm/lib/Target/X86/X86ISelSimple.cpp
diff -u llvm/lib/Target/X86/X86ISelSimple.cpp:1.315 llvm/lib/Target/X86/X86ISelSimple.cpp:1.316
--- llvm/lib/Target/X86/X86ISelSimple.cpp:1.315 Thu Apr 28 16:48:42 2005
+++ llvm/lib/Target/X86/X86ISelSimple.cpp Fri Apr 29 23:12:40 2005
@@ -26,6 +26,7 @@
#include "llvm/CodeGen/SSARegMap.h"
#include "llvm/Target/MRegisterInfo.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/ADT/Statistic.h"
@@ -1744,6 +1745,25 @@
BuildMI(BB, X86::FABS, 1, DestReg).addReg(op1Reg);
return;
}
+ } else if (F->getName() == "sin" && UnsafeFPMath || F->getName() == "sinf") {
+ if (CI.getNumOperands() == 2 && // Basic sanity checks.
+ CI.getOperand(1)->getType()->isFloatingPoint() &&
+ CI.getType() == CI.getOperand(1)->getType()) {
+ unsigned op1Reg = getReg(CI.getOperand(1));
+ unsigned DestReg = getReg(CI);
+ BuildMI(BB, X86::FSIN, 1, DestReg).addReg(op1Reg);
+ return;
+ }
+ }
+ else if (F->getName() == "cos" && UnsafeFPMath || F->getName() == "cosf") {
+ if (CI.getNumOperands() == 2 && // Basic sanity checks.
+ CI.getOperand(1)->getType()->isFloatingPoint() &&
+ CI.getType() == CI.getOperand(1)->getType()) {
+ unsigned op1Reg = getReg(CI.getOperand(1));
+ unsigned DestReg = getReg(CI);
+ BuildMI(BB, X86::FCOS, 1, DestReg).addReg(op1Reg);
+ return;
+ }
}
// Emit a CALL instruction with PC-relative displacement.
@@ -1780,6 +1800,7 @@
case Intrinsic::memcpy:
case Intrinsic::memset:
case Intrinsic::isunordered:
+ case Intrinsic::sqrt:
case Intrinsic::readport:
case Intrinsic::writeport:
// We directly implement these intrinsics
@@ -1860,6 +1881,12 @@
BuildMI(BB, X86::SETPr, 0, TmpReg2);
return;
+ case Intrinsic::sqrt:
+ TmpReg1 = getReg(CI.getOperand(1));
+ TmpReg2 = getReg(CI);
+ BuildMI(BB, X86::FSQRT, 1, TmpReg2).addReg(TmpReg1);
+ return;
+
case Intrinsic::memcpy: {
assert(CI.getNumOperands() == 5 && "Illegal llvm.memcpy call!");
unsigned Align = 1;
More information about the llvm-commits
mailing list