Skip to content

Commit 35feb9b

Browse files
committed
[M68k] Use MOVX for anyext patterns instead of MOVZX
This adjusts ISel patterns matching `anyext` and `extload` to use MOVX instead of MOVZX, correctly keeping the upper bits undefined rather than performing a redundant zero extend in cases where the compiler knows the bits won't matter.
1 parent e486bc5 commit 35feb9b

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

llvm/lib/Target/M68k/M68kInstrData.td

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,11 @@ def MOVI32ri : MxPseudoMove_DI<MxType32r>;
602602
/// what registers are allocated for the operands and if they overlap we just
603603
/// extend the value if the registers are completely different we need to move
604604
/// first.
605-
foreach EXT = ["S", "Z"] in {
605+
/// The "" group (MOVXd16d8, etc.) is similar to the others but does NOT do any
606+
/// value extension, they just load a smaller register into the lower part of
607+
/// another register if operands' real registers are different or does nothing
608+
/// if they are the same.
609+
foreach EXT = ["S", "Z", ""] in {
606610
let hasSideEffects = 0 in {
607611

608612
def MOV#EXT#Xd16d8 : MxPseudoMove_RR<MxType16d, MxType8d>;
@@ -631,14 +635,6 @@ foreach EXT = ["S", "Z"] in {
631635
}
632636
}
633637

634-
/// This group of instructions is similar to the group above but DOES NOT do
635-
/// any value extension, they just load a smaller register into the lower part
636-
/// of another register if operands' real registers are different or does
637-
/// nothing if they are the same.
638-
def MOVXd16d8 : MxPseudoMove_RR<MxType16d, MxType8d>;
639-
def MOVXd32d8 : MxPseudoMove_RR<MxType32d, MxType8d>;
640-
def MOVXd32d16 : MxPseudoMove_RR<MxType32r, MxType16r>;
641-
642638
//===----------------------------------------------------------------------===//
643639
// Extend/Truncate Patterns
644640
//===----------------------------------------------------------------------===//
@@ -686,22 +682,22 @@ def: Pat<(MxZExtLoadi32i16 MxCP_ARII:$src), (MOVZXd32f16 MxARII16:$src)>;
686682
def: Pat<(MxZExtLoadi32i16 MxCP_PCD :$src), (MOVZXd32q16 MxPCD16 :$src)>;
687683

688684
// i16 <- anyext i8
689-
def: Pat<(i16 (anyext i8:$src)), (MOVZXd16d8 MxDRD8:$src)>;
690-
def: Pat<(MxExtLoadi16i8 MxCP_ARI:$src), (MOVZXd16j8 MxARI8:$src)>;
691-
def: Pat<(MxExtLoadi16i8 MxCP_ARID:$src), (MOVZXd16p8 MxARID8:$src)>;
692-
def: Pat<(MxExtLoadi16i8 MxCP_ARII:$src), (MOVZXd16f8 MxARII8:$src)>;
685+
def: Pat<(i16 (anyext i8:$src)), (MOVXd16d8 MxDRD8:$src)>;
686+
def: Pat<(MxExtLoadi16i8 MxCP_ARI:$src), (MOVXd16j8 MxARI8:$src)>;
687+
def: Pat<(MxExtLoadi16i8 MxCP_ARID:$src), (MOVXd16p8 MxARID8:$src)>;
688+
def: Pat<(MxExtLoadi16i8 MxCP_ARII:$src), (MOVXd16f8 MxARII8:$src)>;
693689

694690
// i32 <- anyext i8
695-
def: Pat<(i32 (anyext i8:$src)), (MOVZXd32d8 MxDRD8:$src)>;
696-
def: Pat<(MxExtLoadi32i8 MxCP_ARI :$src), (MOVZXd32j8 MxARI8 :$src)>;
697-
def: Pat<(MxExtLoadi32i8 MxCP_ARID:$src), (MOVZXd32p8 MxARID8:$src)>;
698-
def: Pat<(MxExtLoadi32i8 MxCP_ARII:$src), (MOVZXd32f8 MxARII8:$src)>;
691+
def: Pat<(i32 (anyext i8:$src)), (MOVXd32d8 MxDRD8:$src)>;
692+
def: Pat<(MxExtLoadi32i8 MxCP_ARI :$src), (MOVXd32j8 MxARI8 :$src)>;
693+
def: Pat<(MxExtLoadi32i8 MxCP_ARID:$src), (MOVXd32p8 MxARID8:$src)>;
694+
def: Pat<(MxExtLoadi32i8 MxCP_ARII:$src), (MOVXd32f8 MxARII8:$src)>;
699695

700696
// i32 <- anyext i16
701-
def: Pat<(i32 (anyext i16:$src)), (MOVZXd32d16 MxDRD16:$src)>;
702-
def: Pat<(MxExtLoadi32i16 MxCP_ARI :$src), (MOVZXd32j16 MxARI16 :$src)>;
703-
def: Pat<(MxExtLoadi32i16 MxCP_ARID:$src), (MOVZXd32p16 MxARID16:$src)>;
704-
def: Pat<(MxExtLoadi32i16 MxCP_ARII:$src), (MOVZXd32f16 MxARII16:$src)>;
697+
def: Pat<(i32 (anyext i16:$src)), (MOVXd32d16 MxDRD16:$src)>;
698+
def: Pat<(MxExtLoadi32i16 MxCP_ARI :$src), (MOVXd32j16 MxARI16 :$src)>;
699+
def: Pat<(MxExtLoadi32i16 MxCP_ARID:$src), (MOVXd32p16 MxARID16:$src)>;
700+
def: Pat<(MxExtLoadi32i16 MxCP_ARII:$src), (MOVXd32f16 MxARII16:$src)>;
705701

706702
// trunc patterns
707703
def : Pat<(i16 (trunc i32:$src)),

0 commit comments

Comments
 (0)