1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s -check-prefix=PPC64-P8
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s -check-prefix=PPC64
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s -check-prefix=PPC64-P8
4 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 < %s | FileCheck %s -check-prefix=PPC64
5 ; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu < %s | FileCheck %s -check-prefix=PPC32
7 define i128 @test_abs(ppc_fp128 %x) nounwind {
9 ; PPC64-LABEL: test_abs:
10 ; PPC64-DAG: stfd 2, [[OFFSET_HI:-?[0-9]+]]([[SP:[0-9]+]])
11 ; PPC64-DAG: stfd 1, [[OFFSET_LO:-?[0-9]+]]([[SP]])
12 ; PPC64-DAG: ld [[HI:[0-9]+]], [[OFFSET_LO]]([[SP]])
13 ; PPC64-DAG: ld [[LO:[0-9]+]], [[OFFSET_HI]]([[SP]])
14 ; PPC64-DAG: rldicr [[FLIP_BIT:[0-9]+]], [[HI]], 0, 0
15 ; PPC64-DAG: xor 3, [[HI]], [[FLIP_BIT]]
16 ; PPC64-DAG: xor 4, [[LO]], [[FLIP_BIT]]
19 ; PPC64-P8-LABEL: test_abs:
20 ; PPC64-P8-DAG: mffprd [[LO:[0-9]+]], 2
21 ; PPC64-P8-DAG: mffprd [[HI:[0-9]+]], 1
22 ; PPC64-P8-DAG: rldicr [[FLIP_BIT:[0-9]+]], [[HI]], 0, 0
23 ; PPC64-P8-DAG: xor 3, [[HI]], [[FLIP_BIT]]
24 ; PPC64-P8-DAG: xor 4, [[LO]], [[FLIP_BIT]]
27 ; PPC32-DAG: stfd 1, 24(1)
28 ; PPC32-DAG: stfd 2, 16(1)
29 ; PPC32-DAG: lwz [[HI0:[0-9]+]], 24(1)
30 ; PPC32-DAG: lwz [[LO0:[0-9]+]], 16(1)
31 ; PPC32-DAG: lwz [[HI1:[0-9]+]], 28(1)
32 ; PPC32-DAG: lwz [[LO1:[0-9]+]], 20(1)
33 ; PPC32: rlwinm [[FLIP_BIT:[0-9]+]], [[HI0]], 0, 0, 0
34 ; PPC32-DAG: xor [[HI0]], [[HI0]], [[FLIP_BIT]]
35 ; PPC32-DAG: xor [[LO0]], [[LO0]], [[FLIP_BIT]]
37 %0 = tail call ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %x)
38 %1 = bitcast ppc_fp128 %0 to i128
42 define i128 @test_neg(ppc_fp128 %x) nounwind {
44 ; PPC64-LABEL: test_neg:
45 ; PPC64-DAG: stfd 2, [[OFFSET_HI:-?[0-9]+]]([[SP:[0-9]+]])
46 ; PPC64-DAG: stfd 1, [[OFFSET_LO:-?[0-9]+]]([[SP]])
47 ; PPC64-DAG: li [[FLIP_BIT:[0-9]+]], 1
48 ; PPC64-DAG: sldi [[FLIP_BIT]], [[FLIP_BIT]], 63
49 ; PPC64-DAG: ld [[HI:[0-9]+]], [[OFFSET_LO]]([[SP]])
50 ; PPC64-DAG: ld [[LO:[0-9]+]], [[OFFSET_HI]]([[SP]])
52 ; PPC64-DAG: xor 3, [[HI]], [[FLIP_BIT]]
53 ; PPC64-DAG: xor 4, [[LO]], [[FLIP_BIT]]
56 ; PPC64-P8-LABEL: test_neg:
57 ; PPC64-P8-DAG: mffprd [[LO:[0-9]+]], 2
58 ; PPC64-P8-DAG: mffprd [[HI:[0-9]+]], 1
59 ; PPC64-P8-DAG: li [[IMM1:[0-9]+]], 1
60 ; PPC64-P8-DAG: sldi [[FLIP_BIT:[0-9]+]], [[IMM1]], 63
61 ; PPC64-P8-NOT: BARRIER
62 ; PPC64-P8-DAG: xor 3, [[HI]], [[FLIP_BIT]]
63 ; PPC64-P8-DAG: xor 4, [[LO]], [[FLIP_BIT]]
66 ; PPC32-DAG: stfd 1, 24(1)
67 ; PPC32-DAG: stfd 2, 16(1)
68 ; PPC32-DAG: lwz [[HI0:[0-9]+]], 24(1)
69 ; PPC32-DAG: lwz [[LO0:[0-9]+]], 16(1)
70 ; PPC32-DAG: lwz [[HI1:[0-9]+]], 28(1)
71 ; PPC32-DAG: lwz [[LO1:[0-9]+]], 20(1)
73 ; PPC32-DAG: xoris [[HI0]], [[HI0]], 32768
74 ; PPC32-DAG: xoris [[LO0]], [[LO0]], 32768
76 %0 = fsub ppc_fp128 0xM80000000000000000000000000000000, %x
77 %1 = bitcast ppc_fp128 %0 to i128
81 define i128 @test_copysign(ppc_fp128 %x) nounwind {
83 ; PPC64-LABEL: test_copysign:
84 ; PPC64-DAG: stfd 1, [[OFFSET:-?[0-9]+]](1)
85 ; PPC64-DAG: li [[HI_TMP:[0-9]+]], 16399
86 ; PPC64-DAG: li [[LO_TMP:[0-9]+]], 3019
88 ; PPC64-DAG: sldi [[CST_HI:[0-9]+]], [[HI_TMP]], 48
89 ; PPC64-DAG: sldi [[CST_LO:[0-9]+]], [[LO_TMP]], 52
90 ; PPC64-DAG: ld [[X_HI:[0-9]+]], [[OFFSET]](1)
91 ; PPC64-DAG: rldicr [[NEW_HI_TMP:[0-9]+]], [[X_HI]], 0, 0
92 ; PPC64-DAG: or 3, [[NEW_HI_TMP]], [[CST_HI]]
93 ; PPC64-DAG: xor 4, [[NEW_HI_TMP]], [[CST_LO]]
96 ; PPC64-P8-LABEL: test_copysign:
97 ; PPC64-P8-DAG: mffprd [[X_HI:[0-9]+]], 1
98 ; PPC64-P8-DAG: li [[HI_TMP:[0-9]+]], 16399
99 ; PPC64-P8-DAG: li [[LO_TMP:[0-9]+]], 3019
100 ; PPC64-P8-NOT: BARRIER
101 ; PPC64-P8-DAG: sldi [[CST_HI:[0-9]+]], [[HI_TMP]], 48
102 ; PPC64-P8-DAG: sldi [[CST_LO:[0-9]+]], [[LO_TMP]], 52
103 ; PPC64-P8-DAG: rldicr [[NEW_HI_TMP:[0-9]+]], [[X_HI]], 0, 0
104 ; PPC64-P8-DAG: or 3, [[NEW_HI_TMP]], [[CST_HI]]
105 ; PPC64-P8-DAG: xor 4, [[NEW_HI_TMP]], [[CST_LO]]
108 ; PPC32: stfd 1, [[STACK:[0-9]+]](1)
109 ; PPC32: lwz [[HI:[0-9]+]], [[STACK]](1)
110 ; PPC32: rlwinm [[FLIP_BIT:[0-9]+]], [[HI]], 0, 0, 0
112 ; PPC32-DAG: oris {{[0-9]+}}, [[FLIP_BIT]], 16399
113 ; PPC32-DAG: xoris {{[0-9]+}}, [[FLIP_BIT]], 48304
115 %0 = tail call ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128 0xM400F000000000000BCB0000000000000, ppc_fp128 %x)
116 %1 = bitcast ppc_fp128 %0 to i128
120 declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128)
121 declare ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128, ppc_fp128)