-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LoongArch] Support LA V1.1 feature that div.w[u] and mod.w[u] instructions with inputs not signed-extended. #116764
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 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a01c311
[LoongArch] Support LA V1.1 feature that div.w[u] and mod.w[u] instru…
tangaac 1d0477f
add a test
tangaac b2bc7fa
remove uncessary ir attributes
tangaac 97dcea3
remove LoongArchISD:{DIV_W,MOD_W} , add div32 support in sys::getHost…
tangaac 20c9378
add a todo comment
tangaac 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
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,30 @@ | ||
| /// Test -m[no]div32 options. | ||
|
|
||
| // RUN: %clang --target=loongarch64 -mdiv32 -fsyntax-only %s -### 2>&1 | \ | ||
| // RUN: FileCheck %s --check-prefix=CC1-DIV32 | ||
| // RUN: %clang --target=loongarch64 -mno-div32 -fsyntax-only %s -### 2>&1 | \ | ||
| // RUN: FileCheck %s --check-prefix=CC1-NO-DIV32 | ||
| // RUN: %clang --target=loongarch64 -mno-div32 -mdiv32 -fsyntax-only %s -### 2>&1 | \ | ||
| // RUN: FileCheck %s --check-prefix=CC1-DIV32 | ||
| // RUN: %clang --target=loongarch64 -mdiv32 -mno-div32 -fsyntax-only %s -### 2>&1 | \ | ||
| // RUN: FileCheck %s --check-prefix=CC1-NO-DIV32 | ||
|
|
||
| // RUN: %clang --target=loongarch64 -mdiv32 -S -emit-llvm %s -o - | \ | ||
| // RUN: FileCheck %s --check-prefix=IR-DIV32 | ||
| // RUN: %clang --target=loongarch64 -mno-div32 -S -emit-llvm %s -o - | \ | ||
| // RUN: FileCheck %s --check-prefix=IR-NO-DIV32 | ||
| // RUN: %clang --target=loongarch64 -mno-div32 -mdiv32 -S -emit-llvm %s -o - | \ | ||
| // RUN: FileCheck %s --check-prefix=IR-DIV32 | ||
| // RUN: %clang --target=loongarch64 -mdiv32 -mno-div32 -S -emit-llvm %s -o - | \ | ||
| // RUN: FileCheck %s --check-prefix=IR-NO-DIV32 | ||
|
|
||
|
|
||
| // CC1-DIV32: "-target-feature" "+div32" | ||
| // CC1-NO-DIV32: "-target-feature" "-div32" | ||
|
|
||
| // IR-DIV32: attributes #[[#]] ={{.*}}"target-features"="{{(.*,)?}}+div32{{(,.*)?}}" | ||
| // IR-NO-DIV32: attributes #[[#]] ={{.*}}"target-features"="{{(.*,)?}}-div32{{(,.*)?}}" | ||
|
|
||
| int foo(void) { | ||
| return 42; | ||
| } |
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
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
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
79 changes: 79 additions & 0 deletions
79
llvm/test/CodeGen/LoongArch/ir-instruction/sdiv-udiv-srem-urem-div32.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,79 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc --mtriple=loongarch64 -mattr=+d,-div32 < %s | FileCheck %s --check-prefix=LA64 | ||
| ; RUN: llc --mtriple=loongarch64 -mattr=+d,+div32 < %s | FileCheck %s --check-prefix=LA64-DIV32 | ||
|
|
||
| define i32 @divw(i64 %a, i64 %b) { | ||
| ; LA64-LABEL: divw: | ||
| ; LA64: # %bb.0: | ||
| ; LA64-NEXT: addi.w $a0, $a0, 0 | ||
| ; LA64-NEXT: addi.w $a1, $a1, 0 | ||
| ; LA64-NEXT: div.d $a0, $a0, $a1 | ||
| ; LA64-NEXT: ret | ||
| ; | ||
| ; LA64-DIV32-LABEL: divw: | ||
| ; LA64-DIV32: # %bb.0: | ||
| ; LA64-DIV32-NEXT: addi.w $a0, $a0, 0 | ||
| ; LA64-DIV32-NEXT: addi.w $a1, $a1, 0 | ||
| ; LA64-DIV32-NEXT: div.d $a0, $a0, $a1 | ||
| ; LA64-DIV32-NEXT: ret | ||
| %conv1 = trunc i64 %a to i32 | ||
| %conv2 = trunc i64 %b to i32 | ||
| %r = sdiv i32 %conv1, %conv2 | ||
| ret i32 %r | ||
| } | ||
|
|
||
| define i32 @divwu(i64 %a, i64 %b) { | ||
| ; LA64-LABEL: divwu: | ||
| ; LA64: # %bb.0: | ||
| ; LA64-NEXT: addi.w $a1, $a1, 0 | ||
| ; LA64-NEXT: addi.w $a0, $a0, 0 | ||
| ; LA64-NEXT: div.wu $a0, $a0, $a1 | ||
| ; LA64-NEXT: ret | ||
| ; | ||
| ; LA64-DIV32-LABEL: divwu: | ||
| ; LA64-DIV32: # %bb.0: | ||
| ; LA64-DIV32-NEXT: div.wu $a0, $a0, $a1 | ||
| ; LA64-DIV32-NEXT: ret | ||
| %conv1 = trunc i64 %a to i32 | ||
| %conv2 = trunc i64 %b to i32 | ||
| %r = udiv i32 %conv1, %conv2 | ||
| ret i32 %r | ||
| } | ||
|
|
||
| define i32 @modw(i64 %a, i64 %b) { | ||
| ; LA64-LABEL: modw: | ||
| ; LA64: # %bb.0: | ||
| ; LA64-NEXT: addi.w $a0, $a0, 0 | ||
| ; LA64-NEXT: addi.w $a1, $a1, 0 | ||
| ; LA64-NEXT: mod.d $a0, $a0, $a1 | ||
| ; LA64-NEXT: ret | ||
| ; | ||
| ; LA64-DIV32-LABEL: modw: | ||
| ; LA64-DIV32: # %bb.0: | ||
| ; LA64-DIV32-NEXT: addi.w $a0, $a0, 0 | ||
| ; LA64-DIV32-NEXT: addi.w $a1, $a1, 0 | ||
| ; LA64-DIV32-NEXT: mod.d $a0, $a0, $a1 | ||
| ; LA64-DIV32-NEXT: ret | ||
| %conv1 = trunc i64 %a to i32 | ||
| %conv2 = trunc i64 %b to i32 | ||
| %r = srem i32 %conv1, %conv2 | ||
| ret i32 %r | ||
| } | ||
|
|
||
| define i32 @modwu(i64 %a, i64 %b) { | ||
| ; LA64-LABEL: modwu: | ||
| ; LA64: # %bb.0: | ||
| ; LA64-NEXT: addi.w $a1, $a1, 0 | ||
| ; LA64-NEXT: addi.w $a0, $a0, 0 | ||
| ; LA64-NEXT: mod.wu $a0, $a0, $a1 | ||
| ; LA64-NEXT: ret | ||
| ; | ||
| ; LA64-DIV32-LABEL: modwu: | ||
| ; LA64-DIV32: # %bb.0: | ||
| ; LA64-DIV32-NEXT: mod.wu $a0, $a0, $a1 | ||
| ; LA64-DIV32-NEXT: ret | ||
| %conv1 = trunc i64 %a to i32 | ||
| %conv2 = trunc i64 %b to i32 | ||
| %r = urem i32 %conv1, %conv2 | ||
| ret i32 %r | ||
| } | ||
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.
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.
Leave a
TODOhere that the issue will be addressed by another PR.