From patchwork Tue Jul 24 11:31:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 172839 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 EE2AF2C007F for ; Tue, 24 Jul 2012 21:32:16 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343734337; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=G7rNhxq yTi1fLWNn2aKPaCh5M+M=; b=F9fCLYYv2xStv8+qU0BPtcH9zkzK/I5V9DUPtqA YM/vTvHffp/358aUmxJpWzJBQoby0v5N0iRdTQHxrRl+X7bq1m7J5LptjGIokWrN 4fopzPLISc/jWOB1fAGh6Igdkz04d6CtMpTthvqn5jybhBagOmQyPnggrG0xjCRT jpOo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=muDIC8Os6McerOkn6zYfwdpskg2NAZ9YgwN2FD9pTmLRZ45M9/rRuUWFjRITwM xrW0wnliHqngvHMV5aYOerwoo0UVrjBY0rPSTMBxOJxZ7ORSoIcEMoAF+rlStvgr L2RMu0VmqtyOf8z9C6O7dZ44tByvoFJxjMRv6/TgYMf7E=; Received: (qmail 18359 invoked by alias); 24 Jul 2012 11:32:13 -0000 Received: (qmail 18349 invoked by uid 22791); 24 Jul 2012 11:32:12 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_XF, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 11:31:59 +0000 Received: by pbbrq2 with SMTP id rq2so12635528pbb.20 for ; Tue, 24 Jul 2012 04:31:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.232.170 with SMTP id tp10mr44432232pbc.59.1343129519148; Tue, 24 Jul 2012 04:31:59 -0700 (PDT) Received: by 10.66.11.130 with HTTP; Tue, 24 Jul 2012 04:31:59 -0700 (PDT) Date: Tue, 24 Jul 2012 13:31:59 +0200 Message-ID: Subject: [PATCH, i386]: Reject invalid constant addresses from ix86_decompose_address From: Uros Bizjak To: gcc-patches@gcc.gnu.org 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 Hello! 2012-07-24 Uros Bizjak PR target/53961 * config/i386/i386.c (ix86_legitimate_address_p): Move check for negative constant address for TARET_X32 ... (ix86_decompose_address): ... here. Reject constant addresses that don't satisfy x86_64_immediate_operand predicate. Tested on x86_64-unknown-linux-gnu {,-m32} + various x32 testcases. Committed to mainline SVN. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 189801) +++ config/i386/i386.c (working copy) @@ -11733,6 +11733,19 @@ ix86_decompose_address (rtx addr, struct ix86_addr scale = 1 << scale; retval = -1; } + else if (CONST_INT_P (addr)) + { + if (!x86_64_immediate_operand (addr, VOIDmode)) + return 0; + + /* Constant addresses are sign extended to 64bit, we have to + prevent addresses from 0x80000000 to 0xffffffff in x32 mode. */ + if (TARGET_X32 + && val_signbit_known_set_p (SImode, INTVAL (addr))) + return 0; + + disp = addr; + } else disp = addr; /* displacement */ @@ -12242,13 +12255,6 @@ ix86_legitimate_address_p (enum machine_mode mode rtx base, index, disp; HOST_WIDE_INT scale; - /* Since constant address in x32 is signed extended to 64bit, - we have to prevent addresses from 0x80000000 to 0xffffffff. */ - if (TARGET_X32 - && CONST_INT_P (addr) - && INTVAL (addr) < 0) - return false; - if (ix86_decompose_address (addr, &parts) <= 0) /* Decomposition failed. */ return false;