[llvm] [ValueTracking][NFC]: Use injected condition to compute known FPClass (PR #139832)

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Tue May 13 21:57:40 PDT 2025


https://github.com/hassnaaHamdi updated https://github.com/llvm/llvm-project/pull/139832

>From 4fa3cfe7875b3cfaa3f90264589e8b0e714cc274 Mon Sep 17 00:00:00 2001
From: Hassnaa Hamdi <hassnaa.hamdi at arm.com>
Date: Wed, 14 May 2025 03:50:01 +0000
Subject: [PATCH] [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<Value *, 4> 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;
 



More information about the llvm-commits mailing list