[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
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 13bdad7..51f2a32 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2751,17 +2751,16 @@
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;
}
};