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

Unified 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 side-by-side diff with in-line comments
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 »
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 435332bbef78b3c474ec461a2d94a0472f73e45d..3bc1dde740bba81f1f13453985fd584d7f352f9d 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -5654,6 +5654,39 @@ void TargetX86Base<TraitsType>::lowerLoad(const InstLoad *Load) {
}
template <typename TraitsType>
+void TargetX86Base<TraitsType>::doAddressOptOther() {
+ // Inverts some Icmp instructions which helps doAddressOptLoad later.
+ // TODO(manasijm): Refactor to unify the conditions for Var0 and Var1
+ Inst *Instr = Context.getCur();
+ auto *VMetadata = Func->getVMetadata();
+ if (auto *Icmp = llvm::dyn_cast<InstIcmp>(Instr)) {
+ if (llvm::isa<Constant>(Icmp->getSrc(0)) ||
+ llvm::isa<Constant>(Icmp->getSrc(1)))
+ return;
+ auto *Var0 = llvm::dyn_cast<Variable>(Icmp->getSrc(0));
+ if (Var0 == nullptr)
+ return;
+ if (!VMetadata->isTracked(Var0))
+ return;
+ auto *Op0Def = VMetadata->getFirstDefinitionSingleBlock(Var0);
+ if (Op0Def == nullptr || !llvm::isa<InstLoad>(Op0Def))
+ return;
+ if (VMetadata->getLocalUseNode(Var0) != Context.getNode())
+ return;
+
+ auto *Var1 = llvm::dyn_cast<Variable>(Icmp->getSrc(1));
+ if (Var1 != nullptr && VMetadata->isTracked(Var1)) {
+ auto *Op1Def = VMetadata->getFirstDefinitionSingleBlock(Var1);
+ if (Op1Def != nullptr && !VMetadata->isMultiBlock(Var1) &&
+ llvm::isa<InstLoad>(Op1Def)) {
+ return; // Both are loads
+ }
+ }
+ Icmp->reverseConditionAndOperands();
+ }
+}
+
+template <typename TraitsType>
void TargetX86Base<TraitsType>::doAddressOptLoad() {
Inst *Instr = Context.getCur();
Operand *Addr = Instr->getSrc(0);
« 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