From patchwork Wed Feb 4 10:32:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 436233 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6CB76140218 for ; Wed, 4 Feb 2015 21:37:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; q=dns; s= default; b=EqXdwGStd9T7DUdh5USxTu298HWQeP5O8SkhDb/bGpzsdjxyW74gG nlj55mGgzyU9C5UGiRfQHS1tOnGVghM0q+0PCZi14D4uqd2JmOlhOAsT3cF4NZ/G 7oK8WuAO0oBcuErIk1zOkyBsD0CW3nLG9HmesiBW/3vnODWRXL/QQc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=default; bh=gGLD1htmxnOamKj+CL+IWAU/x90=; b=Vw/QcSW/u3Wv1JgJ6kGXmfg0uU39 umm7Ui4aUI1FRnRjujLl8l7YL4G5WEzMwKsBXcM2iy3TNhQ8qqwWGLtGjNRLoHgE WfpMoH011NO/auRPOkwJrzx8EPfKAWzgYGjArfQee54oUxj8aUKB429P5hVasu1K xt2wDhf/LJ4xjy0= Received: (qmail 19097 invoked by alias); 4 Feb 2015 10:35:36 -0000 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 Received: (qmail 19029 invoked by uid 89); 4 Feb 2015 10:35:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 Feb 2015 10:35:34 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id AD9482C80E68; Wed, 4 Feb 2015 11:35:31 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zfvdr4EQCj18; Wed, 4 Feb 2015 11:35:31 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 8A6432C80E5F; Wed, 4 Feb 2015 11:35:31 +0100 (CET) From: Eric Botcazou To: Zhenqiang Chen Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH, ivopt] Try aligned offset when get_address_cost Date: Wed, 04 Feb 2015 11:32:54 +0100 Message-ID: <3153506.iERQeH6ODR@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) In-Reply-To: <000001cfafad$5de00840$19a018c0$@arm.com> References: <000001cfafad$5de00840$19a018c0$@arm.com> MIME-Version: 1.0 > For some TARGET, like ARM THUMB1, the offset in load/store should be nature > aligned. But in function get_address_cost, when computing max_offset, it > only tries byte-aligned offsets: > > ((unsigned HOST_WIDE_INT) 1 << i) - 1 > > which can not meet thumb_legitimate_offset_p check called from > thumb1_legitimate_address_p for HImode and SImode. > > The patch adds additional try for aligned offset: > > ((unsigned HOST_WIDE_INT) 1 << i) - GET_MODE_SIZE (address_mode). I think that the change is not fully correct, this must be mem_mode instead of address_mode since the alignment of the MEM is given by mem_mode: This fixes unexpected differences in the result of the function between SPARC and SPARC64 for the same source code. OK for mainline after testing? * tree-ssa-loop-ivopts.c (get_address_cost): Use proper mode for offset. Index: tree-ssa-loop-ivopts.c =================================================================== --- tree-ssa-loop-ivopts.c (revision 220343) +++ tree-ssa-loop-ivopts.c (working copy) @@ -3324,12 +3324,12 @@ get_address_cost (bool symbol_present, b XEXP (addr, 1) = gen_int_mode (off, address_mode); if (memory_address_addr_space_p (mem_mode, addr, as)) break; - /* For some TARGET, like ARM THUMB1, the offset should be nature - aligned. Try an aligned offset if address_mode is not QImode. */ - off = (address_mode == QImode) + /* For some strict-alignment targets, the offset must be naturally + aligned. Try an aligned offset if mem_mode is not QImode. */ + off = mem_mode == QImode ? 0 : ((unsigned HOST_WIDE_INT) 1 << i) - - GET_MODE_SIZE (address_mode); + - GET_MODE_SIZE (mem_mode); if (off > 0) { XEXP (addr, 1) = gen_int_mode (off, address_mode);