summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorJohn Brawn <john.brawn@arm.com>2017-11-27 11:29:15 +0000
committerJohn Brawn <john.brawn@arm.com>2017-11-27 11:29:15 +0000
commit4b476488baeb5216a46e51bcdff0c8de366260a5 (patch)
treee8211071c65f24617118da719ae47d64d776afbd /llvm/lib/CodeGen/CodeGenPrepare.cpp
parentf3c0aec9713ab5ed7a6a19f627680d376446b805 (diff)
downloadbcm5719-llvm-4b476488baeb5216a46e51bcdff0c8de366260a5.tar.gz
bcm5719-llvm-4b476488baeb5216a46e51bcdff0c8de366260a5.zip
[CGP] Fix handling of null pointer values in optimizeMemoryInst
The current way that trivial addressing modes are detected incorrectly thinks that null pointers are non-trivial, leading to an infinite loop where we keep duplicating the same select. Fix this by aware of null when deciding if an addressing mode is trivial. Differential Revision: https://reviews.llvm.org/D40447 llvm-svn: 319019
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 64c5db9b560..75f9f81c112 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2080,16 +2080,14 @@ struct ExtAddrMode : public TargetLowering::AddrMode {
return static_cast<FieldName>(Result);
}
- // AddrModes with a baseReg or gv where the reg/gv is
- // the only populated field are trivial.
+ // An AddrMode is trivial if it involves no calculation i.e. it is just a base
+ // with no offset.
bool isTrivial() {
- if (BaseGV && !BaseOffs && !Scale && !BaseReg)
- return true;
-
- if (!BaseGV && !BaseOffs && !Scale && BaseReg)
- return true;
-
- return false;
+ // An AddrMode is (BaseGV + BaseReg + BaseOffs + ScaleReg * Scale) so it is
+ // trivial if at most one of these terms is nonzero, except that BaseGV and
+ // BaseReg both being zero actually means a null pointer value, which we
+ // consider to be 'non-zero' here.
+ return !BaseOffs && !Scale && !(BaseGV && BaseReg);
}
Value *GetFieldAsValue(FieldName Field, Type *IntPtrTy) {
OpenPOWER on IntegriCloud