xref: /aosp_15_r20/external/llvm/test/Transforms/ArgumentPromotion/fp80.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -argpromotion -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-linux-gnu"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker%union.u = type { x86_fp80 }
7*9880d681SAndroid Build Coastguard Worker%struct.s = type { double, i16, i8, [5 x i8] }
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker@b = internal global %struct.s { double 3.14, i16 9439, i8 25, [5 x i8] undef }, align 16
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker%struct.Foo = type { i32, i64 }
12*9880d681SAndroid Build Coastguard Worker@a = internal global %struct.Foo { i32 1, i64 2 }, align 8
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine void @run() {
15*9880d681SAndroid Build Coastguard Workerentry:
16*9880d681SAndroid Build Coastguard Worker  tail call i8 @UseLongDoubleUnsafely(%union.u* byval align 16 bitcast (%struct.s* @b to %union.u*))
17*9880d681SAndroid Build Coastguard Worker  tail call x86_fp80 @UseLongDoubleSafely(%union.u* byval align 16 bitcast (%struct.s* @b to %union.u*))
18*9880d681SAndroid Build Coastguard Worker  call i64 @AccessPaddingOfStruct(%struct.Foo* @a)
19*9880d681SAndroid Build Coastguard Worker  call i64 @CaptureAStruct(%struct.Foo* @a)
20*9880d681SAndroid Build Coastguard Worker  ret void
21*9880d681SAndroid Build Coastguard Worker}
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker; CHECK: internal i8 @UseLongDoubleUnsafely(%union.u* byval align 16 %arg) {
24*9880d681SAndroid Build Coastguard Workerdefine internal i8 @UseLongDoubleUnsafely(%union.u* byval align 16 %arg) {
25*9880d681SAndroid Build Coastguard Workerentry:
26*9880d681SAndroid Build Coastguard Worker  %bitcast = bitcast %union.u* %arg to %struct.s*
27*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr inbounds %struct.s, %struct.s* %bitcast, i64 0, i32 2
28*9880d681SAndroid Build Coastguard Worker  %result = load i8, i8* %gep
29*9880d681SAndroid Build Coastguard Worker  ret i8 %result
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; CHECK: internal x86_fp80 @UseLongDoubleSafely(x86_fp80 {{%.*}}) {
33*9880d681SAndroid Build Coastguard Workerdefine internal x86_fp80 @UseLongDoubleSafely(%union.u* byval align 16 %arg) {
34*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr inbounds %union.u, %union.u* %arg, i64 0, i32 0
35*9880d681SAndroid Build Coastguard Worker  %fp80 = load x86_fp80, x86_fp80* %gep
36*9880d681SAndroid Build Coastguard Worker  ret x86_fp80 %fp80
37*9880d681SAndroid Build Coastguard Worker}
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; CHECK: define internal i64 @AccessPaddingOfStruct(%struct.Foo* byval %a) {
40*9880d681SAndroid Build Coastguard Workerdefine internal i64 @AccessPaddingOfStruct(%struct.Foo* byval %a) {
41*9880d681SAndroid Build Coastguard Worker  %p = bitcast %struct.Foo* %a to i64*
42*9880d681SAndroid Build Coastguard Worker  %v = load i64, i64* %p
43*9880d681SAndroid Build Coastguard Worker  ret i64 %v
44*9880d681SAndroid Build Coastguard Worker}
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker; CHECK: define internal i64 @CaptureAStruct(%struct.Foo* byval %a) {
47*9880d681SAndroid Build Coastguard Workerdefine internal i64 @CaptureAStruct(%struct.Foo* byval %a) {
48*9880d681SAndroid Build Coastguard Workerentry:
49*9880d681SAndroid Build Coastguard Worker  %a_ptr = alloca %struct.Foo*
50*9880d681SAndroid Build Coastguard Worker  br label %loop
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerloop:
53*9880d681SAndroid Build Coastguard Worker  %phi = phi %struct.Foo* [ null, %entry ], [ %gep, %loop ]
54*9880d681SAndroid Build Coastguard Worker  %0   = phi %struct.Foo* [ %a, %entry ],   [ %0, %loop ]
55*9880d681SAndroid Build Coastguard Worker  store %struct.Foo* %phi, %struct.Foo** %a_ptr
56*9880d681SAndroid Build Coastguard Worker  %gep = getelementptr %struct.Foo, %struct.Foo* %a, i64 0
57*9880d681SAndroid Build Coastguard Worker  br label %loop
58*9880d681SAndroid Build Coastguard Worker}
59