From patchwork Sat Jul 21 02:00:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 172398 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 CC8372C040C for ; Sat, 21 Jul 2012 12:00:57 +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=1343440858; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:From:To:Subject:Date: Message-ID:Content-Type:MIME-Version:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=M5lRxT/yzNPkavXR2RwJTMJUqHQ=; b=LgpNNnFHspxp5wO TAtuL7RCKXfFpeB/wVBQKJNU1cA+H38tb1wFpF2r6QX0dJ9nty17jXRYYwyO5YcG iTbJEIdRI03nIFy3rZOF68JyTbq7sT7rr/dfbRKPB4ogw5sINqRfkvQEMPOaoC3+ J0jXhfCgMOhl9Wv3U0hN6L4EVBN0= 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:X-Forefront-Antispam-Report:X-SpamScore:X-BigFish:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:Content-Type:MIME-Version:X-OriginatorOrg:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=YL4tdKkGsVoK4SFGSmoSX/wH6vSxKGujfw/uoF6XmwqCe3twZSogQ2+/bRyfqP vn2LHbdBvg+Hi5yGnrA8XgnStIQQQTtteS/cx2W6Qq4n7B1iM6nsEuEz+FCG0Ca6 SjxZQFFTQ8bcafohr6ae6bHEuFs6S0KZDdxcT5j8xbYNY=; Received: (qmail 26508 invoked by alias); 21 Jul 2012 02:00:51 -0000 Received: (qmail 26499 invoked by uid 22791); 21 Jul 2012 02:00:47 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from am1ehsobe001.messaging.microsoft.com (HELO am1outboundpool.messaging.microsoft.com) (213.199.154.204) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 Jul 2012 02:00:33 +0000 Received: from mail119-am1-R.bigfish.com (10.3.201.234) by AM1EHSOBE008.bigfish.com (10.3.204.28) with Microsoft SMTP Server id 14.1.225.23; Sat, 21 Jul 2012 02:00:31 +0000 Received: from mail119-am1 (localhost [127.0.0.1]) by mail119-am1-R.bigfish.com (Postfix) with ESMTP id 737E2403B0 for ; Sat, 21 Jul 2012 02:00:31 +0000 (UTC) X-Forefront-Antispam-Report: CIP:157.56.236.133; KIP:(null); UIP:(null); IPV:NLI; H:BY2PRD0710HT002.namprd07.prod.outlook.com; RD:none; EFVD:NLI X-SpamScore: -1 X-BigFish: PS-1(zzc85fh4015Izz1202hzzz2dh2a8h668h839hd25hf0ah107ah34h) Received: from mail119-am1 (localhost.localdomain [127.0.0.1]) by mail119-am1 (MessageSwitch) id 1342836027702784_9738; Sat, 21 Jul 2012 02:00:27 +0000 (UTC) Received: from AM1EHSMHS005.bigfish.com (unknown [10.3.201.233]) by mail119-am1.bigfish.com (Postfix) with ESMTP id A04634A0097 for ; Sat, 21 Jul 2012 02:00:27 +0000 (UTC) Received: from BY2PRD0710HT002.namprd07.prod.outlook.com (157.56.236.133) by AM1EHSMHS005.bigfish.com (10.3.207.105) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sat, 21 Jul 2012 02:00:27 +0000 Received: from BY2PRD0710MB377.namprd07.prod.outlook.com ([169.254.2.224]) by BY2PRD0710HT002.namprd07.prod.outlook.com ([10.255.86.37]) with mapi id 14.16.0175.005; Sat, 21 Jul 2012 02:00:25 +0000 From: "Pinski, Andrew" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH][MIPS] Improve Octeon Pop instruction usage Date: Sat, 21 Jul 2012 02:00:24 +0000 Message-ID: MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com 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 Hi, The Octeon pop instruction does not take into account the upper 32bits of the 64bit register, so its usage can be optimized when there is a truncation right before the instruction. This patch implements this small optimization. OK? Bootstrapped and tested on MIPS64-linux-gnu (Octeon) with no regressions. Thanks, Andrew Pinski * config/mips/mips.md (*popcountdi2_trunc): New pattern to handle popcount of a truncation. * testsuite/gcc.target/mips/octeon-pop-2.c: New testcase. Index: testsuite/gcc.target/mips/octeon-pop-2.c =================================================================== --- testsuite/gcc.target/mips/octeon-pop-2.c (revision 0) +++ testsuite/gcc.target/mips/octeon-pop-2.c (revision 0) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O -march=octeon -mgp64" } */ +/* The pop instruction does not depend on the word value to be sign extended. */ +/* { dg-final { scan-assembler-not "sll\t" } } */ + +long long f(long long i) +{ + return __builtin_popcount (i); +} + Index: config/mips/mips.md =================================================================== --- config/mips/mips.md (revision 189737) +++ config/mips/mips.md (working copy) @@ -2643,6 +2643,16 @@ (define_insn "popcount2" "pop\t%0,%1" [(set_attr "type" "pop") (set_attr "mode" "")]) + +;; The POP instruction is special as it does not take into account the upper +;; 32bits and is documented that way. +(define_insn "*popcountdi2_trunc" + [(set (match_operand:SI 0 "register_operand" "=d") + (popcount:SI (truncate:SI (match_operand:DI 1 "register_operand" "d"))))] + "ISA_HAS_POP" + "pop\t%0,%1" + [(set_attr "type" "pop") + (set_attr "mode" "SI")]) ;; ;; ....................