From patchwork Mon Jul 2 20:01:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 168634 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 4B4992C0085 for ; Tue, 3 Jul 2012 06:01:39 +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=1341864100; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Subject:From:To:Date:Content-Type:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=FWQSr8+P0HgI7RMMXjol dDV8Wb8=; b=PVuXOFSzSnbJ5KaMW2dZWYCxHGvcRbu/4IY8nueP26gwzVRiQuiW 0wUzToElvGV+7d+a2GMq6D5qHpLhH1YxX68doyVA3qKh9ssvIIC4hJrGGtbLf4hA DEz2dU2hb9rpHgJ27RRxpyShWv4rNGNCfKVl5NpUa0wIdUbZnMljEZk= 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:Message-ID:Subject:From:To:Date:Content-Type:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=KuLKPHNmNKuHja2ycq6AQ44iOPBJofuUUGd1aIuPleqP2IlUzx8mR0lH6+Nfun S/KdEkb5rrtjE6YrsuU5Z33WMJ7szJJLPCZhTMyHoxPa3RkGBflqzIqDJXLrni51 dSbzu5QLEqYj3vollclFvfwYZg9Cp64t6xUlaYgm6XmQc=; Received: (qmail 27216 invoked by alias); 2 Jul 2012 20:01:35 -0000 Received: (qmail 27208 invoked by uid 22791); 2 Jul 2012 20:01:33 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout03.t-online.de (HELO mailout03.t-online.de) (194.25.134.81) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Jul 2012 20:01:18 +0000 Received: from fwd16.aul.t-online.de (fwd16.aul.t-online.de ) by mailout03.t-online.de with smtp id 1Slmo8-00088B-Rw; Mon, 02 Jul 2012 22:01:16 +0200 Received: from [192.168.0.104] (bpeYm4ZUZhSiytt0s72OC6N9HW9LQVKeS6cFQbLwvq1LtyZribRBJHSAFLnvFdzZGY@[93.218.164.15]) by fwd16.t-online.de with esmtp id 1Slmo4-2Bijc80; Mon, 2 Jul 2012 22:01:12 +0200 Message-ID: <1341259271.2287.4.camel@yam-132-YW-E178-FTW> Subject: [SH] PR 53568 - some bswap32 test cases From: Oleg Endo To: gcc-patches Date: Mon, 02 Jul 2012 22:01:11 +0200 Mime-Version: 1.0 X-IsSubscribed: yes 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, The attached patch adds a few bswap32 test cases for SH. Tested against rev 189175 with make -k check RUNTESTFLAGS="sh.exp=pr53568-1.c --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb, -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" to make sure that the test case passes. Cheers, Oleg testsuite/ChangeLog: PR target/53568 * gcc.target/sh/pr53568-1.c: New. Index: gcc/testsuite/gcc.target/sh/pr53568-1.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr53568-1.c (revision 0) +++ gcc/testsuite/gcc.target/sh/pr53568-1.c (revision 0) @@ -0,0 +1,82 @@ +/* Check that the bswap32 pattern is generated as swap.b and swap.w + instructions. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O2" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */ +/* { dg-final { scan-assembler-times "swap.w" 7 } } */ +/* { dg-final { scan-assembler-times "swap.b" 16 } } */ +/* { dg-final { scan-assembler-times "extu.w" 2 } } */ +/* { dg-final { scan-assembler-times "mov" 1 } } */ +/* { dg-final { scan-assembler-not "{shll8|shlr8|shld|shad}" } } */ + +int +test_func_00 (int a) +{ + /* 1x swap.w + 2x swap.b */ + return __builtin_bswap32 (a); +} + +unsigned int +test_func_01 (unsigned int a) +{ + /* 1x swap.w + 2x swap.b */ + return __builtin_bswap32 (a); +} + +int +test_func_02 (int a) +{ + /* 1x swap.w + 2x swap.b */ + return (((a >> 0) & 0xFF) << 24) + | (((a >> 8) & 0xFF) << 16) + | (((a >> 16) & 0xFF) << 8) + | (((a >> 24) & 0xFF) << 0); +} + +unsigned int +test_func_03 (unsigned int a) +{ + /* 1x swap.w + 2x swap.b */ + return (((a >> 0) & 0xFF) << 24) + | (((a >> 8) & 0xFF) << 16) + | (((a >> 16) & 0xFF) << 8) + | (((a >> 24) & 0xFF) << 0); +} + +int +test_func_04 (int a) +{ + /* 1x swap.b + 1x extu.w */ + return __builtin_bswap32 (a) >> 16; +} + +unsigned short +test_func_05 (unsigned short a) +{ + /* 1x swap.b + 1x extu.w */ + return __builtin_bswap32 (a) >> 16; +} + +long long +test_func_06 (long long a) +{ + /* 2x swap.w + 4x swap.b */ + return __builtin_bswap64 (a); +} + +long long +test_func_07 (long long a) +{ + /* 1x swap.w + 2x swap.b + 1x mov #0,Rn */ + return __builtin_bswap64 (a) >> 32; +} +