diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-11 06:32:48 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-11 06:32:48 +0000 |
commit | 8c75adf95b330fce1ef7eced7a35b35e98237a10 (patch) | |
tree | 71d6d6bd2c91cb40defb8e2a65c1ee0544d8ba1f /llvm/lib/Transforms | |
parent | 7b0ad61eaa79414beef0b8188220d81a1ebc4e91 (diff) | |
download | bcm5719-llvm-8c75adf95b330fce1ef7eced7a35b35e98237a10.tar.gz bcm5719-llvm-8c75adf95b330fce1ef7eced7a35b35e98237a10.zip |
[InstCombine] Refinement of r299915. Only consider a ConstantVector for Neg if all the elements are Undef or ConstantInt.
llvm-svn: 299917
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 3c6f07e7fdd..4782f477e84 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -726,9 +726,20 @@ Value *InstCombiner::dyn_castNegVal(Value *V) const { if (C->getType()->getElementType()->isIntegerTy()) return ConstantExpr::getNeg(C); - if (ConstantVector *C = dyn_cast<ConstantVector>(V)) - if (C->getType()->getElementType()->isIntegerTy()) - return ConstantExpr::getNeg(C); + if (ConstantVector *CV = dyn_cast<ConstantVector>(V)) { + for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) { + Constant *Elt = CV->getAggregateElement(i); + if (!Elt) + return nullptr; + + if (isa<UndefValue>(Elt)) + continue; + + if (!isa<ConstantInt>(Elt)) + return nullptr; + } + return ConstantExpr::getNeg(CV); + } return nullptr; } |