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.p0i8.i64{{.*}} @a
15 ; CHECK: load i32, i32* getelementptr {{.*}} @a
21 %retval = alloca i32, align 4
22 %c = alloca [1 x i32], align 4
23 store i32 0, i32* %retval, align 4
24 %0 = bitcast [1 x i32]* %c to i8*
25 call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 4, i1 false)
26 store i32 1, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
27 store i32 0, i32* @b, align 4
30 for.cond: ; preds = %for.inc, %entry
31 %1 = load i32, i32* @b, align 4
32 %cmp = icmp slt i32 %1, 3
33 br i1 %cmp, label %for.body, label %for.end
35 for.body: ; preds = %for.cond
36 %2 = load i32, i32* @b, align 4
37 %idxprom = sext i32 %2 to i64
38 %arrayidx = getelementptr inbounds [3 x i32], [3 x i32]* @a, i64 0, i64 %idxprom
39 store i32 0, i32* %arrayidx, align 4
42 for.inc: ; preds = %for.body
43 %3 = load i32, i32* @b, align 4
44 %inc = add nsw i32 %3, 1
45 store i32 %inc, i32* @b, align 4
48 for.end: ; preds = %for.cond
49 %4 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
50 %cmp1 = icmp ne i32 %4, 0
51 br i1 %cmp1, label %if.then, label %if.end
53 if.then: ; preds = %for.end
57 if.end: ; preds = %for.end
61 ; Function Attrs: nounwind argmemonly
62 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind argmemonly
64 ; Function Attrs: noreturn nounwind
65 declare void @abort() noreturn nounwind