[DAGCombiner] Vector constant folding for comparisons
[oota-llvm.git] / test / CodeGen / X86 / 2011-10-21-widen-cmp.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s
2
3 ; Check that a <4 x float> compare is generated and that we are
4 ; not stuck in an endless loop.
5
6 define void @cmp_2_floats() {
7 ; CHECK-LABEL: cmp_2_floats:
8 ; CHECK:       # BB#0: # %entry
9 ; CHECK-NEXT:    cmpordps %xmm0, %xmm0
10 ; CHECK-NEXT:    pmovzxdq {{.*#+}} xmm0 = xmm0[0],zero,xmm0[1],zero
11 ; CHECK-NEXT:    psllq $32, %xmm0
12 ; CHECK-NEXT:    pshufd {{.*#+}} xmm1 = xmm0[1,1,3,3]
13 ; CHECK-NEXT:    psrad $31, %xmm0
14 ; CHECK-NEXT:    pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5],xmm0[6,7]
15 ; CHECK-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
16 ; CHECK-NEXT:    pslld $31, %xmm0
17 ; CHECK-NEXT:    blendvps %xmm0, %xmm0
18 ; CHECK-NEXT:    movlps %xmm0, (%rax)
19 ; CHECK-NEXT:    retq
20 entry:
21   %0 = fcmp oeq <2 x float> undef, undef
22   %1 = select <2 x i1> %0, <2 x float> undef, <2 x float> undef
23   store <2 x float> %1, <2 x float>* undef
24   ret void
25 }
26
27 define void @cmp_2_doubles() {
28 ; CHECK-LABEL: cmp_2_doubles:
29 ; CHECK:       # BB#0: # %entry
30 ; CHECK-NEXT:    cmpordpd %xmm0, %xmm0
31 ; CHECK-NEXT:    blendvpd %xmm0, %xmm0
32 ; CHECK-NEXT:    movapd %xmm0, (%rax)
33 ; CHECK-NEXT:    retq
34 entry:
35   %0 = fcmp oeq <2 x double> undef, undef
36   %1 = select <2 x i1> %0, <2 x double> undef, <2 x double> undef
37   store <2 x double> %1, <2 x double>* undef
38   ret void
39 }
40
41 define void @mp_11193(<8 x float> * nocapture %aFOO, <8 x float>* nocapture %RET) nounwind {
42 ; CHECK-LABEL: mp_11193:
43 ; CHECK:       # BB#0: # %allocas
44 ; CHECK-NEXT:    movl $-1082130432, (%rsi) # imm = 0xFFFFFFFFBF800000
45 ; CHECK-NEXT:    retq
46 allocas:
47   %bincmp = fcmp olt <8 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 9.000000e+00, float 1.000000e+00, float 9.000000e+00, float 1.000000e+00> , <float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00>
48   %t = extractelement <8 x i1> %bincmp, i32 0
49   %ft = sitofp i1 %t to float
50   %pp = bitcast <8 x float>* %RET to float*
51   store float %ft, float* %pp
52   ret void
53 }
54