forked from OSchip/llvm-project
Restrict sin/cos optimization to 64-bit only for now. 32-bit is a bit messy and less critical.
llvm-svn: 173987
This commit is contained in:
parent
3980b8c4cc
commit
d2ca4e2ed9
|
@ -1294,7 +1294,7 @@ X86TargetLowering::X86TargetLowering(X86TargetMachine &TM)
|
||||||
if (Subtarget->hasSinCos()) {
|
if (Subtarget->hasSinCos()) {
|
||||||
setLibcallName(RTLIB::SINCOS_F32, "sincosf");
|
setLibcallName(RTLIB::SINCOS_F32, "sincosf");
|
||||||
setLibcallName(RTLIB::SINCOS_F64, "sincos");
|
setLibcallName(RTLIB::SINCOS_F64, "sincos");
|
||||||
if (Subtarget->isTargetDarwin() && Subtarget->is64Bit()) {
|
if (Subtarget->isTargetDarwin()) {
|
||||||
// For MacOSX, we don't want to the normal expansion of a libcall to
|
// For MacOSX, we don't want to the normal expansion of a libcall to
|
||||||
// sincos. We want to issue a libcall to __sincos_stret to avoid memory
|
// sincos. We want to issue a libcall to __sincos_stret to avoid memory
|
||||||
// traffic.
|
// traffic.
|
||||||
|
@ -12037,7 +12037,7 @@ static SDValue LowerADDC_ADDE_SUBC_SUBE(SDValue Op, SelectionDAG &DAG) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue X86TargetLowering::LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const {
|
SDValue X86TargetLowering::LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const {
|
||||||
assert(Subtarget->isTargetDarwin());
|
assert(Subtarget->isTargetDarwin() && Subtarget->is64Bit());
|
||||||
|
|
||||||
// For MacOSX, we want to call an alternative entry point: __sincos_stret,
|
// For MacOSX, we want to call an alternative entry point: __sincos_stret,
|
||||||
// which returns the values in two XMM registers.
|
// which returns the values in two XMM registers.
|
||||||
|
@ -12055,17 +12055,20 @@ SDValue X86TargetLowering::LowerFSINCOS(SDValue Op, SelectionDAG &DAG) const {
|
||||||
Entry.isZExt = false;
|
Entry.isZExt = false;
|
||||||
Args.push_back(Entry);
|
Args.push_back(Entry);
|
||||||
|
|
||||||
|
// Only optimize x86_64 for now. i386 is a bit messy. For f32,
|
||||||
|
// the small struct {f32, f32} is returned in (eax, edx). For f64,
|
||||||
|
// the results are returned via SRet in memory.
|
||||||
const char *LibcallName = (ArgVT == MVT::f64)
|
const char *LibcallName = (ArgVT == MVT::f64)
|
||||||
? "__sincos_stret" : "__sincosf_stret";
|
? "__sincos_stret" : "__sincosf_stret";
|
||||||
SDValue Callee = DAG.getExternalSymbol(LibcallName, getPointerTy());
|
SDValue Callee = DAG.getExternalSymbol(LibcallName, getPointerTy());
|
||||||
|
|
||||||
StructType *RetTy = StructType::get(ArgTy, ArgTy, NULL);
|
StructType *RetTy = StructType::get(ArgTy, ArgTy, NULL);
|
||||||
TargetLowering::
|
TargetLowering::
|
||||||
CallLoweringInfo CLI(DAG.getEntryNode(), RetTy,
|
CallLoweringInfo CLI(DAG.getEntryNode(), RetTy,
|
||||||
false, false, false, false, 0,
|
false, false, false, false, 0,
|
||||||
CallingConv::C, /*isTaillCall=*/false,
|
CallingConv::C, /*isTaillCall=*/false,
|
||||||
/*doesNotRet=*/false, /*isReturnValueUsed*/true,
|
/*doesNotRet=*/false, /*isReturnValueUsed*/true,
|
||||||
Callee, Args, DAG, dl);
|
Callee, Args, DAG, dl);
|
||||||
std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
|
std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
|
||||||
return CallResult.first;
|
return CallResult.first;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,8 @@ const char *X86Subtarget::getBZeroEntry() const {
|
||||||
|
|
||||||
bool X86Subtarget::hasSinCos() const {
|
bool X86Subtarget::hasSinCos() const {
|
||||||
return getTargetTriple().isMacOSX() &&
|
return getTargetTriple().isMacOSX() &&
|
||||||
!getTargetTriple().isMacOSXVersionLT(10, 9);
|
!getTargetTriple().isMacOSXVersionLT(10, 9) &&
|
||||||
|
is64Bit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
|
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
|
||||||
|
|
Loading…
Reference in New Issue