From patchwork Mon Nov 9 16:59:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 541852 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 026951402A3 for ; Tue, 10 Nov 2015 03:59:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=NmHXoqNg; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:in-reply-to :references:content-type:content-transfer-encoding:mime-version; q=dns; s=default; b=Z0hGgp3w8pnAodgtXsmLCNWteU6ly8Ava40aOvub1qy Hhv42RYfgkJzB+UXiyqkXpVr9x4kQxTX8D8zW9aka3ubKG7FzIPvp5rD4sn71jYz 7SzWEoTa1E8YLBNrGvroUiZ/PZvOgSv6tMJbxbUc4xPG6Ulii53/hwy4qihPdcjo = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:in-reply-to :references:content-type:content-transfer-encoding:mime-version; s=default; bh=K/07zxMtJPJAQlrvrQjM7QUy6Cc=; b=NmHXoqNgPvuW4CCZy B1fKmXvpLp9/uu0Y6dMuMn6RucAmguHKwzlBXGJhHfalBkzeAXl+zFT0ek70D31l v9d9lEgAsrmd4ESVbM6YcoMxmglcYz0wHAwPuzm7/JJ9UFyRU0uDa1yxzgqRs+t9 v5hTT8/1lXwdqbF4uc4aZLP87s= Received: (qmail 74461 invoked by alias); 9 Nov 2015 16:59:12 -0000 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 Received: (qmail 74376 invoked by uid 89); 9 Nov 2015 16:59:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Nov 2015 16:59:08 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Websense Email Security Gateway with ESMTPS id CF5A4A9995BAF; Mon, 9 Nov 2015 16:59:02 +0000 (GMT) Received: from BAMAIL02.ba.imgtec.org (10.20.40.28) by hhmail02.hh.imgtec.org (10.100.10.20) with Microsoft SMTP Server (TLS) id 14.3.235.1; Mon, 9 Nov 2015 16:59:05 +0000 Received: from [10.20.3.214] (10.20.3.214) by bamail02.ba.imgtec.org (10.20.40.28) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 9 Nov 2015 08:59:03 -0800 Message-ID: <1447088342.3867.27.camel@ubuntu-sellcey> Subject: Re: [Patch] Change to argument promotion in fixed conversion library calls From: Steve Ellcey Reply-To: To: Bernd Schmidt CC: Date: Mon, 9 Nov 2015 08:59:02 -0800 In-Reply-To: <563CFF8A.9050900@redhat.com> References: <15881f44-1bed-4fda-a47c-45234f9c091e@BAMAIL02.ba.imgtec.org> <563CFC33.8050004@redhat.com> <1446838073.3867.19.camel@ubuntu-sellcey> <563CFF8A.9050900@redhat.com> MIME-Version: 1.0 On Fri, 2015-11-06 at 20:29 +0100, Bernd Schmidt wrote: > On 11/06/2015 08:27 PM, Steve Ellcey wrote: > > > > Are you thinking of a simple function that is called on all targets or a > > target specific function? Maybe a target specific function would be > > safer. > > No, I think just what you have there is probably sufficient. > > > Bernd Bernd, Here is a version with the code moved into a new function. How does this look? 2015-11-09 Steve Ellcey * optabs.c (prepare_libcall_arg): New function. (expand_fixed_convert): Add call to prepare_libcall_arg. diff --git a/gcc/optabs.c b/gcc/optabs.c index fdcdc6a..fb25f90 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -4838,6 +4838,33 @@ expand_fix (rtx to, rtx from, int unsignedp) } } + +/* Promote integer arguments for a libcall if necessary. + emit_library_call_value cannot do the promotion because it does not + know if it should do a signed or unsigned promotion. This is because + there are no tree types defined for libcalls. */ + +static rtx +prepare_libcall_arg (rtx arg, int uintp) +{ + machine_mode mode = GET_MODE (arg); + machine_mode arg_mode; + if (SCALAR_INT_MODE_P (mode)) + { + /* If we need to promote the integer function argument we need to do + it here instead of inside emit_library_call_value because in + emit_library_call_value we don't know if we should do a signed or + unsigned promotion. */ + + int unsigned_p = 0; + arg_mode = promote_function_mode (NULL_TREE, mode, + &unsigned_p, NULL_TREE, 0); + if (arg_mode != mode) + return convert_to_mode (arg_mode, arg, uintp); + } + return arg; +} + /* Generate code to convert FROM or TO a fixed-point. If UINTP is true, either TO or FROM is an unsigned integer. If SATP is true, we need to saturate the result. */ @@ -4880,6 +4907,9 @@ expand_fixed_convert (rtx to, rtx from, int uintp, int satp) libfunc = convert_optab_libfunc (tab, to_mode, from_mode); gcc_assert (libfunc); + from = prepare_libcall_arg (from, uintp); + from_mode = GET_MODE (from); + start_sequence (); value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, to_mode, 1, from, from_mode);