-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[RISCV][ISel] Combine scalable vector fadd/fsub/fmul with fp extend. #88615
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
Open
sun-jacobi
wants to merge
1
commit into
llvm:main
Choose a base branch
from
sun-jacobi:scalable-vfw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+159
−10
Open
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
99 changes: 99 additions & 0 deletions
99
llvm/test/CodeGen/RISCV/rvv/vscale-vfw-web-simplification.ll
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,99 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=1 | FileCheck %s --check-prefixes=NO_FOLDING | ||
; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=2 | FileCheck %s --check-prefixes=NO_FOLDING | ||
; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=3 | FileCheck %s --check-prefixes=FOLDING,ZVFH | ||
; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfhmin,+f,+d -verify-machineinstrs %s -o - --riscv-lower-ext-max-web-size=3 | FileCheck %s --check-prefixes=FOLDING,ZVFHMIN | ||
; Check that the default value enables the web folding and | ||
; that it is bigger than 3. | ||
; RUN: llc -mtriple=riscv64 -mattr=+v,+zfh,+zvfh,+f,+d -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=FOLDING | ||
|
||
define void @vfwmul_v2f116_multiple_users(ptr %x, ptr %y, ptr %z, <vscale x 2 x half> %a, <vscale x 2 x half> %b, <vscale x 2 x half> %b2) { | ||
; NO_FOLDING-LABEL: vfwmul_v2f116_multiple_users: | ||
; NO_FOLDING: # %bb.0: | ||
; NO_FOLDING-NEXT: vsetvli a3, zero, e16, mf2, ta, ma | ||
; NO_FOLDING-NEXT: vfwcvt.f.f.v v11, v8 | ||
; NO_FOLDING-NEXT: vfwcvt.f.f.v v8, v9 | ||
; NO_FOLDING-NEXT: vfwcvt.f.f.v v9, v10 | ||
; NO_FOLDING-NEXT: vsetvli zero, zero, e32, m1, ta, ma | ||
; NO_FOLDING-NEXT: vfmul.vv v10, v11, v8 | ||
; NO_FOLDING-NEXT: vfadd.vv v11, v11, v9 | ||
; NO_FOLDING-NEXT: vfsub.vv v8, v8, v9 | ||
; NO_FOLDING-NEXT: vs1r.v v10, (a0) | ||
; NO_FOLDING-NEXT: vs1r.v v11, (a1) | ||
; NO_FOLDING-NEXT: vs1r.v v8, (a2) | ||
; NO_FOLDING-NEXT: ret | ||
; | ||
; ZVFH-LABEL: vfwmul_v2f116_multiple_users: | ||
; ZVFH: # %bb.0: | ||
; ZVFH-NEXT: vsetvli a3, zero, e16, mf2, ta, ma | ||
; ZVFH-NEXT: vfwmul.vv v11, v8, v9 | ||
; ZVFH-NEXT: vfwadd.vv v12, v8, v10 | ||
; ZVFH-NEXT: vfwsub.vv v8, v9, v10 | ||
; ZVFH-NEXT: vs1r.v v11, (a0) | ||
; ZVFH-NEXT: vs1r.v v12, (a1) | ||
; ZVFH-NEXT: vs1r.v v8, (a2) | ||
; ZVFH-NEXT: ret | ||
; | ||
; ZVFHMIN-LABEL: vfwmul_v2f116_multiple_users: | ||
; ZVFHMIN: # %bb.0: | ||
; ZVFHMIN-NEXT: vsetvli a3, zero, e16, mf2, ta, ma | ||
; ZVFHMIN-NEXT: vfwcvt.f.f.v v11, v8 | ||
; ZVFHMIN-NEXT: vfwcvt.f.f.v v8, v9 | ||
; ZVFHMIN-NEXT: vfwcvt.f.f.v v9, v10 | ||
; ZVFHMIN-NEXT: vsetvli zero, zero, e32, m1, ta, ma | ||
; ZVFHMIN-NEXT: vfmul.vv v10, v11, v8 | ||
; ZVFHMIN-NEXT: vfadd.vv v11, v11, v9 | ||
; ZVFHMIN-NEXT: vfsub.vv v8, v8, v9 | ||
; ZVFHMIN-NEXT: vs1r.v v10, (a0) | ||
; ZVFHMIN-NEXT: vs1r.v v11, (a1) | ||
; ZVFHMIN-NEXT: vs1r.v v8, (a2) | ||
; ZVFHMIN-NEXT: ret | ||
%c = fpext <vscale x 2 x half> %a to <vscale x 2 x float> | ||
%d = fpext <vscale x 2 x half> %b to <vscale x 2 x float> | ||
%d2 = fpext <vscale x 2 x half> %b2 to <vscale x 2 x float> | ||
%e = fmul <vscale x 2 x float> %c, %d | ||
%f = fadd <vscale x 2 x float> %c, %d2 | ||
%g = fsub <vscale x 2 x float> %d, %d2 | ||
store <vscale x 2 x float> %e, ptr %x | ||
store <vscale x 2 x float> %f, ptr %y | ||
store <vscale x 2 x float> %g, ptr %z | ||
ret void | ||
} | ||
|
||
define void @vfwmul_v2f32_multiple_users(ptr %x, ptr %y, ptr %z, <vscale x 2 x float> %a, <vscale x 2 x float> %b, <vscale x 2 x float> %b2) { | ||
; NO_FOLDING-LABEL: vfwmul_v2f32_multiple_users: | ||
; NO_FOLDING: # %bb.0: | ||
; NO_FOLDING-NEXT: vsetvli a3, zero, e32, m1, ta, ma | ||
; NO_FOLDING-NEXT: vfwcvt.f.f.v v12, v8 | ||
; NO_FOLDING-NEXT: vfwcvt.f.f.v v14, v9 | ||
; NO_FOLDING-NEXT: vfwcvt.f.f.v v8, v10 | ||
; NO_FOLDING-NEXT: vsetvli zero, zero, e64, m2, ta, ma | ||
; NO_FOLDING-NEXT: vfmul.vv v10, v12, v14 | ||
; NO_FOLDING-NEXT: vfadd.vv v12, v12, v8 | ||
; NO_FOLDING-NEXT: vfsub.vv v8, v14, v8 | ||
; NO_FOLDING-NEXT: vs2r.v v10, (a0) | ||
; NO_FOLDING-NEXT: vs2r.v v12, (a1) | ||
; NO_FOLDING-NEXT: vs2r.v v8, (a2) | ||
; NO_FOLDING-NEXT: ret | ||
; | ||
; FOLDING-LABEL: vfwmul_v2f32_multiple_users: | ||
; FOLDING: # %bb.0: | ||
; FOLDING-NEXT: vsetvli a3, zero, e32, m1, ta, ma | ||
; FOLDING-NEXT: vfwmul.vv v12, v8, v9 | ||
; FOLDING-NEXT: vfwadd.vv v14, v8, v10 | ||
; FOLDING-NEXT: vfwsub.vv v16, v9, v10 | ||
; FOLDING-NEXT: vs2r.v v12, (a0) | ||
; FOLDING-NEXT: vs2r.v v14, (a1) | ||
; FOLDING-NEXT: vs2r.v v16, (a2) | ||
; FOLDING-NEXT: ret | ||
%c = fpext <vscale x 2 x float> %a to <vscale x 2 x double> | ||
%d = fpext <vscale x 2 x float> %b to <vscale x 2 x double> | ||
%d2 = fpext <vscale x 2 x float> %b2 to <vscale x 2 x double> | ||
%e = fmul <vscale x 2 x double> %c, %d | ||
%f = fadd <vscale x 2 x double> %c, %d2 | ||
%g = fsub <vscale x 2 x double> %d, %d2 | ||
store <vscale x 2 x double> %e, ptr %x | ||
store <vscale x 2 x double> %f, ptr %y | ||
store <vscale x 2 x double> %g, ptr %z | ||
ret void | ||
} |
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.
How does this work for fixed length float splats currently if we didn't already handle
RISCVISD::VFMV_V_F_VL
? Since in #81248 it looks like we emit vfwadd.vfThere 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.
Why do we need to look through scalar FP_EXTEND here, but we don't need to look throug ZERO_EXTEND or SIGN_EXTEND for integer?
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.
The extend on those tests are happening in the vector domain not the scalar domain I think.
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.
Yes, you are right. We also need to handle the extension in the scalar domain (i.e. similar to #87249) for
RISCVISD::VFMV_V_F_VL
. Thanks for pointing out this.Uh oh!
There was an error while loading. Please reload this page.
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.
For integers, I think the
DAG.getSplat
would do an implicit truncation for us. But it seems that the float does not work.