diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-04-27 22:41:55 +0000 | 
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-04-27 22:41:55 +0000 | 
| commit | 406c471b69f2d079582b6d09a752d96e826f0535 (patch) | |
| tree | a8aa50b3ecc2519f5d08759498ba8978b42b6eeb /llvm/lib/Target/X86/X86FastISel.cpp | |
| parent | 121d27e9e432a6a59f1bf5c3d4b013cf482a53ce (diff) | |
| download | bcm5719-llvm-406c471b69f2d079582b6d09a752d96e826f0535.tar.gz bcm5719-llvm-406c471b69f2d079582b6d09a752d96e826f0535.zip | |
Make the fast-isel code for literal 0.0 a bit shorter/faster, since 0.0 is common.  rdar://problem/9303592 .
llvm-svn: 130338
Diffstat (limited to 'llvm/lib/Target/X86/X86FastISel.cpp')
| -rw-r--r-- | llvm/lib/Target/X86/X86FastISel.cpp | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index 2a5c6282d73..82ed9bad43b 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -124,6 +124,8 @@ private:    unsigned TargetMaterializeAlloca(const AllocaInst *C); +  unsigned TargetMaterializeFloatZero(const ConstantFP *CF); +    /// isScalarFPTypeInSSEReg - Return true if the specified scalar FP type is    /// computed in an SSE register, not on the X87 floating point stack.    bool isScalarFPTypeInSSEReg(EVT VT) const { @@ -2049,6 +2051,45 @@ unsigned X86FastISel::TargetMaterializeAlloca(const AllocaInst *C) {    return ResultReg;  } +unsigned X86FastISel::TargetMaterializeFloatZero(const ConstantFP *CF) { +  MVT VT; +  if (!isTypeLegal(CF->getType(), VT)) +    return false; + +  // Get opcode and regclass for the given zero. +  unsigned Opc = 0; +  const TargetRegisterClass *RC = NULL; +  switch (VT.SimpleTy) { +    default: return false; +    case MVT::f32: +      if (Subtarget->hasSSE1()) { +        Opc = X86::FsFLD0SS; +        RC  = X86::FR32RegisterClass; +      } else { +        Opc = X86::LD_Fp032; +        RC  = X86::RFP32RegisterClass; +      } +      break; +    case MVT::f64: +      if (Subtarget->hasSSE2()) { +        Opc = X86::FsFLD0SD; +        RC  = X86::FR64RegisterClass; +      } else { +        Opc = X86::LD_Fp064; +        RC  = X86::RFP64RegisterClass; +      } +      break; +    case MVT::f80: +      // No f80 support yet. +      return false; +  } + +  unsigned ResultReg = createResultReg(RC); +  BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc), ResultReg); +  return ResultReg; +} + +  /// TryToFoldLoad - The specified machine instr operand is a vreg, and that  /// vreg is being provided by the specified load instruction.  If possible,  /// try to fold the load as an operand to the instruction, returning true if | 

