Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: src/IceTargetLoweringX86BaseImpl.h

Issue 2064073005: Subzero: Improve register availability peephole for function return values. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX86BaseImpl.h
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h
index fcfe6ed8114f5630c838ee5f9c4e9bcbe6d8b072..b28c00944af1149af8191627cae5a3e7079dd687 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -2688,7 +2688,7 @@ void TargetX86Base<TraitsType>::lowerCall(const InstCall *Instr) {
// Mark the call as killing all the caller-save registers.
Context.insert<InstFakeKill>(NewCall);
// Handle x86-32 floating point returns.
- if (Dest != nullptr && isScalarFloatingType(Dest->getType()) &&
+ if (Dest != nullptr && isScalarFloatingType(DestTy) &&
!Traits::X86_PASS_SCALAR_FP_IN_XMM) {
// Special treatment for an FP function which returns its result in st(0).
// If Dest ends up being a physical xmm register, the fstp emit code will
@@ -2706,14 +2706,19 @@ void TargetX86Base<TraitsType>::lowerCall(const InstCall *Instr) {
// Process the return value, if any.
if (Dest == nullptr)
return;
- // Assign the result of the call to Dest.
+ // Assign the result of the call to Dest. Route it through a temporary so
+ // that the local register availability peephole can be subsequently used.
+ Variable *Tmp = nullptr;
if (isVectorType(DestTy)) {
assert(ReturnReg && "Vector type requires a return register");
- _movp(Dest, ReturnReg);
+ Tmp = makeReg(DestTy);
+ _movp(Tmp, ReturnReg);
+ _movp(Dest, Tmp);
} else if (isScalarFloatingType(DestTy)) {
if (Traits::X86_PASS_SCALAR_FP_IN_XMM) {
assert(ReturnReg && "FP type requires a return register");
- _mov(Dest, ReturnReg);
+ _mov(Tmp, ReturnReg);
+ _mov(Dest, Tmp);
}
} else {
assert(isScalarIntegerType(DestTy));
@@ -2723,10 +2728,14 @@ void TargetX86Base<TraitsType>::lowerCall(const InstCall *Instr) {
auto *Dest64On32 = llvm::cast<Variable64On32>(Dest);
Variable *DestLo = Dest64On32->getLo();
Variable *DestHi = Dest64On32->getHi();
- _mov(DestLo, ReturnReg);
- _mov(DestHi, ReturnRegHi);
+ _mov(Tmp, ReturnReg);
+ _mov(DestLo, Tmp);
+ Variable *TmpHi = nullptr;
Eric Holk 2016/06/15 00:14:38 Why is it okay for TmpHi to be NULL?
Jim Stichnoth 2016/06/15 00:35:31 The _mov() method is "special" in that if the dest
+ _mov(TmpHi, ReturnRegHi);
+ _mov(DestHi, TmpHi);
} else {
- _mov(Dest, ReturnReg);
+ _mov(Tmp, ReturnReg);
+ _mov(Dest, Tmp);
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698