1 ; NOTE: This is a timeout test for some O(something silly) constant folding behaviour. It may not be the best test. Providing it finishes, it passes.
2 ; RUN: opt < %s -O3 -S | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "armv8-none-eabi"
6 %struct.ST = type { ptr }
8 @global = internal global [121 x i8] zeroinitializer, align 1
10 define void @func() #0 {
13 %s = alloca ptr, align 4
14 %j = alloca i32, align 4
15 store ptr @global, ptr %s, align 4
16 store i32 0, ptr %j, align 4
19 for.cond: ; preds = %for.inc, %entry
20 %0 = load i32, ptr %j, align 4
21 %cmp = icmp slt i32 %0, 30
22 br i1 %cmp, label %for.body, label %for.end
24 for.body: ; preds = %for.cond
25 %1 = load ptr, ptr %s, align 4
26 %add.ptr = getelementptr inbounds i8, ptr %1, i32 4
27 %2 = ptrtoint ptr %add.ptr to i32
28 %3 = load ptr, ptr %s, align 4
29 %add.ptr1 = getelementptr inbounds i8, ptr %3, i32 4
30 %4 = ptrtoint ptr %add.ptr1 to i32
32 %cmp2 = icmp eq i32 %rem, 0
33 br i1 %cmp2, label %cond.true, label %cond.false
35 cond.true: ; preds = %for.body
38 cond.false: ; preds = %for.body
39 %5 = load ptr, ptr %s, align 4
40 %add.ptr3 = getelementptr inbounds i8, ptr %5, i32 4
41 %6 = ptrtoint ptr %add.ptr3 to i32
42 %rem4 = urem i32 %6, 2
45 cond.end: ; preds = %cond.false, %cond.true
46 %cond = phi i32 [ 0, %cond.true ], [ %rem4, %cond.false ]
47 %add = add i32 %2, %cond
48 %7 = inttoptr i32 %add to ptr
49 %8 = load ptr, ptr %s, align 4
50 %next = getelementptr inbounds %struct.ST, ptr %8, i32 0, i32 0
51 store ptr %7, ptr %next, align 4
52 %9 = load ptr, ptr %s, align 4
53 %next5 = getelementptr inbounds %struct.ST, ptr %9, i32 0, i32 0
54 %10 = load ptr, ptr %next5, align 4
55 store ptr %10, ptr %s, align 4
58 for.inc: ; preds = %cond.end
59 %11 = load i32, ptr %j, align 4
60 %inc = add nsw i32 %11, 1
61 store i32 %inc, ptr %j, align 4
64 for.end: ; preds = %for.cond
65 %12 = load ptr, ptr %s, align 4
66 %next6 = getelementptr inbounds %struct.ST, ptr %12, i32 0, i32 0
67 store ptr null, ptr %next6, align 4