From patchwork Tue Aug 24 14:58:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 62600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5497AB70B4 for ; Wed, 25 Aug 2010 00:59:17 +1000 (EST) Received: (qmail 7542 invoked by alias); 24 Aug 2010 14:59:14 -0000 Received: (qmail 7523 invoked by uid 22791); 24 Aug 2010 14:59:10 -0000 X-SWARE-Spam-Status: No, hits=-0.0 required=5.0 tests=BAYES_20 X-Spam-Check-By: sourceware.org Received: from caiajhbdccah.dreamhost.com (HELO homiemail-a28.g.dreamhost.com) (208.97.132.207) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Aug 2010 14:59:02 +0000 Received: from homiemail-a28.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a28.g.dreamhost.com (Postfix) with ESMTP id ABDD21B4091; Tue, 24 Aug 2010 07:59:00 -0700 (PDT) Received: from hungry-tiger.westford.ibm.com (bi01pt1.ct.us.ibm.com [129.33.1.37]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: gnu@the-meissners.org) by homiemail-a28.g.dreamhost.com (Postfix) with ESMTPSA id 85C3F1B4097; Tue, 24 Aug 2010 07:58:59 -0700 (PDT) Date: Tue, 24 Aug 2010 10:58:57 -0400 From: Michael Meissner To: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com Subject: [PATCH, powerpc] Improve integer to floating point conversions on powerpc Message-ID: <20100824145857.GA6425@hungry-tiger.westford.ibm.com> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, dje.gcc@gmail.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org (Something has futzed with my work email configuration, so I'm routing this through my home email account). This patch is the first of 3 patches that I wrote to improve floating point conversions on modern powerpc's. This patch improves the conversion of integer types to binary floating point. The second patch will improve the conversion of binary floating point to integer types. The third patch will add support for patterns to optimize rounding conversions like (double)(int)x. A few defines and unspec constants are defined in this patch that won't be used until the other patches are submitted. The main changes in this patch are: 1) On newer machines, generate the FCFID instruction in 32-bit mode. In older machines, the FCFID was only available in 64-bit mode. 2) Add support for ISA 2.05 (LFIWAX) and ISA 2.06 (LFIWZX, FCFIDS, FCFIDU, FCFIDUS) instructions. 3) Tweak the previous changes I had made to automatically set various options if one of the newer ISA switches is used. Split embedded from server options. If -mcpu=power7 -mno-altivec, note -mvsx is an explicit option. 4) Fix up the constraints in a mode attribute that previously was unused. 5) Add combiners for converting items from memory to optimize not loading the value into a GPR, then spilling it on the stack, and reloading it into a FPR for conversion. 6) Use "d" or "f" constraints, instead of !d#r, to reduce the spills generated by the compiler. I did a bootstrap and make check. There were no regressions with this patch. In addition, the test gcc.target/powerpc/ppc64-double-1.c is now fixed. I built an powerpc-eabispe compiler, and verified that the compiler with the patches generates exactly the same code as the compiler without the patches for -mcpu=e500mc and -mcpu=e500mc64. I tested the code for -mcpu=750 in 32-bit, and verified that the code was the same (i.e. no FCFID was generated in 32-bit mode). I added 4 tests to test the code for various machines. Are these patches ok to apply? Index: gcc/config/rs6000/rs6000-protos.h =================================================================== --- gcc/config/rs6000/rs6000-protos.h (.../svn+ssh://meissner@gcc.gnu.org/svn/gcc/trunk) (revision 163471) +++ gcc/config/rs6000/rs6000-protos.h (working copy) @@ -129,6 +129,9 @@ extern void rs6000_emit_parity (rtx, rtx extern rtx rs6000_machopic_legitimize_pic_address (rtx, enum machine_mode, rtx); +extern rtx rs6000_address_for_fpconvert (rtx); +extern rtx rs6000_allocate_stack_temp (enum machine_mode, bool, bool); +extern void rs6000_expand_convert_si_to_sfdf (rtx, rtx, bool); #endif /* RTX_CODE */ #ifdef TREE_CODE Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (.../svn+ssh://meissner@gcc.gnu.org/svn/gcc/trunk) (revision 163471) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -2501,10 +2501,10 @@ rs6000_override_options (const char *def POWERPC_BASE_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_PPC_GFXOPT | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_MFPGPR | MASK_RECIP_PRECISION}, - {"power7", PROCESSOR_POWER7, + {"power7", PROCESSOR_POWER7, /* Don't add MASK_ISEL by default */ POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD - | MASK_VSX| MASK_RECIP_PRECISION}, /* Don't add MASK_ISEL by default */ + | MASK_VSX | MASK_RECIP_PRECISION}, {"powerpc", PROCESSOR_POWERPC, POWERPC_BASE_MASK}, {"powerpc64", PROCESSOR_POWERPC64, POWERPC_BASE_MASK | MASK_PPC_GFXOPT | MASK_POWERPC64}, @@ -2541,15 +2541,19 @@ rs6000_override_options (const char *def ISA_2_1_MASKS = MASK_MFCRF, ISA_2_2_MASKS = (ISA_2_1_MASKS | MASK_POPCNTB | MASK_FPRND), - /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and - don't add ALTIVEC, since in general it isn't a win on power6. */ - ISA_2_5_MASKS = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION - | MASK_DFP), + /* For ISA 2.05, do not add MFPGPR, since it isn't in ISA 2.06, and don't + add ALTIVEC, since in general it isn't a win on power6. In ISA 2.04, + fsel, fre, fsqrt, etc. were no longer documented as optional. Group + masks by server and embedded. */ + ISA_2_5_MASKS_EMBEDDED = (ISA_2_2_MASKS | MASK_CMPB | MASK_RECIP_PRECISION + | MASK_PPC_GFXOPT | MASK_PPC_GPOPT), + ISA_2_5_MASKS_SERVER = (ISA_2_5_MASKS_EMBEDDED | MASK_DFP), /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but altivec is a win so enable it. */ - ISA_2_6_MASKS = (ISA_2_5_MASKS | MASK_ALTIVEC | MASK_POPCNTD - | MASK_VSX | MASK_RECIP_PRECISION) + ISA_2_6_MASKS_EMBEDDED = (ISA_2_5_MASKS_EMBEDDED | MASK_POPCNTD), + ISA_2_6_MASKS_SERVER = (ISA_2_5_MASKS_SERVER | MASK_POPCNTD | MASK_ALTIVEC + | MASK_VSX) }; /* Numerous experiment shows that IRA based loop pressure @@ -2690,15 +2694,22 @@ rs6000_override_options (const char *def { warning (0, msg); target_flags &= ~ MASK_VSX; + target_flags_explicit |= MASK_VSX; } } /* For the newer switches (vsx, dfp, etc.) set some of the older options, unless the user explicitly used the -mno-