From patchwork Tue Jan 11 00:28:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 78264 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 71CEFB7112 for ; Tue, 11 Jan 2011 11:28:58 +1100 (EST) Received: (qmail 12439 invoked by alias); 11 Jan 2011 00:28:56 -0000 Received: (qmail 12425 invoked by uid 22791); 11 Jan 2011 00:28:53 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e8.ny.us.ibm.com (HELO e8.ny.us.ibm.com) (32.97.182.138) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Jan 2011 00:28:48 +0000 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e8.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p0B0Bc4s026744 for ; Mon, 10 Jan 2011 19:11:38 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 1A608728059 for ; Mon, 10 Jan 2011 19:28:45 -0500 (EST) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0B0Si3q195434 for ; Mon, 10 Jan 2011 19:28:44 -0500 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0B0Sice007358 for ; Mon, 10 Jan 2011 17:28:44 -0700 Received: from hungry-tiger.westford.ibm.com (dyn9033037078.westford.ibm.com [9.33.37.78]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p0B0Shjv007341; Mon, 10 Jan 2011 17:28:43 -0700 Received: by hungry-tiger.westford.ibm.com (Postfix, from userid 500) id AD979F7E09; Mon, 10 Jan 2011 19:28:42 -0500 (EST) Date: Mon, 10 Jan 2011 19:28:42 -0500 From: Michael Meissner To: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com Cc: bergner@vnet.ibm.com Subject: [PATCH] PR 42751, Fix conversion of unsigned to float on powerpc -m32 -msoft-float -mcpu=power7 Message-ID: <20110111002842.GA22074@hungry-tiger.westford.ibm.com> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, bergner@vnet.ibm.com MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Content-Scanned: Fidelis XPS MAILER 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 When I put in the floating point conversion changes, I forgot to check whether hardware floating point was available if the user did -mcpu=power7. This shows up if you try to build a compiler configured using --with-cpu=power7. The failure is the compiler generates this insn, and then gets a reload failure because there are no floating point registers available with -msoft-float. There are some other problems in building a compiler with the --with-cpu=power7 option, but this fixes the immediate problem. I did bootstrap builds with/without the patch, and there were no regressions in the test suite. Is this patch ok to apply? [gcc] 2011-01-10 Michael Meissner PR target/42751 * config/rs6000/rs6000.md (floatunsdidf2): Add check for hardware floating point. (floatunsdidf2_fcfidu): Ditto. [gcc/testsuite] 2011-01-10 Michael Meissner PR target/42751 * gcc.target/powerpc/pr47251.c: New file, test PR 42751 fix. Index: gcc/config/rs6000/rs6000.md =================================================================== --- gcc/config/rs6000/rs6000.md (revision 168634) +++ gcc/config/rs6000/rs6000.md (working copy) @@ -7167,13 +7167,13 @@ (define_expand "floatunsdidf2" [(set (match_operand:DF 0 "gpc_reg_operand" "") (unsigned_float:DF (match_operand:DI 1 "gpc_reg_operand" "")))] - "TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode)" + "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))" "") (define_insn "*floatunsdidf2_fcfidu" [(set (match_operand:DF 0 "gpc_reg_operand" "=d") (unsigned_float:DF (match_operand:DI 1 "gpc_reg_operand" "d")))] - "TARGET_FCFIDU && !VECTOR_UNIT_VSX_P (DFmode)" + "TARGET_HARD_FLOAT && TARGET_FCFIDU && !VECTOR_UNIT_VSX_P (DFmode)" "fcfidu %0,%1" [(set_attr "type" "fp") (set_attr "length" "4")]) @@ -7182,7 +7182,7 @@ (define_insn_and_split "*floatunsdidf2_m [(set (match_operand:DF 0 "gpc_reg_operand" "=d") (unsigned_float:DF (match_operand:DI 1 "memory_operand" "m"))) (clobber (match_scratch:DI 2 "=d"))] - "TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode)" + "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))" "#" "&& reload_completed" [(set (match_dup 2) (match_dup 1)) bash: svi: command not found Index: gcc/testsuite/gcc.target/powerpc/pr47251.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr47251.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr47251.c (revision 0) @@ -0,0 +1,15 @@ +/* { dg-do compile { target { powerpc*-*-* && ip32 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-O2 -msoft-float -mcpu=power7" } */ + +/* PR 47151: libgcc fails to build when using --with-cpu=power7 due to a missed + TARGET_HARD_FLOAT test. */ +unsigned int +__fixunssfdi (float a) +{ + const float dfa = a; + const unsigned int hi = dfa / 0x1p32f; + const unsigned int lo = dfa - (float) hi * 0x1p32f; + return ((unsigned int) hi << (4 * 8)) | lo; +}