From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4683 invoked by alias); 4 Oct 2011 14:09:45 -0000 Received: (qmail 4675 invoked by uid 22791); 4 Oct 2011 14:09:43 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,TW_OV X-Spam-Check-By: sourceware.org Received: from va3ehsobe005.messaging.microsoft.com (HELO VA3EHSOBE005.bigfish.com) (216.32.180.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 Oct 2011 14:09:26 +0000 Received: from mail199-va3-R.bigfish.com (10.7.14.250) by VA3EHSOBE005.bigfish.com (10.7.40.25) with Microsoft SMTP Server id 14.1.225.22; Tue, 4 Oct 2011 14:09:26 +0000 Received: from mail199-va3 (localhost.localdomain [127.0.0.1]) by mail199-va3-R.bigfish.com (Postfix) with ESMTP id 9D70EE601F4 for ; Tue, 4 Oct 2011 14:09:25 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzzz32i2a8h668h839h8e2h8e3h944h) X-Forefront-Antispam-Report: CIP:220.225.38.51;KIP:(null);UIP:(null);IPVD:NLI;H:Outbound.kpitcummins.com;RD:none;EFVD:NLI X-FB-SS: 13, Received: from mail199-va3 (localhost.localdomain [127.0.0.1]) by mail199-va3 (MessageSwitch) id 1317737317160116_27386; Tue, 4 Oct 2011 14:08:37 +0000 (UTC) Received: from VA3EHSMHS036.bigfish.com (unknown [10.7.14.237]) by mail199-va3.bigfish.com (Postfix) with ESMTP id D05B3104851D for ; Tue, 4 Oct 2011 14:07:53 +0000 (UTC) Received: from Outbound.kpitcummins.com (220.225.38.51) by VA3EHSMHS036.bigfish.com (10.7.99.46) with Microsoft SMTP Server (TLS) id 14.1.225.22; Tue, 4 Oct 2011 14:07:51 +0000 Received: from KCHJEXMB02.kpit.com ([169.254.2.140]) by KCHJEXHC02.kpit.com ([172.10.15.74]) with mapi id 14.01.0255.000; Tue, 4 Oct 2011 19:37:46 +0530 From: "Naveen H. S" To: "gcc-help@gcc.gnu.org" Subject: Problem with peephole optimizing the register Date: Tue, 04 Oct 2011 14:09:00 -0000 Message-ID: <5CD0E437A05A514A90A1B12527F33154176B9EAB@KCHJEXMB02.kpit.com> References: <5CD0E437A05A514A90A1B12527F331540E4182@KCHJEXMB02.kpit.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: kpitcummins.com Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00021.txt.bz2 Hi, We have implemented peephole for generation of tbit instruction in CR16 port. The TBIT instruction copies the bit located in register or memory location src at the bit position specified by offset, to PSR.F flag. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D tbitb $3, 8(r1) - Copies bit in pos 3 to mem loc 8 (R1) to PSR.F flag =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D One of the instances of peephole generated is as follows:- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Earlier code loadw _Fdi@l,r7=20=09=09=09 andw $16384,r7 bne0w r7,.L9=20=20 -------------------> -------------------> -------------------> movb r7, r2=20=20 bal (ra), _ClrFlags@c=20 Optimized code=20=20=20=20=20 tbitw $14,_Fdi@l bfs .L9 -------------------> -------------------> ------------------->=09 movb r7, r2 <=3D=3D=3D=3D=3D=3D=3D Problem bal (ra), _ClrFlags@c=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D It can be noted that the value at Fdi(label ref) is copied into r7=20 register. The r7 register is modified and the branch depends on r7. However, with tbit peepholes; r7 register is optimized away. In an application, r7 register is being used as source in the sequence after tbit instruction. The above snippet shows that the r7 value is moved into r2. However, as the r2 value is optimized away; wrong value is moved into r2 and hence application crashes. The peep2_reg_dead_p, find_reg_note and other functions were tried=20 out without much use. Please let us know if there are any functions that would let compiler=20 know about the register being used in later sequence and hence avoid the peephole in such scenarios. Thanks & Regards, Naveen