forked from OSchip/llvm-project
Avoid storing and reloading zeros and other constants from stack slots
by flagging the associated instructions as being trivially rematerializable. llvm-svn: 41775
This commit is contained in:
parent
9e70086c8f
commit
a95cbb0007
|
@ -2313,6 +2313,7 @@ def CDQ : I<0x99, RawFrm, (outs), (ins),
|
||||||
|
|
||||||
// Alias instructions that map movr0 to xor.
|
// Alias instructions that map movr0 to xor.
|
||||||
// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
|
// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
|
||||||
|
let isReMaterializable = 1 in {
|
||||||
def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
|
def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
|
||||||
"xor{b}\t$dst, $dst",
|
"xor{b}\t$dst, $dst",
|
||||||
[(set GR8:$dst, 0)]>;
|
[(set GR8:$dst, 0)]>;
|
||||||
|
@ -2322,6 +2323,7 @@ def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
|
||||||
def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
|
def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
|
||||||
"xor{l}\t$dst, $dst",
|
"xor{l}\t$dst, $dst",
|
||||||
[(set GR32:$dst, 0)]>;
|
[(set GR32:$dst, 0)]>;
|
||||||
|
}
|
||||||
|
|
||||||
// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
|
// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
|
||||||
// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
|
// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
|
||||||
|
|
|
@ -399,6 +399,7 @@ def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
|
||||||
// start with 'Fs'.
|
// start with 'Fs'.
|
||||||
|
|
||||||
// Alias instructions that map fld0 to pxor for sse.
|
// Alias instructions that map fld0 to pxor for sse.
|
||||||
|
let isReMaterializable = 1 in
|
||||||
def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
|
def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins),
|
||||||
"pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
|
"pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>,
|
||||||
Requires<[HasSSE1]>, TB, OpSize;
|
Requires<[HasSSE1]>, TB, OpSize;
|
||||||
|
@ -1063,6 +1064,7 @@ def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2),
|
||||||
// start with 'Fs'.
|
// start with 'Fs'.
|
||||||
|
|
||||||
// Alias instructions that map fld0 to pxor for sse.
|
// Alias instructions that map fld0 to pxor for sse.
|
||||||
|
let isReMaterializable = 1 in
|
||||||
def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
|
def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins),
|
||||||
"pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
|
"pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>,
|
||||||
Requires<[HasSSE2]>, TB, OpSize;
|
Requires<[HasSSE2]>, TB, OpSize;
|
||||||
|
|
|
@ -156,12 +156,14 @@ def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}",
|
||||||
def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
|
def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
|
||||||
"mov{q}\t{$src, $dst|$dst, $src}", []>;
|
"mov{q}\t{$src, $dst|$dst, $src}", []>;
|
||||||
|
|
||||||
|
let isReMaterializable = 1 in {
|
||||||
def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
|
def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src),
|
||||||
"movabs{q}\t{$src, $dst|$dst, $src}",
|
"movabs{q}\t{$src, $dst|$dst, $src}",
|
||||||
[(set GR64:$dst, imm:$src)]>;
|
[(set GR64:$dst, imm:$src)]>;
|
||||||
def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
|
def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src),
|
||||||
"mov{q}\t{$src, $dst|$dst, $src}",
|
"mov{q}\t{$src, $dst|$dst, $src}",
|
||||||
[(set GR64:$dst, i64immSExt32:$src)]>;
|
[(set GR64:$dst, i64immSExt32:$src)]>;
|
||||||
|
}
|
||||||
|
|
||||||
let isLoad = 1 in
|
let isLoad = 1 in
|
||||||
def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
|
def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
|
||||||
|
@ -990,13 +992,13 @@ def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src),
|
||||||
// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
|
// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
|
||||||
// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
|
// FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove
|
||||||
// when we have a better way to specify isel priority.
|
// when we have a better way to specify isel priority.
|
||||||
let AddedComplexity = 1 in
|
let AddedComplexity = 1, isReMaterializable = 1 in
|
||||||
def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
|
def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins),
|
||||||
"xor{q}\t$dst, $dst",
|
"xor{q}\t$dst, $dst",
|
||||||
[(set GR64:$dst, 0)]>;
|
[(set GR64:$dst, 0)]>;
|
||||||
|
|
||||||
// Materialize i64 constant where top 32-bits are zero.
|
// Materialize i64 constant where top 32-bits are zero.
|
||||||
let AddedComplexity = 1 in
|
let AddedComplexity = 1, isReMaterializable = 1 in
|
||||||
def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
|
def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src),
|
||||||
"mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
|
"mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
|
||||||
[(set GR64:$dst, i64immZExt32:$src)]>;
|
[(set GR64:$dst, i64immZExt32:$src)]>;
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
; RUN: llvm-as < %s | llc -march=x86-64 | grep xor | count 4
|
||||||
|
; RUN: llvm-as < %s | llc -march=x86-64 -stats -info-output-file - | grep asm-printer | grep 12
|
||||||
|
|
||||||
|
declare void @bar(double %x)
|
||||||
|
declare void @barf(float %x)
|
||||||
|
|
||||||
|
define double @foo() {
|
||||||
|
call void @bar(double 0.0)
|
||||||
|
ret double 0.0
|
||||||
|
}
|
||||||
|
define float @foof() {
|
||||||
|
call void @barf(float 0.0)
|
||||||
|
ret float 0.0
|
||||||
|
}
|
Loading…
Reference in New Issue