From patchwork Tue Nov 10 23:57:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 542651 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 CEB26141418 for ; Wed, 11 Nov 2015 10:58:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=owfM1bkG; 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:from :date:to:cc:subject:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=JKX+K 8C1F2JdFp0f9LlZvJQIUM/EoZ2P4UZcyE2bPeMCvtExmZNdUFxjv3bHCD4hIG2Ko cPEAeM6ybnN2roImsQd1BoXuSwI6uZSxRBoUg+90daa6T12yq/6xffpZBM56BO5J mb95gNlfk2YZxQCGDZOPFvJkcwgmQ4IcHTcG9k= 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:from :date:to:cc:subject:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=ULIfZm/vMXa 29HtNJsFfiYj7g5Q=; b=owfM1bkGcvG2/qfzwHtLi1hIeCcTTq8Sv215tRRZrqM UH6aQ/JeZXX8CG6aScOK7wWZdOAnElZHrMwHEi3GZF5Crt5Eb+JF8P3OjtCLsyKj 5fxNbFRYfeYHlS4kP1j3N4gWwag9YI3jSUbGr9aoVw5dXOYo8AxsLJq7j3Lp++nc = Received: (qmail 66650 invoked by alias); 10 Nov 2015 23:58:00 -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 66631 invoked by uid 89); 10 Nov 2015 23:58:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 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; Tue, 10 Nov 2015 23:57:58 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Websense Email Security Gateway with ESMTPS id 4824BBA2C7C2B; Tue, 10 Nov 2015 23:57:51 +0000 (GMT) Received: from HHMAIL01.hh.imgtec.org (10.100.10.19) by hhmail02.hh.imgtec.org (10.100.10.20) with Microsoft SMTP Server (TLS) id 14.3.235.1; Tue, 10 Nov 2015 23:57:55 +0000 Received: from BAMAIL02.ba.imgtec.org (10.20.40.28) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (TLS) id 14.3.235.1; Tue, 10 Nov 2015 23:57:55 +0000 Received: from ubuntu-sellcey.mips.com (10.20.3.214) by bamail02.ba.imgtec.org (10.20.40.28) with Microsoft SMTP Server id 14.3.174.1; Tue, 10 Nov 2015 15:57:52 -0800 Received: by ubuntu-sellcey.mips.com (sSMTP sendmail emulation); Tue, 10 Nov 2015 15:57:51 -0800 From: "Steve Ellcey " Date: Tue, 10 Nov 2015 15:57:51 -0800 To: CC: , Subject: [Patch, MIPS] Remove definition of TARGET_PROMOTE_PROTOTYPES User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-ID: <9003b977-ba2d-4c32-9078-af164c7305c8@BAMAIL02.ba.imgtec.org> This patch removes the definition of TARGET_PROMOTE_PROTOTYPES from MIPS, where it was defined as true, so that it now defaults to false. Currently MIPS does prototype promotion in the caller and the callee and this patch removes the TARGET_PROMOTE_PROTOTYPES macro definition so that the promotion is only done in the caller (due to PROMOTE_MODE being defined). This does not break the ABI which requires the caller to do promotions anyway. (See https://gcc.gnu.org/ml/gcc/2015-10/msg00223.html). This change also causes GCC to match what the LLVM and Greenhills compilers already do on MIPS. After removing this macro I had three regressions, two were just tests that needed changing but one was a bug (gcc.dg/fixed-point/convert-sat.c). This test was calling a library function to convert a signed char into an unsigned fixed type and because we don't have tree type information about libcalls GCC cannot do the ABI required type promotion on those calls that it does on normal user defined calls. In fact promote_mode in explow.c expicitly returns without doing anything if no type is given it. Before this change it didn't matter on MIPS because the callee did the same promotion that the caller was supposed to have done before using the argument. Now that callee code is gone we depend on the caller doing the correct promotion and that was not happening. I submitted and checked in another patch to optabs.c (See https://gcc.gnu.org/ml/gcc-patches/2015-11/msg00704.html) to provide me with the infrastructure to do the correct type promotion in expand_fixed and this patch redefines TARGET_PROMOTE_FUNCTION_MODE to return the needed promotion mode even when type is NULL_TREE. When type is set it does the same thing as it used to do. This change allows me to remote the definition of TARGET_PROMOTE_PROTOTYPES without the convert-sat.c test failing. The two tests that I changed are gcc.dg/tree-ssa/ssa-fre-4.c and gcc.target/mips/ext-2.c. ssa-fre-4.c no longer applies to MIPS now that we do not define TARGET_PROMOTE_PROTOTYPES so I removed the MIPS target from it. ext-2.c now generates an srl instruction instead of a dext instruction but the number of instructions has not changed and I updated the scan checks. Tested on mips-mti-linux-gnu with no unfixed regressions. OK to checkin? Steve Ellcey sellcey@imgtec.com 2015-11-10 Steve Ellcey * config/mips/mips.c (mips_promote_function_mode): New function. (TARGET_PROMOTE_FUNCTION_MODE): Define as above function. (TARGET_PROMOTE_PROTOTYPES): Remove. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 9880b23..e9c3830 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -19760,6 +19760,32 @@ mips_ira_change_pseudo_allocno_class (int regno, reg_class_t allocno_class) return GR_REGS; return allocno_class; } + +/* Implement TARGET_PROMOTE_FUNCTION_MODE */ + +/* This function is equivalent to default_promote_function_mode_always_promote + except that it returns a promoted mode even if type is NULL_TREE. This is + needed by libcalls which have no type (only a mode) such as fixed conversion + routines that take a signed or unsigned char/short argument and convert it + to a fixed type. */ + +static machine_mode +mips_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + machine_mode mode, + int *punsignedp ATTRIBUTE_UNUSED, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return ATTRIBUTE_UNUSED) +{ + int unsignedp; + + if (type != NULL_TREE) + return promote_mode (type, mode, punsignedp); + + unsignedp = *punsignedp; + PROMOTE_MODE (mode, unsignedp, type); + *punsignedp = unsignedp; + return mode; +} /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP @@ -19864,10 +19890,7 @@ mips_ira_change_pseudo_allocno_class (int regno, reg_class_t allocno_class) #define TARGET_GIMPLIFY_VA_ARG_EXPR mips_gimplify_va_arg_expr #undef TARGET_PROMOTE_FUNCTION_MODE -#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote -#undef TARGET_PROMOTE_PROTOTYPES -#define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true - +#define TARGET_PROMOTE_FUNCTION_MODE mips_promote_function_mode #undef TARGET_FUNCTION_VALUE #define TARGET_FUNCTION_VALUE mips_function_value #undef TARGET_LIBCALL_VALUE 2015-11-10 Steve Ellcey * gcc.dg/tree-ssa/ssa-fre-4.c: Remove mips*-*-* target. * gcc.target/mips/ext-2.c: Update scan checks. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c index 02b6719..5a7588f 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-4.c @@ -1,6 +1,6 @@ /* If the target returns false for TARGET_PROMOTE_PROTOTYPES, then there will be no casts for FRE to eliminate and the test will fail. */ -/* { dg-do compile { target i?86-*-* x86_64-*-* hppa*-*-* mips*-*-* m68k*-*-* } } */ +/* { dg-do compile { target i?86-*-* x86_64-*-* hppa*-*-* m68k*-*-* } } */ /* { dg-options "-O -fno-tree-ccp -fno-tree-forwprop -fdump-tree-fre1-details" } */ /* From PR21608. */ diff --git a/gcc/testsuite/gcc.target/mips/ext-2.c b/gcc/testsuite/gcc.target/mips/ext-2.c index 320d42d..9770321 100644 --- a/gcc/testsuite/gcc.target/mips/ext-2.c +++ b/gcc/testsuite/gcc.target/mips/ext-2.c @@ -1,12 +1,13 @@ /* Turn the truncate,zero_extend,lshiftrt sequence before the or into a zero_extract. The truncate is due to TARGET_PROMOTE_PROTOTYPES, the - zero_extend to PROMOTE_MODE. */ + zero_extend to PROMOTE_MODE. As of GCC 6, we no longer define + TARGET_PROMOTE_PROTOTYPES so that truncate is gone and we can + generate either a single extract or a single shift instruction. */ /* { dg-do compile } */ /* { dg-options "isa_rev>=2 -mgp64 -mlong64" } */ /* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */ -/* { dg-final { scan-assembler "\tdext\t" } } */ +/* { dg-final { scan-assembler-times "\tdext\t|\td?srl" 1 } } */ /* { dg-final { scan-assembler-not "\tand" } } */ -/* { dg-final { scan-assembler-not "\td?srl" } } */ NOMIPS16 void f (unsigned char x, unsigned char *r)