diff options
author | Johannes Doerfert <jdoerfert@anl.gov> | 2019-07-15 03:24:35 +0000 |
---|---|---|
committer | Johannes Doerfert <jdoerfert@anl.gov> | 2019-07-15 03:24:35 +0000 |
commit | 2d63fbb7b1f7bbbd91f9f862946663a813e1780c (patch) | |
tree | 370a97cbd411250b7e21cbecac99ee44b2989062 /llvm/lib/Analysis | |
parent | 635d103e0be69342b65c251b7aa0e07bed418010 (diff) | |
download | bcm5719-llvm-2d63fbb7b1f7bbbd91f9f862946663a813e1780c.tar.gz bcm5719-llvm-2d63fbb7b1f7bbbd91f9f862946663a813e1780c.zip |
[ValueTracking] Look through constant Int2Ptr/Ptr2Int expressions
Summary:
This is analogous to the int2ptr/ptr2int instruction handling introduced
in D54956.
Reviewers: fhahn, efriedma, spatel, nlopes, sanjoy, lebedev.ri
Subscribers: hiraditya, bollu, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64708
llvm-svn: 366036
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index ad8034b2d7b..49a328bbc9b 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1998,6 +1998,15 @@ bool isKnownNonZero(const Value *V, unsigned Depth, const Query &Q) { // Must be non-zero due to null test above. return true; + if (auto *CE = dyn_cast<ConstantExpr>(C)) { + // See the comment for IntToPtr/PtrToInt instructions below. + if (CE->getOpcode() == Instruction::IntToPtr || + CE->getOpcode() == Instruction::PtrToInt) + if (Q.DL.getTypeSizeInBits(CE->getOperand(0)->getType()) <= + Q.DL.getTypeSizeInBits(CE->getType())) + return isKnownNonZero(CE->getOperand(0), Depth, Q); + } + // For constant vectors, check that all elements are undefined or known // non-zero to determine that the whole vector is known non-zero. if (auto *VecTy = dyn_cast<VectorType>(C->getType())) { |