1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -o - %s | FileCheck %s
3; Check that selection dag legalization of fcopysign works in cases with
4; different modes for the arguments.
5target triple = "aarch64--"
6
7declare fp128 @llvm.copysign.f128(fp128, fp128)
8
9@val_float = global float zeroinitializer, align 4
10@val_double = global double zeroinitializer, align 8
11@val_fp128 = global fp128 zeroinitializer, align 16
12
13define fp128 @copysign0() {
14; CHECK-LABEL: copysign0:
15; CHECK:       // %bb.0: // %entry
16; CHECK-NEXT:    .cfi_def_cfa_offset 16
17; CHECK-NEXT:    adrp x8, .LCPI0_0
18; CHECK-NEXT:    ldr q0, [x8, :lo12:.LCPI0_0]
19; CHECK-NEXT:    adrp x8, val_double
20; CHECK-NEXT:    str q0, [sp, #-16]!
21; CHECK-NEXT:    ldr x8, [x8, :lo12:val_double]
22; CHECK-NEXT:    ldrb w9, [sp, #15]
23; CHECK-NEXT:    and x8, x8, #0x8000000000000000
24; CHECK-NEXT:    lsr x8, x8, #56
25; CHECK-NEXT:    bfxil w8, w9, #0, #7
26; CHECK-NEXT:    strb w8, [sp, #15]
27; CHECK-NEXT:    ldr q0, [sp], #16
28; CHECK-NEXT:    ret
29entry:
30  %v = load double, double* @val_double, align 8
31  %conv = fpext double %v to fp128
32  %call = tail call fp128 @llvm.copysign.f128(fp128 0xL00000000000000007FFF000000000000, fp128 %conv) #2
33  ret fp128 %call
34}
35
36define fp128@copysign1() {
37; CHECK-LABEL: copysign1:
38; CHECK:       // %bb.0: // %entry
39; CHECK-NEXT:    .cfi_def_cfa_offset 16
40; CHECK-NEXT:    adrp x8, val_fp128
41; CHECK-NEXT:    ldr q0, [x8, :lo12:val_fp128]
42; CHECK-NEXT:    adrp x8, val_float
43; CHECK-NEXT:    str q0, [sp, #-16]!
44; CHECK-NEXT:    ldr w8, [x8, :lo12:val_float]
45; CHECK-NEXT:    ldrb w9, [sp, #15]
46; CHECK-NEXT:    and w8, w8, #0x80000000
47; CHECK-NEXT:    lsr w8, w8, #24
48; CHECK-NEXT:    bfxil w8, w9, #0, #7
49; CHECK-NEXT:    strb w8, [sp, #15]
50; CHECK-NEXT:    ldr q0, [sp], #16
51; CHECK-NEXT:    ret
52entry:
53  %v0 = load fp128, fp128* @val_fp128, align 16
54  %v1 = load float, float* @val_float, align 4
55  %conv = fpext float %v1 to fp128
56  %call = tail call fp128 @llvm.copysign.f128(fp128 %v0, fp128 %conv)
57  ret fp128 %call
58}
59