-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Hexagon] Optimize sfclass/dfclass compares #165735
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
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,86 @@ | ||
| ; Tests lowering of sfclass/dfclass compares. | ||
| ; Sub-optimal code | ||
| ; { | ||
| ; p0 = sfclass(r0,#16) | ||
| ; r0 = sfadd(r0,r0) | ||
| ; } | ||
| ; { | ||
| ; r2 = p0 | ||
| ; } | ||
| ; { | ||
| ; if (p0.new) r0 = ##1065353216 | ||
| ; p0 = cmp.eq(r2,#0) | ||
| ; jumpr r31 | ||
| ; } | ||
| ; With the patterns added, we should be generating | ||
| ; { | ||
| ; p0 = sfclass(r0,#16) | ||
| ; r0 = sfadd(r0,r0) | ||
| ; } | ||
| ; { | ||
| ; if (!p0) r0 = ##1065353216 | ||
| ; jumpr r31 | ||
| ; } | ||
|
|
||
| ; RUN: llc -march=hexagon -stop-after=hexagon-isel %s -o - | FileCheck %s | ||
|
|
||
| ; CHECK: bb.0.entry1 | ||
| ; CHECK: F2_sfclass | ||
| ; CHECK-NOT: C2_cmp | ||
| ; CHECK: C2_not | ||
| ; CHECK: F2_sfadd | ||
| ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) | ||
| define float @test1(float noundef %x) { | ||
| entry1: | ||
| %0 = tail call i32 @llvm.hexagon.F2.sfclass(float %x, i32 16) | ||
| %tobool.not = icmp eq i32 %0, 0 | ||
| %add = fadd float %x, %x | ||
| %spec.select = select i1 %tobool.not, float 1.000000e+00, float %add | ||
| ret float %spec.select | ||
| } | ||
|
|
||
| ; CHECK: bb.0.entry2 | ||
| ; CHECK: F2_sfclass | ||
| ; CHECK-NOT: C2_cmp | ||
| ; CHECK: F2_sfadd | ||
| define float @test2(float noundef %x) { | ||
| entry2: | ||
| %0 = tail call i32 @llvm.hexagon.F2.sfclass(float %x, i32 16) | ||
| %tobool.not = icmp eq i32 %0, 0 | ||
| %add = fadd float %x, %x | ||
| %spec.select = select i1 %tobool.not, float %add, float 1.000000e+00 | ||
| ret float %spec.select | ||
| } | ||
|
|
||
| ; CHECK: bb.0.entry3 | ||
| ; CHECK: F2_dfclass | ||
| ; CHECK-NOT: C2_cmp | ||
| ; CHECK: C2_not | ||
| ; CHECK: F2_dfadd | ||
| define double @test3(double noundef %x) { | ||
| entry3: | ||
| %0 = tail call i32 @llvm.hexagon.F2.dfclass(double %x, i32 16) | ||
| %tobool.not = icmp eq i32 %0, 0 | ||
| %add = fadd double %x, %x | ||
| %spec.select = select i1 %tobool.not, double 1.000000e+00, double %add | ||
| ret double %spec.select | ||
| } | ||
|
|
||
| ; CHECK: bb.0.entry4 | ||
| ; CHECK: F2_dfclass | ||
| ; CHECK-NOT: C2_cmp | ||
| ; CHECK: F2_dfadd | ||
| define double @test4(double noundef %x) { | ||
| entry4: | ||
| %0 = tail call i32 @llvm.hexagon.F2.dfclass(double %x, i32 16) | ||
| %tobool.not = icmp eq i32 %0, 0 | ||
| %add = fadd double %x, %x | ||
| %spec.select = select i1 %tobool.not, double %add, double 1.000000e+00 | ||
| ret double %spec.select | ||
| } | ||
|
|
||
| ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) | ||
| declare i32 @llvm.hexagon.F2.dfclass(double, i32 immarg) | ||
|
|
||
| ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) | ||
| declare i32 @llvm.hexagon.F2.sfclass(float, i32 immarg) |
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.
Inconsistent indentation between lines 3441 and 3443. Line 3441 uses 14 spaces while line 3443 uses 13 spaces. Both should use the same indentation to align with the opening parenthesis of the pattern's first argument, consistent with the style used in lines 3428 and 3430 above.