| 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);
|
| }
|
| }
|
|
|