PPC: Combine duplicate (offset) lvsl Altivec intrinsics
[oota-llvm.git] / test / CodeGen / PowerPC / unal-altivec.ll
1 ; RUN: llc < %s -mcpu=g5 | FileCheck %s
2 ; RUN: llc < %s -mcpu=g5 | FileCheck %s -check-prefix=CHECK-PC
3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
4 target triple = "powerpc64-unknown-linux-gnu"
5
6 define void @foo(float* noalias nocapture %a, float* noalias nocapture %b) #0 {
7 vector.ph:
8   br label %vector.body
9
10 vector.body:                                      ; preds = %vector.body, %vector.ph
11   %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
12   %0 = getelementptr inbounds float* %b, i64 %index
13   %1 = bitcast float* %0 to <4 x float>*
14   %wide.load = load <4 x float>* %1, align 4
15   %.sum11 = or i64 %index, 4
16   %2 = getelementptr float* %b, i64 %.sum11
17   %3 = bitcast float* %2 to <4 x float>*
18   %wide.load8 = load <4 x float>* %3, align 4
19   %4 = fadd <4 x float> %wide.load, <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
20   %5 = fadd <4 x float> %wide.load8, <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
21   %6 = getelementptr inbounds float* %a, i64 %index
22   %7 = bitcast float* %6 to <4 x float>*
23   store <4 x float> %4, <4 x float>* %7, align 4
24   %.sum12 = or i64 %index, 4
25   %8 = getelementptr float* %a, i64 %.sum12
26   %9 = bitcast float* %8 to <4 x float>*
27   store <4 x float> %5, <4 x float>* %9, align 4
28   %index.next = add i64 %index, 8
29   %10 = icmp eq i64 %index.next, 16000
30   br i1 %10, label %for.end, label %vector.body
31
32 ; CHECK: @foo
33 ; CHECK: lvx [[CNST:[0-9]+]],
34 ; CHECK-DAG: lvsl [[PC:[0-9]+]], [[B1:[0-9]+]], [[B2:[0-9]+]]
35 ; CHECK-DAG: lvx [[LD1:[0-9]+]], [[B1]], [[B2]]
36 ; CHECK-DAG: add [[B3:[0-9]+]], [[B1]], [[B2]]
37 ; CHECK-DAG: lvx [[LD2:[0-9]+]], [[B3]],
38 ; CHECK-DAG: vperm [[R1:[0-9]+]], [[LD1]], [[LD2]], [[PC]]
39 ; CHECK: vaddfp {{[0-9]+}}, [[R1]], [[CNST]]
40 ; CHECK: blr
41
42 ; CHECK-PC: @foo
43 ; CHECK-PC: lvsl
44 ; CHECK-PC-NOT: lvsl
45 ; CHECK-PC: blr
46
47 for.end:                                          ; preds = %vector.body
48   ret void
49 }
50
51 attributes #0 = { nounwind }