From c2b62e02e8ac5a3df255332ad82f55d708d76884 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 20 Aug 2015 01:18:20 +0000 Subject: [PATCH] [PowerPC] Fix the int2fp(fp2int(x)) DAGCombine to ignore ppc_fp128 This DAGCombine was creating custom SDAG nodes with an illegal ppc_fp128 operand type because it was triggering on f64/f32 int2fp(fp2int(ppc_fp128 x)), but shouldn't (it should only apply to f32/f64 types). The result was a crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245530 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPCISelLowering.cpp | 3 +++ test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index 173269c7395..72d1d19d0f3 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -9991,6 +9991,9 @@ SDValue PPCTargetLowering::combineFPToIntToFP(SDNode *N, if (Src.getValueType() == MVT::f32) { Src = DAG.getNode(ISD::FP_EXTEND, dl, MVT::f64, Src); DCI.AddToWorklist(Src.getNode()); + } else if (Src.getValueType() != MVT::f64) { + // Make sure that we don't pick up a ppc_fp128 source value. + return SDValue(); } unsigned FCTOp = diff --git a/test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll b/test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll new file mode 100644 index 00000000000..7742ffe3315 --- /dev/null +++ b/test/CodeGen/PowerPC/fp2int2fp-ppcfp128.ll @@ -0,0 +1,16 @@ +; RUN: llc -mcpu=a2 < %s | FileCheck %s +target datalayout = "E-m:e-i64:64-n32:64" +target triple = "powerpc64-bgq-linux" + +define linkonce_odr double @test1() { +entry: + %conv6.i.i = fptosi ppc_fp128 undef to i64 + %conv.i = sitofp i64 %conv6.i.i to double + ret double %conv.i + +; CHECK-LABEL: @test1 +; CHECK: bl __fixtfdi +; CHECK: fcfid +; CHECK: blr +} + -- 2.34.1