From patchwork Thu Nov 29 14:42:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Gretton-Dann X-Patchwork-Id: 202760 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 B8D802C0094 for ; Fri, 30 Nov 2012 01:42:31 +1100 (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=1354804953; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=AI1WUuuFVyfO66hqKDkTdfPyU5A=; b=XhIP4tron6ENVgfbTT8ILARXiJJ+wm8/CRPUKlxDkYrH6keOWrO2pPZrj9L74V 4ndTBF1Qoj9dyX3bbYTFsXS3Aw/PaofY31XDHcVCI3n9uTyLiJTzm7KmDEJP7sI5 jwqyvEjTNRI8UkUmg8h+PhkhILGWLwr0jPhya0/ViSe4M= 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:X-Google-DKIM-Signature:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=BpNpV087gOV8gcwrKJZiVfqw17W0O7QVzIT1mexdu6vUJ0uj524pTt8Wp8SgAb xwvlw3YM7M5GxKXya2JYik5aFiysbgYEhvBAPMZA1zYlnML29HYZRS5Sg6mzvEuz StkCJfV8atSxezsOodS7G8F8c2suNbDjGLjYHeYetMUIs=; Received: (qmail 20681 invoked by alias); 29 Nov 2012 14:42:25 -0000 Received: (qmail 20664 invoked by uid 22791); 29 Nov 2012 14:42:23 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Nov 2012 14:42:13 +0000 Received: by mail-la0-f47.google.com with SMTP id u2so11641887lag.20 for ; Thu, 29 Nov 2012 06:42:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=TyxL4mM5/h9RdiwMMNA1iQG/9nwI3NzEr3Ie2uT500c=; b=Jb61SCam5NvL8AGYC+PC45aC/hrek0wOoF7qdv++24TMxfiu9APPCH3I0x9ELeewic oIhjI2Ir0+Gak5/lQ6H9RLEsqqw/FCmhcCbetApVWa3LTy3aZVZpq6rHSt1jse9FoMQu Hkbdj5PQ7+9cPZj9jwlii1YRGLlPm6F+bcdgdc+qGPjl3k0tMpshFNqFmBeKfIIAE6xC 9gfQABGJiClG/4UusoB2MoPqCxMrcF3nLWKNZq5MUorEcG/dl67jTXIINlRWwvc9fqhr jDr7S6SIJ+/aHkZlztzTbDLCt8FqYkh5yIhnsrPe1My974cQige9ByGlcHuVwB+wfHK3 EtUg== MIME-Version: 1.0 Received: by 10.152.103.18 with SMTP id fs18mr21818354lab.32.1354200131556; Thu, 29 Nov 2012 06:42:11 -0800 (PST) Received: by 10.114.17.10 with HTTP; Thu, 29 Nov 2012 06:42:11 -0800 (PST) In-Reply-To: References: <2179328.yVVT7qyyS9@e103209-lin> Date: Thu, 29 Nov 2012 14:42:11 +0000 Message-ID: Subject: Re: [RFA/ARM] Fix PR54974: Thumb literal pools don't handle PC rounding From: Matthew Gretton-Dann To: ramrad01@arm.com Cc: "gcc-patches@gcc.gnu.org" , Richard Earnshaw , doko@canonical.com, Patch Tracking X-Gm-Message-State: ALoCoQmdt4g5T6ScIa/wBbGQ8uTLdoY7RKI0VHQ4KYLx9d4/PaCB1WgpGEI1d5UQ+CMSvJNskrpm X-IsSubscribed: yes 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 24 November 2012 00:27, Ramana Radhakrishnan wrote: > On Wed, Nov 21, 2012 at 7:59 PM, Matthew Gretton-Dann > wrote: [snip] >> The fix is to decrease the pool_range of all insns by 2 when generating >> Thumb code. There is no need to change neg_pool_range values as rounding >> down here will reduce the distance of the literal pool. > > A comment about this fact around thumb2_pool_range would be appropriate. > [snip] >> >> Tested arm-none-linux-gnueabi cross, and with the testcase attached to the >> PR. No added testcase in the patch as this code is sensitive to other code >> generation and so it is not easy to generate a testcase which will reliably >> test this condition. >> >> OK for trunk, 4.7, and 4.6? > > > Ok for trunk today - please wait a few days before backporting into > 4.6 and 4.7 to see what the fallout is like . Watch out for any > fallout with the auto-testers. The attached is what was actually committed as revision 193930 (original patch + requested comment). Thanks, Matt --- Matthew Gretton-Dann Linaro Toolchain Working Group matthew.gretton-dann@linaro.org Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 193929) +++ gcc/ChangeLog (revision 193930) @@ -1,3 +1,33 @@ +2012-11-29 Matthew Gretton-Dann + + PR target/54974 + * config/arm/arm.md (thumb2_pool_range, pool_range): Add comment on + Thumb pool ranges. + (thumb1_extendhisi2): Reduce Thumb pool range. + (arm_movdi): Likewise. + (thumb1_movdi_insn): Likewise. + (thumb1_movsi_insn): Likewise. + (pic_load_addr_unified): Likewise. + (pic_load_addr_32bit): Likewise. + (pic_load_addr_thumb1): Likewise. + (thumb1_movhf): Likewise. + (arm_movsf_soft_insn): Likewise. + (thumb1_movsf_soft_insn): Likewise. + (movdf_soft_insn): Likewise. + (thumb1_movdf_soft_insn): Likewise. + * config/arm/neon.md (*neon_mov): Likewise. + (*neon_mov): Likwise. + * config/arm/thumb2.md: (*thumb2_movsi_insn): Likewise. + (*thumb2_movhi_insn): Likewise. + (*thumb2_extendqisi_v6): Likewise. + (*thumb2_zero_extendqisi_v6): Likewise. + (*thumb2_zero_extendqisi2_v6): Likewise. + * config/arm/vfp.md: (*thumb2_movsi_vfp): Likewise. + (*movdi_vfp): Likewise. + (*movdi_vfp_cortexa8): Likewise. + (*thumb2_movsf_vfp): Likewise. + (*thumb2_movdf_vfp): Likewise. + 2012-11-29 Kai Tietz PR target/55171 Index: gcc/config/arm/thumb2.md =================================================================== --- gcc/config/arm/thumb2.md (revision 193929) +++ gcc/config/arm/thumb2.md (revision 193930) @@ -182,7 +182,7 @@ str%?\\t%1, %0" [(set_attr "type" "*,*,*,*,load1,load1,store1,store1") (set_attr "predicable" "yes") - (set_attr "pool_range" "*,*,*,*,1020,4096,*,*") + (set_attr "pool_range" "*,*,*,*,1018,4094,*,*") (set_attr "neg_pool_range" "*,*,*,*,0,0,*,*")] ) @@ -217,7 +217,7 @@ ldr%(h%)\\t%0, %1\\t%@ movhi" [(set_attr "type" "*,*,store1,load1") (set_attr "predicable" "yes") - (set_attr "pool_range" "*,*,*,4096") + (set_attr "pool_range" "*,*,*,4094") (set_attr "neg_pool_range" "*,*,*,250")] ) @@ -570,7 +570,7 @@ ldr%(sb%)\\t%0, %1" [(set_attr "type" "alu_shift,load_byte") (set_attr "predicable" "yes") - (set_attr "pool_range" "*,4096") + (set_attr "pool_range" "*,4094") (set_attr "neg_pool_range" "*,250")] ) @@ -583,7 +583,7 @@ ldr%(h%)\\t%0, %1" [(set_attr "type" "alu_shift,load_byte") (set_attr "predicable" "yes") - (set_attr "pool_range" "*,4096") + (set_attr "pool_range" "*,4094") (set_attr "neg_pool_range" "*,250")] ) @@ -596,7 +596,7 @@ ldr%(b%)\\t%0, %1\\t%@ zero_extendqisi2" [(set_attr "type" "alu_shift,load_byte") (set_attr "predicable" "yes") - (set_attr "pool_range" "*,4096") + (set_attr "pool_range" "*,4094") (set_attr "neg_pool_range" "*,250")] ) Index: gcc/config/arm/vfp.md =================================================================== --- gcc/config/arm/vfp.md (revision 193929) +++ gcc/config/arm/vfp.md (revision 193930) @@ -123,7 +123,7 @@ (set_attr "type" "*,*,*,*,load1,load1,store1,store1,r_2_f,f_2_r,fcpys,f_loads,f_stores") (set_attr "neon_type" "*,*,*,*,*,*,*,*,neon_mcr,neon_mrc,neon_vmov,*,*") (set_attr "insn" "mov,mov,mvn,mov,*,*,*,*,*,*,*,*,*") - (set_attr "pool_range" "*,*,*,*,1020,4096,*,*,*,*,*,1020,*") + (set_attr "pool_range" "*,*,*,*,1018,4094,*,*,*,*,*,1018,*") (set_attr "neg_pool_range" "*,*,*,*, 0, 0,*,*,*,*,*,1008,*")] ) @@ -176,7 +176,8 @@ (const_int 8) (const_int 4))] (const_int 4))) - (set_attr "pool_range" "*,*,*,*,1020,4096,*,*,*,*,1020,*") + (set_attr "arm_pool_range" "*,*,*,*,1020,4096,*,*,*,*,1020,*") + (set_attr "thumb2_pool_range" "*,*,*,*,1018,4094,*,*,*,*,1018,*") (set_attr "neg_pool_range" "*,*,*,*,1004,0,*,*,*,*,1004,*") (set_attr "arch" "t2,any,any,any,a,t2,any,any,any,any,any,any")] ) @@ -224,7 +225,8 @@ * 4")] (const_int 4))) (set_attr "predicable" "yes") - (set_attr "pool_range" "*,*,*,*,1020,4096,*,*,*,*,1020,*") + (set_attr "arm_pool_range" "*,*,*,*,1018,4094,*,*,*,*,1018,*") + (set_attr "thumb2_pool_range" "*,*,*,*,1018,4094,*,*,*,*,1018,*") (set_attr "neg_pool_range" "*,*,*,*,1004,0,*,*,*,*,1004,*") (set (attr "ce_count") (symbol_ref "get_attr_length (insn) / 4")) @@ -413,7 +415,7 @@ "r_2_f,f_2_r,fconsts,f_loads,f_stores,load1,store1,fcpys,*") (set_attr "neon_type" "neon_mcr,neon_mrc,*,*,*,*,*,neon_vmov,*") (set_attr "insn" "*,*,*,*,*,*,*,*,mov") - (set_attr "pool_range" "*,*,*,1020,*,4092,*,*,*") + (set_attr "pool_range" "*,*,*,1018,*,4090,*,*,*") (set_attr "neg_pool_range" "*,*,*,1008,*,0,*,*,*")] ) @@ -509,7 +511,7 @@ (const_int 8) (const_int 4))] (const_int 4))) - (set_attr "pool_range" "*,*,*,1020,*,4096,*,*,*") + (set_attr "pool_range" "*,*,*,1018,*,4094,*,*,*") (set_attr "neg_pool_range" "*,*,*,1008,*,0,*,*,*")] ) Index: gcc/config/arm/neon.md =================================================================== --- gcc/config/arm/neon.md (revision 193929) +++ gcc/config/arm/neon.md (revision 193930) @@ -196,7 +196,8 @@ (set_attr "type" "*,f_stored,*,f_loadd,*,*,alu,load2,store2") (set_attr "insn" "*,*,*,*,*,*,mov,*,*") (set_attr "length" "4,4,4,4,4,4,8,8,8") - (set_attr "pool_range" "*,*,*,1020,*,*,*,1020,*") + (set_attr "arm_pool_range" "*,*,*,1020,*,*,*,1020,*") + (set_attr "thumb2_pool_range" "*,*,*,1018,*,*,*,1018,*") (set_attr "neg_pool_range" "*,*,*,1004,*,*,*,1004,*")]) (define_insn "*neon_mov" @@ -241,7 +242,8 @@ (set_attr "type" "*,*,*,*,*,*,alu,load4,store4") (set_attr "insn" "*,*,*,*,*,*,mov,*,*") (set_attr "length" "4,8,4,8,8,8,16,8,16") - (set_attr "pool_range" "*,*,*,1020,*,*,*,1020,*") + (set_attr "arm_pool_range" "*,*,*,1020,*,*,*,1020,*") + (set_attr "thumb2_pool_range" "*,*,*,1018,*,*,*,1018,*") (set_attr "neg_pool_range" "*,*,*,996,*,*,*,996,*")]) (define_expand "movti" Index: gcc/config/arm/arm.md =================================================================== --- gcc/config/arm/arm.md (revision 193929) +++ gcc/config/arm/arm.md (revision 193930) @@ -297,6 +297,9 @@ ; POOL_RANGE is how far away from a constant pool entry that this insn ; can be placed. If the distance is zero, then this insn will never ; reference the pool. +; Note that for Thumb constant pools the PC value is rounded down to the +; nearest multiple of four. Therefore, THUMB2_POOL_RANGE (and POOL_RANGE for +; Thumb insns) should be set to - 2. ; NEG_POOL_RANGE is nonzero for insns that can reference a constant pool entry ; before its address. It is set to - (8 + ). (define_attr "arm_pool_range" "" (const_int 0)) @@ -4966,7 +4969,7 @@ (const_int 2) (const_int 4)) (const_int 4)]) (set_attr "type" "alu_shift,load_byte") - (set_attr "pool_range" "*,1020")] + (set_attr "pool_range" "*,1018")] ) ;; This pattern will only be used when ldsh is not available @@ -5373,7 +5376,7 @@ (set_attr "type" "*,*,*,load2,store2") (set_attr "arm_pool_range" "*,*,*,1020,*") (set_attr "arm_neg_pool_range" "*,*,*,1004,*") - (set_attr "thumb2_pool_range" "*,*,*,4096,*") + (set_attr "thumb2_pool_range" "*,*,*,4094,*") (set_attr "thumb2_neg_pool_range" "*,*,*,0,*")] ) @@ -5512,7 +5515,7 @@ [(set_attr "length" "4,4,6,2,2,6,4,4") (set_attr "type" "*,*,*,load2,store2,load2,store2,*") (set_attr "insn" "*,mov,*,*,*,*,*,mov") - (set_attr "pool_range" "*,*,*,*,*,1020,*,*")] + (set_attr "pool_range" "*,*,*,*,*,1018,*,*")] ) (define_expand "movsi" @@ -5682,7 +5685,7 @@ mov\\t%0, %1" [(set_attr "length" "2,2,4,4,2,2,2,2,2") (set_attr "type" "*,*,*,*,load1,store1,load1,store1,*") - (set_attr "pool_range" "*,*,*,*,*,*,1020,*,*") + (set_attr "pool_range" "*,*,*,*,*,*,1018,*,*") (set_attr "conds" "set,clob,*,*,nocond,nocond,nocond,nocond,nocond")]) (define_split @@ -5790,7 +5793,7 @@ (match_dup 2)] UNSPEC_PIC_BASE))] "operands[3] = TARGET_THUMB ? GEN_INT (4) : GEN_INT (8);" [(set_attr "type" "load1,load1,load1") - (set_attr "pool_range" "4096,4096,1024") + (set_attr "pool_range" "4096,4094,1022") (set_attr "neg_pool_range" "4084,0,0") (set_attr "arch" "a,t2,t1") (set_attr "length" "8,6,4")] @@ -5806,7 +5809,10 @@ "TARGET_32BIT && flag_pic" "ldr%?\\t%0, %1" [(set_attr "type" "load1") - (set_attr "pool_range" "4096") + (set (attr "pool_range") + (if_then_else (eq_attr "is_thumb" "no") + (const_int 4096) + (const_int 4094))) (set (attr "neg_pool_range") (if_then_else (eq_attr "is_thumb" "no") (const_int 4084) @@ -5819,7 +5825,7 @@ "TARGET_THUMB1 && flag_pic" "ldr\\t%0, %1" [(set_attr "type" "load1") - (set (attr "pool_range") (const_int 1024))] + (set (attr "pool_range") (const_int 1018))] ) (define_insn "pic_add_dot_plus_four" @@ -6614,7 +6620,7 @@ [(set_attr "length" "2") (set_attr "type" "*,load1,store1,*,*") (set_attr "insn" "mov,*,*,mov,mov") - (set_attr "pool_range" "*,1020,*,*,*") + (set_attr "pool_range" "*,1018,*,*,*") (set_attr "conds" "clob,nocond,nocond,nocond,nocond")]) (define_expand "movsf" @@ -6669,7 +6675,8 @@ [(set_attr "predicable" "yes") (set_attr "type" "*,load1,store1") (set_attr "insn" "mov,*,*") - (set_attr "pool_range" "*,4096,*") + (set_attr "arm_pool_range" "*,4096,*") + (set_attr "thumb2_pool_range" "*,4094,*") (set_attr "arm_neg_pool_range" "*,4084,*") (set_attr "thumb2_neg_pool_range" "*,0,*")] ) @@ -6691,7 +6698,7 @@ mov\\t%0, %1" [(set_attr "length" "2") (set_attr "type" "*,load1,store1,load1,store1,*,*") - (set_attr "pool_range" "*,*,*,1020,*,*,*") + (set_attr "pool_range" "*,*,*,1018,*,*,*") (set_attr "insn" "*,*,*,*,*,mov,mov") (set_attr "conds" "clob,nocond,nocond,nocond,nocond,nocond,nocond")] ) @@ -6780,7 +6787,8 @@ " [(set_attr "length" "8,12,16,8,8") (set_attr "type" "*,*,*,load2,store2") - (set_attr "pool_range" "*,*,*,1020,*") + (set_attr "arm_pool_range" "*,*,*,1020,*") + (set_attr "thumb2_pool_range" "*,*,*,1018,*") (set_attr "arm_neg_pool_range" "*,*,*,1004,*") (set_attr "thumb2_neg_pool_range" "*,*,*,0,*")] ) @@ -6824,7 +6832,7 @@ [(set_attr "length" "4,2,2,6,4,4") (set_attr "type" "*,load2,store2,load2,store2,*") (set_attr "insn" "*,*,*,*,*,mov") - (set_attr "pool_range" "*,*,*,1020,*,*")] + (set_attr "pool_range" "*,*,*,1018,*,*")] )