1; RUN: llc < %s -O2 -mtriple=arm64-apple-darwin | FileCheck %s
2
3%0 = type opaque
4%struct.CGRect = type { %struct.CGPoint, %struct.CGSize }
5%struct.CGPoint = type { double, double }
6%struct.CGSize = type { double, double }
7
8@"OBJC_IVAR_$_UIScreen._bounds" = external hidden global i64, section "__DATA, __objc_ivar", align 8
9
10define hidden %struct.CGRect @nofold(%0* nocapture %self, i8* nocapture %_cmd) nounwind readonly optsize ssp {
11entry:
12; CHECK-LABEL: nofold:
13; CHECK: add x[[REG:[0-9]+]], x0, x{{[0-9]+}}
14; CHECK: ldp d0, d1, [x[[REG]]]
15; CHECK: ldp d2, d3, [x[[REG]], #16]
16; CHECK: ret
17  %ivar = load i64* @"OBJC_IVAR_$_UIScreen._bounds", align 8, !invariant.load !4
18  %0 = bitcast %0* %self to i8*
19  %add.ptr = getelementptr inbounds i8* %0, i64 %ivar
20  %add.ptr10.0 = bitcast i8* %add.ptr to double*
21  %tmp11 = load double* %add.ptr10.0, align 8
22  %add.ptr.sum = add i64 %ivar, 8
23  %add.ptr10.1 = getelementptr inbounds i8* %0, i64 %add.ptr.sum
24  %1 = bitcast i8* %add.ptr10.1 to double*
25  %tmp12 = load double* %1, align 8
26  %add.ptr.sum17 = add i64 %ivar, 16
27  %add.ptr4.1 = getelementptr inbounds i8* %0, i64 %add.ptr.sum17
28  %add.ptr4.1.0 = bitcast i8* %add.ptr4.1 to double*
29  %tmp = load double* %add.ptr4.1.0, align 8
30  %add.ptr4.1.sum = add i64 %ivar, 24
31  %add.ptr4.1.1 = getelementptr inbounds i8* %0, i64 %add.ptr4.1.sum
32  %2 = bitcast i8* %add.ptr4.1.1 to double*
33  %tmp5 = load double* %2, align 8
34  %insert14 = insertvalue %struct.CGPoint undef, double %tmp11, 0
35  %insert16 = insertvalue %struct.CGPoint %insert14, double %tmp12, 1
36  %insert = insertvalue %struct.CGRect undef, %struct.CGPoint %insert16, 0
37  %insert7 = insertvalue %struct.CGSize undef, double %tmp, 0
38  %insert9 = insertvalue %struct.CGSize %insert7, double %tmp5, 1
39  %insert3 = insertvalue %struct.CGRect %insert, %struct.CGSize %insert9, 1
40  ret %struct.CGRect %insert3
41}
42
43define hidden %struct.CGRect @fold(%0* nocapture %self, i8* nocapture %_cmd) nounwind readonly optsize ssp {
44entry:
45; CHECK-LABEL: fold:
46; CHECK: ldr d0, [x0, x{{[0-9]+}}]
47; CHECK-NOT: add x0, x0, x1
48; CHECK: ret
49  %ivar = load i64* @"OBJC_IVAR_$_UIScreen._bounds", align 8, !invariant.load !4
50  %0 = bitcast %0* %self to i8*
51  %add.ptr = getelementptr inbounds i8* %0, i64 %ivar
52  %add.ptr10.0 = bitcast i8* %add.ptr to double*
53  %tmp11 = load double* %add.ptr10.0, align 8
54  %add.ptr10.1 = getelementptr inbounds i8* %0, i64 %ivar
55  %1 = bitcast i8* %add.ptr10.1 to double*
56  %tmp12 = load double* %1, align 8
57  %add.ptr4.1 = getelementptr inbounds i8* %0, i64 %ivar
58  %add.ptr4.1.0 = bitcast i8* %add.ptr4.1 to double*
59  %tmp = load double* %add.ptr4.1.0, align 8
60  %add.ptr4.1.1 = getelementptr inbounds i8* %0, i64 %ivar
61  %2 = bitcast i8* %add.ptr4.1.1 to double*
62  %tmp5 = load double* %2, align 8
63  %insert14 = insertvalue %struct.CGPoint undef, double %tmp11, 0
64  %insert16 = insertvalue %struct.CGPoint %insert14, double %tmp12, 1
65  %insert = insertvalue %struct.CGRect undef, %struct.CGPoint %insert16, 0
66  %insert7 = insertvalue %struct.CGSize undef, double %tmp, 0
67  %insert9 = insertvalue %struct.CGSize %insert7, double %tmp5, 1
68  %insert3 = insertvalue %struct.CGRect %insert, %struct.CGSize %insert9, 1
69  ret %struct.CGRect %insert3
70}
71
72
73!llvm.module.flags = !{!0, !1, !2, !3}
74
75!0 = !{i32 1, !"Objective-C Version", i32 2}
76!1 = !{i32 1, !"Objective-C Image Info Version", i32 0}
77!2 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
78!3 = !{i32 4, !"Objective-C Garbage Collection", i32 0}
79!4 = !{}
80