From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30384 invoked by alias); 6 Apr 2012 18:16:05 -0000 Received: (qmail 30370 invoked by uid 22791); 6 Apr 2012 18:16:04 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,MSGID_FROM_MTA_HEADER,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e06smtp16.uk.ibm.com (HELO e06smtp16.uk.ibm.com) (195.75.94.112) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Apr 2012 18:15:50 +0000 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 6 Apr 2012 19:15:49 +0100 Received: from d06nrmr1507.portsmouth.uk.ibm.com (9.149.38.233) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 6 Apr 2012 19:15:47 +0100 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q36IFlI12134056 for ; Fri, 6 Apr 2012 19:15:47 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q36IFkBQ021733 for ; Fri, 6 Apr 2012 12:15:46 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q36IFjJ4021718; Fri, 6 Apr 2012 12:15:45 -0600 Message-Id: <201204061815.q36IFjJ4021718@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 06 Apr 2012 20:15:45 +0200 Subject: Re: i370 port To: mutazilah@gmail.com (Paul Edwards) Date: Fri, 06 Apr 2012 18:16:00 -0000 From: "Ulrich Weigand" Cc: gcc@gcc.gnu.org In-Reply-To: from "Paul Edwards" at Apr 06, 2012 10:48:50 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit x-cbid: 12040618-3548-0000-0000-0000018E454B Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg00215.txt.bz2 Paul Edwards wrote: > I've managed to isolate the problem to a small test program. > > Any suggestions on how to debug this? > bug27.c:28: error: unrecognizable insn: > (insn 116 34 35 2 (set (reg:SI 5 5) > (plus:SI (plus:SI (reg:SI 2 2 [orig:54 i ] [54]) > (reg/f:SI 13 13)) > (const_int 104 [0x68]))) -1 (nil) > (nil)) Ah, yes. The problem is that reload assumes any valid address can be loaded into a register with a single instruction, and it will thus simply generate such instructions unconditionally -- and if the target then doesn't actually provide such a pattern, it will fail with "unrecognizable insn". The "LA" pattern you showed accepts only "(certain) single register + constant", which doesn't match the pattern above "register + register + constant". The difficulty is now that while "LA" *does* actually support adding base + index + displacement, you cannot simply add a pattern expressing that, because LA only does a 31-bit add, so it must only be used to add addresses, not when adding general 32-bit SImode values. The way I handle this in the s390 port is to provide a "forced" LA instruction pattern using a magic marker that prevents the pattern from being matched by regular instructions, and then add a secondary reload to emit that "forced" LA when reload needs to load an address. Here's the relevant snippets from the 3.4 s390 back-end: /* We need a secondary reload when loading a PLUS which is not a valid operand for LOAD ADDRESS. */ #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, IN) \ s390_secondary_input_reload_class ((CLASS), (MODE), (IN)) (define_insn "*la_31" [(set (match_operand:SI 0 "register_operand" "=d,d") (match_operand:QI 1 "address_operand" "U,W"))] "!TARGET_64BIT && legitimate_la_operand_p (operands[1])" "@ la\t%0,%a1 lay\t%0,%a1" [(set_attr "op_type" "RX,RXY") (set_attr "type" "la")]) (define_insn "force_la_31" [(set (match_operand:SI 0 "register_operand" "=d,d") (match_operand:QI 1 "address_operand" "U,W")) (use (const_int 0))] "!TARGET_64BIT" "@ la\t%0,%a1 lay\t%0,%a1" [(set_attr "op_type" "RX") (set_attr "type" "la")]) (define_expand "reload_insi" [(parallel [(match_operand:SI 0 "register_operand" "=a") (match_operand:SI 1 "s390_plus_operand" "") (match_operand:SI 2 "register_operand" "=&a")])] "!TARGET_64BIT" { s390_expand_plus_operand (operands[0], operands[1], operands[2]); DONE; }) (and of course the functions in s390.c called by these.) You ought to be able to do something similar in your backend ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com