Skip to content

Commit 0ab789a

Browse files
committed
[SOL] Use mov32 to load and zero extend immediate in V2+ (#166)
1 parent 6aaaa59 commit 0ab789a

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

llvm/lib/Target/SBF/SBFInstrInfo.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,14 @@ let Predicates = [SBFExplicitSignExt], DecoderNamespace = "SBFv2" in {
443443
[]>;
444444
}
445445

446+
let Predicates = [SBFExplicitSignExt], DecoderNamespace = "Repeated" in {
447+
def MOV_ri_32_zext : MATH_RI<SBF_ALU, SBF_MOV,
448+
(outs GPR:$dst),
449+
(ins i64imm:$imm),
450+
"mov32 $dst, $imm",
451+
[(set GPR:$dst, (i64 i64immZExt32:$imm))]>;
452+
}
453+
446454
def MOV_rr_32_no_sext_v1 : MATH_RR<SBF_ALU, SBF_MOV,
447455
(outs GPR32:$dst),
448456
(ins GPR32:$src),

llvm/test/CodeGen/SBF/mov_zext.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; RUN: llc -march=sbf -mcpu=v1 < %s | FileCheck --check-prefix=CHECK-V1 %s
2+
; RUN: llc -march=sbf -mcpu=v2 < %s | FileCheck --check-prefix=CHECK-V2 %s
3+
4+
define dso_local i64 @mov_1() {
5+
entry:
6+
; CHECK-LABEL: mov_1
7+
; CHECK-V1: lddw r0, 4294967294
8+
; CHECK-V2: mov32 r0, -2
9+
; CHECK-V2-NOT: hor64
10+
ret i64 4294967294
11+
}
12+
13+
define dso_local i64 @mov_2() {
14+
entry:
15+
; CHECK-LABEL: mov_2
16+
; CHECK-V1: lddw r0, -4294967294
17+
; CHECK-V2: mov32 r0, 2
18+
; CHECK-V2: hor64 r0, -1
19+
ret i64 -4294967294
20+
}
21+
22+
define dso_local i64 @mov_3() {
23+
entry:
24+
; CHECK-LABEL: mov_3
25+
; CHECK-V1: mov64 r0, 429496729
26+
; CHECK-V2: mov64 r0, 429496729
27+
ret i64 429496729
28+
}

0 commit comments

Comments
 (0)