-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have sufficient leading zero/sign bits #152273
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
12 commits
Select commit
Hold shift + click to select a range
80e303c
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 24287f7
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting c8cc2a9
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 1115256
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 08138a2
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 728b37d
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 44609a3
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 2d268fc
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 32041fb
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 4e1af14
Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have suffici…
houngkoungting c4ea7bd
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have s…
houngkoungting 6f84361
Merge branch 'main' into main
RKSimon 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,53 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=aarch64-- -O2 -mattr=+neon < %s | FileCheck %s | ||
RKSimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| define <8 x i8> @avgceil_u_i8_to_i16(<8 x i8> %a, <8 x i8> %b) { | ||
| ; CHECK-LABEL: avgceil_u_i8_to_i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: urhadd v0.8b, v0.8b, v1.8b | ||
| ; CHECK-NEXT: ret | ||
| %a16 = zext <8 x i8> %a to <8 x i16> | ||
| %b16 = zext <8 x i8> %b to <8 x i16> | ||
| %avg16 = call <8 x i16> @llvm.aarch64.neon.urhadd.v8i16(<8 x i16> %a16, <8 x i16> %b16) | ||
| %r = trunc <8 x i16> %avg16 to <8 x i8> | ||
| ret <8 x i8> %r | ||
| } | ||
RKSimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| define <8 x i8> @test_avgceil_s(<8 x i8> %a, <8 x i8> %b) { | ||
| ; CHECK-LABEL: test_avgceil_s: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: srhadd v0.8b, v0.8b, v1.8b | ||
| ; CHECK-NEXT: ret | ||
| %a16 = sext <8 x i8> %a to <8 x i16> | ||
| %b16 = sext <8 x i8> %b to <8 x i16> | ||
| %avg16 = call <8 x i16> @llvm.aarch64.neon.srhadd.v8i16(<8 x i16> %a16, <8 x i16> %b16) | ||
| %res = trunc <8 x i16> %avg16 to <8 x i8> | ||
| ret <8 x i8> %res | ||
| } | ||
|
|
||
| define <8 x i8> @avgfloor_u_i8_to_i16(<8 x i8> %a, <8 x i8> %b) { | ||
| ; CHECK-LABEL: avgfloor_u_i8_to_i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: uhadd v0.8b, v0.8b, v1.8b | ||
| ; CHECK-NEXT: ret | ||
| %a16 = zext <8 x i8> %a to <8 x i16> | ||
| %b16 = zext <8 x i8> %b to <8 x i16> | ||
| %avg16 = call <8 x i16> @llvm.aarch64.neon.uhadd.v8i16(<8 x i16> %a16, <8 x i16> %b16) | ||
| %res = trunc <8 x i16> %avg16 to <8 x i8> | ||
| ret <8 x i8> %res | ||
| } | ||
|
|
||
| define <8 x i8> @test_avgfloor_s(<8 x i8> %a, <8 x i8> %b) { | ||
| ; CHECK-LABEL: test_avgfloor_s: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: shadd v0.8b, v0.8b, v1.8b | ||
| ; CHECK-NEXT: ret | ||
| %a16 = sext <8 x i8> %a to <8 x i16> | ||
| %b16 = sext <8 x i8> %b to <8 x i16> | ||
| %avg16 = call <8 x i16> @llvm.aarch64.neon.shadd.v8i16(<8 x i16> %a16, <8 x i16> %b16) | ||
| %res = trunc <8 x i16> %avg16 to <8 x i8> | ||
| ret <8 x i8> %res | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
NeededLeadingZeros = SrcBits - DstBits;? (NeededSignBits is correct though you could use ComputeMaxSignificantBits instead if you wish)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.
Sorry I think you misunderstood - you need to use
computeKnownBits.countMinLeadingZeros() >= (SrcBits - DstBits)