Convert some X86 blendv* intrinsics into IR.
authorFilipe Cabecinhas <me@filcab.net>
Tue, 27 May 2014 03:42:20 +0000 (03:42 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Tue, 27 May 2014 03:42:20 +0000 (03:42 +0000)
commitc5f611404c4eecf5006e7bb72b69d6da029e382a
treec04d399aa1d1bfb15601334920b7c906522f5e6d
parentb84ced649ee46c4709770e22ccfbc73cc094f81e
Convert some X86 blendv* intrinsics into IR.

Summary:
Implemented an InstCombine transformation that takes a blendv* intrinsic
call and translates it into an IR select, if the mask is constant.

This will eventually get lowered into blends with immediates if possible,
or pblendvb (with an option to further optimize if we can transform the
pblendvb into a blend+immediate instruction, depending on the selector).
It will also enable optimizations by the IR passes, which give up on
sight of the intrinsic.

Both the transformation and the lowering of its result to asm got shiny
new tests.

The transformation is a bit convoluted because of blendvp[sd]'s
definition:

Its mask is a floating point value! This forces us to convert it and get
the highest bit. I suppose this happened because the mask has type
__m128 in Intel's intrinsic and v4sf (for blendps) in gcc's builtin.

I will send an email to llvm-dev to discuss if we want to change this or
not.

Reviewers: grosbach, delena, nadav

Differential Revision: http://reviews.llvm.org/D3859

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209643 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCalls.cpp
test/CodeGen/X86/avx-blend.ll
test/CodeGen/X86/avx2-blend.ll [new file with mode: 0644]
test/CodeGen/X86/sse41-blend.ll
test/Transforms/InstCombine/blend_x86.ll [new file with mode: 0644]