-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[GISel] Convert zext nneg to sext if it is cheaper #93856
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 all commits
e69add4
4043821
a018925
1990898
56e9ce2
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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -101,3 +101,13 @@ entry: | |||||||||||||||
%0 = urem i64 %a, %b | ||||||||||||||||
ret i64 %0 | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
define i64 @zext_nneg_i32_i64(i32 %a) { | ||||||||||||||||
; RV64IM-LABEL: zext_nneg_i32_i64: | ||||||||||||||||
; RV64IM: # %bb.0: # %entry | ||||||||||||||||
; RV64IM-NEXT: sext.w a0, a0 | ||||||||||||||||
; RV64IM-NEXT: ret | ||||||||||||||||
entry: | ||||||||||||||||
%b = zext nneg i32 %a to i64 | ||||||||||||||||
ret i64 %b | ||||||||||||||||
} | ||||||||||||||||
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. Vector case 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. Sorry, I cannot provide vector tests as both RISC-V and LoongArch only handle scalar i32 -> i64. llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp Lines 1881 to 1883 in a65771f
llvm-project/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp Lines 4982 to 4985 in a65771f
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
# RUN: llc -run-pass=riscv-prelegalizer-combiner -mtriple riscv64 %s -o - | FileCheck %s --check-prefix=RV64 | ||
|
||
--- | ||
name: nneg_zext | ||
body: | | ||
bb.0: | ||
|
||
; RV64-LABEL: name: nneg_zext | ||
; RV64: [[COPY:%[0-9]+]]:_(s64) = COPY $x10 | ||
; RV64-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) | ||
; RV64-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[TRUNC]](s32) | ||
; RV64-NEXT: $x10 = COPY [[SEXT]](s64) | ||
; RV64-NEXT: PseudoRET implicit $x10 | ||
%0:_(s64) = COPY $x10 | ||
%2:_(s32) = G_TRUNC %0 | ||
%3:_(s64) = nneg G_ZEXT %2 | ||
$x10 = COPY %3(s64) | ||
PseudoRET implicit $x10 | ||
... |
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.
we probably should have a "mostly" target independent group, but that's another change