-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86][DAGCombiner] Skip x87 fp80 values in combineFMulOrFDivWithIntPow2
#128618
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
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-llvm-support @llvm/pr-subscribers-backend-x86 Author: Yingwei Zheng (dtcxzyw) Changesf80 is not a valid IEEE floating-point type. Full diff: https://github.com/llvm/llvm-project/pull/128618.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index a83be13ebff2b..7347923c7d33d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -17271,6 +17271,10 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
// prefer it.
SDValue DAGCombiner::combineFMulOrFDivWithIntPow2(SDNode *N) {
EVT VT = N->getValueType(0);
+ if (!Type::getFloatingPointTy(*DAG.getContext(), VT.getFltSemantics())
+ ->isIEEELikeFPTy())
+ return SDValue();
+
SDValue ConstOp, Pow2Op;
std::optional<int> Mantissa;
@@ -17297,8 +17301,8 @@ SDValue DAGCombiner::combineFMulOrFDivWithIntPow2(SDNode *N) {
const APFloat &APF = CFP->getValueAPF();
- // Make sure we have normal/ieee constant.
- if (!APF.isNormal() || !APF.isIEEE())
+ // Make sure we have normal constant.
+ if (!APF.isNormal())
return false;
// Make sure the floats exponent is within the bounds that this transform
diff --git a/llvm/test/CodeGen/X86/fold-int-pow2-with-fmul-or-fdiv.ll b/llvm/test/CodeGen/X86/fold-int-pow2-with-fmul-or-fdiv.ll
index e513b666ebf83..67c9e7cc22236 100644
--- a/llvm/test/CodeGen/X86/fold-int-pow2-with-fmul-or-fdiv.ll
+++ b/llvm/test/CodeGen/X86/fold-int-pow2-with-fmul-or-fdiv.ll
@@ -1688,3 +1688,31 @@ define float @fdiv_pow_shl_cnt32_okay(i32 %cnt) nounwind {
%mul = fdiv float 0x3a20000000000000, %conv
ret float %mul
}
+
+define x86_fp80 @pr128528(i1 %cond) {
+; CHECK-SSE-LABEL: pr128528:
+; CHECK-SSE: # %bb.0:
+; CHECK-SSE-NEXT: testb $1, %dil
+; CHECK-SSE-NEXT: movl $8, %eax
+; CHECK-SSE-NEXT: movl $1, %ecx
+; CHECK-SSE-NEXT: cmovnel %eax, %ecx
+; CHECK-SSE-NEXT: movl %ecx, -{{[0-9]+}}(%rsp)
+; CHECK-SSE-NEXT: fildl -{{[0-9]+}}(%rsp)
+; CHECK-SSE-NEXT: fmull {{\.?LCPI[0-9]+_[0-9]+}}(%rip)
+; CHECK-SSE-NEXT: retq
+;
+; CHECK-AVX-LABEL: pr128528:
+; CHECK-AVX: # %bb.0:
+; CHECK-AVX-NEXT: testb $1, %dil
+; CHECK-AVX-NEXT: movl $8, %eax
+; CHECK-AVX-NEXT: movl $1, %ecx
+; CHECK-AVX-NEXT: cmovnel %eax, %ecx
+; CHECK-AVX-NEXT: movl %ecx, -{{[0-9]+}}(%rsp)
+; CHECK-AVX-NEXT: fildl -{{[0-9]+}}(%rsp)
+; CHECK-AVX-NEXT: fmull {{\.?LCPI[0-9]+_[0-9]+}}(%rip)
+; CHECK-AVX-NEXT: retq
+ %sub9 = select i1 %cond, i32 8, i32 1
+ %conv = uitofp i32 %sub9 to x86_fp80
+ %mul = fmul x86_fp80 %conv, 0xK4007D055555555555800
+ ret x86_fp80 %mul
+}
|
arsenm
reviewed
Feb 25, 2025
arsenm
reviewed
Feb 25, 2025
arsenm
approved these changes
Feb 25, 2025
/cherry-pick 44d1dbd |
/pull-request #128717 |
swift-ci
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Feb 25, 2025
…ow2` (llvm#128618) f80 is not a valid IEEE floating-point type. Closes llvm#128528. (cherry picked from commit 44d1dbd)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
f80 is not a valid IEEE floating-point type.
Closes #128528.