From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1261 invoked by alias); 23 Dec 2012 09:44:11 -0000 Received: (qmail 1250 invoked by uid 22791); 23 Dec 2012 09:44:10 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,KHOP_RCVD_TRUST,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f42.google.com (HELO mail-wg0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 23 Dec 2012 09:44:02 +0000 Received: by mail-wg0-f42.google.com with SMTP id dr1so2207467wgb.1 for ; Sun, 23 Dec 2012 01:44:01 -0800 (PST) X-Received: by 10.180.14.2 with SMTP id l2mr30621593wic.2.1356255841044; Sun, 23 Dec 2012 01:44:01 -0800 (PST) Received: from localhost ([2.28.234.219]) by mx.google.com with ESMTPS id h19sm37722659wiv.7.2012.12.23.01.43.59 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Dec 2012 01:44:00 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: RFA: Fix ICE on PARALLEL returns when expand builtins Date: Sun, 23 Dec 2012 09:44:00 -0000 Message-ID: <87pq21umqp.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-12/txt/msg01369.txt.bz2 Some of the maths builtins can expand to a call followed by a bit of postprocessing. With 4.8's PARALLEL return optimisations, these embedded calls might return a PARALLEL of pseudos, but the postprocessing isn't prepared to deal with that. This leads to an ICE in builtins-53.c on n32 and n64 mips64-linux-gnu. One fix might have been to pass an explicit register target to the expand routines, but that target's only a hint. This patch instead adds an avoid_group_rtx function (named after gen_group_rtx) to convert PARALLELs to pseudos where necessary. I wondered whether it was really safe for expand_builtin_int_roundingfn_2 to pass "target == const0_rtx" as the "ignore" parameter to expand_call, given that we don't actually ignore the return value ourselves (even if the caller does). I suppose it is safe though, since expand_call will always return const0_rtx in that case, and this code is dealing with integer return values. Tested on mips64-linux-gnu. OK to install? Or is there a better way? Richard gcc/ * expr.h (avoid_group_rtx): Declare. * expr.c (avoid_group_rtx): New function. * builtins.c (expand_builtin_int_roundingfn): Call it. (expand_builtin_int_roundingfn_2): Likewise. Index: gcc/expr.h =================================================================== --- gcc/expr.h 2012-12-23 09:21:21.969086853 +0000 +++ gcc/expr.h 2012-12-23 09:32:03.487440220 +0000 @@ -334,6 +334,8 @@ extern rtx emit_group_move_into_temps (r PARALLEL. */ extern void emit_group_store (rtx, rtx, tree, int); +extern rtx avoid_group_rtx (rtx, tree); + /* Copy BLKmode object from a set of registers. */ extern void copy_blkmode_from_reg (rtx, rtx, tree); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2012-12-23 09:21:21.980086911 +0000 +++ gcc/expr.c 2012-12-23 09:32:03.485440208 +0000 @@ -2079,6 +2079,23 @@ emit_group_store (rtx orig_dst, rtx src, emit_move_insn (orig_dst, dst); } +/* Return a form of X that does not use a PARALLEL. TYPE is the type + of the value stored in X. */ + +rtx +avoid_group_rtx (rtx x, tree type) +{ + enum machine_mode mode = TYPE_MODE (type); + gcc_checking_assert (GET_MODE (x) == VOIDmode || GET_MODE (x) == mode); + if (GET_CODE (x) == PARALLEL) + { + rtx result = gen_reg_rtx (mode); + emit_group_store (result, x, type, int_size_in_bytes (type)); + return result; + } + return x; +} + /* Copy a BLKmode object of TYPE out of a register SRCREG into TARGET. This is used on targets that return BLKmode values in registers. */ Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2012-12-23 09:21:21.981086916 +0000 +++ gcc/builtins.c 2012-12-23 09:34:47.813323158 +0000 @@ -2757,6 +2757,7 @@ expand_builtin_int_roundingfn (tree exp, exp = build_call_nofold_loc (EXPR_LOCATION (exp), fallback_fndecl, 1, arg); tmp = expand_normal (exp); + tmp = avoid_group_rtx (tmp, TREE_TYPE (exp)); /* Truncate the result of floating point optab to integer via expand_fix (). */ @@ -2860,6 +2861,7 @@ expand_builtin_int_roundingfn_2 (tree ex fallback_fndecl, 1, arg); target = expand_call (exp, NULL_RTX, target == const0_rtx); + target = avoid_group_rtx (target, TREE_TYPE (exp)); return convert_to_mode (mode, target, 0); }