| Index: src/IceInst.cpp
|
| diff --git a/src/IceInst.cpp b/src/IceInst.cpp
|
| index 2d67f377be8278c45e9d9dd84c5656c5e5152db7..2ffb0ccc1316195c87d77f448a84124b19da9e04 100644
|
| --- a/src/IceInst.cpp
|
| +++ b/src/IceInst.cpp
|
| @@ -1090,9 +1090,10 @@ void InstIcmp::reverseConditionAndOperands() {
|
| Condition = InstIcmpAttributes[Condition].Reverse;
|
| std::swap(Srcs[0], Srcs[1]);
|
| }
|
| +
|
| bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
|
| const auto *SrcVar = llvm::dyn_cast<const Variable>(Source);
|
| - if (!SrcVar)
|
| + if (SrcVar == nullptr)
|
| return false;
|
| if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) {
|
| // TODO: On x86-64, instructions like "mov eax, eax" are used to clear the
|
| @@ -1101,6 +1102,8 @@ bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
|
| }
|
| if (!Dest->hasReg() && !SrcVar->hasReg()) {
|
| if (!Dest->hasStackOffset() || !SrcVar->hasStackOffset()) {
|
| + // If called before stack slots have been assigned (i.e. as part of the
|
| + // dump() routine), conservatively return false.
|
| return false;
|
| }
|
| if (Dest->getStackOffset() != SrcVar->getStackOffset()) {
|
| @@ -1108,6 +1111,15 @@ bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
|
| }
|
| return true;
|
| }
|
| + // For a "v=t" assignment where t has a register, v has a stack slot, and v
|
| + // has a LinkedTo stack root, and v and t share the same LinkedTo root, return
|
| + // true. This is because this assignment is effectively reassigning the same
|
| + // value to the original LinkedTo stack root.
|
| + if (SrcVar->hasReg() && Dest->hasStackOffset() &&
|
| + Dest->getLinkedToStackRoot() != nullptr &&
|
| + Dest->getLinkedToRoot() == SrcVar->getLinkedToRoot()) {
|
| + return true;
|
| + }
|
| return false;
|
| }
|
|
|
|
|