xref: /llvm-project/llvm/test/CodeGen/PowerPC/ppc64-align-long-double.ll (revision 5403c59c608c08c8ecd4303763f08eb046eb5e4d)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs -mcpu=pwr7 -O2 -fast-isel=false -mattr=-vsx < %s | FileCheck %s
3; RUN: llc -verify-machineinstrs -mcpu=pwr7 -O2 -fast-isel=false -mattr=+vsx < %s | FileCheck -check-prefix=CHECK-VSX %s
4; RUN: llc -verify-machineinstrs -mcpu=pwr9 -O2 -fast-isel=false -mattr=+vsx < %s | FileCheck -check-prefix=CHECK-P9 %s
5
6; Verify internal alignment of long double in a struct.  The double
7; argument comes in GPR3; GPR4 is skipped; GPRs 5 and 6 contain
8; the long double.  Check that these are stored to proper locations
9; in the parameter save area and loaded from there for return in FPR1/2.
10
11target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
12target triple = "powerpc64-unknown-linux-gnu"
13
14%struct.S = type { double, ppc_fp128 }
15
16; The additional stores are caused because we forward the value in the
17; store->load->bitcast path to make a store and bitcast of the same
18; value. Since the target does bitcast through memory and we no longer
19; remember the address we need to do the store in a fresh local
20; address.
21define ppc_fp128 @test(ptr byval(%struct.S) %x) nounwind {
22; CHECK-LABEL: test:
23; CHECK:       # %bb.0: # %entry
24; CHECK-NEXT:    std 5, -16(1)
25; CHECK-NEXT:    std 6, -8(1)
26; CHECK-NEXT:    lfd 1, -16(1)
27; CHECK-NEXT:    lfd 2, -8(1)
28; CHECK-NEXT:    std 6, 72(1)
29; CHECK-NEXT:    std 5, 64(1)
30; CHECK-NEXT:    std 3, 48(1)
31; CHECK-NEXT:    std 4, 56(1)
32; CHECK-NEXT:    blr
33;
34; CHECK-VSX-LABEL: test:
35; CHECK-VSX:       # %bb.0: # %entry
36; CHECK-VSX-NEXT:    std 5, -16(1)
37; CHECK-VSX-NEXT:    std 6, -8(1)
38; CHECK-VSX-NEXT:    lfd 1, -16(1)
39; CHECK-VSX-NEXT:    lfd 2, -8(1)
40; CHECK-VSX-NEXT:    std 6, 72(1)
41; CHECK-VSX-NEXT:    std 5, 64(1)
42; CHECK-VSX-NEXT:    std 3, 48(1)
43; CHECK-VSX-NEXT:    std 4, 56(1)
44; CHECK-VSX-NEXT:    blr
45;
46; CHECK-P9-LABEL: test:
47; CHECK-P9:       # %bb.0: # %entry
48; CHECK-P9-NEXT:    mtfprd 1, 5
49; CHECK-P9-NEXT:    mtfprd 2, 6
50; CHECK-P9-NEXT:    std 6, 72(1)
51; CHECK-P9-NEXT:    std 5, 64(1)
52; CHECK-P9-NEXT:    std 3, 48(1)
53; CHECK-P9-NEXT:    std 4, 56(1)
54; CHECK-P9-NEXT:    blr
55entry:
56  %b = getelementptr inbounds %struct.S, ptr %x, i32 0, i32 1
57  %0 = load ppc_fp128, ptr %b, align 16
58  ret ppc_fp128 %0
59}
60
61