aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-25 20:35:10 +0000
committerChris Lattner <sabre@nondot.org>2005-01-25 20:35:10 +0000
commit3576c84baf5c1a5e0fb37b48c67bb893397011b1 (patch)
treed5df57b4cb80e55bc2502d71a2bd4cd4bb821dbb
parent44129b5b68bf0d53ec21417b8b1c692aba8e6a46 (diff)
We can fold promoted and non-promoted loads into divs also!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19835 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/X86ISelPattern.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp
index d721baf2d8..caba4f6965 100644
--- a/lib/Target/X86/X86ISelPattern.cpp
+++ b/lib/Target/X86/X86ISelPattern.cpp
@@ -2034,6 +2034,34 @@ unsigned ISel::SelectExpr(SDOperand N) {
"We don't support this operator!");
if (N.getOpcode() == ISD::SDIV)
+
+ // We can fold loads into FpDIVs, but not really into any others.
+ if (N.getValueType() == MVT::f64) {
+ // Check for reversed and unreversed DIV.
+ if (isFoldableLoad(N.getOperand(0), N.getOperand(1), true)) {
+ if (N.getOperand(0).getOpcode() == ISD::EXTLOAD)
+ Opc = X86::FDIVR32m;
+ else
+ Opc = X86::FDIVR64m;
+ X86AddressMode AM;
+ EmitFoldedLoad(N.getOperand(0), AM);
+ Tmp1 = SelectExpr(N.getOperand(1));
+ addFullAddress(BuildMI(BB, Opc, 5, Result).addReg(Tmp1), AM);
+ return Result;
+ } else if (isFoldableLoad(N.getOperand(1), N.getOperand(0), true) &&
+ N.getOperand(1).getOpcode() == ISD::LOAD) {
+ if (N.getOperand(1).getOpcode() == ISD::EXTLOAD)
+ Opc = X86::FDIV32m;
+ else
+ Opc = X86::FDIV64m;
+ X86AddressMode AM;
+ EmitFoldedLoad(N.getOperand(1), AM);
+ Tmp1 = SelectExpr(N.getOperand(0));
+ addFullAddress(BuildMI(BB, Opc, 5, Result).addReg(Tmp1), AM);
+ return Result;
+ }
+ }
+
if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
// FIXME: These special cases should be handled by the lowering impl!
unsigned RHS = CN->getValue();