Merging r259740:
[oota-llvm.git] / test / CodeGen / PowerPC / addi-licm.ll
1 ; RUN: llc -mcpu=pwr7 -disable-ppc-preinc-prep < %s | FileCheck %s
2 ; RUN: llc -mcpu=pwr7 < %s | FileCheck %s -check-prefix=PIP
3 target datalayout = "E-m:e-i64:64-n32:64"
4 target triple = "powerpc64-unknown-linux-gnu"
5
6 ; Function Attrs: nounwind
7 define double @foo() #1 {
8 entry:
9   %x = alloca [2048 x float], align 4
10   %y = alloca [2048 x float], align 4
11   %0 = bitcast [2048 x float]* %x to i8*
12   call void @llvm.lifetime.start(i64 8192, i8* %0) #2
13   %1 = bitcast [2048 x float]* %y to i8*
14   call void @llvm.lifetime.start(i64 8192, i8* %1) #2
15   br label %for.body.i
16
17 ; CHECK-LABEL: @foo
18 ; CHECK: addi [[REG1:[0-9]+]], 1,
19 ; CHECK: addi [[REG2:[0-9]+]], 1,
20 ; CHECK: %for.body.i
21 ; CHECK-DAG: lfsx {{[0-9]+}}, [[REG1]],
22 ; CHECK-DAG: lfsx {{[0-9]+}}, [[REG2]],
23 ; CHECK: blr
24
25 ; PIP-LABEL: @foo
26 ; PIP: addi [[REG1:[0-9]+]], 1,
27 ; PIP: addi [[REG2:[0-9]+]], 1,
28 ; PIP: %for.body.i
29 ; PIP-DAG: lfsu {{[0-9]+}}, 4([[REG1]])
30 ; PIP-DAG: lfsu {{[0-9]+}}, 4([[REG2]])
31 ; PIP: blr
32
33 for.body.i:                                       ; preds = %for.body.i.preheader, %for.body.i
34   %accumulator.09.i = phi double [ %add.i, %for.body.i ], [ 0.000000e+00, %entry ]
35   %i.08.i = phi i64 [ %inc.i, %for.body.i ], [ 0, %entry ]
36   %arrayidx.i = getelementptr inbounds [2048 x float], [2048 x float]* %x, i64 0, i64 %i.08.i
37   %v14 = load float, float* %arrayidx.i, align 4
38   %conv.i = fpext float %v14 to double
39   %arrayidx1.i = getelementptr inbounds [2048 x float], [2048 x float]* %y, i64 0, i64 %i.08.i
40   %v15 = load float, float* %arrayidx1.i, align 4
41   %conv2.i = fpext float %v15 to double
42   %mul.i = fmul double %conv.i, %conv2.i
43   %add.i = fadd double %accumulator.09.i, %mul.i
44   %inc.i = add nuw nsw i64 %i.08.i, 1
45   %exitcond.i = icmp eq i64 %i.08.i, 2047
46   br i1 %exitcond.i, label %loop.exit, label %for.body.i
47
48 loop.exit:                                        ; preds = %for.body.i
49   ret double %accumulator.09.i
50 }
51
52 ; Function Attrs: nounwind
53 declare void @llvm.lifetime.start(i64, i8* nocapture) #2
54
55 declare void @bar(float*, float*)
56
57 ; Function Attrs: nounwind
58 declare void @llvm.lifetime.end(i64, i8* nocapture) #2
59
60 attributes #0 = { nounwind readonly }
61 attributes #1 = { nounwind }
62 attributes #2 = { nounwind }
63
64