1 ; RUN: opt -passes=gvn -S -o - %s | FileCheck %s
\r
2 ; RUN: opt -passes=newgvn -S -o - %s | FileCheck %s
\r
3 ; Test that the constantfolding getelementptr computation results in
\r
5 ; and not [1][4][4][1] (#449) which is an incorrect out-of-range error
\r
6 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
\r
7 target triple = "armv7-none-eabi"
\r
9 @f = local_unnamed_addr global i32 2, align 4
\r
10 @t6 = local_unnamed_addr global i32 1, align 4
\r
11 @j = local_unnamed_addr global [6 x [6 x [7 x i8]]] [[6 x [7 x i8]] [[7 x i8] c"\06\00\00\00\00\00\00", [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer], [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer], align 1
\r
12 @p = internal global i64 0, align 8
\r
13 @y = local_unnamed_addr global ptr @p, align 4
\r
14 @b = internal unnamed_addr global i32 0, align 4
\r
15 @h = common local_unnamed_addr global i16 0, align 2
\r
16 @a = common local_unnamed_addr global i32 0, align 4
\r
17 @k = common local_unnamed_addr global i32 0, align 4
\r
18 @t11 = common local_unnamed_addr global i32 0, align 4
\r
20 ; Function Attrs: nounwind
\r
21 define i32 @main() local_unnamed_addr {
\r
23 %0 = load i32, ptr @t6, align 4
\r
24 %inc = add nsw i32 %0, 1
\r
25 store i32 %inc, ptr @t6, align 4
\r
26 store i16 4, ptr @h, align 2
\r
27 %1 = load i32, ptr @a, align 4
\r
28 %conv = trunc i32 %1 to i8
\r
29 store i32 1, ptr @f, align 4
\r
30 %2 = load i64, ptr @p, align 8
\r
31 %cmp4 = icmp slt i64 %2, 2
\r
32 %conv6 = zext i1 %cmp4 to i8
\r
33 %3 = load i16, ptr @h, align 2
\r
34 %conv7 = sext i16 %3 to i32
\r
35 %add = add nsw i32 %conv7, 1
\r
36 %f.promoted = load i32, ptr @f, align 4
\r
37 %4 = mul i32 %conv7, 7
\r
39 %6 = sub i32 -1, %f.promoted
\r
40 %7 = icmp sgt i32 %6, -2
\r
41 %smax = select i1 %7, i32 %6, i32 -2
\r
42 %8 = sub i32 6, %smax
\r
43 %scevgep = getelementptr [6 x [6 x [7 x i8]]], ptr @j, i32 0, i32 0, i32 %5, i32 %8
\r
44 %9 = add i32 %f.promoted, %smax
\r
46 call void @llvm.memset.p0.i32(ptr %scevgep, i8 %conv6, i32 %10, i1 false)
\r
47 ; CHECK: call void @llvm.memset.p0.i32(ptr getelementptr inbounds ([6 x [6 x [7 x i8]]], ptr @j, i32 0, i{{32|64}} 5, i{{32|64}} 4, i32 1), i8 %conv6, i32 1, i1 false)
\r
48 ; CHECK-NOT: call void @llvm.memset.p0.i32(ptr getelementptr ([6 x [6 x [7 x i8]]], ptr @j, i64 1, i64 4, i64 4, i32 1)
\r
51 ; Function Attrs: argmemonly nounwind
\r
52 declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1)
\r