-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[ValueTracking][NFC]: Use injected condition to compute known FPClass #139832
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
|
@llvm/pr-subscribers-llvm-analysis Author: Hassnaa Hamdi (hassnaaHamdi) ChangesFull diff: https://github.com/llvm/llvm-project/pull/139832.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Analysis/SimplifyQuery.h b/llvm/include/llvm/Analysis/SimplifyQuery.h
index e8f43c8c2e91f..063ca4eaa9db0 100644
--- a/llvm/include/llvm/Analysis/SimplifyQuery.h
+++ b/llvm/include/llvm/Analysis/SimplifyQuery.h
@@ -62,6 +62,8 @@ struct InstrInfoQuery {
struct CondContext {
Value *Cond;
bool Invert = false;
+ // Condition is true if CxtI is in the true successor of Cond.
+ bool CondIsTrue = false;
SmallPtrSet<Value *, 4> AffectedValues;
CondContext(Value *Cond) : Cond(Cond) {}
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3d403531cea2f..527e8c549c04f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5014,6 +5014,10 @@ static KnownFPClass computeKnownFPClassFromContext(const Value *V,
const SimplifyQuery &Q) {
KnownFPClass KnownFromContext;
+ if (Q.CC && Q.CC->AffectedValues.contains(V))
+ computeKnownFPClassFromCond(V, Q.CC->Cond, 0, Q.CC->CondIsTrue,
+ Q.CxtI, KnownFromContext);
+
if (!Q.CxtI)
return KnownFromContext;
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| Value *Cond; | ||
| bool Invert = false; | ||
| // Condition is true if CxtI is in the true successor of Cond. | ||
| bool CondIsTrue = false; |
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 what Invert is for. (Or rather !Invert in this context.)
llvm/lib/Analysis/ValueTracking.cpp
Outdated
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.
| computeKnownFPClassFromCond(V, Q.CC->Cond, 0, Q.CC->Invert, Q.CxtI, | |
| computeKnownFPClassFromCond(V, Q.CC->Cond, 0, !Q.CC->Invert, Q.CxtI, |
This accepts CondIsTrue, so we should pass true for Invert=false.
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.
LGTM
No description provided.