-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV] Add lowerVECTOR_SHUFFLEAsCONCAT_VECTORS. #109948
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -mtriple riscv64 -mattr=+v -riscv-v-vector-bits-min=512 -verify-machineinstrs < %s | FileCheck %s | ||
|
|
||
| define <16 x float> @test1(<8 x float> %0) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InstCombine already flattens both of these tests. Do you have other examples?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is true. But I want to make sure INSERT_SUBVECTOR + VECTOR_SHUFFLE can be folded into CONCAT_VECTORS. SLP will generate the code like this.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. InstCombine should run after SLP. Do you have examples where InstCombine isn't cleaning it up? If you do, we should investigate InstCombine first.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No for now.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also doesn't seem like a RISC-V specific optimization.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that as well. It looks like GISel canonicalizes shuffles to concats: https://reviews.llvm.org/D69149 I didn't notice any codegen changes with this patch when building SPEC or the test suite so I presume that's InstCombine already taking care of this. |
||
| ; CHECK-LABEL: test1: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: vmv1r.v v9, v8 | ||
| ; CHECK-NEXT: vsetivli zero, 16, e32, m1, ta, ma | ||
| ; CHECK-NEXT: vslideup.vi v9, v8, 8 | ||
| ; CHECK-NEXT: vmv.v.v v8, v9 | ||
| ; CHECK-NEXT: ret | ||
| entry: | ||
| %1 = call <16 x float> @llvm.vector.insert.v16f32.v8f32(<16 x float> poison, <8 x float> poison, i64 8) | ||
| %2 = call <16 x float> @llvm.vector.insert.v16f32.v8f32(<16 x float> %1, <8 x float> %0, i64 0) | ||
|
||
| %3 = shufflevector <16 x float> %2, <16 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> | ||
| ret <16 x float> %3 | ||
| } | ||
|
|
||
| define <16 x i32> @test2(<4 x i32> %0) { | ||
| ; CHECK-LABEL: test2: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: vmv1r.v v9, v8 | ||
| ; CHECK-NEXT: vsetivli zero, 8, e32, mf2, ta, ma | ||
| ; CHECK-NEXT: vslideup.vi v9, v8, 4 | ||
| ; CHECK-NEXT: vmv1r.v v8, v9 | ||
| ; CHECK-NEXT: vsetivli zero, 16, e32, m1, ta, ma | ||
| ; CHECK-NEXT: vslideup.vi v8, v9, 8 | ||
| ; CHECK-NEXT: ret | ||
| entry: | ||
| %1 = call <16 x i32> @llvm.vector.insert.v16i32.v4i32(<16 x i32> poison, <4 x i32> poison, i64 4) | ||
| %2 = call <16 x i32> @llvm.vector.insert.v16i32.v4i32(<16 x i32> %1, <4 x i32> poison, i64 8) | ||
| %3 = call <16 x i32> @llvm.vector.insert.v16i32.v4i32(<16 x i32> %2, <4 x i32> poison, i64 12) | ||
| %4 = call <16 x i32> @llvm.vector.insert.v16i32.v4i32(<16 x i32> %3, <4 x i32> %0, i64 0) | ||
| %5 = shufflevector <16 x i32> %4, <16 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3> | ||
| ret <16 x i32> %5 | ||
| } | ||
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.
You could simplify the zero check and maybe move it beside the undef check
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.
done