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