From 4fa3cfe7875b3cfaa3f90264589e8b0e714cc274 Mon Sep 17 00:00:00 2001 From: Hassnaa Hamdi Date: Wed, 14 May 2025 03:50:01 +0000 Subject: [PATCH 1/2] [ValueTracking][NFC]: Use injected condition to compute known FPClass --- llvm/include/llvm/Analysis/SimplifyQuery.h | 2 ++ llvm/lib/Analysis/ValueTracking.cpp | 4 ++++ 2 files changed, 6 insertions(+) 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 AffectedValues; CondContext(Value *Cond) : Cond(Cond) {} diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 3d403531cea2f..e7d937a0893ab 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; From 308e479325ad01d1938f361501eea691ce8ab8b6 Mon Sep 17 00:00:00 2001 From: Hassnaa Hamdi Date: Fri, 30 May 2025 16:44:40 +0000 Subject: [PATCH 2/2] Use !CondContext.Invert instead of CondIsTrue --- llvm/include/llvm/Analysis/SimplifyQuery.h | 2 -- llvm/lib/Analysis/ValueTracking.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/llvm/include/llvm/Analysis/SimplifyQuery.h b/llvm/include/llvm/Analysis/SimplifyQuery.h index 063ca4eaa9db0..e8f43c8c2e91f 100644 --- a/llvm/include/llvm/Analysis/SimplifyQuery.h +++ b/llvm/include/llvm/Analysis/SimplifyQuery.h @@ -62,8 +62,6 @@ 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 AffectedValues; CondContext(Value *Cond) : Cond(Cond) {} diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index e7d937a0893ab..025a4d3cf56e2 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -5015,7 +5015,7 @@ static KnownFPClass computeKnownFPClassFromContext(const Value *V, KnownFPClass KnownFromContext; if (Q.CC && Q.CC->AffectedValues.contains(V)) - computeKnownFPClassFromCond(V, Q.CC->Cond, 0, Q.CC->CondIsTrue, Q.CxtI, + computeKnownFPClassFromCond(V, Q.CC->Cond, 0, !Q.CC->Invert, Q.CxtI, KnownFromContext); if (!Q.CxtI)