From b4ae2da7e4bacbcfee146c30b03c568274b320b8 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 22 Aug 2008 19:19:31 +0000 Subject: Anyext tweaks for x86. When extloading a value to i32 or i64, choose instructions that define the full 32 or 64-bit value. When anyexting from i8 to i16 or i32, it's not necessary to zero out the high portion of the register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55190 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86Instr64bit.td | 12 +++--------- lib/Target/X86/X86InstrInfo.td | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/Target/X86/X86Instr64bit.td b/lib/Target/X86/X86Instr64bit.td index 5e7c73c..446cfda 100644 --- a/lib/Target/X86/X86Instr64bit.td +++ b/lib/Target/X86/X86Instr64bit.td @@ -1254,15 +1254,9 @@ def : Pat<(i64 (zext GR32:$src)), def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; // extload -def : Pat<(extloadi64i1 addr:$src), - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV8rm addr:$src), - x86_subreg_8bit)>; -def : Pat<(extloadi64i8 addr:$src), - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV8rm addr:$src), - x86_subreg_8bit)>; -def : Pat<(extloadi64i16 addr:$src), - (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV16rm addr:$src), - x86_subreg_16bit)>; +def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; +def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; +def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; def : Pat<(extloadi64i32 addr:$src), (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src), x86_subreg_32bit)>; diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index e55edce..aa2fe09 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -2784,19 +2784,24 @@ def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>; // extload bool -> extload byte def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>; -def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>, - Requires<[In32BitMode]>; +def : Pat<(extloadi16i1 addr:$src), + (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src), + x86_subreg_8bit)>; +def : Pat<(extloadi16i8 addr:$src), + (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src), + x86_subreg_8bit)>; +// For extloads with 32-bit results, chose instructions that +// define the whole 32 bits of the result, to avoid partial-register +// updates. def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>; -def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>, - Requires<[In32BitMode]>; def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>; def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>; // anyext -def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>, - Requires<[In32BitMode]>; -def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>, - Requires<[In32BitMode]>; +def : Pat<(i16 (anyext GR8:$src)), + (INSERT_SUBREG (i16 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>; +def : Pat<(i32 (anyext GR8:$src)), + (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>; def : Pat<(i32 (anyext GR16:$src)), (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>; -- cgit v1.1