
Add three more special cases for loading registers with immediates. The first allows values in the range of [-255, 255] to be loaded with MOVEQ, even if the register is more than 8 bits and the sign extention is unwanted. This is done by loading the bitwise complement of the desired value, then performing a NOT instruction on the loaded register. This special case is only used when a simple MOVEQ cannot be used, and is only used for 32 bit data registers. Address registers cannot support MOVEQ, and the two-instruction sequence is no faster or smaller than a plain MOVE instruction when loading 16 bit immediates on the 68000, and likely slower for more sophisticated microarchitectures. However, the instruction sequence is both smaller and faster than the corresponding MOVE instruction for 32 bit register widths. The second special case is for zeroing address registers. This simply expands to subtracting a register with itself, consuming one instruction word rather than 2-3, with a small improvement in speed as well. The last special case is for assigning sign-extended 16-bit values to a full address register. This takes advantage of the fact that the movea.w instruction sign extends the output, permitting the immediate to be smaller. This is similar to using lea with a 16-bit address, which is not added in this patch as 16-bit absolute addressing is not yet implemented. This is a v2 submission of #90817. It also creates a 'Data' test directory to better align with the backend's tablegen layout.
44 lines
1.3 KiB
LLVM
44 lines
1.3 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
|
|
; RUN: llc < %s -mtriple=m68k-linux -verify-machineinstrs | FileCheck %s
|
|
|
|
@0 = external constant <{ [32 x i8] }>
|
|
|
|
define i32 @"test_zext_pcd_i8_to_i32"() {
|
|
; CHECK-LABEL: test_zext_pcd_i8_to_i32:
|
|
; CHECK: .cfi_startproc
|
|
; CHECK-NEXT: ; %bb.0:
|
|
; CHECK-NEXT: move.b (__unnamed_1+16,%pc), %d0
|
|
; CHECK-NEXT: and.l #255, %d0
|
|
; CHECK-NEXT: rts
|
|
%p = getelementptr inbounds i8, ptr @0, i32 16
|
|
%val = load i8, ptr %p
|
|
%val2 = zext i8 %val to i32
|
|
ret i32 %val2
|
|
}
|
|
|
|
define i16 @"test_zext_pcd_i8_to_i16"() {
|
|
; CHECK-LABEL: test_zext_pcd_i8_to_i16:
|
|
; CHECK: .cfi_startproc
|
|
; CHECK-NEXT: ; %bb.0:
|
|
; CHECK-NEXT: move.b (__unnamed_1+16,%pc), %d0
|
|
; CHECK-NEXT: and.w #255, %d0
|
|
; CHECK-NEXT: rts
|
|
%p = getelementptr inbounds i8, ptr @0, i32 16
|
|
%val = load i8, ptr %p
|
|
%val2 = zext i8 %val to i16
|
|
ret i16 %val2
|
|
}
|
|
|
|
define i32 @"test_zext_pcd_i16_to_i32"() {
|
|
; CHECK-LABEL: test_zext_pcd_i16_to_i32:
|
|
; CHECK: .cfi_startproc
|
|
; CHECK-NEXT: ; %bb.0:
|
|
; CHECK-NEXT: move.w (__unnamed_1+16,%pc), %d0
|
|
; CHECK-NEXT: and.l #65535, %d0
|
|
; CHECK-NEXT: rts
|
|
%p = getelementptr inbounds i16, ptr @0, i32 8
|
|
%val = load i16, ptr %p
|
|
%val2 = zext i16 %val to i32
|
|
ret i32 %val2
|
|
}
|