From patchwork Sat Aug 7 17:54:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 61187 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 EA8DCB6EEF for ; Sun, 8 Aug 2010 03:54:24 +1000 (EST) Received: (qmail 22884 invoked by alias); 7 Aug 2010 17:54:23 -0000 Received: (qmail 22875 invoked by uid 22791); 7 Aug 2010 17:54:22 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-fx0-f47.google.com (HELO mail-fx0-f47.google.com) (209.85.161.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 07 Aug 2010 17:54:18 +0000 Received: by fxm12 with SMTP id 12so4973117fxm.20 for ; Sat, 07 Aug 2010 10:54:15 -0700 (PDT) Received: by 10.223.104.134 with SMTP id p6mr14562302fao.10.1281203655715; Sat, 07 Aug 2010 10:54:15 -0700 (PDT) Received: from [93.103.18.160] (93-103-18-160.static.t-2.net [93.103.18.160]) by mx.google.com with ESMTPS id r5sm1113133faq.32.2010.08.07.10.54.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 07 Aug 2010 10:54:14 -0700 (PDT) Subject: Re: PATCH: PR target/45213: "suffix or operands invalid for `push'" triggered by optimisations on x86_64 From: Uros Bizjak To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org In-Reply-To: References: Date: Sat, 07 Aug 2010 19:54:13 +0200 Message-ID: <1281203653.883.2.camel@localhost> Mime-Version: 1.0 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 On Sat, 2010-08-07 at 08:52 -0700, H.J. Lu wrote: > On Sat, Aug 7, 2010 at 3:45 AM, Uros Bizjak wrote: > > On Sat, Aug 7, 2010 at 12:11 PM, Uros Bizjak wrote: > > > >>> "pushq $imm32S" only takes 32bit signed extended immediate. You can't push > >>> 0xbf800000. Instead, you push -1082130432 or 0xffffffffbf800000. This > >>> patch makes it signed. OK for trunk/4.5/4.4? > >> > >> No, see the comment in real.h: > >> > >> /* IN is a REAL_VALUE_TYPE. OUT is a long. */ > >> #define REAL_VALUE_TO_TARGET_SINGLE(IN, OUT) \ > >> ((OUT) = real_to_target (NULL, &(IN), mode_for_size (32, MODE_FLOAT, 0))) > > > > IMO, this is correct patch, to also generate correct extension on ILP32 hosts. > > > > Index: i386.c > > =================================================================== > > --- i386.c (revision 162975) > > +++ i386.c (working copy) > > @@ -12921,7 +12921,7 @@ > > > > if (ASSEMBLER_DIALECT == ASM_ATT) > > putc ('$', file); > > - fprintf (file, "0x%08lx", (long unsigned int) l); > > + fprintf (file, "0x%08llx", (unsigned long long) (int) l); > > } > > > > /* These float cases don't actually occur as immediate operands. */ > > > > SF is 4 bytes, the same as SI. pushq takes 32bit signed extended immediate. > It is safe for pushq since the upper 4 bytes, which are all 1s, are unused. > For everything else, we use 32bit unsigned int. We don't want > > movl $0xffffffffbf800000, (%rsp) > > How does this patch look? Based on your patch, I think this is what we want: Uros. Index: i386.c =================================================================== --- i386.c (revision 162975) +++ i386.c (working copy) @@ -12921,7 +12921,11 @@ if (ASSEMBLER_DIALECT == ASM_ATT) putc ('$', file); - fprintf (file, "0x%08lx", (long unsigned int) l); + /* For 64bit ABI sign extend 32bit immediate to 8 bytes. */ + if (code == 'q') + fprintf (file, "0x%08llx", (unsigned long long) (int) l); + else + fprintf (file, "0x%08x", (unsigned int) l); } /* These float cases don't actually occur as immediate operands. */