[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)
commit08bd14803cf6a89700db914b68affe98879f4049
treec35687f4905d8eaade1b11320ead725448cce388
parent0d797a34d8be0707c4f17e88d7d22004d844fbf4
[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

llvm-svn: 323016
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/prefer-avx256-lzcnt.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/prefer-avx256-mask-extend.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/prefer-avx256-mask-shuffle.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/prefer-avx256-popcnt.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/prefer-avx256-shift.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/prefer-avx256-trunc.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/prefer-avx256-wide-mul.ll [new file with mode: 0644]