[llvm] [llvm] Fix fabs simplification (PR #152825)

Oliver Hunt via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 21:01:22 PDT 2025


https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/152825

The existing code hits the std::optional<bool> is of comparing to a bool being "correct" for the std::optional and the intended comparison.

This corrects the comparison while reinforcing the idea that we need some way to diagnose this.

Fixes #152824

>From 01c27fd67f927523038853b8b14da8b84e23f0d4 Mon Sep 17 00:00:00 2001
From: Oliver Hunt <oliver at apple.com>
Date: Fri, 8 Aug 2025 20:58:57 -0700
Subject: [PATCH] [llvm] Fix fabs simplification

The existing code hits the std::optional<bool> is of comparing
to a bool being "correct" for the std::optional and the intended
comparison.

This corrects the comparison while reinforcing the idea that we
need some way to diagnose this.

Fixes #152824
---
 llvm/lib/Analysis/InstructionSimplify.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 5907e21065331..afe6275d0426e 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -6304,7 +6304,7 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
   Value *X;
   switch (IID) {
   case Intrinsic::fabs:
-    if (computeKnownFPSignBit(Op0, Q) == false)
+    if (*computeKnownFPSignBit(Op0, Q) == false)
       return Op0;
     break;
   case Intrinsic::bswap:



More information about the llvm-commits mailing list