From patchwork Mon Jul 16 03:53:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 171129 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 20EC42C00F4 for ; Mon, 16 Jul 2012 13:53:26 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343015607; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Date:Message-Id:From:To: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=lHw/l/20eaIDT4ASmrad QOGjp4Y=; b=NVxTZJK2x0dTpkoWfFJjFkPw34SEs52YuVF86hy8u5zr1RfszVcP +m8AMQQlel5mooTDKb2FUugdQPUQPUePYUbKJo9tfH/GzdD39ttCHwHu0wbwPxHS 4VaaU3KE8OeQFwi3eX/GVnCQPpqAuF2LNVTMmRB81GBFhaIqzqFrWRI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:Date:Message-Id:From:To:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=O0VB3cbqhtkhBD7YTRzY2HPvLAsg51vv85xEBxYBVBvAJ2kc+er7kxDNX1P5Fe rWTybdcmptSnhvicNh9oHsGeHDZDiPua/YyfPTbrBbkr55PiRSlGq8x78hxWCMm5 ZEOHJZTJsgoQox0H/jKk1Op7viuLrSv05SNZlUyjB4sL0=; Received: (qmail 15147 invoked by alias); 16 Jul 2012 03:53:22 -0000 Received: (qmail 15139 invoked by uid 22791); 16 Jul 2012 03:53:20 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from anubis.se.axis.com (HELO anubis.se.axis.com) (195.60.68.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Jul 2012 03:53:05 +0000 Received: from localhost (localhost [127.0.0.1]) by anubis.se.axis.com (Postfix) with ESMTP id 8304119DD8 for ; Mon, 16 Jul 2012 05:53:04 +0200 (CEST) Received: from anubis.se.axis.com ([127.0.0.1]) by localhost (anubis.se.axis.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id k7XAVyT4SKZy for ; Mon, 16 Jul 2012 05:53:03 +0200 (CEST) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by anubis.se.axis.com (Postfix) with ESMTP id C0DCC19D7A for ; Mon, 16 Jul 2012 05:53:03 +0200 (CEST) Received: from ignucius.se.axis.com (ignucius.se.axis.com [10.88.21.50]) by thoth.se.axis.com (Postfix) with ESMTP id B49B93413D; Mon, 16 Jul 2012 05:53:03 +0200 (CEST) Received: from ignucius.se.axis.com (localhost [127.0.0.1]) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) with ESMTP id q6G3r375019907; Mon, 16 Jul 2012 05:53:03 +0200 Received: (from hp@localhost) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) id q6G3r3Qq019903; Mon, 16 Jul 2012 05:53:03 +0200 Date: Mon, 16 Jul 2012 05:53:03 +0200 Message-Id: <201207160353.q6G3r3Qq019903@ignucius.se.axis.com> From: Hans-Peter Nilsson To: gcc-patches@gcc.gnu.org Subject: Fixing gcc.c-torture/compile/pr44707.c for CRIS v32 2/2: RFC: CONSTANT_ADDRESS_P and its default are evil! MIME-Version: 1.0 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 I think CONSTANT_ADDRESS_P can and should be eliminated, replaced by something like CONSTANT_P (x) && targetm.legitimate_address_p (QImode, x, false) (or QImode replaced by the known used mode) in the code currently calling it. It should, because the default definition is redundant and evil; easy to miss for targets where (mem (const x)) is not valid for any arbitrary generic x (symbol_ref, label_ref or const_int, including offsetted ones; (plus x (const_int N)). This is the case for CRIS v32, for which only (mem reg) and (mem (post_inc reg)) are valid. Like ia64 it has no offsettable addressing mode. For example, the constraint in gcc.c-torture/compile/pr44707.c of "nro" can only match for the "r" part. If your target fails gcc.c-torture/compile/pr44707.c, this might be the reason. No regressions for cris-elf nor crisv32-elf; fixes gcc.c-torture/compile/pr44707.c for the latter. Committed. * config/cris/cris-protos.h (cris_legitimate_address_p): Declare. * config/cris/cris.h (CONSTANT_ADDRESS_P): Define in terms of CONSTANT_P and cris_legitimate_address_p. * config/cris/cris.c (cris_legitimate_address_p): Make non-static. brgds, H-P Index: config/cris/cris.c =================================================================== --- config/cris/cris.c (revision 189506) +++ config/cris/cris.c (working copy) @@ -127,8 +127,6 @@ static void cris_init_libfuncs (void); static reg_class_t cris_preferred_reload_class (rtx, reg_class_t); -static bool cris_legitimate_address_p (enum machine_mode, rtx, bool); - static int cris_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int cris_memory_move_cost (enum machine_mode, reg_class_t, bool); static bool cris_rtx_costs (rtx, int, int, int, int *, bool); @@ -1414,7 +1412,7 @@ cris_biap_index_p (const_rtx x, bool str here (but is thankfully a general_operand in itself). A local PIC symbol is valid for the plain "symbol + offset" case. */ -static bool +bool cris_legitimate_address_p (enum machine_mode mode, rtx x, bool strict) { const_rtx x1, x2; Index: config/cris/cris.h =================================================================== --- config/cris/cris.h (revision 189504) +++ config/cris/cris.h (working copy) @@ -778,6 +778,9 @@ struct cum_args {int regs;}; #define HAVE_POST_INCREMENT 1 +#define CONSTANT_ADDRESS_P(X) \ + (CONSTANT_P (X) && cris_legitimate_address_p (QImode, X, false)) + /* Must be a compile-time constant, so we go with the highest value among all CRIS variants. */ #define MAX_REGS_PER_ADDRESS 2 Index: config/cris/cris-protos.h =================================================================== --- config/cris/cris-protos.h (revision 189499) +++ config/cris/cris-protos.h (working copy) @@ -40,6 +40,7 @@ extern bool cris_base_p (const_rtx, bool extern bool cris_base_or_autoincr_p (const_rtx, bool); extern bool cris_bdap_index_p (const_rtx, bool); extern bool cris_biap_index_p (const_rtx, bool); +extern bool cris_legitimate_address_p (enum machine_mode, rtx, bool); extern bool cris_store_multiple_op_p (rtx); extern bool cris_movem_load_rest_p (rtx, int); extern void cris_asm_output_symbol_ref (FILE *, rtx);