[x86] Simplify vector selection if condition value type matches vselect value type...
[oota-llvm.git] / test / CodeGen / X86 / vselect-avx.ll
1 ; RUN: llc %s -o - -mattr=+avx | FileCheck %s
2 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-apple-macosx"
4
5 ; For this test we used to optimize the <i1 true, i1 false, i1 false, i1 true>
6 ; mask into <i32 2147483648, i32 0, i32 0, i32 2147483648> because we thought
7 ; we would lower that into a blend where only the high bit is relevant.
8 ; However, since the whole mask is constant, this is simplified incorrectly
9 ; by the generic code, because it was expecting -1 in place of 2147483648.
10
11 ; The problem does not occur without AVX, because vselect of v4i32 is not legal
12 ; nor custom.
13 ;
14 ; <rdar://problem/18675020>
15
16 ; CHECK-LABEL: test:
17 ; CHECK: vmovdqa {{.*#+}} xmm0 = [65535,0,0,65535]
18 ; CHECK: vmovdqa {{.*#+}} xmm2 = [65533,124,125,14807]
19 ; CHECK: ret
20 define void @test(<4 x i16>* %a, <4 x i16>* %b) {
21 body:
22   %predphi = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i16> <i16 -3, i16 545, i16 4385, i16 14807>, <4 x i16> <i16 123, i16 124, i16 125, i16 127>
23   %predphi42 = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1>, <4 x i16> zeroinitializer
24   store <4 x i16> %predphi, <4 x i16>* %a, align 8
25   store <4 x i16> %predphi42, <4 x i16>* %b, align 8
26   ret void
27 }