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