[CGP] Fix the detection of trivial case for addressing mode

The address can be presented as a bitcast of baseReg.
In this case it is still trivial but OriginalValue != baseReg.

llvm-svn: 316980
This commit is contained in:
Serguei Katkov 2017-10-31 07:01:35 +00:00
parent 84286ce5dd
commit f66a59ee88
1 changed files with 9 additions and 10 deletions

View File

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