[llvm] r185821 - [PowerPC] Fix PR16556 (handle undef ppcf128 in LowerFP_TO_INT).

Bill Schmidt wschmidt at linux.vnet.ibm.com
Mon Jul 8 07:22:46 PDT 2013


Author: wschmidt
Date: Mon Jul  8 09:22:45 2013
New Revision: 185821

URL: http://llvm.org/viewvc/llvm-project?rev=185821&view=rev
Log:
[PowerPC] Fix PR16556 (handle undef ppcf128 in LowerFP_TO_INT).

PPCTargetLowering::LowerFP_TO_INT() expects its source operand to be
either an f32 or f64, but this is not checked.  A long double
(ppcf128) operand will normally be custom-lowered to a conversion to
f64 in this context.  However, this isn't the case for an UNDEF node.

This patch recognizes a ppcf128 as a legal source operand for
FP_TO_INT only if it's an undef, in which case it creates an undef of
the target type.

At some point we might want to do a wholesale custom lowering of
ISD::UNDEF when the type is ppcf128, but it's not really clear that's
a great idea, and probably more work than it's worth for a situation
that only arises in the case of a programming error.  At this point I
think simple is best.

The test case comes from PR16556, and is a crash-test only.

Added:
    llvm/trunk/test/CodeGen/PowerPC/pr16556.ll
Modified:
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=185821&r1=185820&r2=185821&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Jul  8 09:22:45 2013
@@ -4685,6 +4685,15 @@ SDValue PPCTargetLowering::LowerFP_TO_IN
                                            SDLoc dl) const {
   assert(Op.getOperand(0).getValueType().isFloatingPoint());
   SDValue Src = Op.getOperand(0);
+
+  // If we have a long double here, it must be that we have an undef of
+  // that type.  In this case return an undef of the target type.
+  if (Src.getValueType() == MVT::ppcf128) {
+    assert(Src.getOpcode() == ISD::UNDEF && "Unhandled ppcf128!");
+    return DAG.getNode(ISD::UNDEF, dl,
+                       Op.getValueType().getSimpleVT().SimpleTy);
+  }
+
   if (Src.getValueType() == MVT::f32)
     Src = DAG.getNode(ISD::FP_EXTEND, dl, MVT::f64, Src);
 

Added: llvm/trunk/test/CodeGen/PowerPC/pr16556.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/pr16556.ll?rev=185821&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/pr16556.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/pr16556.ll Mon Jul  8 09:22:45 2013
@@ -0,0 +1,20 @@
+; RUN: llc < %s
+
+; This test formerly failed due to no handling for a ppc_fp128 undef.
+
+target datalayout = "E-p:32:32:32-S0-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:64:128-v64:64:64-v128:128:128-a0:0:64-n32"
+target triple = "powerpc-unknown-linux-gnu"
+
+%core.time.TickDuration.37.125 = type { i64 }
+
+define weak_odr fastcc i64 @_D4core4time12TickDuration30__T2toVAyaa7_7365636f6e6473TlZ2toMxFNaNbNfZl(%core.time.TickDuration.37.125* %.this_arg) {
+entry:
+  br i1 undef, label %noassert, label %assert
+
+assert:                                           ; preds = %entry
+  unreachable
+
+noassert:                                         ; preds = %entry
+  %tmp9 = fptosi ppc_fp128 undef to i64
+  ret i64 %tmp9
+}





More information about the llvm-commits mailing list