-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[X86] Combine FRINT + FP_TO_SINT to LRINT #126477
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
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2225596
[X86] Combine FRINT + FP_TO_SINT to LRINT
phoebewang 9a70a3e
Remove fast math constraint
phoebewang f7eb84b
Add v2f64 / v4f64 cases and AVX test coverage
phoebewang d6a1fa3
Merge branch 'main' into rint
phoebewang 114d435
Check SSE2
phoebewang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86 | ||
| ; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefixes=X64 | ||
|
|
||
| define i32 @combine_f32(float %x) nounwind { | ||
| ; X86-LABEL: combine_f32: | ||
| ; X86: # %bb.0: # %entry | ||
| ; X86-NEXT: cvtss2si {{[0-9]+}}(%esp), %eax | ||
| ; X86-NEXT: retl | ||
| ; | ||
| ; X64-LABEL: combine_f32: | ||
| ; X64: # %bb.0: # %entry | ||
| ; X64-NEXT: cvtss2si %xmm0, %eax | ||
| ; X64-NEXT: retq | ||
| entry: | ||
| %0 = tail call float @llvm.rint.f32(float %x) | ||
| %1 = fptosi float %0 to i32 | ||
| ret i32 %1 | ||
| } | ||
|
|
||
| define i32 @combine_f64(double %x) nounwind { | ||
| ; X86-LABEL: combine_f64: | ||
| ; X86: # %bb.0: # %entry | ||
| ; X86-NEXT: cvtsd2si {{[0-9]+}}(%esp), %eax | ||
| ; X86-NEXT: retl | ||
| ; | ||
| ; X64-LABEL: combine_f64: | ||
| ; X64: # %bb.0: # %entry | ||
| ; X64-NEXT: cvtsd2si %xmm0, %eax | ||
| ; X64-NEXT: retq | ||
| entry: | ||
| %0 = tail call double @llvm.rint.f32(double %x) | ||
| %1 = fptosi double %0 to i32 | ||
| ret i32 %1 | ||
| } | ||
|
|
||
| define <4 x i32> @combine_v4f32(<4 x float> %x) nounwind { | ||
RKSimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; X86-LABEL: combine_v4f32: | ||
| ; X86: # %bb.0: # %entry | ||
| ; X86-NEXT: cvtps2dq %xmm0, %xmm0 | ||
| ; X86-NEXT: retl | ||
| ; | ||
| ; X64-LABEL: combine_v4f32: | ||
| ; X64: # %bb.0: # %entry | ||
| ; X64-NEXT: cvtps2dq %xmm0, %xmm0 | ||
| ; X64-NEXT: retq | ||
| entry: | ||
| %0 = tail call <4 x float> @llvm.rint.v4f32(<4 x float> %x) | ||
| %1 = fptosi <4 x float> %0 to <4 x i32> | ||
| ret <4 x i32> %1 | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this is OK if it fires for vcvtph2dq?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check soft float and no-sse+no-x87 to avoid creating libcalls with the wrong register? Maybe isTypeLegal for the FP type is enough?
Do we need to check f16 is legal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! We need to support LRINT for FP16 first: #127382
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. It is different with #126217, 1) we don't combine TRUNC this time, so we won't eliminate ZEXT; 2) we based on the fact the out of range result is UB. We don't care the result in this case.
I think it doesn't matter. 1) if the f16 is not legal, the ABI is broken, it's UB to the compiler; 2) we don't have f16 math library so far, the lowering for f16 FRINT/LRINT is not supported for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think creating libcalls with the wrong register class is in general a bad idea even we can't find a functional issue with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add checking for SSE2.