[llvm] 094d129 - Revert "[ValueLattice] Fix getCompare() for undef values"
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 1 09:04:33 PDT 2022
Author: Nikita Popov
Date: 2022-11-01T17:03:40+01:00
New Revision: 094d1298d1a8c7eca942febf195fba0c1e54c3dc
URL: https://github.com/llvm/llvm-project/commit/094d1298d1a8c7eca942febf195fba0c1e54c3dc
DIFF: https://github.com/llvm/llvm-project/commit/094d1298d1a8c7eca942febf195fba0c1e54c3dc.diff
LOG: Revert "[ValueLattice] Fix getCompare() for undef values"
This reverts commit 6de41e6d7652b74a5aa2bd78b0597cc53a8c3c2a.
Missed a unit test affected by this change, revert for now.
Added:
Modified:
llvm/include/llvm/Analysis/ValueLattice.h
llvm/lib/Transforms/Utils/SCCPSolver.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ValueLattice.h b/llvm/include/llvm/Analysis/ValueLattice.h
index 7fe45d9f4dc96..bc6b279e9ed52 100644
--- a/llvm/include/llvm/Analysis/ValueLattice.h
+++ b/llvm/include/llvm/Analysis/ValueLattice.h
@@ -453,14 +453,8 @@ class ValueLatticeElement {
/// evaluated.
Constant *getCompare(CmpInst::Predicate Pred, Type *Ty,
const ValueLatticeElement &Other) const {
- // Not yet resolved.
- if (isUnknown() || Other.isUnknown())
- return nullptr;
-
- // TODO: Can be made more precise, but always returning undef would be
- // incorrect.
- if (isUndef() || isUndef())
- return nullptr;
+ if (isUnknownOrUndef() || Other.isUnknownOrUndef())
+ return UndefValue::get(Ty);
if (isConstant() && Other.isConstant())
return ConstantExpr::getCompare(Pred, getConstant(), Other.getConstant());
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 3d467f2fd68f9..a3455577a35c5 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1044,6 +1044,9 @@ void SCCPInstVisitor::visitCmpInst(CmpInst &I) {
Constant *C = V1State.getCompare(I.getPredicate(), I.getType(), V2State);
if (C) {
+ // TODO: getCompare() currently has incorrect handling for unknown/undef.
+ if (isa<UndefValue>(C))
+ return;
ValueLatticeElement CV;
CV.markConstant(C);
mergeInValue(&I, CV);
More information about the llvm-commits
mailing list