1 ; RUN: opt < %s -O1 -S | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.10.0"
6 @a = internal global [3 x i32] zeroinitializer, align 4
7 @b = common global i32 0, align 4
9 ; The important thing we're checking for here is the reload of (some element of)
10 ; @a after the memset.
13 ; CHECK: call void @llvm.memset.p0.i64{{.*}} @a
15 ; CHECK: load i32, ptr getelementptr {{.*}} @a
21 %retval = alloca i32, align 4
22 %c = alloca [1 x i32], align 4
23 store i32 0, ptr %retval, align 4
24 call void @llvm.memset.p0.i64(ptr align 4 %c, i8 0, i64 4, i1 false)
25 store i32 1, ptr getelementptr inbounds ([3 x i32], ptr @a, i64 0, i64 2), align 4
26 store i32 0, ptr @b, align 4
29 for.cond: ; preds = %for.inc, %entry
30 %0 = load i32, ptr @b, align 4
31 %cmp = icmp slt i32 %0, 3
32 br i1 %cmp, label %for.body, label %for.end
34 for.body: ; preds = %for.cond
35 %1 = load i32, ptr @b, align 4
36 %idxprom = sext i32 %1 to i64
37 %arrayidx = getelementptr inbounds [3 x i32], ptr @a, i64 0, i64 %idxprom
38 store i32 0, ptr %arrayidx, align 4
41 for.inc: ; preds = %for.body
42 %2 = load i32, ptr @b, align 4
43 %inc = add nsw i32 %2, 1
44 store i32 %inc, ptr @b, align 4
47 for.end: ; preds = %for.cond
48 %3 = load i32, ptr getelementptr inbounds ([3 x i32], ptr @a, i64 0, i64 2), align 4
49 %cmp1 = icmp ne i32 %3, 0
50 br i1 %cmp1, label %if.then, label %if.end
52 if.then: ; preds = %for.end
56 if.end: ; preds = %for.end
60 ; Function Attrs: nounwind argmemonly
61 declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind argmemonly
63 ; Function Attrs: noreturn nounwind
64 declare void @abort() noreturn nounwind