From patchwork Fri Aug 3 17:42:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 175032 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 D8AFC2C007D for ; Sat, 4 Aug 2012 03:43:04 +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=1344620585; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=waBG6of 9Mr21zMPiuuQ85Zut5ec=; b=EH+udfO7KRqtckVhxC5NBsBys4lJz96vcZVueLa gPDUK1uMyal6XDz95AiZSyLEneUvoHQ2jkQVCiGmJldzAJtbCSJ4HPzaWRSqLh9b JIuaVy9Rr+5OeubDLNYok09kWIKbTM1srhVE7//a07ABxlJ3Xh8W3sOuFB/HXnP7 kEmI= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=G+GzKEBFbI55/r0L7K9b4Ug9e9BdqLrFkNioFrrsx6kMxG2oXT90U5ZT6dE40E QS5pXCy/7heRKEicDW+mBDXOjYoVA/DYScJD5jnuXSmNLAkTAduM8ggA6qaFcJ0w faAw3RoWhZvBXBDrkiwqErNfRc0DMZVx7wk0+p64HPzsU=; Received: (qmail 10178 invoked by alias); 3 Aug 2012 17:43:01 -0000 Received: (qmail 10170 invoked by uid 22791); 3 Aug 2012 17:43:00 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SARE_SUB_PCT_LETTER, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-gh0-f175.google.com (HELO mail-gh0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 17:42:46 +0000 Received: by ghbz2 with SMTP id z2so1137409ghb.20 for ; Fri, 03 Aug 2012 10:42:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.89.234 with SMTP id br10mr457169pab.25.1344015765935; Fri, 03 Aug 2012 10:42:45 -0700 (PDT) Received: by 10.66.11.130 with HTTP; Fri, 3 Aug 2012 10:42:45 -0700 (PDT) Date: Fri, 3 Aug 2012 19:42:45 +0200 Message-ID: Subject: [PATCH, i386]: Improve sync inc/dec selection, add %K RTM operand modifier From: Uros Bizjak To: gcc-patches@gcc.gnu.org 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! Small improvement in inc/dec selection, added forgotten %K operand modifier. 2012-08-03 Uros Bizjak * config/i386/sync.md (*atomic_fetch_add_cmp): Use incdec_operand predicate to return INC or DEC insn mnemonic. Add %K operand modifier. (atomic_add): Use incdec_operand predicate to return INC or DEC insn mnemonic. (atomic_dec): Ditto. Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN. Uros. Index: config/i386/sync.md =================================================================== --- config/i386/sync.md (revision 190125) +++ config/i386/sync.md (working copy) @@ -495,29 +495,33 @@ (define_insn "*atomic_fetch_add_cmp" [(set (reg:CCZ FLAGS_REG) - (compare:CCZ (unspec_volatile:SWI - [(match_operand:SWI 0 "memory_operand" "+m") - (match_operand:SI 3 "const_int_operand")] - UNSPECV_XCHG) - (match_operand:SWI 2 "const_int_operand" "i"))) + (compare:CCZ + (unspec_volatile:SWI + [(match_operand:SWI 0 "memory_operand" "+m") + (match_operand:SI 3 "const_int_operand")] ;; model + UNSPECV_XCHG) + (match_operand:SWI 2 "const_int_operand" "i"))) (set (match_dup 0) (plus:SWI (match_dup 0) (match_operand:SWI 1 "const_int_operand" "i")))] "(unsigned HOST_WIDE_INT) INTVAL (operands[1]) == -(unsigned HOST_WIDE_INT) INTVAL (operands[2])" { - if (TARGET_USE_INCDEC) + if (incdec_operand (operands[1], mode)) { if (operands[1] == const1_rtx) - return "lock{%;} inc{}\t%0"; - if (operands[1] == constm1_rtx) - return "lock{%;} dec{}\t%0"; + return "lock{%;} %K3inc{}\t%0"; + else + { + gcc_assert (operands[1] == constm1_rtx); + return "lock{%;} %K3dec{}\t%0"; + } } if (x86_maybe_negate_const_int (&operands[1], mode)) - return "lock{%;} sub{}\t{%1, %0|%0, %1}"; + return "lock{%;} %K3sub{}\t{%1, %0|%0, %1}"; - return "lock{%;} add{}\t{%1, %0|%0, %1}"; + return "lock{%;} %K3add{}\t{%1, %0|%0, %1}"; }) ;; Recall that xchg implicitly sets LOCK#, so adding it again wastes space. @@ -543,12 +547,15 @@ (clobber (reg:CC FLAGS_REG))] "" { - if (TARGET_USE_INCDEC) + if (incdec_operand (operands[1], mode)) { if (operands[1] == const1_rtx) return "lock{%;} %K2inc{}\t%0"; - if (operands[1] == constm1_rtx) - return "lock{%;} %K2dec{}\t%0"; + else + { + gcc_assert (operands[1] == constm1_rtx); + return "lock{%;} %K2dec{}\t%0"; + } } if (x86_maybe_negate_const_int (&operands[1], mode)) @@ -567,12 +574,15 @@ (clobber (reg:CC FLAGS_REG))] "" { - if (TARGET_USE_INCDEC) + if (incdec_operand (operands[1], mode)) { if (operands[1] == const1_rtx) return "lock{%;} %K2dec{}\t%0"; - if (operands[1] == constm1_rtx) - return "lock{%;} %K2inc{}\t%0"; + else + { + gcc_assert (operands[1] == constm1_rtx); + return "lock{%;} %K2inc{}\t%0"; + } } if (x86_maybe_negate_const_int (&operands[1], mode))