-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Clang: ExprConstant use maxnum/minnum for fmax/fmin #129630
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang Author: YunQiang Su (wzssyqa) ChangesIn APFloat, we have defined maxnum and minnum, so let's use them directly here. Full diff: https://github.com/llvm/llvm-project/pull/129630.diff 1 Files Affected:
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index ef1d763009453..10076a69290f2 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15609,11 +15609,7 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
if (!EvaluateFloat(E->getArg(0), Result, Info) ||
!EvaluateFloat(E->getArg(1), RHS, Info))
return false;
- // When comparing zeroes, return +0.0 if one of the zeroes is positive.
- if (Result.isZero() && RHS.isZero() && Result.isNegative())
- Result = RHS;
- else if (Result.isNaN() || RHS > Result)
- Result = RHS;
+ Result = maxnum(Result, RHS);
return true;
}
@@ -15622,16 +15618,11 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
case Builtin::BI__builtin_fminl:
case Builtin::BI__builtin_fminf16:
case Builtin::BI__builtin_fminf128: {
- // TODO: Handle sNaN.
APFloat RHS(0.);
if (!EvaluateFloat(E->getArg(0), Result, Info) ||
!EvaluateFloat(E->getArg(1), RHS, Info))
return false;
- // When comparing zeroes, return -0.0 if one of the zeroes is negative.
- if (Result.isZero() && RHS.isZero() && RHS.isNegative())
- Result = RHS;
- else if (Result.isNaN() || RHS < Result)
- Result = RHS;
+ Result = minnum(Result, RHS);
return true;
}
|
In APFloat, we have defined maxnum and minnum, so let's use them directly here.
b76717f
to
9498907
Compare
arsenm
approved these changes
Mar 4, 2025
tbaederr
added a commit
to tbaederr/llvm-project
that referenced
this pull request
Mar 4, 2025
Equivalent of llvm#129630 for the bytecode interpreter.
tbaederr
added a commit
that referenced
this pull request
Mar 4, 2025
Equivalent of #129630 for the bytecode interpreter.
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Mar 4, 2025
…29643) Equivalent of llvm/llvm-project#129630 for the bytecode interpreter.
jph-13
pushed a commit
to jph-13/llvm-project
that referenced
this pull request
Mar 21, 2025
In APFloat, we have defined maxnum and minnum, so let's use them directly here. In `maxnum`/`minnum` of APFloat, we process sNaN, signed-zero as strictly as possible.
jph-13
pushed a commit
to jph-13/llvm-project
that referenced
this pull request
Mar 21, 2025
Equivalent of llvm#129630 for the bytecode interpreter.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In APFloat, we have defined maxnum and minnum, so let's use them directly here.
In
maxnum
/minnum
of APFloat, we process sNaN, signed-zero as strictly as possible.