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/IceTargetLoweringX8632.cpp

Issue 1193103005: Subzero: Apply commutativity to the RMW optimization. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Simplify the logic Created 5 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 | tests_lit/llvm2ice_tests/rmw.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 94ab396ccaffdbb52390180d8791bbab315095ab..938c6746cb827e78a60f7102dc5eaaaf63762596 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -689,10 +689,13 @@ void TargetX8632::findRMW() {
if (!isSameMemAddressOperand(Load->getSourceAddress(),
Store->getAddr()))
continue;
- if (false && Load->getSourceAddress() != Store->getAddr())
- continue;
- if (Arith->getSrc(0) != Load->getDest())
- continue;
+ Operand *ArithSrcFromLoad = Arith->getSrc(0);
+ Operand *ArithSrcOther = Arith->getSrc(1);
+ if (ArithSrcFromLoad != Load->getDest()) {
+ if (!Arith->isCommutative() || ArithSrcOther != Load->getDest())
+ continue;
+ std::swap(ArithSrcFromLoad, ArithSrcOther);
+ }
if (Arith->getDest() != Store->getData())
continue;
if (!canRMW(Arith))
@@ -712,8 +715,7 @@ void TargetX8632::findRMW() {
InstFakeDef *BeaconDef = InstFakeDef::create(Func, Beacon);
Node->getInsts().insert(I3, BeaconDef);
InstX8632FakeRMW *RMW = InstX8632FakeRMW::create(
- Func, Arith->getSrc(1), Store->getAddr(), Beacon,
- Arith->getOp());
+ Func, ArithSrcOther, Store->getAddr(), Beacon, Arith->getOp());
Node->getInsts().insert(I3, RMW);
}
}
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/rmw.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698