-
Notifications
You must be signed in to change notification settings - Fork 15.8k
[SCCPSolver] Move getValueState to later #175307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If the IV is overDefined, there is no reason for us to init V0State.
|
@llvm/pr-subscribers-llvm-transforms Author: None (aokblast) ChangesIf the IV is overDefined, there is no reason for us to init V0State. Full diff: https://github.com/llvm/llvm-project/pull/175307.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 021bf0618754a..b5b7a7fbb587b 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1661,14 +1661,13 @@ void SCCPInstVisitor::visitSelectInst(SelectInst &I) {
// Handle Unary Operators.
void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
- ValueLatticeElement V0State = getValueState(I.getOperand(0));
-
ValueLatticeElement &IV = ValueState[&I];
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
// discover a concrete value later.
if (IV.isOverdefined())
return (void)markOverdefined(&I);
+ ValueLatticeElement V0State = getValueState(I.getOperand(0));
// If something is unknown/undef, wait for it to resolve.
if (V0State.isUnknownOrUndef())
return;
@@ -1687,13 +1686,13 @@ void SCCPInstVisitor::visitFreezeInst(FreezeInst &I) {
if (I.getType()->isStructTy())
return (void)markOverdefined(&I);
- ValueLatticeElement V0State = getValueState(I.getOperand(0));
ValueLatticeElement &IV = ValueState[&I];
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
// discover a concrete value later.
if (IV.isOverdefined())
return (void)markOverdefined(&I);
+ ValueLatticeElement V0State = getValueState(I.getOperand(0));
// If something is unknown/undef, wait for it to resolve.
if (V0State.isUnknownOrUndef())
return;
|
|
@llvm/pr-subscribers-function-specialization Author: None (aokblast) ChangesIf the IV is overDefined, there is no reason for us to init V0State. Full diff: https://github.com/llvm/llvm-project/pull/175307.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index 021bf0618754a..b5b7a7fbb587b 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -1661,14 +1661,13 @@ void SCCPInstVisitor::visitSelectInst(SelectInst &I) {
// Handle Unary Operators.
void SCCPInstVisitor::visitUnaryOperator(Instruction &I) {
- ValueLatticeElement V0State = getValueState(I.getOperand(0));
-
ValueLatticeElement &IV = ValueState[&I];
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
// discover a concrete value later.
if (IV.isOverdefined())
return (void)markOverdefined(&I);
+ ValueLatticeElement V0State = getValueState(I.getOperand(0));
// If something is unknown/undef, wait for it to resolve.
if (V0State.isUnknownOrUndef())
return;
@@ -1687,13 +1686,13 @@ void SCCPInstVisitor::visitFreezeInst(FreezeInst &I) {
if (I.getType()->isStructTy())
return (void)markOverdefined(&I);
- ValueLatticeElement V0State = getValueState(I.getOperand(0));
ValueLatticeElement &IV = ValueState[&I];
// resolvedUndefsIn might mark I as overdefined. Bail out, even if we would
// discover a concrete value later.
if (IV.isOverdefined())
return (void)markOverdefined(&I);
+ ValueLatticeElement V0State = getValueState(I.getOperand(0));
// If something is unknown/undef, wait for it to resolve.
if (V0State.isUnknownOrUndef())
return;
|
nikic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct due to iterator invalidation. The subsequent markConstant() calls on IV may use an invalidated pointer.
Hi! Thanks for your review. But I cannot get the point on how |
|
llvm-project/llvm/docs/ProgrammersManual.rst Lines 2416 to 2417 in bf01761
getValueState may insert new items into ValueState. |
Hi. Thanks for your explanation! I think we should move up |
|
Close this since I don't see any perceptabile acceleration after move upper. |
If the IV is overDefined, there is no reason for us to init V0State.