-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[DAG] Constant fold ISD::FSHL/FSHR nodes #154480
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 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
de442b6
[SelectionDAG] NFC. Add constant fold testcases for fshl/fshr
XChy d1a1e48
[SelectionDAG] Constant fold ISD:FSHL/FSHR nodes
XChy 1892862
Refactor to folding ternary arithmetic operator
XChy 8b607f9
add const reference
XChy aa2f225
remove assertion
XChy 4c42db6
resolve comment
XChy 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,149 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,CHECK-EXPAND | ||
| ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512vl,+avx512vbmi2 | FileCheck %s --check-prefixes=CHECK,CHECK-UNEXPAND | ||
|
|
||
| define <4 x i32> @test_fshl_constants() { | ||
| ; CHECK-EXPAND-LABEL: test_fshl_constants: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vmovaps {{.*#+}} xmm0 = [0,512,2048,6144] | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshl_constants: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpmovsxwd {{.*#+}} xmm0 = [0,512,2048,6144] | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32> <i32 8, i32 9, i32 10, i32 11>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshl_splat_constants() { | ||
| ; CHECK-LABEL: test_fshl_splat_constants: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vbroadcastss {{.*#+}} xmm0 = [256,256,256,256] | ||
| ; CHECK-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 4, i32 4, i32 4, i32 4>, <4 x i32> <i32 8, i32 8, i32 8, i32 8>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshl_two_constants(<4 x i32> %a) { | ||
| ; CHECK-EXPAND-LABEL: test_fshl_two_constants: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshl_two_constants: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpmovsxbd {{.*#+}} xmm1 = [4,5,6,7] | ||
| ; CHECK-UNEXPAND-NEXT: vpshldvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm0 | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %a, <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32> <i32 8, i32 9, i32 10, i32 11>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshl_one_constant(<4 x i32> %a, <4 x i32> %b) { | ||
| ; CHECK-EXPAND-LABEL: test_fshl_one_constant: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vpsrlvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1 | ||
| ; CHECK-EXPAND-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: vpor %xmm1, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshl_one_constant: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpshldvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm0 | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 8, i32 9, i32 10, i32 11>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshl_none_constant(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { | ||
| ; CHECK-EXPAND-LABEL: test_fshl_none_constant: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vpbroadcastd {{.*#+}} xmm3 = [31,31,31,31] | ||
| ; CHECK-EXPAND-NEXT: vpandn %xmm3, %xmm2, %xmm4 | ||
| ; CHECK-EXPAND-NEXT: vpsrld $1, %xmm1, %xmm1 | ||
| ; CHECK-EXPAND-NEXT: vpsrlvd %xmm4, %xmm1, %xmm1 | ||
| ; CHECK-EXPAND-NEXT: vpand %xmm3, %xmm2, %xmm2 | ||
| ; CHECK-EXPAND-NEXT: vpsllvd %xmm2, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: vpor %xmm1, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshl_none_constant: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpshldvd %xmm2, %xmm1, %xmm0 | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshr_constants() { | ||
| ; CHECK-LABEL: test_fshr_constants: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vmovaps {{.*#+}} xmm0 = [0,8388608,8388608,6291456] | ||
| ; CHECK-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32> <i32 8, i32 9, i32 10, i32 11>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshr_two_constants(<4 x i32> %a) { | ||
| ; CHECK-EXPAND-LABEL: test_fshr_two_constants: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshr_two_constants: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpmovsxbd {{.*#+}} xmm1 = [4,5,6,7] | ||
| ; CHECK-UNEXPAND-NEXT: vpshrdvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1 | ||
| ; CHECK-UNEXPAND-NEXT: vmovdqa %xmm1, %xmm0 | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %a, <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32> <i32 8, i32 9, i32 10, i32 11>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshr_one_constant(<4 x i32> %a, <4 x i32> %b) { | ||
| ; CHECK-EXPAND-LABEL: test_fshr_one_constant: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vpsrlvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1 | ||
| ; CHECK-EXPAND-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: vpor %xmm1, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshr_one_constant: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpshrdvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1 | ||
| ; CHECK-UNEXPAND-NEXT: vmovdqa %xmm1, %xmm0 | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 8, i32 9, i32 10, i32 11>) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshr_none_constant(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) { | ||
| ; CHECK-EXPAND-LABEL: test_fshr_none_constant: | ||
| ; CHECK-EXPAND: # %bb.0: | ||
| ; CHECK-EXPAND-NEXT: vpbroadcastd {{.*#+}} xmm3 = [31,31,31,31] | ||
| ; CHECK-EXPAND-NEXT: vpand %xmm3, %xmm2, %xmm4 | ||
| ; CHECK-EXPAND-NEXT: vpsrlvd %xmm4, %xmm1, %xmm1 | ||
| ; CHECK-EXPAND-NEXT: vpandn %xmm3, %xmm2, %xmm2 | ||
| ; CHECK-EXPAND-NEXT: vpaddd %xmm0, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: vpsllvd %xmm2, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: vpor %xmm1, %xmm0, %xmm0 | ||
| ; CHECK-EXPAND-NEXT: retq | ||
| ; | ||
| ; CHECK-UNEXPAND-LABEL: test_fshr_none_constant: | ||
| ; CHECK-UNEXPAND: # %bb.0: | ||
| ; CHECK-UNEXPAND-NEXT: vpshrdvd %xmm2, %xmm0, %xmm1 | ||
| ; CHECK-UNEXPAND-NEXT: vmovdqa %xmm1, %xmm0 | ||
| ; CHECK-UNEXPAND-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) | ||
| ret <4 x i32> %res | ||
| } | ||
|
|
||
| define <4 x i32> @test_fshr_splat_constants() { | ||
| ; CHECK-LABEL: test_fshr_splat_constants: | ||
| ; CHECK: # %bb.0: | ||
| ; CHECK-NEXT: vbroadcastss {{.*#+}} xmm0 = [16777216,16777216,16777216,16777216] | ||
| ; CHECK-NEXT: retq | ||
| %res = call <4 x i32> @llvm.fshr.v4i32(<4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 4, i32 4, i32 4, i32 4>, <4 x i32> <i32 8, i32 8, i32 8, i32 8>) | ||
| ret <4 x i32> %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.
Uh oh!
There was an error while loading. Please reload this page.