Skip to content

[SOL] Use mov32 to load and zero extend immediate in V2+ #166

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 3 commits into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/lib/Target/SBF/SBFInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ let Predicates = [SBFExplicitSignExt], DecoderNamespace = "SBFv2" in {
[]>;
}

let Predicates = [SBFExplicitSignExt], DecoderNamespace = "Repeated" in {
def MOV_ri_32_zext : MATH_RI<SBF_ALU, SBF_MOV,
(outs GPR:$dst),
(ins i64imm:$imm),
"mov32 $dst, $imm",
[(set GPR:$dst, (i64 i64immZExt32:$imm))]>;
}

def MOV_rr_32_no_sext_v1 : MATH_RR<SBF_ALU, SBF_MOV,
(outs GPR32:$dst),
(ins GPR32:$src),
Expand Down
28 changes: 28 additions & 0 deletions llvm/test/CodeGen/SBF/mov_zext.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
; RUN: llc -march=sbf -mcpu=v1 < %s | FileCheck --check-prefix=CHECK-V1 %s
; RUN: llc -march=sbf -mcpu=v2 < %s | FileCheck --check-prefix=CHECK-V2 %s

define dso_local i64 @mov_1() {
entry:
; CHECK-LABEL: mov_1
; CHECK-V1: lddw r0, 4294967294
; CHECK-V2: mov32 r0, -2
; CHECK-V2-NOT: hor64
ret i64 4294967294
}

define dso_local i64 @mov_2() {
entry:
; CHECK-LABEL: mov_2
; CHECK-V1: lddw r0, -4294967294
; CHECK-V2: mov32 r0, 2
; CHECK-V2: hor64 r0, -1
ret i64 -4294967294
}

define dso_local i64 @mov_3() {
entry:
; CHECK-LABEL: mov_3
; CHECK-V1: mov64 r0, 429496729
; CHECK-V2: mov64 r0, 429496729
ret i64 429496729
}
Loading