OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// |
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 // This file implements the TargetLoweringX8632 class, which | 10 // This file implements the TargetLoweringX8632 class, which |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 // RMW instruction is ignored during lowering because it is | 682 // RMW instruction is ignored during lowering because it is |
683 // redundant with the Store instruction. | 683 // redundant with the Store instruction. |
684 // | 684 // |
685 // Note that if "a" has further uses, the RMW transformation may | 685 // Note that if "a" has further uses, the RMW transformation may |
686 // still trigger, resulting in two loads and one store, which is | 686 // still trigger, resulting in two loads and one store, which is |
687 // worse than the original one load and one store. However, this is | 687 // worse than the original one load and one store. However, this is |
688 // probably rare, and caching probably keeps it just as fast. | 688 // probably rare, and caching probably keeps it just as fast. |
689 if (!isSameMemAddressOperand(Load->getSourceAddress(), | 689 if (!isSameMemAddressOperand(Load->getSourceAddress(), |
690 Store->getAddr())) | 690 Store->getAddr())) |
691 continue; | 691 continue; |
692 if (false && Load->getSourceAddress() != Store->getAddr()) | 692 Operand *ArithSrcFromLoad = Arith->getSrc(0); |
693 continue; | 693 Operand *ArithSrcOther = Arith->getSrc(1); |
694 if (Arith->getSrc(0) != Load->getDest()) | 694 if (ArithSrcFromLoad != Load->getDest()) { |
695 continue; | 695 if (!Arith->isCommutative() || ArithSrcOther != Load->getDest()) |
| 696 continue; |
| 697 std::swap(ArithSrcFromLoad, ArithSrcOther); |
| 698 } |
696 if (Arith->getDest() != Store->getData()) | 699 if (Arith->getDest() != Store->getData()) |
697 continue; | 700 continue; |
698 if (!canRMW(Arith)) | 701 if (!canRMW(Arith)) |
699 continue; | 702 continue; |
700 if (Func->isVerbose(IceV_RMW)) { | 703 if (Func->isVerbose(IceV_RMW)) { |
701 Str << "Found RMW in " << Func->getFunctionName() << ":\n "; | 704 Str << "Found RMW in " << Func->getFunctionName() << ":\n "; |
702 Load->dump(Func); | 705 Load->dump(Func); |
703 Str << "\n "; | 706 Str << "\n "; |
704 Arith->dump(Func); | 707 Arith->dump(Func); |
705 Str << "\n "; | 708 Str << "\n "; |
706 Store->dump(Func); | 709 Store->dump(Func); |
707 Str << "\n"; | 710 Str << "\n"; |
708 } | 711 } |
709 Variable *Beacon = Func->makeVariable(IceType_i32); | 712 Variable *Beacon = Func->makeVariable(IceType_i32); |
710 Beacon->setWeight(0); | 713 Beacon->setWeight(0); |
711 Store->setRmwBeacon(Beacon); | 714 Store->setRmwBeacon(Beacon); |
712 InstFakeDef *BeaconDef = InstFakeDef::create(Func, Beacon); | 715 InstFakeDef *BeaconDef = InstFakeDef::create(Func, Beacon); |
713 Node->getInsts().insert(I3, BeaconDef); | 716 Node->getInsts().insert(I3, BeaconDef); |
714 InstX8632FakeRMW *RMW = InstX8632FakeRMW::create( | 717 InstX8632FakeRMW *RMW = InstX8632FakeRMW::create( |
715 Func, Arith->getSrc(1), Store->getAddr(), Beacon, | 718 Func, ArithSrcOther, Store->getAddr(), Beacon, Arith->getOp()); |
716 Arith->getOp()); | |
717 Node->getInsts().insert(I3, RMW); | 719 Node->getInsts().insert(I3, RMW); |
718 } | 720 } |
719 } | 721 } |
720 } | 722 } |
721 } | 723 } |
722 } | 724 } |
723 } | 725 } |
724 | 726 |
725 namespace { | 727 namespace { |
726 | 728 |
(...skipping 4618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5345 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 5347 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
5346 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 5348 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
5347 } break; | 5349 } break; |
5348 } | 5350 } |
5349 } | 5351 } |
5350 | 5352 |
5351 TargetHeaderX8632::TargetHeaderX8632(GlobalContext *Ctx) | 5353 TargetHeaderX8632::TargetHeaderX8632(GlobalContext *Ctx) |
5352 : TargetHeaderLowering(Ctx) {} | 5354 : TargetHeaderLowering(Ctx) {} |
5353 | 5355 |
5354 } // end of namespace Ice | 5356 } // end of namespace Ice |
OLD | NEW |