1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
3 ; RUN: opt -O3 -S < %s | FileCheck %s
5 define internal i32 @loop(ptr %arg, ptr %arg1) {
10 %phi = phi ptr [ %arg, %bb ], [ %phi8, %bb11 ]
11 %phi3 = phi i32 [ 0, %bb ], [ %add, %bb11 ]
12 %icmp = icmp ne ptr %arg1, null
13 %icmp4 = icmp eq ptr %phi, %arg1
14 br i1 %icmp4, label %bb7, label %bb5
17 %getelementptr = getelementptr inbounds i32, ptr %phi, i64 1
21 %phi8 = phi ptr [ %phi, %bb2 ], [ %getelementptr, %bb5 ]
22 %phi9 = phi ptr [ null, %bb2 ], [ %phi, %bb5 ]
23 %icmp10 = icmp eq ptr %phi9, null
24 br i1 %icmp10, label %bb12, label %bb11
27 %load = load i32, ptr %phi9, align 4
28 %add = add i32 %load, %phi3
35 define i32 @using_alloca() {
36 ; CHECK-LABEL: define i32 @using_alloca
37 ; CHECK-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
39 ; CHECK-NEXT: ret i32 6
42 %alloca = alloca [3 x i32], align 4
43 store i32 1, ptr %alloca, align 4
44 %getelementptr = getelementptr i32, ptr %alloca, i32 1
45 store i32 2, ptr %getelementptr, align 4
46 %getelementptr1 = getelementptr i32, ptr %alloca, i32 2
47 store i32 3, ptr %getelementptr1, align 4
48 %getelementptr2 = getelementptr i32, ptr %alloca, i32 3
49 %call = call i32 @loop(ptr %alloca, ptr %getelementptr2)
53 define i32 @using_malloc() {
54 ; CHECK-LABEL: define i32 @using_malloc
55 ; CHECK-SAME: () local_unnamed_addr #[[ATTR0]] {
57 ; CHECK-NEXT: ret i32 6
60 %alloc = call dereferenceable_or_null(64) ptr @malloc(i64 64)
61 store i32 1, ptr %alloc, align 4
62 %getelementptr = getelementptr i32, ptr %alloc, i64 1
63 store i32 2, ptr %getelementptr, align 4
64 %getelementptr1 = getelementptr i32, ptr %alloc, i64 2
65 store i32 3, ptr %getelementptr1, align 4
66 %getelementptr2 = getelementptr i32, ptr %alloc, i64 3
67 %call = call i32 @loop(ptr %alloc, ptr %getelementptr2)
71 declare ptr @malloc(i64)
73 declare void @free(ptr)