From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26748 invoked by alias); 18 May 2009 07:58:43 -0000 Received: (qmail 26738 invoked by uid 22791); 18 May 2009 07:58:42 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_52,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f173.google.com (HELO mail-pz0-f173.google.com) (209.85.222.173) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 May 2009 07:58:38 +0000 Received: by pzk3 with SMTP id 3so1764154pzk.0 for ; Mon, 18 May 2009 00:58:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.90.16 with SMTP id n16mr1855809wfb.314.1242633514910; Mon, 18 May 2009 00:58:34 -0700 (PDT) In-Reply-To: <4A103C46.7060503@codesourcery.com> References: <31d002d40905170209v5fedd93cvec67d5e9a72c9f17@mail.gmail.com> <4A103C46.7060503@codesourcery.com> Date: Mon, 18 May 2009 12:34:00 -0000 Message-ID: <31d002d40905180058g4391c71fo8c66119e20300936@mail.gmail.com> Subject: Re: Destructive comparison From: Michael Hope To: Jim Wilson Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00450.txt.bz2 Thanks, that worked. I ended up using: (define_insn "cmpcc_xor" [(set (match_operand:CC 0 "register_operand" "=3DC") (compare:CC (not:SI (xor:SI (match_operand:SI 1 "register_operand" "%r") (match_operand:SI 2 "register_operand" "b"))) (const_int 0))) (set (match_operand:SI 3 "register_operand" "=3D1") (not:SI (xor:SI (match_dup 1) (match_dup 2))))] "" "XOR, %1" ) The important thing was in the generation. The XOR is two operand but I needed to supply a third pretend operand using: emit_insn (gen_cmpcc_(cc_reg, x, y, gen_reg_rtx(SImode))); Using a match_dup instead of operand 3 above, or supplying 'x' twice, lead to the compiler not noticing the change. -- Michael 2009/5/18 Jim Wilson : > Michael Hope wrote: >> >> =A0* Using a define_insn to mark it as both a destructive xor and >> compare in parallel, such as: > > When a compare is in a parallel, the compare must be the first operation. > =A0You have it second. =A0This kind of pattern should work. =A0You can fi= nd many > examples of it in the sparc.md file for instance. =A0Of course, in this c= ase, > they aren't generated at RTL generation time. They are generated at combi= ne > time. =A0Still, I'd expect this to work, though there might be some early= RTL > optimization passes that are not prepared to handle it. > > See for instance the cmp_cc_xor_not_set pattern in the sparc.md file, whi= ch > is similar to what you want. > > Jim >