[x86] Generalize BuildVectorSDNode::getConstantSplatValue to work for
[oota-llvm.git] / test / CodeGen / X86 / widen_cast-4.ll
1 ; RUN: llc < %s -march=x86 -mattr=+sse4.2 | FileCheck %s
2 ; RUN: llc < %s -march=x86 -mattr=+sse4.2 -x86-experimental-vector-widening-legalization | FileCheck %s --check-prefix=CHECK-WIDE
3
4 define void @update(i64* %dst_i, i64* %src_i, i32 %n) nounwind {
5 ; CHECK-LABEL: update:
6 ; CHECK-WIDE-LABEL: update:
7 entry:
8         %dst_i.addr = alloca i64*               ; <i64**> [#uses=2]
9         %src_i.addr = alloca i64*               ; <i64**> [#uses=2]
10         %n.addr = alloca i32            ; <i32*> [#uses=2]
11         %i = alloca i32, align 4                ; <i32*> [#uses=8]
12         %dst = alloca <8 x i8>*, align 4                ; <<8 x i8>**> [#uses=2]
13         %src = alloca <8 x i8>*, align 4                ; <<8 x i8>**> [#uses=2]
14         store i64* %dst_i, i64** %dst_i.addr
15         store i64* %src_i, i64** %src_i.addr
16         store i32 %n, i32* %n.addr
17         store i32 0, i32* %i
18         br label %forcond
19
20 forcond:                ; preds = %forinc, %entry
21         %tmp = load i32* %i             ; <i32> [#uses=1]
22         %tmp1 = load i32* %n.addr               ; <i32> [#uses=1]
23         %cmp = icmp slt i32 %tmp, %tmp1         ; <i1> [#uses=1]
24         br i1 %cmp, label %forbody, label %afterfor
25
26 forbody:                ; preds = %forcond
27 ; CHECK: %forbody
28 ; CHECK-WIDE: %forbody
29         %tmp2 = load i32* %i            ; <i32> [#uses=1]
30         %tmp3 = load i64** %dst_i.addr          ; <i64*> [#uses=1]
31         %arrayidx = getelementptr i64* %tmp3, i32 %tmp2         ; <i64*> [#uses=1]
32         %conv = bitcast i64* %arrayidx to <8 x i8>*             ; <<8 x i8>*> [#uses=1]
33         store <8 x i8>* %conv, <8 x i8>** %dst
34         %tmp4 = load i32* %i            ; <i32> [#uses=1]
35         %tmp5 = load i64** %src_i.addr          ; <i64*> [#uses=1]
36         %arrayidx6 = getelementptr i64* %tmp5, i32 %tmp4                ; <i64*> [#uses=1]
37         %conv7 = bitcast i64* %arrayidx6 to <8 x i8>*           ; <<8 x i8>*> [#uses=1]
38         store <8 x i8>* %conv7, <8 x i8>** %src
39         %tmp8 = load i32* %i            ; <i32> [#uses=1]
40         %tmp9 = load <8 x i8>** %dst            ; <<8 x i8>*> [#uses=1]
41         %arrayidx10 = getelementptr <8 x i8>* %tmp9, i32 %tmp8          ; <<8 x i8>*> [#uses=1]
42         %tmp11 = load i32* %i           ; <i32> [#uses=1]
43         %tmp12 = load <8 x i8>** %src           ; <<8 x i8>*> [#uses=1]
44         %arrayidx13 = getelementptr <8 x i8>* %tmp12, i32 %tmp11                ; <<8 x i8>*> [#uses=1]
45         %tmp14 = load <8 x i8>* %arrayidx13             ; <<8 x i8>> [#uses=1]
46         %add = add <8 x i8> %tmp14, < i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1 >          ; <<8 x i8>> [#uses=1]
47         %shr = ashr <8 x i8> %add, < i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2, i8 2 >           ; <<8 x i8>> [#uses=1]
48         store <8 x i8> %shr, <8 x i8>* %arrayidx10
49         br label %forinc
50 ; CHECK:      pmovzxbw
51 ; CHECK-NEXT: paddw
52 ; CHECK-NEXT: psllw $8
53 ; CHECK-NEXT: psraw $8
54 ; CHECK-NEXT: psraw $2
55 ; CHECK-NEXT: pshufb
56 ; CHECK-NEXT: movlpd
57 ;
58 ; FIXME: We shouldn't require both a movd and an insert.
59 ; CHECK-WIDE:      movd
60 ; CHECK-WIDE-NEXT: pinsrd
61 ; CHECK-WIDE-NEXT: paddb
62 ; CHECK-WIDE-NEXT: psrlw $2
63 ; CHECK-WIDE-NEXT: pand
64 ; CHECK-WIDE-NEXT: pxor
65 ; CHECK-WIDE-NEXT: psubb
66 ; CHECK-WIDE-NEXT: pextrd
67 ; CHECK-WIDE-NEXT: movd
68
69 forinc:         ; preds = %forbody
70         %tmp15 = load i32* %i           ; <i32> [#uses=1]
71         %inc = add i32 %tmp15, 1                ; <i32> [#uses=1]
72         store i32 %inc, i32* %i
73         br label %forcond
74
75 afterfor:               ; preds = %forcond
76         ret void
77 }
78