From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29889 invoked by alias); 16 Nov 2009 20:06:39 -0000 Received: (qmail 29878 invoked by uid 22791); 16 Nov 2009 20:06:38 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.17.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Nov 2009 20:05:30 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.1/8.13.1) with ESMTP id nAGK5Skr023852 for ; Mon, 16 Nov 2009 20:05:28 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nAGK5RFW1220754 for ; Mon, 16 Nov 2009 21:05:27 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id nAGK5R8G031031 for ; Mon, 16 Nov 2009 21:05:27 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmakerneu.boeblingen.de.ibm.com [9.152.84.202]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id nAGK5QrA031019; Mon, 16 Nov 2009 21:05:26 +0100 Message-Id: <200911162005.nAGK5QrA031019@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Mon, 16 Nov 2009 21:05:26 +0100 Subject: [patch] Fix regression (Re: Fix PR tree-optimization/41857) To: gcc-patches@gcc.gnu.org Date: Mon, 16 Nov 2009 20:07:00 -0000 From: "Ulrich Weigand" Cc: richard.guenther@gmail.com (Richard Guenther), rakdver@kam.mff.cuni.cz (Zdenek Dvorak) In-Reply-To: <20091102093837.GA21250@kam.mff.cuni.cz> from "Zdenek Dvorak" at Nov 02, 2009 10:38:37 AM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2009-11/txt/msg00806.txt.bz2 Hello, the fix to PR 41857 unfortunately introduced a regression. The move_hint_to_base routine now casts the base register to a pointer type whose target type is the type of the final memory reference. However, this may cause alignment issues. When the base register is gimplified, a DECL_RTL is allocated for its value by the routine expand_one_register_var. The resulting register RTX will be marked as pointer that is aligned to its target type alignment: if (POINTER_TYPE_P (type)) mark_reg_pointer (x, TYPE_ALIGN (TREE_TYPE (type))); This is usually correct. However, in this particular case, the IV optimizations only guarantee that the *full* memory address is properly aligned; a single component like the base may by itself be *not* aligned. This means the register RTX may be marked with an incorrect alignment. As the SPU back-end relies on the REGNO_POINTER_ALIGN information for correct code generation, this can cause broken output. To fix this, while still keeping the fix for 41857 in place, the patch below changes move_hint_to_base to cast the base to a void pointer (using the appropriate address space), instead of a pointer to the target type. Tested on s390-ibm-linux and spu-elf with no regressions. OK for mainline? Bye, Ulrich ChangeLog: PR tree-optimization/41857 * tree-ssa-address.c (move_hint_to_base): Use void pointer to TYPE's address space instead of pointer to TYPE. Index: gcc/tree-ssa-address.c =================================================================== *** gcc/tree-ssa-address.c (revision 154075) --- gcc/tree-ssa-address.c (working copy) *************** move_hint_to_base (tree type, struct mem *** 400,405 **** --- 400,406 ---- { unsigned i; tree val = NULL_TREE; + int qual; for (i = 0; i < addr->n; i++) { *************** move_hint_to_base (tree type, struct mem *** 414,420 **** if (i == addr->n) return; ! /* Cast value to appropriate pointer type. */ parts->base = fold_convert (build_pointer_type (type), val); aff_combination_remove_elt (addr, i); } --- 415,426 ---- if (i == addr->n) return; ! /* Cast value to appropriate pointer type. We cannot use a pointer ! to TYPE directly, as the back-end will assume registers of pointer ! type are aligned, and just the base itself may not actually be. ! We use void pointer to the type's address space instead. */ ! qual = ENCODE_QUAL_ADDR_SPACE (TYPE_ADDR_SPACE (type)); ! type = build_qualified_type (void_type_node, qual); parts->base = fold_convert (build_pointer_type (type), val); aff_combination_remove_elt (addr, i); } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com