-
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 all 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,114 @@ | ||
| ; 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 | ||
| ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX | ||
|
|
||
| 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 | ||
| ; | ||
| ; AVX-LABEL: combine_f32: | ||
| ; AVX: # %bb.0: # %entry | ||
| ; AVX-NEXT: vcvtss2si %xmm0, %eax | ||
| ; AVX-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 | ||
| ; | ||
| ; AVX-LABEL: combine_f64: | ||
| ; AVX: # %bb.0: # %entry | ||
| ; AVX-NEXT: vcvtsd2si %xmm0, %eax | ||
| ; AVX-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 { | ||
| ; 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 | ||
| ; | ||
| ; AVX-LABEL: combine_v4f32: | ||
| ; AVX: # %bb.0: # %entry | ||
| ; AVX-NEXT: vcvtps2dq %xmm0, %xmm0 | ||
| ; AVX-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 | ||
| } | ||
|
|
||
| define <2 x i32> @combine_v2f64(<2 x double> %x) nounwind { | ||
| ; X86-LABEL: combine_v2f64: | ||
| ; X86: # %bb.0: # %entry | ||
| ; X86-NEXT: cvtpd2dq %xmm0, %xmm0 | ||
| ; X86-NEXT: retl | ||
| ; | ||
| ; X64-LABEL: combine_v2f64: | ||
| ; X64: # %bb.0: # %entry | ||
| ; X64-NEXT: cvtpd2dq %xmm0, %xmm0 | ||
| ; X64-NEXT: retq | ||
| ; | ||
| ; AVX-LABEL: combine_v2f64: | ||
| ; AVX: # %bb.0: # %entry | ||
| ; AVX-NEXT: vcvtpd2dq %xmm0, %xmm0 | ||
| ; AVX-NEXT: retq | ||
| entry: | ||
| %0 = tail call <2 x double> @llvm.rint.v2f64(<2 x double> %x) | ||
| %1 = fptosi <2 x double> %0 to <2 x i32> | ||
| ret <2 x i32> %1 | ||
| } | ||
|
|
||
| define <4 x i32> @combine_v4f64(<4 x double> %x) nounwind { | ||
| ; X86-LABEL: combine_v4f64: | ||
| ; X86: # %bb.0: # %entry | ||
| ; X86-NEXT: cvtpd2dq %xmm1, %xmm1 | ||
| ; X86-NEXT: cvtpd2dq %xmm0, %xmm0 | ||
| ; X86-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0] | ||
| ; X86-NEXT: retl | ||
| ; | ||
| ; X64-LABEL: combine_v4f64: | ||
| ; X64: # %bb.0: # %entry | ||
| ; X64-NEXT: cvtpd2dq %xmm1, %xmm1 | ||
| ; X64-NEXT: cvtpd2dq %xmm0, %xmm0 | ||
| ; X64-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0] | ||
| ; X64-NEXT: retq | ||
| ; | ||
| ; AVX-LABEL: combine_v4f64: | ||
| ; AVX: # %bb.0: # %entry | ||
| ; AVX-NEXT: vcvtpd2dq %ymm0, %xmm0 | ||
| ; AVX-NEXT: vzeroupper | ||
| ; AVX-NEXT: retq | ||
| entry: | ||
| %0 = tail call <4 x double> @llvm.rint.v4f64(<4 x double> %x) | ||
| %1 = fptosi <4 x double> %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.
Uh oh!
There was an error while loading. Please reload this page.