diff options
author | Juneyoung Lee <aqjune@gmail.com> | 2020-11-27 11:04:04 +0900 |
---|---|---|
committer | Juneyoung Lee <aqjune@gmail.com> | 2020-11-29 02:28:40 +0900 |
commit | c6b62efb9103466b6cefca1bd99a5b04b4ced044 (patch) | |
tree | c39b23d7f4708eb878f748e2cb15e1538b144aa2 /llvm/lib/IR/Constants.cpp | |
parent | 47c902ba8479fc1faed73b86f59d58830df06644 (diff) | |
download | llvm-c6b62efb9103466b6cefca1bd99a5b04b4ced044.zip llvm-c6b62efb9103466b6cefca1bd99a5b04b4ced044.tar.gz llvm-c6b62efb9103466b6cefca1bd99a5b04b4ced044.tar.bz2 |
[ConstantFold] Fold operations to poison if possible
This patch updates ConstantFold, so operations are folded into poison if possible.
<alive2 proofs>
casts: https://alive2.llvm.org/ce/z/WSj7rw
binary operations (arithmetic): https://alive2.llvm.org/ce/z/_7dEyJ
binary operations (bitwise): https://alive2.llvm.org/ce/z/cezjVN
vector/aggregate operations: https://alive2.llvm.org/ce/z/BQ7hWz
unary ops: https://alive2.llvm.org/ce/z/yBRs4q
other ops: https://alive2.llvm.org/ce/z/iXbcFD
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D92203
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 764d32e..7ebe461 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -418,6 +418,9 @@ Constant *Constant::getAggregateElement(unsigned Elt) const { if (const auto *CAZ = dyn_cast<ConstantAggregateZero>(this)) return Elt < CAZ->getNumElements() ? CAZ->getElementValue(Elt) : nullptr; + if (const auto *PV = dyn_cast<PoisonValue>(this)) + return Elt < PV->getNumElements() ? PV->getElementValue(Elt) : nullptr; + if (const auto *UV = dyn_cast<UndefValue>(this)) return Elt < UV->getNumElements() ? UV->getElementValue(Elt) : nullptr; |