OSDN Git Service

[X86] Teach X86 codegen to use vector width preference to avoid promoting to 512...
authorCraig Topper <craig.topper@intel.com>
Sat, 20 Jan 2018 00:26:12 +0000 (00:26 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 20 Jan 2018 00:26:12 +0000 (00:26 +0000)
commit8bb1297fe0106ef72e338c0cad50ca1580353f8d
tree01e0e1de1a3ff570c4cb4ecfddff2d308756604f
parent2f472871bc182b1cd56a717dedeffdd9bae823e4
[X86] Teach X86 codegen to use vector width preference to avoid promoting to 512-bit types when VLX is enabled and the preference is for a smaller size.

This change applies to places where we would turn 128/256-bit code into 512-bit in order to get a wider element type through sext/zext. Any 512-bit types that already existed in the IR/DAG will be left that way.

The width preference has no effect on codegen behavior when the target does not have AVX512 enabled. So AVX/AVX2 codegen cannot be limited via this mechanism yet.

If the preference is lower than 256 we may still use a 256 bit type to do the operation. Constraining to 128 bits makes it much more difficult to support some operations. For many of these cases we need to change element width while keeping element count constant which is easiest done by switching between 256 and 128 bit.

The preference is only obeyed when AVX512 and VLX are available. This means the preference is not obeyed for KNL, but is obeyed for SKX, Cannonlake, and Icelake. For KNL, the only way to do masked operation is on 512-bit registers so we would have to completely disable masking to obey the preference. We would also lose support for gather, scatter, ctlz, vXi64 multiplies, etc. This may change in the future, but this simplifies the initial implementation.

Differential Revision: https://reviews.llvm.org/D41895

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323016 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86Subtarget.h
test/CodeGen/X86/prefer-avx256-lzcnt.ll [new file with mode: 0644]
test/CodeGen/X86/prefer-avx256-mask-extend.ll [new file with mode: 0644]
test/CodeGen/X86/prefer-avx256-mask-shuffle.ll [new file with mode: 0644]
test/CodeGen/X86/prefer-avx256-popcnt.ll [new file with mode: 0644]
test/CodeGen/X86/prefer-avx256-shift.ll [new file with mode: 0644]
test/CodeGen/X86/prefer-avx256-trunc.ll [new file with mode: 0644]
test/CodeGen/X86/prefer-avx256-wide-mul.ll [new file with mode: 0644]