From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16516 invoked by alias); 14 Dec 2007 15:52:32 -0000 Received: (qmail 16507 invoked by uid 22791); 14 Dec 2007 15:52:31 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.29.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Dec 2007 15:52:16 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.8/8.13.8) with ESMTP id lBEFqDOi175712 for ; Fri, 14 Dec 2007 15:52:13 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id lBEFqCR42727990 for ; Fri, 14 Dec 2007 16:52:12 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id lBEFqCt1023703 for ; Fri, 14 Dec 2007 16:52:12 +0100 Received: from d12ml062.megacenter.de.ibm.com (d12ml062.megacenter.de.ibm.com [9.149.166.219]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id lBEFqCSV023691; Fri, 14 Dec 2007 16:52:12 +0100 To: gcc-patches@gcc.gnu.org Cc: trevor_smigiel@playstation.sony.com, Andrew_Pinski@playstation.sony.com MIME-Version: 1.0 Subject: [PATCH,spu]: generate inline code for divdf3 X-Mailer: Lotus Notes Release 7.0 HF277 June 21, 2006 Message-ID: From: Sa Liu Date: Fri, 14 Dec 2007 15:54:00 -0000 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-12/txt/msg00679.txt.bz2 Similar to the int-to-double conversion patch=20 (http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01161.html), this patch is=20 about to genetate inline code for double division. The implementation=20 doesn't handle INF or NAN, therefore it only applies when=20 -ffinite-math-only is given. No regression found in gcc test suites. OK for mainline? Thanks! Sa Index: gcc/gcc/config/spu/spu.md =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc.orig/gcc/config/spu/spu.md +++ gcc/gcc/config/spu/spu.md @@ -1735,6 +1735,58 @@ DONE; }) =20 +;; Taken from STI's gcc +;; Does not correctly handle INF or NAN. +(define_expand "divdf3" + [(set (match_operand:DF 0 "register_operand" "=3Dr") + (div:DF (match_operand:DF 1 "register_operand" "r") + (match_operand:DF 2 "register_operand" "r")))] + "flag_finite_math_only" + "{=20 + /* + double + divdf3 (double x, double y) + { + float x0; + float y_f =3D (float) y; + double x1, x2; + + x0 =3D spu_extract(spu_re(spu_promote(y_f, 0)), 0); + x1 =3D (double)(x0 * (2.0f - y_f * x0));=20 + x2 =3D x1 * (2.0 - y * x1); + return (x * x2 * (2.0 - y * x2)); + } + */ + + rtx dst =3D operands[0]; + rtx x =3D operands[1]; + rtx y =3D operands[2]; + rtx y_f =3D gen_reg_rtx(SFmode); + rtx x0_f =3D gen_reg_rtx(SFmode); + rtx x1_f =3D gen_reg_rtx(SFmode); + rtx x1 =3D gen_reg_rtx(DFmode); + rtx x2 =3D gen_reg_rtx(DFmode); + rtx t1_f =3D gen_reg_rtx(SFmode); + rtx t1 =3D gen_reg_rtx(DFmode); + rtx two =3D gen_reg_rtx(DFmode); + rtx two_f =3D gen_reg_rtx(SFmode); + + emit_insn (gen_truncdfsf2 (y_f, y)); + emit_insn (gen_frest_sf (x0_f, y_f)); + emit_insn (gen_fi_sf (x0_f, y_f, x0_f)); + emit_insn (gen_movsf (two_f, spu_float_const(\"2.0\",SFmode))); + emit_insn (gen_fnms_sf (t1_f, y_f, x0_f, two_f)); + emit_insn (gen_mulsf3 (x1_f, t1_f, x0_f)); + emit_insn (gen_extendsfdf2 (x1, x1_f)); + emit_insn (gen_extendsfdf2 (two, two_f)); + emit_insn (gen_movdf (t1, two)); + emit_insn (gen_fnms_df (t1, y, x1, t1)); + emit_insn (gen_muldf3 (x2, x1, t1)); + emit_insn (gen_fnms_df (two, y, x2, two)); + emit_insn (gen_muldf3 (dst, x2, two)); + emit_insn (gen_muldf3 (dst, dst, x)); + DONE; +}") =0C ;; sqrt =20