xref: /aosp_15_r20/external/llvm/test/Transforms/GlobalOpt/heap-sra-2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -globalopt -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker	%struct.foo = type { i32, i32 }
5*9880d681SAndroid Build Coastguard Worker@X = internal global %struct.foo* null		; <%struct.foo**> [#uses=2]
6*9880d681SAndroid Build Coastguard Worker; CHECK: @X.f0
7*9880d681SAndroid Build Coastguard Worker; CHECK: @X.f1
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workerdefine void @bar(i32 %Size) nounwind noinline {
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker	%malloccall = tail call i8* @malloc(i64 8000000) ; <i8*> [#uses=1]
12*9880d681SAndroid Build Coastguard Worker	%0 = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1]
13*9880d681SAndroid Build Coastguard Worker	%.sub = getelementptr [1000000 x %struct.foo], [1000000 x %struct.foo]* %0, i32 0, i32 0		; <%struct.foo*> [#uses=1]
14*9880d681SAndroid Build Coastguard Worker	store %struct.foo* %.sub, %struct.foo** @X, align 4
15*9880d681SAndroid Build Coastguard Worker	ret void
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerdeclare noalias i8* @malloc(i64)
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerdefine i32 @baz() nounwind readonly noinline {
21*9880d681SAndroid Build Coastguard Workerbb1.thread:
22*9880d681SAndroid Build Coastguard Worker	%0 = load %struct.foo*, %struct.foo** @X, align 4		; <%struct.foo*> [#uses=1]
23*9880d681SAndroid Build Coastguard Worker	br label %bb1
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Workerbb1:		; preds = %bb1, %bb1.thread
26*9880d681SAndroid Build Coastguard Worker	%i.0.reg2mem.0 = phi i32 [ 0, %bb1.thread ], [ %indvar.next, %bb1 ]		; <i32> [#uses=2]
27*9880d681SAndroid Build Coastguard Worker	%sum.0.reg2mem.0 = phi i32 [ 0, %bb1.thread ], [ %3, %bb1 ]		; <i32> [#uses=1]
28*9880d681SAndroid Build Coastguard Worker	%1 = getelementptr %struct.foo, %struct.foo* %0, i32 %i.0.reg2mem.0, i32 0		; <i32*> [#uses=1]
29*9880d681SAndroid Build Coastguard Worker	%2 = load i32, i32* %1, align 4		; <i32> [#uses=1]
30*9880d681SAndroid Build Coastguard Worker	%3 = add i32 %2, %sum.0.reg2mem.0		; <i32> [#uses=2]
31*9880d681SAndroid Build Coastguard Worker	%indvar.next = add i32 %i.0.reg2mem.0, 1		; <i32> [#uses=2]
32*9880d681SAndroid Build Coastguard Worker	%exitcond = icmp eq i32 %indvar.next, 1200		; <i1> [#uses=1]
33*9880d681SAndroid Build Coastguard Worker	br i1 %exitcond, label %bb2, label %bb1
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workerbb2:		; preds = %bb1
36*9880d681SAndroid Build Coastguard Worker	ret i32 %3
37*9880d681SAndroid Build Coastguard Worker}
38*9880d681SAndroid Build Coastguard Worker
39