[X86] Rewrite to the vXi1 subvector insertion code to not rely on the value of bits...
authorCraig Topper <craig.topper@intel.com>
Wed, 2 Oct 2019 17:47:09 +0000 (17:47 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 2 Oct 2019 17:47:09 +0000 (17:47 +0000)
commit74c7d6be2843b2040f5b8ca712ee715475369196
tree4a861a8cdab9ba8c711d4867b013be5638dd03e7
parent0cacf136fcbce5eeacd2d225264f62dba272c64f
[X86] Rewrite to the vXi1 subvector insertion code to not rely on the value of bits that might be undef

The previous code tried to do a trick where we would extract the subvector from the location we were inserting. Then xor that with the new value. Take the xored value and clear out the bits above the subvector size. Then shift that xored subvector to the insert location. And finally xor that with the original vector. Since the old subvector was used in both xors, this would leave just the new subvector at the inserted location. Since the surrounding bits had been zeroed no other bits of the original vector would be modified.

Unfortunately, if the old subvector came from undef we might aggressively propagate the undef. Then we end up with the XORs not cancelling because they aren't using the same value for the two uses of the old subvector. @bkramer gave me a case that demonstrated this, but we haven't reduced it enough to make it easily readable to see what's happening.

This patch uses a safer, but more costly approach. It isolate the bits above the insertion and bits below the insert point and ORs those together leaving 0 for the insertion location. Then widens the subvector with 0s in the upper bits, shifts it into position with 0s in the lower bits. Then we do another OR.

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

llvm-svn: 373495
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx512-calling-conv.ll
llvm/test/CodeGen/X86/avx512-ext.ll
llvm/test/CodeGen/X86/avx512-insert-extract.ll
llvm/test/CodeGen/X86/avx512-mask-op.ll
llvm/test/CodeGen/X86/masked_store.ll
llvm/test/CodeGen/X86/vec_smulo.ll
llvm/test/CodeGen/X86/vec_umulo.ll