From patchwork Mon Apr 27 10:03:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 464927 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 9ABD61402B6 for ; Mon, 27 Apr 2015 20:03:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yfy0nYmn; dkim-adsp=none (unprotected policy); 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 :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=bo1EggdSxG0My8Dy 5w/VgMyeObLoMsDy9x7gin2hpDB9aND3n1dBbXipIWk761ZJPMqaCF1x8BM3t71U ZUI9J1d1mY6Jz4pffOvENmF7cCPVOR6D2LngDsF3eSWg8Sr0oxoHic+KlpMxzC+Q yBE4c54pqiydKkjlW8DBe9McKCc= 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 :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=ygL+qZSDQC1ne2b7H2vqK+ CQleA=; b=yfy0nYmnhrknoHCcghehZThoD1VBAYRtggrPOw5vQf8CNGbqs07yOU yDjzRXbiq6/RNZWx9bItv94UA7lYfHMttpolSinyuxcWcc2mLPZMsL0NJDRC6T1B 5IXtS6b3hmtfENDSlBVL6DnEGDRHljymWkJzo4fKEV05G+UYgCN+c= Received: (qmail 126336 invoked by alias); 27 Apr 2015 10:03:51 -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 126325 invoked by uid 89); 27 Apr 2015 10:03:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Apr 2015 10:03:50 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-27.uk.mimecast.lan; Mon, 27 Apr 2015 11:03:47 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Apr 2015 11:03:46 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org, nickc@redhat.com Mail-Followup-To: gcc-patches@gcc.gnu.org, nickc@redhat.com, richard.sandiford@arm.com Subject: Fix xstormy16 handling of HImode predicates Date: Mon, 27 Apr 2015 11:03:46 +0100 Message-ID: <87r3r5yjjx.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: eAjN41UpSZmkrMoCw5YQWw-1 xstormy16 has: (define_predicate "xs_hi_general_operand" (match_code "const_int,reg,subreg,mem,symbol_ref,label_ref,const") { if ((GET_CODE (op) == CONST_INT) && ((INTVAL (op) >= 32768) || (INTVAL (op) < -32768))) { error ("constant halfword load operand out of range"); return false; } return general_operand (op, mode); }) I think this is wrong for two reasons: - Predicates are supposed to accept things in different modes and weed out the invalid values. That's why the predicates start with a check that GET_MODE (op) == VOIDmode || GET_MODE (op) == mode. IMO it doesn't make sense to handle (e.g.) SImode REGs correctly but raise an error for SImode CONST_INTs. The generic predicates later reject CONST_INTs that aren't suitable for the mode, so invalid HImode CONST_INTs will fail to match rather than be silently accepted. - If we did have a check, it should be an assert rather than a user error. The port is effectively relying on the matching algorithm in genrecog to ensure that the predicate is only called on SET_SRC rtxes once the mode of the SET_DEST has been checked. This patch removes the predicate and uses general_operand instead. xs_hi_nonmemory_operand is similar except that it rejects symbol_ref and label_ref constants. The patch therefore removes the error check but keeps the restricted code list. Note that we have an assert in rtl.h that CONST_INTs fit into the range appropriate for the wi:: precision. This should catch more cases than the predicate checks would have. (It has flagged up problems that were latent before.) Tested by building xstormy16-elf and making sure that there were no differences in assembly output for the GCC testsuite. OK to install? Thanks, Richard gcc/ * config/stormy16/predicates.md (xs_hi_general_operand): Delete. (xs_hi_nonmemory_operand): Remove error. * config/stormy16/stormy16.md (movhi, movhi_internal): Use general_operand rather than xs_hi_general_operand. Index: gcc/config/stormy16/predicates.md =================================================================== --- gcc/config/stormy16/predicates.md 2015-04-27 10:38:48.000000000 +0100 +++ gcc/config/stormy16/predicates.md 2015-04-27 10:40:00.709344494 +0100 @@ -151,28 +151,8 @@ (define_predicate "xstormy16_carry_plus_ && (INTVAL (XEXP (op, 1)) < -4 || INTVAL (XEXP (op, 1)) > 4)); }) -(define_predicate "xs_hi_general_operand" - (match_code "const_int,reg,subreg,mem,symbol_ref,label_ref,const") -{ - if ((GET_CODE (op) == CONST_INT) - && ((INTVAL (op) >= 32768) || (INTVAL (op) < -32768))) - { - error ("constant halfword load operand out of range"); - return false; - } - - return general_operand (op, mode); -}) - (define_predicate "xs_hi_nonmemory_operand" (match_code "const_int,reg,subreg,const") { - if ((GET_CODE (op) == CONST_INT) - && ((INTVAL (op) >= 32768) || (INTVAL (op) < -32768))) - { - error ("constant arithmetic operand out of range"); - return false; - } - return nonmemory_operand (op, mode); }) Index: gcc/config/stormy16/stormy16.md =================================================================== --- gcc/config/stormy16/stormy16.md 2015-04-27 10:38:48.000000000 +0100 +++ gcc/config/stormy16/stormy16.md 2015-04-27 10:40:00.709344494 +0100 @@ -185,7 +185,7 @@ (define_insn "pophi1" (define_expand "movhi" [(set (match_operand:HI 0 "nonimmediate_nonstack_operand" "") - (match_operand:HI 1 "xs_hi_general_operand" ""))] + (match_operand:HI 1 "general_operand" ""))] "" { xstormy16_expand_move (HImode, operands[0], operands[1]); DONE; @@ -193,7 +193,7 @@ (define_expand "movhi" (define_insn "movhi_internal" [(set (match_operand:HI 0 "nonimmediate_nonstack_operand" "=r,m,e,e,T,r,S,W,e") - (match_operand:HI 1 "xs_hi_general_operand" "r,e,m,L,L,i,i,ie,W"))] + (match_operand:HI 1 "general_operand" "r,e,m,L,L,i,i,ie,W"))] "" "@ mov %0,%1