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

Unified Diff: src/IceTargetLoweringX86BaseImpl.h

Issue 1371703003: Generate better two address code by using commutativity (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 3 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 | « src/IceInst.def ('k') | 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 ebdfb1e86b7e94dc86c2ad4f413da5dc754a41a0..d06474c1a602ab347fa66cb1d088467e93017ed9 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -1283,6 +1283,11 @@ void TargetX86Base<Machine>::lowerArithmetic(const InstArithmetic *Inst) {
std::swap(Src0, Src1);
if (llvm::isa<Constant>(Src0) && !llvm::isa<Constant>(Src1))
std::swap(Src0, Src1);
+ // Improve two-address code patterns by avoiding a copy to the dest
+ // register when one of the source operands ends its lifetime here.
+ if (!Inst->isLastUse(Src0) && Inst->isLastUse(Src1))
+ std::swap(Src0, Src1);
Jim Stichnoth 2015/09/25 21:12:09 I'm starting to get nervous about "swap wars". Co
sehr 2015/10/06 18:42:00 I added the counter.
+
}
if (!Traits::Is64Bit && Dest->getType() == IceType_i64) {
// These x86-32 helper-call-involved instructions are lowered in this
« no previous file with comments | « src/IceInst.def ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698