aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2022-12-26 13:12:44 -0500
committerSanjay Patel <spatel@rotateright.com>2022-12-26 13:16:03 -0500
commita0c8017286de0cc34db41bfe7ab3176ca4f8ae64 (patch)
treeb5cf483c8f557eeaecfa9b23b70fcb3d3dede662 /llvm/lib/IR/Constants.cpp
parent00c7840115fb742cd7278a5b3f5337990429ca47 (diff)
downloadllvm-a0c8017286de0cc34db41bfe7ab3176ca4f8ae64.zip
llvm-a0c8017286de0cc34db41bfe7ab3176ca4f8ae64.tar.gz
llvm-a0c8017286de0cc34db41bfe7ab3176ca4f8ae64.tar.bz2
[InstCombine] do not add "nuw" to 1<<X if the "1" has undefined elements
This was noted as a potential miscompile in the post-commit feedback for the patch that added this fold: d4493dd1ed58ac3f1eab0
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 9c8e299..a6c4c8b 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -337,6 +337,12 @@ bool Constant::containsPoisonElement() const {
this, [&](const auto *C) { return isa<PoisonValue>(C); });
}
+bool Constant::containsUndefElement() const {
+ return containsUndefinedElement(this, [&](const auto *C) {
+ return isa<UndefValue>(C) && !isa<PoisonValue>(C);
+ });
+}
+
bool Constant::containsConstantExpression() const {
if (auto *VTy = dyn_cast<FixedVectorType>(getType())) {
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)