-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[AArch64][Codegen]Transform saturating smull to sqdmulh #143671
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
9 commits
Select commit
Hold shift + click to select a range
211c1d4
[AArch64][Codegen]Transform saturating smull to sqdmulh
nasherm 5738dc3
Responding to review comments
nasherm f5a3619
Arithmetic error for Q types
nasherm 657f8f7
Responding to review comments
nasherm 7e977ac
Responding to review comments
nasherm a0873ee
Responding to review comments
nasherm 1bb0ad6
Response to review comments addressing:
nasherm c0298c8
Clang format
nasherm a6fc487
Review comments
nasherm 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
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,223 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc -mtriple=aarch64-none-elf < %s | FileCheck %s | ||
|
|
||
|
|
||
| define <2 x i16> @saturating_2xi16(<2 x i16> %a, <2 x i16> %b) { | ||
| ; CHECK-LABEL: saturating_2xi16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: shl v0.2s, v0.2s, #16 | ||
| ; CHECK-NEXT: shl v1.2s, v1.2s, #16 | ||
| ; CHECK-NEXT: sshr v0.2s, v0.2s, #16 | ||
| ; CHECK-NEXT: sshr v1.2s, v1.2s, #16 | ||
| ; CHECK-NEXT: sqdmulh v0.2s, v1.2s, v0.2s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <2 x i16> %a to <2 x i32> | ||
| %bs = sext <2 x i16> %b to <2 x i32> | ||
| %m = mul <2 x i32> %bs, %as | ||
| %sh = ashr <2 x i32> %m, splat (i32 15) | ||
| %ma = tail call <2 x i32> @llvm.smin.v4i32(<2 x i32> %sh, <2 x i32> splat (i32 32767)) | ||
| %t = trunc <2 x i32> %ma to <2 x i16> | ||
| ret <2 x i16> %t | ||
| } | ||
|
|
||
| define <4 x i16> @saturating_4xi16(<4 x i16> %a, <4 x i16> %b) { | ||
nasherm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; CHECK-LABEL: saturating_4xi16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: sqdmulh v0.4h, v1.4h, v0.4h | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <4 x i16> %a to <4 x i32> | ||
| %bs = sext <4 x i16> %b to <4 x i32> | ||
| %m = mul <4 x i32> %bs, %as | ||
| %sh = ashr <4 x i32> %m, splat (i32 15) | ||
| %ma = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %sh, <4 x i32> splat (i32 32767)) | ||
| %t = trunc <4 x i32> %ma to <4 x i16> | ||
| ret <4 x i16> %t | ||
| } | ||
|
|
||
| define <8 x i16> @saturating_8xi16(<8 x i16> %a, <8 x i16> %b) { | ||
| ; CHECK-LABEL: saturating_8xi16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: sqdmulh v0.8h, v1.8h, v0.8h | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <8 x i16> %a to <8 x i32> | ||
| %bs = sext <8 x i16> %b to <8 x i32> | ||
| %m = mul <8 x i32> %bs, %as | ||
| %sh = ashr <8 x i32> %m, splat (i32 15) | ||
| %ma = tail call <8 x i32> @llvm.smin.v8i32(<8 x i32> %sh, <8 x i32> splat (i32 32767)) | ||
| %t = trunc <8 x i32> %ma to <8 x i16> | ||
| ret <8 x i16> %t | ||
| } | ||
|
|
||
| define <2 x i32> @saturating_2xi32(<2 x i32> %a, <2 x i32> %b) { | ||
nasherm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; CHECK-LABEL: saturating_2xi32: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: sqdmulh v0.2s, v1.2s, v0.2s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <2 x i32> %a to <2 x i64> | ||
| %bs = sext <2 x i32> %b to <2 x i64> | ||
| %m = mul <2 x i64> %bs, %as | ||
| %sh = ashr <2 x i64> %m, splat (i64 31) | ||
| %ma = tail call <2 x i64> @llvm.smin.v8i64(<2 x i64> %sh, <2 x i64> splat (i64 2147483647)) | ||
| %t = trunc <2 x i64> %ma to <2 x i32> | ||
| ret <2 x i32> %t | ||
| } | ||
|
|
||
| define <4 x i32> @saturating_4xi32(<4 x i32> %a, <4 x i32> %b) { | ||
| ; CHECK-LABEL: saturating_4xi32: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: sqdmulh v0.4s, v1.4s, v0.4s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <4 x i32> %a to <4 x i64> | ||
| %bs = sext <4 x i32> %b to <4 x i64> | ||
| %m = mul <4 x i64> %bs, %as | ||
| %sh = ashr <4 x i64> %m, splat (i64 31) | ||
| %ma = tail call <4 x i64> @llvm.smin.v4i64(<4 x i64> %sh, <4 x i64> splat (i64 2147483647)) | ||
| %t = trunc <4 x i64> %ma to <4 x i32> | ||
| ret <4 x i32> %t | ||
| } | ||
|
|
||
| define <8 x i32> @saturating_8xi32(<8 x i32> %a, <8 x i32> %b) { | ||
| ; CHECK-LABEL: saturating_8xi32: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: sqdmulh v1.4s, v3.4s, v1.4s | ||
| ; CHECK-NEXT: sqdmulh v0.4s, v2.4s, v0.4s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <8 x i32> %a to <8 x i64> | ||
| %bs = sext <8 x i32> %b to <8 x i64> | ||
| %m = mul <8 x i64> %bs, %as | ||
| %sh = ashr <8 x i64> %m, splat (i64 31) | ||
| %ma = tail call <8 x i64> @llvm.smin.v8i64(<8 x i64> %sh, <8 x i64> splat (i64 2147483647)) | ||
| %t = trunc <8 x i64> %ma to <8 x i32> | ||
| ret <8 x i32> %t | ||
| } | ||
|
|
||
| define <2 x i64> @saturating_2xi32_2xi64(<2 x i32> %a, <2 x i32> %b) { | ||
| ; CHECK-LABEL: saturating_2xi32_2xi64: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: sqdmulh v0.2s, v1.2s, v0.2s | ||
| ; CHECK-NEXT: sshll v0.2d, v0.2s, #0 | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <2 x i32> %a to <2 x i64> | ||
| %bs = sext <2 x i32> %b to <2 x i64> | ||
| %m = mul <2 x i64> %bs, %as | ||
| %sh = ashr <2 x i64> %m, splat (i64 31) | ||
| %ma = tail call <2 x i64> @llvm.smin.v8i64(<2 x i64> %sh, <2 x i64> splat (i64 2147483647)) | ||
| ret <2 x i64> %ma | ||
| } | ||
|
|
||
| define <6 x i16> @saturating_6xi16(<6 x i16> %a, <6 x i16> %b) { | ||
| ; CHECK-LABEL: saturating_6xi16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: smull2 v3.4s, v1.8h, v0.8h | ||
| ; CHECK-NEXT: movi v2.4s, #127, msl #8 | ||
| ; CHECK-NEXT: sqdmulh v0.4h, v1.4h, v0.4h | ||
| ; CHECK-NEXT: sshr v3.4s, v3.4s, #15 | ||
| ; CHECK-NEXT: smin v2.4s, v3.4s, v2.4s | ||
| ; CHECK-NEXT: xtn2 v0.8h, v2.4s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <6 x i16> %a to <6 x i32> | ||
| %bs = sext <6 x i16> %b to <6 x i32> | ||
| %m = mul <6 x i32> %bs, %as | ||
| %sh = ashr <6 x i32> %m, splat (i32 15) | ||
| %ma = tail call <6 x i32> @llvm.smin.v6i32(<6 x i32> %sh, <6 x i32> splat (i32 32767)) | ||
| %t = trunc <6 x i32> %ma to <6 x i16> | ||
| ret <6 x i16> %t | ||
| } | ||
|
|
||
| define <4 x i16> @unsupported_saturation_value_v4i16(<4 x i16> %a, <4 x i16> %b) { | ||
| ; CHECK-LABEL: unsupported_saturation_value_v4i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: smull v0.4s, v1.4h, v0.4h | ||
| ; CHECK-NEXT: movi v1.4s, #42 | ||
| ; CHECK-NEXT: sshr v0.4s, v0.4s, #15 | ||
| ; CHECK-NEXT: smin v0.4s, v0.4s, v1.4s | ||
| ; CHECK-NEXT: xtn v0.4h, v0.4s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <4 x i16> %a to <4 x i32> | ||
| %bs = sext <4 x i16> %b to <4 x i32> | ||
| %m = mul <4 x i32> %bs, %as | ||
| %sh = ashr <4 x i32> %m, splat (i32 15) | ||
| %ma = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %sh, <4 x i32> splat (i32 42)) | ||
| %t = trunc <4 x i32> %ma to <4 x i16> | ||
| ret <4 x i16> %t | ||
| } | ||
|
|
||
| define <4 x i16> @unsupported_shift_value_v4i16(<4 x i16> %a, <4 x i16> %b) { | ||
| ; CHECK-LABEL: unsupported_shift_value_v4i16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: smull v0.4s, v1.4h, v0.4h | ||
| ; CHECK-NEXT: movi v1.4s, #127, msl #8 | ||
| ; CHECK-NEXT: sshr v0.4s, v0.4s, #3 | ||
| ; CHECK-NEXT: smin v0.4s, v0.4s, v1.4s | ||
| ; CHECK-NEXT: xtn v0.4h, v0.4s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <4 x i16> %a to <4 x i32> | ||
| %bs = sext <4 x i16> %b to <4 x i32> | ||
| %m = mul <4 x i32> %bs, %as | ||
| %sh = ashr <4 x i32> %m, splat (i32 3) | ||
| %ma = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %sh, <4 x i32> splat (i32 32767)) | ||
| %t = trunc <4 x i32> %ma to <4 x i16> | ||
| ret <4 x i16> %t | ||
| } | ||
|
|
||
| define <2 x i16> @extend_to_illegal_type(<2 x i16> %a, <2 x i16> %b) { | ||
| ; CHECK-LABEL: extend_to_illegal_type: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: shl v0.2s, v0.2s, #16 | ||
| ; CHECK-NEXT: shl v1.2s, v1.2s, #16 | ||
| ; CHECK-NEXT: sshr v0.2s, v0.2s, #16 | ||
| ; CHECK-NEXT: sshr v1.2s, v1.2s, #16 | ||
| ; CHECK-NEXT: sqdmulh v0.2s, v1.2s, v0.2s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <2 x i16> %a to <2 x i48> | ||
| %bs = sext <2 x i16> %b to <2 x i48> | ||
| %m = mul <2 x i48> %bs, %as | ||
| %sh = ashr <2 x i48> %m, splat (i48 15) | ||
| %ma = tail call <2 x i48> @llvm.smin.v4i32(<2 x i48> %sh, <2 x i48> splat (i48 32767)) | ||
| %t = trunc <2 x i48> %ma to <2 x i16> | ||
| ret <2 x i16> %t | ||
| } | ||
|
|
||
| define <2 x i11> @illegal_source(<2 x i11> %a, <2 x i11> %b) { | ||
| ; CHECK-LABEL: illegal_source: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: shl v0.2s, v0.2s, #21 | ||
| ; CHECK-NEXT: shl v1.2s, v1.2s, #21 | ||
| ; CHECK-NEXT: sshr v0.2s, v0.2s, #21 | ||
| ; CHECK-NEXT: sshr v1.2s, v1.2s, #21 | ||
| ; CHECK-NEXT: mul v0.2s, v1.2s, v0.2s | ||
| ; CHECK-NEXT: movi v1.2s, #127, msl #8 | ||
| ; CHECK-NEXT: sshr v0.2s, v0.2s, #15 | ||
| ; CHECK-NEXT: smin v0.2s, v0.2s, v1.2s | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <2 x i11> %a to <2 x i32> | ||
| %bs = sext <2 x i11> %b to <2 x i32> | ||
| %m = mul <2 x i32> %bs, %as | ||
| %sh = ashr <2 x i32> %m, splat (i32 15) | ||
| %ma = tail call <2 x i32> @llvm.smin.v2i32(<2 x i32> %sh, <2 x i32> splat (i32 32767)) | ||
| %t = trunc <2 x i32> %ma to <2 x i11> | ||
| ret <2 x i11> %t | ||
| } | ||
| define <1 x i16> @saturating_1xi16(<1 x i16> %a, <1 x i16> %b) { | ||
| ; CHECK-LABEL: saturating_1xi16: | ||
| ; CHECK: // %bb.0: | ||
| ; CHECK-NEXT: zip1 v0.4h, v0.4h, v0.4h | ||
| ; CHECK-NEXT: zip1 v1.4h, v1.4h, v0.4h | ||
| ; CHECK-NEXT: shl v0.2s, v0.2s, #16 | ||
| ; CHECK-NEXT: sshr v0.2s, v0.2s, #16 | ||
| ; CHECK-NEXT: shl v1.2s, v1.2s, #16 | ||
| ; CHECK-NEXT: sshr v1.2s, v1.2s, #16 | ||
| ; CHECK-NEXT: mul v0.2s, v1.2s, v0.2s | ||
| ; CHECK-NEXT: movi v1.2s, #127, msl #8 | ||
| ; CHECK-NEXT: sshr v0.2s, v0.2s, #15 | ||
| ; CHECK-NEXT: smin v0.2s, v0.2s, v1.2s | ||
| ; CHECK-NEXT: uzp1 v0.4h, v0.4h, v0.4h | ||
| ; CHECK-NEXT: ret | ||
| %as = sext <1 x i16> %a to <1 x i32> | ||
| %bs = sext <1 x i16> %b to <1 x i32> | ||
| %m = mul <1 x i32> %bs, %as | ||
| %sh = ashr <1 x i32> %m, splat (i32 15) | ||
| %ma = tail call <1 x i32> @llvm.smin.v1i32(<1 x i32> %sh, <1 x i32> splat (i32 32767)) | ||
| %t = trunc <1 x i32> %ma to <1 x i16> | ||
| ret <1 x i16> %t | ||
| } | ||
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.