1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse4.2 -post-RA-scheduler=true | FileCheck %s
3
4; Widen a v3i16 to v8i16 to do a vector add
5
6@.str = internal constant [4 x i8] c"%d \00"
7@.str1 = internal constant [2 x i8] c"\0A\00"
8
9define void @update(<3 x i16>* %dst, <3 x i16>* %src, i32 %n) nounwind {
10; CHECK-LABEL: update:
11; CHECK:       # %bb.0: # %entry
12; CHECK-NEXT:    pushl %ebp
13; CHECK-NEXT:    movl %esp, %ebp
14; CHECK-NEXT:    andl $-8, %esp
15; CHECK-NEXT:    subl $16, %esp
16; CHECK-NEXT:    pcmpeqd %xmm0, %xmm0
17; CHECK-NEXT:    movw $1, {{[0-9]+}}(%esp)
18; CHECK-NEXT:    movl $65537, {{[0-9]+}}(%esp) # imm = 0x10001
19; CHECK-NEXT:    movl $0, {{[0-9]+}}(%esp)
20; CHECK-NEXT:    .p2align 4, 0x90
21; CHECK-NEXT:  .LBB0_1: # %forcond
22; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
23; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
24; CHECK-NEXT:    cmpl 16(%ebp), %eax
25; CHECK-NEXT:    jge .LBB0_3
26; CHECK-NEXT:  # %bb.2: # %forbody
27; CHECK-NEXT:    # in Loop: Header=BB0_1 Depth=1
28; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
29; CHECK-NEXT:    movl 12(%ebp), %edx
30; CHECK-NEXT:    movl 8(%ebp), %ecx
31; CHECK-NEXT:    movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
32; CHECK-NEXT:    pinsrw $2, 4(%edx,%eax,8), %xmm1
33; CHECK-NEXT:    psubw %xmm0, %xmm1
34; CHECK-NEXT:    pextrw $2, %xmm1, 4(%ecx,%eax,8)
35; CHECK-NEXT:    movd %xmm1, (%ecx,%eax,8)
36; CHECK-NEXT:    incl {{[0-9]+}}(%esp)
37; CHECK-NEXT:    jmp .LBB0_1
38; CHECK-NEXT:  .LBB0_3: # %afterfor
39; CHECK-NEXT:    movl %ebp, %esp
40; CHECK-NEXT:    popl %ebp
41; CHECK-NEXT:    retl
42entry:
43	%dst.addr = alloca <3 x i16>*
44	%src.addr = alloca <3 x i16>*
45	%n.addr = alloca i32
46	%v = alloca <3 x i16>, align 8
47	%i = alloca i32, align 4
48	store <3 x i16>* %dst, <3 x i16>** %dst.addr
49	store <3 x i16>* %src, <3 x i16>** %src.addr
50	store i32 %n, i32* %n.addr
51	store <3 x i16> < i16 1, i16 1, i16 1 >, <3 x i16>* %v
52	store i32 0, i32* %i
53	br label %forcond
54
55forcond:
56	%tmp = load i32, i32* %i
57	%tmp1 = load i32, i32* %n.addr
58	%cmp = icmp slt i32 %tmp, %tmp1
59	br i1 %cmp, label %forbody, label %afterfor
60
61forbody:
62	%tmp2 = load i32, i32* %i
63	%tmp3 = load <3 x i16>*, <3 x i16>** %dst.addr
64	%arrayidx = getelementptr <3 x i16>, <3 x i16>* %tmp3, i32 %tmp2
65	%tmp4 = load i32, i32* %i
66	%tmp5 = load <3 x i16>*, <3 x i16>** %src.addr
67	%arrayidx6 = getelementptr <3 x i16>, <3 x i16>* %tmp5, i32 %tmp4
68	%tmp7 = load <3 x i16>, <3 x i16>* %arrayidx6
69	%add = add <3 x i16> %tmp7, < i16 1, i16 1, i16 1 >
70	store <3 x i16> %add, <3 x i16>* %arrayidx
71	br label %forinc
72
73forinc:
74	%tmp8 = load i32, i32* %i
75	%inc = add i32 %tmp8, 1
76	store i32 %inc, i32* %i
77	br label %forcond
78
79afterfor:
80	ret void
81}
82
83