Skip to content

Commit bc3754d

Browse files
authored
[M68k] Add anyext patterns for PCD addressing mode (#150356)
Does what it says on the tin: anyext loads with the PCD addressing mode were failing addr mode selection, adding the patterns resolved it.
1 parent 29d49c8 commit bc3754d

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

llvm/lib/Target/M68k/M68kInstrData.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,18 +701,22 @@ def: Pat<(MxExtLoadi16i8 MxCP_ARID:$src),
701701
(EXTRACT_SUBREG (MOVZXd32p8 MxARID8:$src), MxSubRegIndex16Lo)>;
702702
def: Pat<(MxExtLoadi16i8 MxCP_ARII:$src),
703703
(EXTRACT_SUBREG (MOVZXd32f8 MxARII8:$src), MxSubRegIndex16Lo)>;
704+
def: Pat<(MxExtLoadi16i8 MxCP_PCD:$src),
705+
(EXTRACT_SUBREG (MOVZXd32q8 MxPCD8:$src), MxSubRegIndex16Lo)>;
704706

705707
// i32 <- anyext i8
706708
def: Pat<(i32 (anyext i8:$src)), (MOVZXd32d8 MxDRD8:$src)>;
707709
def: Pat<(MxExtLoadi32i8 MxCP_ARI :$src), (MOVZXd32j8 MxARI8 :$src)>;
708710
def: Pat<(MxExtLoadi32i8 MxCP_ARID:$src), (MOVZXd32p8 MxARID8:$src)>;
709711
def: Pat<(MxExtLoadi32i8 MxCP_ARII:$src), (MOVZXd32f8 MxARII8:$src)>;
712+
def: Pat<(MxExtLoadi32i8 MxCP_PCD:$src), (MOVZXd32q8 MxPCD8:$src)>;
710713

711714
// i32 <- anyext i16
712715
def: Pat<(i32 (anyext i16:$src)), (MOVZXd32d16 MxDRD16:$src)>;
713716
def: Pat<(MxExtLoadi32i16 MxCP_ARI :$src), (MOVZXd32j16 MxARI16 :$src)>;
714717
def: Pat<(MxExtLoadi32i16 MxCP_ARID:$src), (MOVZXd32p16 MxARID16:$src)>;
715718
def: Pat<(MxExtLoadi32i16 MxCP_ARII:$src), (MOVZXd32f16 MxARII16:$src)>;
719+
def: Pat<(MxExtLoadi32i16 MxCP_PCD:$src), (MOVZXd32q16 MxPCD16:$src)>;
716720

717721
// trunc patterns
718722
def : Pat<(i16 (trunc i32:$src)),

llvm/test/CodeGen/M68k/Data/load-extend.ll

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,45 @@ define i32 @"test_zext_pcd_i16_to_i32"() {
4141
%val2 = zext i16 %val to i32
4242
ret i32 %val2
4343
}
44+
45+
define i16 @test_anyext_pcd_i8_to_i16() nounwind {
46+
; CHECK-LABEL: test_anyext_pcd_i8_to_i16:
47+
; CHECK: ; %bb.0:
48+
; CHECK-NEXT: move.b (__unnamed_1+4,%pc), %d0
49+
; CHECK-NEXT: and.l #255, %d0
50+
; CHECK-NEXT: lsl.w #8, %d0
51+
; CHECK-NEXT: ; kill: def $wd0 killed $wd0 killed $d0
52+
; CHECK-NEXT: rts
53+
%copyload = load i8, ptr getelementptr inbounds nuw (i8, ptr @0, i32 4)
54+
%insert_ext = zext i8 %copyload to i16
55+
%insert_shift = shl i16 %insert_ext, 8
56+
ret i16 %insert_shift
57+
}
58+
59+
define i32 @test_anyext_pcd_i8_to_i32() nounwind {
60+
; CHECK-LABEL: test_anyext_pcd_i8_to_i32:
61+
; CHECK: ; %bb.0:
62+
; CHECK-NEXT: moveq #24, %d1
63+
; CHECK-NEXT: move.b (__unnamed_1+4,%pc), %d0
64+
; CHECK-NEXT: and.l #255, %d0
65+
; CHECK-NEXT: lsl.l %d1, %d0
66+
; CHECK-NEXT: rts
67+
%copyload = load i8, ptr getelementptr inbounds nuw (i8, ptr @0, i32 4)
68+
%insert_ext = zext i8 %copyload to i32
69+
%insert_shift = shl i32 %insert_ext, 24
70+
ret i32 %insert_shift
71+
}
72+
73+
define i32 @test_anyext_pcd_i16_to_i32() nounwind {
74+
; CHECK-LABEL: test_anyext_pcd_i16_to_i32:
75+
; CHECK: ; %bb.0:
76+
; CHECK-NEXT: moveq #16, %d1
77+
; CHECK-NEXT: move.w (__unnamed_1+4,%pc), %d0
78+
; CHECK-NEXT: and.l #65535, %d0
79+
; CHECK-NEXT: lsl.l %d1, %d0
80+
; CHECK-NEXT: rts
81+
%copyload = load i16, ptr getelementptr inbounds nuw (i8, ptr @0, i32 4)
82+
%insert_ext = zext i16 %copyload to i32
83+
%insert_shift = shl i32 %insert_ext, 16
84+
ret i32 %insert_shift
85+
}

0 commit comments

Comments
 (0)