Skip to content

Commit

Permalink
[CGP] Fix the detection of trivial case for addressing mode
Browse files Browse the repository at this point in the history
The address can be presented as a bitcast of baseReg.
In this case it is still trivial but OriginalValue != baseReg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316980 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Serguei Katkov committed Oct 31, 2017
1 parent 9091262 commit 49bad88
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2751,17 +2751,16 @@ struct ExtAddrMode : public TargetLowering::AddrMode {
return static_cast<FieldName>(Result);
}

// AddrModes with a base reg or gv where the reg/gv is just the original
// value are trivial.
// AddrModes with a baseReg or gv where the reg/gv is
// the only populated field are trivial.
bool isTrivial() {
bool Trivial = (BaseGV && BaseGV == OriginalValue) ||
(BaseReg && BaseReg == OriginalValue);
// If the AddrMode is trivial it shouldn't have an offset or be scaled.
if (Trivial) {
assert(BaseOffs == 0);
assert(Scale == 0);
}
return Trivial;
if (BaseGV && !BaseOffs && !Scale && !BaseReg)
return true;

if (!BaseGV && !BaseOffs && !Scale && BaseReg)
return true;

return false;
}
};

Expand Down

0 comments on commit 49bad88

Please sign in to comment.