1 ; RUN: opt -disable-verify -passes='default<O2>' -S < %s | FileCheck %s
3 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; The local array %tmp can only be optimized away by sroa after loop unroll.
8 ; CHECK-LABEL: define void @foo
10 ; CHECK-NOT: call void @llvm.memcpy.p0.p0.i64
12 ; Function Attrs: nounwind uwtable
13 define void @foo(ptr %a, ptr %b) {
15 %a.addr = alloca ptr, align 8
16 %b.addr = alloca ptr, align 8
17 %tmp = alloca [4 x float], align 16
18 %i = alloca i32, align 4
19 store ptr %a, ptr %a.addr, align 8
20 store ptr %b, ptr %b.addr, align 8
21 store i32 0, ptr %i, align 4
24 for.cond: ; preds = %for.inc, %entry
25 %iter2 = load i32, ptr %i, align 4
26 %cmp = icmp slt i32 %iter2, 4
27 br i1 %cmp, label %for.body, label %for.cond.cleanup
29 for.cond.cleanup: ; preds = %for.cond
32 for.body: ; preds = %for.cond
33 %inptr = load ptr, ptr %a.addr, align 8
34 %idx2 = load i32, ptr %i, align 4
35 %idxprom = sext i32 %idx2 to i64
36 %arrayidx = getelementptr inbounds i32, ptr %inptr, i64 %idxprom
37 %val = load i32, ptr %arrayidx, align 4
38 %conv = sitofp i32 %val to float
39 %idx = load i32, ptr %i, align 4
40 %idxprom1 = sext i32 %idx to i64
41 %arrayidx2 = getelementptr inbounds [4 x float], ptr %tmp, i64 0, i64 %idxprom1
42 store float %conv, ptr %arrayidx2, align 4
45 for.inc: ; preds = %for.body
46 %iter = load i32, ptr %i, align 4
47 %inc = add nsw i32 %iter, 1
48 store i32 %inc, ptr %i, align 4
51 for.end: ; preds = %for.cond.cleanup
52 %dstptr = load ptr, ptr %b.addr, align 8
53 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %dstptr, ptr align 16 %tmp, i64 16, i1 false)
57 ; Function Attrs: argmemonly nounwind willreturn
58 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)