From 8674849d6e9156d693ed3b36c723822a05c55f06 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 11 Jul 2016 05:36:41 +0000 Subject: [PATCH] [X86] Add the AVX512 SET0 pseudos to foldMemoryOperandImpl since they are marked for CanFoldAsLoad. I don't really know how to test this. llvm-svn: 275044 --- llvm/lib/Target/X86/X86InstrAVX512.td | 4 ++-- llvm/lib/Target/X86/X86InstrInfo.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td index cf1c096b5af4..357b51797184 100644 --- a/llvm/lib/Target/X86/X86InstrAVX512.td +++ b/llvm/lib/Target/X86/X86InstrAVX512.td @@ -413,13 +413,13 @@ def : Pat<(v64i8 (bitconvert (v16f32 VR512:$src))), (v64i8 VR512:$src)>; // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-zeros value if folding it would be beneficial. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, - isPseudo = 1, Predicates = [HasAVX512] in { + isPseudo = 1, Predicates = [HasAVX512], SchedRW = [WriteZero] in { def AVX512_512_SET0 : I<0, Pseudo, (outs VR512:$dst), (ins), "", [(set VR512:$dst, (v16i32 immAllZerosV))]>; } let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, - isPseudo = 1, Predicates = [HasVLX] in { + isPseudo = 1, Predicates = [HasVLX], SchedRW = [WriteZero] in { def AVX512_128_SET0 : I<0, Pseudo, (outs VR128X:$dst), (ins), "", [(set VR128X:$dst, (v4i32 immAllZerosV))]>; def AVX512_256_SET0 : I<0, Pseudo, (outs VR256X:$dst), (ins), "", diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 79a1ddea786d..cc0388bb0db6 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -6230,12 +6230,17 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl( Alignment = (*LoadMI.memoperands_begin())->getAlignment(); else switch (LoadMI.getOpcode()) { + case X86::AVX512_512_SET0: + Alignment = 64; + break; case X86::AVX2_SETALLONES: case X86::AVX_SET0: + case X86::AVX512_256_SET0: Alignment = 32; break; case X86::V_SET0: case X86::V_SETALLONES: + case X86::AVX512_128_SET0: Alignment = 16; break; case X86::FsFLD0SD: @@ -6273,6 +6278,9 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl( case X86::V_SETALLONES: case X86::AVX2_SETALLONES: case X86::AVX_SET0: + case X86::AVX512_128_SET0: + case X86::AVX512_256_SET0: + case X86::AVX512_512_SET0: case X86::FsFLD0SD: case X86::FsFLD0SS: { // Folding a V_SET0 or V_SETALLONES as a load, to ease register pressure. @@ -6304,7 +6312,10 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl( Ty = Type::getFloatTy(MF.getFunction()->getContext()); else if (Opc == X86::FsFLD0SD) Ty = Type::getDoubleTy(MF.getFunction()->getContext()); - else if (Opc == X86::AVX2_SETALLONES || Opc == X86::AVX_SET0) + else if (Opc == X86::AVX512_512_SET0) + Ty = VectorType::get(Type::getInt32Ty(MF.getFunction()->getContext()),16); + else if (Opc == X86::AVX2_SETALLONES || Opc == X86::AVX_SET0 || + Opc == X86::AVX512_256_SET0) Ty = VectorType::get(Type::getInt32Ty(MF.getFunction()->getContext()), 8); else Ty = VectorType::get(Type::getInt32Ty(MF.getFunction()->getContext()), 4);