From patchwork Mon Feb 23 20:45:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 442668 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 C9A5D140119 for ; Tue, 24 Feb 2015 07:46:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:date:content-type:mime-version; q= dns; s=default; b=eUPX1eS8liG7HaKFdosgkbSgkxsluuJIJShYDaDuJZWr+O g+jiRhfmJaoY1qVncpEgeTwuHcYgb/CGpUk2MvgYrbsG0xOh2tLOi3teAVFydF23 tiaXKccHi3AIhIhL+PysMqGOgkRyAULS7XStMcDgTixPmVD8NAlzE23Vc3O20= 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 :message-id:subject:from:to:date:content-type:mime-version; s= default; bh=v3aSOYDaLtioO7olx3me6HOrToU=; b=Q63AAvBCKqKv3vJ3ECiJ VTwa6CS0+sFHMjbLbrfANFW6498ycvE5rjCPZXqxbRUp3OQ56BODu2i42d1HVI5o bVQ8hKu0KY2ZMPLQ6zF9htvruvFep/GWKjmgOUdSjR+4fjyhTP27FjJnh6K5Kdbn rDENrDQ/flhNmWz/Nq8ccL8= Received: (qmail 45045 invoked by alias); 23 Feb 2015 20:46:03 -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 45014 invoked by uid 89); 23 Feb 2015 20:46:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailout02.t-online.de Received: from mailout02.t-online.de (HELO mailout02.t-online.de) (194.25.134.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 23 Feb 2015 20:46:00 +0000 Received: from fwd28.aul.t-online.de (fwd28.aul.t-online.de [172.20.26.133]) by mailout02.t-online.de (Postfix) with SMTP id 084C662FF42 for ; Mon, 23 Feb 2015 21:45:56 +0100 (CET) Received: from [192.168.0.106] (EXTpy6ZLQhYm8x8g-e8-c4sREIto+118LOzowHGEPmOjcw+WnjB7pbkE+H7mKI6gIJ@[84.183.240.30]) by fwd28.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1YPzt4-0wWwQi0; Mon, 23 Feb 2015 21:45:54 +0100 Message-ID: <1424724346.14981.348.camel@yam-132-YW-E178-FTW> Subject: [SH][committed] Fix PR 65163 From: Oleg Endo To: gcc-patches Date: Mon, 23 Feb 2015 21:45:46 +0100 Mime-Version: 1.0 X-IsSubscribed: yes Hi, The attached patch fixes PR 65163. Although the problem started to show up on trunk and not on the 4.8 / 4.9 branches, I've also backported it, since it's a latent bug. Tested on trunk with make -k check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" and on the branches briefly with make -k check-gcc RUNTESTFLAGS="sh.exp --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" Committed as r220916 (trunk), r220917 (4.9), r220918 (4.8). Cheers, Oleg gcc/ChangeLog: PR target/65163 * config/sh/sh.md (swapbsi2, related peephole2): Use const_int -65536 instead of const_int 4294901760. gcc/testsuite/ChangeLog: PR target/65163 * gcc.c-torture/compile/pr65163.c: New. Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 220892) +++ gcc/config/sh/sh.md (working copy) @@ -6218,7 +6218,7 @@ (define_insn "swapbsi2" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (ior:SI (and:SI (match_operand:SI 1 "arith_reg_operand" "r") - (const_int 4294901760)) + (const_int -65536)) ;; 0xFFFF0000 (ior:SI (and:SI (ashift:SI (match_dup 1) (const_int 8)) (const_int 65280)) (and:SI (ashiftrt:SI (match_dup 1) (const_int 8)) @@ -6286,7 +6286,7 @@ (define_peephole2 [(set (match_operand:SI 0 "arith_reg_dest" "") (ior:SI (and:SI (match_operand:SI 1 "arith_reg_operand" "") - (const_int 4294901760)) + (const_int -65536)) ;; 0xFFFF0000 (ior:SI (and:SI (ashift:SI (match_dup 1) (const_int 8)) (const_int 65280)) (and:SI (ashiftrt:SI (match_dup 1) (const_int 8)) @@ -6296,7 +6296,7 @@ "TARGET_SH1 && peep2_reg_dead_p (2, operands[0])" [(set (match_dup 2) (ior:SI (and:SI (match_operand:SI 1 "arith_reg_operand" "") - (const_int 4294901760)) + (const_int -65536)) ;; 0xFFFF0000 (ior:SI (and:SI (ashift:SI (match_dup 1) (const_int 8)) (const_int 65280)) (and:SI (ashiftrt:SI (match_dup 1) (const_int 8)) Index: gcc/testsuite/gcc.c-torture/compile/pr65163.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/pr65163.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/pr65163.c (revision 0) @@ -0,0 +1,22 @@ +/* PR target/65163 */ + +typedef unsigned int uint32_t; +typedef unsigned short uint16_t; +union unaligned_32 { uint32_t l; } __attribute__((packed)); +union unaligned_16 { uint16_t l; } __attribute__((packed)); + +int +test_00 (unsigned char* buf, int bits_per_component) +{ + (((union unaligned_32*)(buf))->l) = + __builtin_bswap32 (bits_per_component == 10 ? 1 : 0); + return 0; +} + +int +test_01 (unsigned char* buf, int bits_per_component) +{ + (((union unaligned_16*)(buf))->l) = + __builtin_bswap16 (bits_per_component == 10 ? 1 : 0); + return 0; +}