From patchwork Thu Jun 24 03:47:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 56741 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 5A371B6F18 for ; Thu, 24 Jun 2010 13:47:36 +1000 (EST) Received: (qmail 30362 invoked by alias); 24 Jun 2010 03:47:34 -0000 Received: (qmail 30354 invoked by uid 22791); 24 Jun 2010 03:47:33 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS 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; Thu, 24 Jun 2010 03:47:29 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5O3lQk3002173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Jun 2010 23:47:27 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5O3lONJ003640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Jun 2010 23:47:26 -0400 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by localhost.localdomain (8.14.4/8.14.3) with ESMTP id o5O3lOpC027649 for ; Thu, 24 Jun 2010 00:47:24 -0300 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o5O3lMFw000397; Thu, 24 Jun 2010 00:47:23 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id o5O3lMtk000395; Thu, 24 Jun 2010 00:47:22 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PR44610] don't delegitimize MEM from base without offset Date: Thu, 24 Jun 2010 00:47:21 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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 Interesting bug... All words of a multi-word variable ended up mapped to the same VALUE during cselib in var-tracking, and then their location was set to the same REG, that held only the first word. Problem was that we were initializing the variable within a loop, from an array element that lived in memory and varied per iteration of the loop. This means the MEM_OFFSETs couldn't be set: they weren't constant. Turns out that some recently-added code that attempted to simplify MEMs to something more palatable than complex expressions involving frame, stack or GOT pointers, mistook the absence of an offset for a zero offset. So, because of this delegitimization, each of the words loaded into part of the variable was regarded by cselib as a MEM referencing the first word of the array. Oops. This patch prevents the delegitimization when the offset is unknown, so that we don't get bogus equivalences. Regstrapped on x86_64-linux-gnu, i686-linux-gnu and ia64-linux-gnu. Ok for trunk? for gcc/ChangeLog from Alexandre Oliva PR debug/44610 * simplify-rtx.c (delegitimize_mem_from_attrs): Don't use a base address if the offset is unknown. Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c.orig 2010-06-23 01:15:14.000000000 -0300 +++ gcc/simplify-rtx.c 2010-06-23 01:20:21.000000000 -0300 @@ -208,10 +208,11 @@ avoid_constant_pool_reference (rtx x) rtx delegitimize_mem_from_attrs (rtx x) { + /* MEMs without MEM_OFFSETs may have been offset, so we can't just + use their base addresses as equivalent. */ if (MEM_P (x) && MEM_EXPR (x) - && (!MEM_OFFSET (x) - || GET_CODE (MEM_OFFSET (x)) == CONST_INT)) + && MEM_OFFSET (x)) { tree decl = MEM_EXPR (x); enum machine_mode mode = GET_MODE (x); @@ -264,8 +265,7 @@ delegitimize_mem_from_attrs (rtx x) { rtx newx; - if (MEM_OFFSET (x)) - offset += INTVAL (MEM_OFFSET (x)); + offset += INTVAL (MEM_OFFSET (x)); newx = DECL_RTL (decl);