-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[llvm] Fix fabs simplification #152825
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
[llvm] Fix fabs simplification #152825
Conversation
@llvm/pr-subscribers-llvm-analysis Author: Oliver Hunt (ojhunt) ChangesThe 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:
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:
|
I can make a test for this at the clang level but this seems like it should be an llvm/ir test and I have no idea how to write it :D |
751516f
to
4bebc84
Compare
I realized it's possible I've just completely broken fabs-optimizations so I need to run more than clang tests :D |
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
4bebc84
to
47c862f
Compare
Ok, this is weird, I believe (based on other code) that this is the "correct" fix for this specific piece of code, but making that fix does not actually fix the original bug? |
Given |
Is that the conversion path that is actually happening? (and yes with more testing I found the actual issue is that in my first pass I was just disabling the optimization) I'm closing this PR for now, although independent of fixing anything I think this code would be clearer with the |
operator== is overloaded, so it's not literally doing the conversion, but yes. |
The existing code hits the std::optional 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