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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Oliver Hunt (ojhunt)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/152825.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/InstructionSimplify.cpp (+1-1) 


``````````diff
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:

``````````

</details>


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


More information about the llvm-commits mailing list