[PATCH] D15138: Disable signbit related bitcast optimization for ppc_fp128

Tim Shen via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 2 17:14:19 PST 2015


timshen updated this revision to Diff 41701.
timshen added a comment.

Oops, wrong diff. Updated diff.


Repository:
  rL LLVM

http://reviews.llvm.org/D15138

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/PowerPC/fp128-bitcast-after-operation.ll

Index: test/CodeGen/PowerPC/fp128-bitcast-after-operation.ll
===================================================================
--- /dev/null
+++ test/CodeGen/PowerPC/fp128-bitcast-after-operation.ll
@@ -0,0 +1,26 @@
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
+
+define ppc_fp128 @test_abs(ppc_fp128 %x) nounwind  {
+entry:
+; CHECK: xsabsdp 1
+; CHECK: xscmpudp [[REG:[0-9]+]]
+; CHECK: beqlr [[REG]]
+; CHECK: xsnegdp 2
+	%tmp2 = tail call ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128 %x)
+	ret ppc_fp128 %tmp2
+}
+
+define i128 @test_copysign(ppc_fp128 %x) nounwind  {
+entry:
+; CHECK: bl copysignl
+; CHECK: stxsdx 1, 0, [[REG1:[0-9]+]]
+; CHECK: stxsdx 2, 0, [[REG2:[0-9]+]]
+; CHECK: ld [[REG1]], 96(1)
+; CHECK: ld [[REG2]], 104(1)
+	%tmp2 = tail call ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128 0xM3FF00000000000000000000000000000, ppc_fp128 %x)
+	%tmp3 = bitcast ppc_fp128 %tmp2 to i128
+	ret i128 %tmp3
+}
+
+declare ppc_fp128 @llvm.fabs.ppcf128(ppc_fp128)
+declare ppc_fp128 @llvm.copysign.ppcf128(ppc_fp128, ppc_fp128)
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -7314,7 +7314,10 @@
   if (((N0.getOpcode() == ISD::FNEG && !TLI.isFNegFree(N0.getValueType())) ||
        (N0.getOpcode() == ISD::FABS && !TLI.isFAbsFree(N0.getValueType()))) &&
       N0.getNode()->hasOneUse() && VT.isInteger() &&
-      !VT.isVector() && !N0.getValueType().isVector()) {
+      // ppcf128 uses two doubles; the signbit should be calculated in other
+      // ways.
+      N0.getValueType() != MVT::ppcf128 && !VT.isVector() &&
+      !N0.getValueType().isVector()) {
     SDValue NewConv = DAG.getNode(ISD::BITCAST, SDLoc(N0), VT,
                                   N0.getOperand(0));
     AddToWorklist(NewConv.getNode());
@@ -7335,7 +7338,11 @@
   // folded to an fneg or fabs.
   if (N0.getOpcode() == ISD::FCOPYSIGN && N0.getNode()->hasOneUse() &&
       isa<ConstantFPSDNode>(N0.getOperand(0)) &&
-      VT.isInteger() && !VT.isVector()) {
+      // ppcf128 uses two doubles; the signbit should be calculated in other
+      // ways.
+      N0.getOperand(0).getValueType() != MVT::ppcf128 &&
+      N0.getOperand(1).getValueType() != MVT::ppcf128 && VT.isInteger() &&
+      !VT.isVector()) {
     unsigned OrigXWidth = N0.getOperand(1).getValueType().getSizeInBits();
     EVT IntXVT = EVT::getIntegerVT(*DAG.getContext(), OrigXWidth);
     if (isTypeLegal(IntXVT)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15138.41701.patch
Type: text/x-patch
Size: 2568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/c6970ef3/attachment.bin>


More information about the llvm-commits mailing list