Re-implement the main strength-reduction portion of LoopStrengthReduction.
[oota-llvm.git] / test / CodeGen / X86 / widen_arith-1.ll
1 ; RUN: llc < %s -march=x86 -mattr=+sse42 -disable-mmx |  FileCheck %s
2
3 ; Widen a v3i8 to v16i8 to use a vector add
4
5 define void @update(<3 x i8>* %dst, <3 x i8>* %src, i32 %n) nounwind {
6 entry:
7 ; CHECK-NOT: pextrw
8 ; CHECK: paddb
9 ; CHECK: pextrb
10         %dst.addr = alloca <3 x i8>*            ; <<3 x i8>**> [#uses=2]
11         %src.addr = alloca <3 x i8>*            ; <<3 x i8>**> [#uses=2]
12         %n.addr = alloca i32            ; <i32*> [#uses=2]
13         %i = alloca i32, align 4                ; <i32*> [#uses=6]
14         store <3 x i8>* %dst, <3 x i8>** %dst.addr
15         store <3 x i8>* %src, <3 x i8>** %src.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         %tmp2 = load i32* %i            ; <i32> [#uses=1]
28         %tmp3 = load <3 x i8>** %dst.addr               ; <<3 x i8>*> [#uses=1]
29         %arrayidx = getelementptr <3 x i8>* %tmp3, i32 %tmp2            ; <<3 x i8>*> [#uses=1]
30         %tmp4 = load i32* %i            ; <i32> [#uses=1]
31         %tmp5 = load <3 x i8>** %src.addr               ; <<3 x i8>*> [#uses=1]
32         %arrayidx6 = getelementptr <3 x i8>* %tmp5, i32 %tmp4           ; <<3 x i8>*> [#uses=1]
33         %tmp7 = load <3 x i8>* %arrayidx6               ; <<3 x i8>> [#uses=1]
34         %add = add <3 x i8> %tmp7, < i8 1, i8 1, i8 1 >         ; <<3 x i8>> [#uses=1]
35         store <3 x i8> %add, <3 x i8>* %arrayidx
36         br label %forinc
37
38 forinc:         ; preds = %forbody
39         %tmp8 = load i32* %i            ; <i32> [#uses=1]
40         %inc = add i32 %tmp8, 1         ; <i32> [#uses=1]
41         store i32 %inc, i32* %i
42         br label %forcond
43
44 afterfor:               ; preds = %forcond
45         ret void
46 }