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

Side by Side Diff: src/IceTargetLoweringX86BaseImpl.h

Issue 2124973005: Selectively invert ICMP operands for better address optimization (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Address Comments Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/IceTargetLoweringX86Base.h ('k') | tests_lit/llvm2ice_tests/address-mode-opt.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 5636 matching lines...) Expand 10 before | Expand all | Expand 10 after
5647 // it doesn't need another level of transformation. 5647 // it doesn't need another level of transformation.
5648 Variable *DestLoad = Load->getDest(); 5648 Variable *DestLoad = Load->getDest();
5649 Type Ty = DestLoad->getType(); 5649 Type Ty = DestLoad->getType();
5650 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty); 5650 Operand *Src0 = formMemoryOperand(Load->getSourceAddress(), Ty);
5651 doMockBoundsCheck(Src0); 5651 doMockBoundsCheck(Src0);
5652 auto *Assign = InstAssign::create(Func, DestLoad, Src0); 5652 auto *Assign = InstAssign::create(Func, DestLoad, Src0);
5653 lowerAssign(Assign); 5653 lowerAssign(Assign);
5654 } 5654 }
5655 5655
5656 template <typename TraitsType> 5656 template <typename TraitsType>
5657 void TargetX86Base<TraitsType>::doAddressOptOther() {
5658 // Inverts some Icmp instructions which helps doAddressOptLoad later.
5659 // TODO(manasijm): Refactor to unify the conditions for Var0 and Var1
5660 Inst *Instr = Context.getCur();
5661 auto *VMetadata = Func->getVMetadata();
5662 if (auto *Icmp = llvm::dyn_cast<InstIcmp>(Instr)) {
5663 if (llvm::isa<Constant>(Icmp->getSrc(0)) ||
5664 llvm::isa<Constant>(Icmp->getSrc(1)))
5665 return;
5666 auto *Var0 = llvm::dyn_cast<Variable>(Icmp->getSrc(0));
5667 if (Var0 == nullptr)
5668 return;
5669 if (!VMetadata->isTracked(Var0))
5670 return;
5671 auto *Op0Def = VMetadata->getFirstDefinitionSingleBlock(Var0);
5672 if (Op0Def == nullptr || !llvm::isa<InstLoad>(Op0Def))
5673 return;
5674 if (VMetadata->getLocalUseNode(Var0) != Context.getNode())
5675 return;
5676
5677 auto *Var1 = llvm::dyn_cast<Variable>(Icmp->getSrc(1));
5678 if (Var1 != nullptr && VMetadata->isTracked(Var1)) {
5679 auto *Op1Def = VMetadata->getFirstDefinitionSingleBlock(Var1);
5680 if (Op1Def != nullptr && !VMetadata->isMultiBlock(Var1) &&
5681 llvm::isa<InstLoad>(Op1Def)) {
5682 return; // Both are loads
5683 }
5684 }
5685 Icmp->reverseConditionAndOperands();
5686 }
5687 }
5688
5689 template <typename TraitsType>
5657 void TargetX86Base<TraitsType>::doAddressOptLoad() { 5690 void TargetX86Base<TraitsType>::doAddressOptLoad() {
5658 Inst *Instr = Context.getCur(); 5691 Inst *Instr = Context.getCur();
5659 Operand *Addr = Instr->getSrc(0); 5692 Operand *Addr = Instr->getSrc(0);
5660 Variable *Dest = Instr->getDest(); 5693 Variable *Dest = Instr->getDest();
5661 if (auto *OptAddr = computeAddressOpt(Instr, Dest->getType(), Addr)) { 5694 if (auto *OptAddr = computeAddressOpt(Instr, Dest->getType(), Addr)) {
5662 Instr->setDeleted(); 5695 Instr->setDeleted();
5663 Context.insert<InstLoad>(Dest, OptAddr); 5696 Context.insert<InstLoad>(Dest, OptAddr);
5664 } 5697 }
5665 } 5698 }
5666 5699
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
8034 emitGlobal(*Var, SectionSuffix); 8067 emitGlobal(*Var, SectionSuffix);
8035 } 8068 }
8036 } 8069 }
8037 } break; 8070 } break;
8038 } 8071 }
8039 } 8072 }
8040 } // end of namespace X86NAMESPACE 8073 } // end of namespace X86NAMESPACE
8041 } // end of namespace Ice 8074 } // end of namespace Ice
8042 8075
8043 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H 8076 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX86Base.h ('k') | tests_lit/llvm2ice_tests/address-mode-opt.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698