From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4259 invoked by alias); 4 Jun 2011 15:40:01 -0000 Received: (qmail 4233 invoked by uid 22791); 4 Jun 2011 15:40:00 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Jun 2011 15:39:40 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p54FddqX005532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 4 Jun 2011 11:39:40 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p54FddJ6027332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 4 Jun 2011 11:39:39 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p54Fdclc031227; Sat, 4 Jun 2011 17:39:38 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p54FdcSs031225; Sat, 4 Jun 2011 17:39:38 +0200 Date: Sat, 04 Jun 2011 15:40:00 -0000 From: Jakub Jelinek To: "H.J. Lu" Cc: Uros Bizjak , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Optimize (x * 8) | 5 and (x << 3) ^ 3 to use lea (PR target/48688) Message-ID: <20110604153938.GM17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110420160959.GR17079@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg00312.txt.bz2 On Sat, Jun 04, 2011 at 08:19:57AM -0700, H.J. Lu wrote: > I don't think this pattern is correct. See: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49281 Fixed thusly, committed as obvious: 2011-06-04 Jakub Jelinek PR target/49281 * config/i386/i386.md (*lea_general_4): Require INTVAL (operands[3]) to be strictly smaller than 1 << shiftcount. * gcc.c-torture/execute/pr49281.c: New test. --- gcc/config/i386/i386.md.jj 2011-06-01 10:20:02.000000000 +0200 +++ gcc/config/i386/i386.md 2011-06-04 17:21:02.000000000 +0200 @@ -6425,7 +6425,7 @@ (define_insn_and_split "*lea_general_4" || optimize_function_for_size_p (cfun)) && ((unsigned HOST_WIDE_INT) INTVAL (operands[2])) - 1 < 3 && ((unsigned HOST_WIDE_INT) INTVAL (operands[3]) - <= ((unsigned HOST_WIDE_INT) 1 << INTVAL (operands[2])))" + < ((unsigned HOST_WIDE_INT) 1 << INTVAL (operands[2])))" "#" "&& reload_completed" [(const_int 0)] --- gcc/testsuite/gcc.c-torture/execute/pr49281.c.jj 2011-06-04 17:29:39.000000000 +0200 +++ gcc/testsuite/gcc.c-torture/execute/pr49281.c 2011-06-04 17:32:05.000000000 +0200 @@ -0,0 +1,25 @@ +/* PR target/49281 */ + +extern void abort (void); + +__attribute__((noinline, noclone)) int +foo (int x) +{ + return (x << 2) | 4; +} + +__attribute__((noinline, noclone)) int +bar (int x) +{ + return (x << 2) | 3; +} + +int +main () +{ + if (foo (43) != 172 || foo (1) != 4 || foo (2) != 12) + abort (); + if (bar (43) != 175 || bar (1) != 7 || bar (2) != 11) + abort (); + return 0; +} Jakub