-
Notifications
You must be signed in to change notification settings - Fork 15k
[RISCV][GISel] Fold G_FCONSTANT 0.0 store into G_CONSTANT x0 #163008
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9225aa9
pre-commit
sunshaoce 9b25edd
[RISCV][GISel] Fold `G_FCONSTANT` 0.0 store into `sw x0`
sunshaoce 74e65af
only add tests
sunshaoce 1946132
remove duplicate option
sunshaoce 1dbeb86
update
sunshaoce 2d94858
Use tablegen
sunshaoce cb4c37d
add test for f64 on rv32
sunshaoce 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
196 changes: 196 additions & 0 deletions
196
llvm/test/CodeGen/RISCV/GlobalISel/store-fp-zero-to-x0.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,196 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -global-isel -mtriple=riscv32 -mattr=+f,+zfh < %s \ | ||
sunshaoce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; RUN: | FileCheck %s --check-prefix=RV32 | ||
| ; RUN: llc -global-isel -mtriple=riscv64 -mattr=+d,+zfh < %s \ | ||
| ; RUN: | FileCheck %s --check-prefix=RV64 | ||
|
|
||
| define void @zero_f16(ptr %i) { | ||
| ; RV32-LABEL: zero_f16: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: sh zero, 0(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_f16: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sh zero, 0(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store half 0.0, ptr %i, align 4 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_bf16(ptr %i) { | ||
| ; RV32-LABEL: zero_bf16: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: sh zero, 0(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_bf16: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sh zero, 0(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store bfloat 0.0, ptr %i, align 4 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_f32(ptr %i) { | ||
| ; RV32-LABEL: zero_f32: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: sw zero, 0(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_f32: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sw zero, 0(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store float 0.0, ptr %i, align 4 | ||
| ret void | ||
| } | ||
|
|
||
|
|
||
| define void @zero_f64(ptr %i) { | ||
sunshaoce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; RV32-LABEL: zero_f64: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: lui a1, %hi(.LCPI3_0) | ||
| ; RV32-NEXT: addi a1, a1, %lo(.LCPI3_0) | ||
| ; RV32-NEXT: lw a2, 0(a1) | ||
| ; RV32-NEXT: lw a1, 4(a1) | ||
| ; RV32-NEXT: sw a2, 0(a0) | ||
| ; RV32-NEXT: sw a1, 4(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_f64: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sd zero, 0(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store double 0.0, ptr %i, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_v1f32(ptr %i) { | ||
| ; RV32-LABEL: zero_v1f32: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: sw zero, 0(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_v1f32: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sw zero, 0(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store <1 x float> <float 0.0>, ptr %i, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_v2f32(ptr %i) { | ||
| ; RV32-LABEL: zero_v2f32: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: sw zero, 0(a0) | ||
| ; RV32-NEXT: sw zero, 4(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_v2f32: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sw zero, 0(a0) | ||
| ; RV64-NEXT: sw zero, 4(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store <2 x float> <float 0.0, float 0.0>, ptr %i, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_v4f32(ptr %i) { | ||
| ; RV32-LABEL: zero_v4f32: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: sw zero, 0(a0) | ||
| ; RV32-NEXT: sw zero, 4(a0) | ||
| ; RV32-NEXT: sw zero, 8(a0) | ||
| ; RV32-NEXT: sw zero, 12(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_v4f32: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sw zero, 0(a0) | ||
| ; RV64-NEXT: sw zero, 4(a0) | ||
| ; RV64-NEXT: sw zero, 8(a0) | ||
| ; RV64-NEXT: sw zero, 12(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store <4 x float> <float 0.0, float 0.0, float 0.0, float 0.0>, ptr %i, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_v1f64(ptr %i) { | ||
| ; RV32-LABEL: zero_v1f64: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: lui a1, %hi(.LCPI7_0) | ||
| ; RV32-NEXT: addi a1, a1, %lo(.LCPI7_0) | ||
| ; RV32-NEXT: lw a2, 0(a1) | ||
| ; RV32-NEXT: lw a1, 4(a1) | ||
| ; RV32-NEXT: sw a2, 0(a0) | ||
| ; RV32-NEXT: sw a1, 4(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_v1f64: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sd zero, 0(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store <1 x double> <double 0.0>, ptr %i, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_v2f64(ptr %i) { | ||
| ; RV32-LABEL: zero_v2f64: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: lui a1, %hi(.LCPI8_0) | ||
| ; RV32-NEXT: addi a1, a1, %lo(.LCPI8_0) | ||
| ; RV32-NEXT: lw a2, 0(a1) | ||
| ; RV32-NEXT: lw a1, 4(a1) | ||
| ; RV32-NEXT: sw a2, 0(a0) | ||
| ; RV32-NEXT: sw a1, 4(a0) | ||
| ; RV32-NEXT: sw a2, 8(a0) | ||
| ; RV32-NEXT: sw a1, 12(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_v2f64: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sd zero, 0(a0) | ||
| ; RV64-NEXT: sd zero, 8(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store <2 x double> <double 0.0, double 0.0>, ptr %i, align 8 | ||
| ret void | ||
| } | ||
|
|
||
| define void @zero_v4f64(ptr %i) { | ||
| ; RV32-LABEL: zero_v4f64: | ||
| ; RV32: # %bb.0: # %entry | ||
| ; RV32-NEXT: lui a1, %hi(.LCPI9_0) | ||
| ; RV32-NEXT: addi a1, a1, %lo(.LCPI9_0) | ||
| ; RV32-NEXT: lw a2, 0(a1) | ||
| ; RV32-NEXT: lw a1, 4(a1) | ||
| ; RV32-NEXT: sw a2, 0(a0) | ||
| ; RV32-NEXT: sw a1, 4(a0) | ||
| ; RV32-NEXT: sw a2, 8(a0) | ||
| ; RV32-NEXT: sw a1, 12(a0) | ||
| ; RV32-NEXT: sw a2, 16(a0) | ||
| ; RV32-NEXT: sw a1, 20(a0) | ||
| ; RV32-NEXT: sw a2, 24(a0) | ||
| ; RV32-NEXT: sw a1, 28(a0) | ||
| ; RV32-NEXT: ret | ||
| ; | ||
| ; RV64-LABEL: zero_v4f64: | ||
| ; RV64: # %bb.0: # %entry | ||
| ; RV64-NEXT: sd zero, 0(a0) | ||
| ; RV64-NEXT: sd zero, 8(a0) | ||
| ; RV64-NEXT: sd zero, 16(a0) | ||
| ; RV64-NEXT: sd zero, 24(a0) | ||
| ; RV64-NEXT: ret | ||
| entry: | ||
| store <4 x double> <double 0.0, double 0.0, double 0.0, double 0.0>, ptr %i, align 8 | ||
| ret void | ||
| } | ||
sunshaoce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.