From patchwork Wed Sep 22 14:08:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hariharan Sandanagobalane X-Patchwork-Id: 65421 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 A76FDB70DC for ; Thu, 23 Sep 2010 00:08:42 +1000 (EST) Received: (qmail 8371 invoked by alias); 22 Sep 2010 14:08:39 -0000 Received: (qmail 8357 invoked by uid 22791); 22 Sep 2010 14:08:37 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL, BAYES_05, TW_OV, TW_VH, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail2.picochip.com (HELO thurne.picochip.com) (82.111.145.34) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Sep 2010 14:08:26 +0000 Received: from haddeo.picochip.com (haddeo.picochip.com [172.17.3.47]) (authenticated bits=0) by thurne.picochip.com (8.13.8/8.13.8) with ESMTP id o8ME835A009798 for ; Wed, 22 Sep 2010 15:08:03 +0100 Message-ID: <4C9A0DD7.7070404@picochip.com> Date: Wed, 22 Sep 2010 15:08:23 +0100 From: Hariharan Sandanagobalane User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.1 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH, picochip] split movhicc after reload 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 Hello all, The attached patch enables picochip port to split movhicc to the CC generating instruction and cond-copy after reload. Splitting it earlier confuses combine as shown in 930718-1.c dejagnu test. Patch applied to mainline as r164523. Thanks Hari ChangeLog: * config/picochip/picochip.md (movhicc): Use expand to check whether movhicc is available and split it after reload. Patch: + (match_operand:HI 3 "picochip_register_or_immediate_operand" "r,i"))) + (use (match_dup 6))])] + "{ + operands[6] = GEN_INT(GET_CODE(operands[0])); + }") + ;; We dont do any checks here. But this pattern is used only when movhicc ;; was checked. Put a "use" clause to make sure. (define_insn "*conditional_copy" @@ -2534,7 +2550,7 @@ (if_then_else:HI (match_operator:HI 4 "picochip_peephole_comparison_operator" [(reg:CC CC_REGNUM) (const_int 0)]) - (match_operand:HI 1 "picochip_register_or_immediate_operand" "0,0") + (match_operand:HI 1 "register_operand" "0,0") (match_operand:HI 2 "picochip_register_or_immediate_operand" "r,i"))) (use (match_operand:HI 3 "const_int_operand" ""))] "" Index: gcc/config/picochip/picochip.md =================================================================== --- gcc/config/picochip/picochip.md (revision 164522) +++ gcc/config/picochip/picochip.md (working copy) @@ -622,7 +622,7 @@ ; Match a branch instruction, created from a tstport/cbranch split. ; We use a "use" clause so GCC doesnt try to use this pattern generally. -(define_insn "*branch" +(define_insn "branch" [(set (pc) (if_then_else (match_operator 2 "comparison_operator" @@ -2511,22 +2511,38 @@ ;;============================================================================ ;; Define expand seems to consider the resulting two instructions to be -;; independent. It was moving the actual copy instruction further down -;; with a call instruction in between. The call was clobbering the CC -;; and hence the cond_copy was wrong. With a split, it works correctly. +;; independent. With a split, guarded by reload, it works correctly. (define_expand "movhicc" - [(set (reg:CC CC_REGNUM) (match_operand 1 "comparison_operator" "")) - (parallel [(set (match_operand:HI 0 "register_operand" "=r,r") - (if_then_else:HI (match_op_dup:HI 1 [(reg:CC CC_REGNUM) (const_int 0)]) - (match_operand:HI 2 "picochip_register_or_immediate_operand" "0,0") - (match_operand:HI 3 "picochip_register_or_immediate_operand" "r,i"))) - (use (match_dup 4))])] + [(set (match_operand:HI 0 "register_operand" "=r,r") + (if_then_else:HI (match_operand:HI 1 "" "") + (match_operand:HI 2 "register_operand" "0,0") + (match_operand:HI 3 "picochip_register_or_immediate_operand" "r,i")))] "" {if (!picochip_check_conditional_copy (operands)) FAIL; operands[4] = GEN_INT(GET_CODE(operands[1])); }) +(define_insn_and_split "*checked_movhicc" + [(set (match_operand:HI 0 "register_operand" "=r,r") + (if_then_else:HI (match_operator 1 "picochip_peephole_comparison_operator" + [(match_operand:HI 4 "register_operand" "r,r") + (match_operand:HI 5 "picochip_comparison_operand" "r,i")]) + (match_operand:HI 2 "register_operand" "0,0") + (match_operand:HI 3 "picochip_register_or_immediate_operand" "r,i")))] + "" + "#" + "reload_completed" + [(set (reg:CC CC_REGNUM) (match_dup 1)) + (parallel [(set (match_operand:HI 0 "register_operand" "=r,r") + (if_then_else:HI (match_op_dup:HI 1 [(reg:CC CC_REGNUM) (const_int 0)]) + (match_operand:HI 2 "picochip_register_or_immediate_operand" "0,0")