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 6 7define i128 @test_abs(ppc_fp128 %x) nounwind { 8entry: 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]] 17; PPC64: blr 18 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]] 25; PPC64-P8: blr 26 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: rlwinm [[FLIP_BIT:[0-9]+]], [[HI0]], 0, 0, 0 32; PPC32-DAG: lwz [[HI1:[0-9]+]], 28(1) 33; PPC32-DAG: lwz [[LO1:[0-9]+]], 20(1) 34; PPC32-DAG: xor [[HI0]], [[HI0]], [[FLIP_BIT]] 35; PPC32-DAG: xor [[LO0]], [[LO0]], [[FLIP_BIT]] 36; PPC32: blr 37 %0 = tail call ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %x) 38 %1 = bitcast ppc_fp128 %0 to i128 39 ret i128 %1 40} 41 42define i128 @test_neg(ppc_fp128 %x) nounwind { 43entry: 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: rldic [[FLIP_BIT]], [[FLIP_BIT]], 63, 0 49; PPC64-DAG: ld [[HI:[0-9]+]], [[OFFSET_LO]]([[SP]]) 50; PPC64-DAG: ld [[LO:[0-9]+]], [[OFFSET_HI]]([[SP]]) 51; PPC64-NOT: BARRIER 52; PPC64-DAG: xor 3, [[HI]], [[FLIP_BIT]] 53; PPC64-DAG: xor 4, [[LO]], [[FLIP_BIT]] 54; PPC64: blr 55 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: rldic [[FLIP_BIT:[0-9]+]], [[IMM1]], 63, 0 61; PPC64-P8-NOT: BARRIER 62; PPC64-P8-DAG: xor 3, [[HI]], [[FLIP_BIT]] 63; PPC64-P8-DAG: xor 4, [[LO]], [[FLIP_BIT]] 64; PPC64-P8: blr 65 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-NOT: BARRIER 72; PPC32-DAG: xoris [[HI0]], [[HI0]], 32768 73; PPC32-DAG: lwz [[LO1:[0-9]+]], 20(1) 74; PPC32-DAG: xoris [[LO0]], [[LO0]], 32768 75; PPC32: blr 76 %0 = fsub ppc_fp128 0xM80000000000000000000000000000000, %x 77 %1 = bitcast ppc_fp128 %0 to i128 78 ret i128 %1 79} 80 81define i128 @test_copysign(ppc_fp128 %x) nounwind { 82entry: 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 87; PPC64-NOT: BARRIER 88; PPC64-DAG: rldic [[CST_HI:[0-9]+]], [[HI_TMP]], 48, 1 89; PPC64-DAG: rldic [[CST_LO:[0-9]+]], [[LO_TMP]], 52, 0 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]] 94; PPC64: blr 95 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: rldic [[CST_HI:[0-9]+]], [[HI_TMP]], 48, 1 102; PPC64-P8-DAG: rldic [[CST_LO:[0-9]+]], [[LO_TMP]], 52, 0 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]] 106; PPC64-P8: blr 107 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 111; PPC32-NOT: BARRIER 112; PPC32-DAG: oris {{[0-9]+}}, [[FLIP_BIT]], 16399 113; PPC32-DAG: xoris {{[0-9]+}}, [[FLIP_BIT]], 48304 114; PPC32: blr 115 %0 = tail call ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128 0xM400F000000000000BCB0000000000000, ppc_fp128 %x) 116 %1 = bitcast ppc_fp128 %0 to i128 117 ret i128 %1 118} 119 120declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128) 121declare ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128, ppc_fp128) 122