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 { %struct.ST* }
8 @global = internal global [121 x i8] zeroinitializer, align 1
10 define void @func() #0 {
13 %s = alloca %struct.ST*, align 4
14 %j = alloca i32, align 4
15 store %struct.ST* bitcast ([121 x i8]* @global to %struct.ST*), %struct.ST** %s, align 4
16 store i32 0, i32* %j, align 4
19 for.cond: ; preds = %for.inc, %entry
20 %0 = load i32, i32* %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 %struct.ST*, %struct.ST** %s, align 4
26 %2 = bitcast %struct.ST* %1 to i8*
27 %add.ptr = getelementptr inbounds i8, i8* %2, i32 4
28 %3 = ptrtoint i8* %add.ptr to i32
29 %4 = load %struct.ST*, %struct.ST** %s, align 4
30 %5 = bitcast %struct.ST* %4 to i8*
31 %add.ptr1 = getelementptr inbounds i8, i8* %5, i32 4
32 %6 = ptrtoint i8* %add.ptr1 to i32
34 %cmp2 = icmp eq i32 %rem, 0
35 br i1 %cmp2, label %cond.true, label %cond.false
37 cond.true: ; preds = %for.body
40 cond.false: ; preds = %for.body
41 %7 = load %struct.ST*, %struct.ST** %s, align 4
42 %8 = bitcast %struct.ST* %7 to i8*
43 %add.ptr3 = getelementptr inbounds i8, i8* %8, i32 4
44 %9 = ptrtoint i8* %add.ptr3 to i32
45 %rem4 = urem i32 %9, 2
48 cond.end: ; preds = %cond.false, %cond.true
49 %cond = phi i32 [ 0, %cond.true ], [ %rem4, %cond.false ]
50 %add = add i32 %3, %cond
51 %10 = inttoptr i32 %add to %struct.ST*
52 %11 = load %struct.ST*, %struct.ST** %s, align 4
53 %next = getelementptr inbounds %struct.ST, %struct.ST* %11, i32 0, i32 0
54 store %struct.ST* %10, %struct.ST** %next, align 4
55 %12 = load %struct.ST*, %struct.ST** %s, align 4
56 %next5 = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 0
57 %13 = load %struct.ST*, %struct.ST** %next5, align 4
58 store %struct.ST* %13, %struct.ST** %s, align 4
61 for.inc: ; preds = %cond.end
62 %14 = load i32, i32* %j, align 4
63 %inc = add nsw i32 %14, 1
64 store i32 %inc, i32* %j, align 4
67 for.end: ; preds = %for.cond
68 %15 = load %struct.ST*, %struct.ST** %s, align 4
69 %next6 = getelementptr inbounds %struct.ST, %struct.ST* %15, i32 0, i32 0
70 store %struct.ST* null, %struct.ST** %next6, align 4