1; RUN: opt < %s -O1 -S | FileCheck %s 2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-apple-macosx10.10.0" 5 6@a = internal global [3 x i32] zeroinitializer, align 4 7@b = common global i32 0, align 4 8 9; The important thing we're checking for here is the reload of (some element of) 10; @a after the memset. 11 12; CHECK-LABEL: @main 13; CHECK: call void @llvm.memset.p0.i64{{.*}} @a 14; CHECK: store i32 3 15; CHECK: load i32, ptr getelementptr {{.*}} @a 16; CHECK: icmp eq i32 17; CHECK: br i1 18 19define i32 @main() { 20entry: 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 27 br label %for.cond 28 29for.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 33 34for.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 39 br label %for.inc 40 41for.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 45 br label %for.cond 46 47for.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 51 52if.then: ; preds = %for.end 53 call void @abort() #3 54 unreachable 55 56if.end: ; preds = %for.end 57 ret i32 0 58} 59 60; Function Attrs: nounwind argmemonly 61declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind argmemonly 62 63; Function Attrs: noreturn nounwind 64declare void @abort() noreturn nounwind 65