summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorZvi Rackover <zvi.rackover@intel.com>2018-01-24 17:22:00 +0000
committerZvi Rackover <zvi.rackover@intel.com>2018-01-24 17:22:00 +0000
commit51f0d64b9cd847f7637e5c480016a6f6e9fad173 (patch)
tree5e6833ea3af0816376021896ee7cd5be6b1dfb54 /llvm/lib/Analysis/InstructionSimplify.cpp
parent262ed0ecd715afe3e1c0194a80317e3d342ebc5c (diff)
downloadbcm5719-llvm-51f0d64b9cd847f7637e5c480016a6f6e9fad173.tar.gz
bcm5719-llvm-51f0d64b9cd847f7637e5c480016a6f6e9fad173.zip
InstSimplify: If divisor element is undef simplify to undef
Summary: If any vector divisor element is undef, we can arbitrarily choose it be zero which would make the div/rem an undef value by definition. Reviewers: spatel, reames Reviewed By: spatel Subscribers: magabari, llvm-commits Differential Revision: https://reviews.llvm.org/D42485 llvm-svn: 323343
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 245133fb912..a258c4df898 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -868,13 +868,14 @@ static Value *simplifyDivRem(Value *Op0, Value *Op1, bool IsDiv) {
if (match(Op1, m_Zero()))
return UndefValue::get(Ty);
- // If any element of a constant divisor vector is zero, the whole op is undef.
+ // If any element of a constant divisor vector is zero or undef, the whole op
+ // is undef.
auto *Op1C = dyn_cast<Constant>(Op1);
if (Op1C && Ty->isVectorTy()) {
unsigned NumElts = Ty->getVectorNumElements();
for (unsigned i = 0; i != NumElts; ++i) {
Constant *Elt = Op1C->getAggregateElement(i);
- if (Elt && Elt->isNullValue())
+ if (Elt && (Elt->isNullValue() || isa<UndefValue>(Elt)))
return UndefValue::get(Ty);
}
}
OpenPOWER on IntegriCloud