From patchwork Mon Nov 17 16:06:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 411712 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 73EDE14017D for ; Tue, 18 Nov 2014 03:07:09 +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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=T8GUrxg+MMzS0mT6t7HYBlYT8mam+qruRQVQspUpsFNREzoT1g TFTzszznewA1nu5PbYbZkK1Om5ZvIPmmhLDWiPWgdqHGtd0VpmIXGOmD7Pzk9i5F iLBTkELYxj+crW1uz8BJO23b3ABAwq3+dGteJbCtnvPBWKZmg1V8bgslA= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=lM6GrzQlme2KBSpBtNc9TiAdaGg=; b=n+MSRI2rgerqoqV607mn Fng2M4my6zHotbeT5BbgLK5PJ4hSgEQjeaAx3/VOVmckT7dGybQNJrNDDvGjT5wx 4IqJpRGmzE6wm8lLsvdG7A29aYjg9Ck3cCTose1Jn8/FDBdRpHkfLqhDSDFF/pIU CfzWvfQQArvef0yXhOm/Imk= Received: (qmail 18995 invoked by alias); 17 Nov 2014 16:07:01 -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 18971 invoked by uid 89); 17 Nov 2014 16:06:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Nov 2014 16:06:56 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XqOpI-0003WZ-Bh from Maciej_Rozycki@mentor.com ; Mon, 17 Nov 2014 08:06:52 -0800 Received: from localhost (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 17 Nov 2014 16:06:50 +0000 Date: Mon, 17 Nov 2014 16:06:47 +0000 From: "Maciej W. Rozycki" To: CC: Catherine Moore , Eric Christopher , Matthew Fortune Subject: [PATCH] MIPS/GCC: Unconditional jump generation bug fix Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Hi, This was lost in the original microMIPS submission. For absolute microMIPS jumps GCC always produces a branch instruction, causing a `relocation truncated to fit: R_MICROMIPS_PC16_S1' linker error if the branch target turns out of range. The TARGET_ABICALLS_PIC2 macro is never set in absolute code. This is the only RTL pattern that we have that does not handle this case correctly, all the other ones set the type of the pattern to "branch" and rely on instruction length calculation to see if branch relaxation would trigger on not. If so, then they produce an appropriate jump instruction. So do it here as well; this affects the standard mode too (branches are now always produced whenever in range), but IMHO in a good or at least neutral way. Regression-tested with the mips-linux-gnu target and these multilibs: -EB -EB -mips16 -EB -mmicromips -EB -mabi=n32 -EB -mabi=64 and the -EL variants of same, fixing these failures: g++.dg/opt/longbranch1.C -std=gnu++11 (test for excess errors) g++.dg/opt/longbranch1.C -std=gnu++14 (test for excess errors) g++.dg/opt/longbranch1.C -std=gnu++98 (test for excess errors) across microMIPS multilibs, e.g.: FAIL: g++.dg/opt/longbranch1.C -std=gnu++11 (test for excess errors) Excess errors: longbranch1.C:(.text+0x15092): relocation truncated to fit: R_MICROMIPS_PC16_S1 against `$L2' No other changes in test results. OK to apply? 2014-11-17 Maciej W. Rozycki gcc/ * gcc/config/mips/mips.md (*jump_absolute): Use a branch when in range, a jump otherwise. Maciej gcc-mips-jump-branch.diff Index: gcc-fsf-trunk-quilt/gcc/config/mips/mips.md =================================================================== --- gcc-fsf-trunk-quilt.orig/gcc/config/mips/mips.md 2014-11-16 19:54:17.000000000 +0000 +++ gcc-fsf-trunk-quilt/gcc/config/mips/mips.md 2014-11-17 04:44:32.847732003 +0000 @@ -5957,14 +5957,12 @@ (label_ref (match_operand 0)))] "!TARGET_MIPS16 && TARGET_ABSOLUTE_JUMPS" { - /* Use a branch for microMIPS. The assembler will choose - a 16-bit branch, a 32-bit branch, or a 32-bit jump. */ - if (TARGET_MICROMIPS && !TARGET_ABICALLS_PIC2) + if (get_attr_length (insn) <= 8) return "%*b\t%l0%/"; else return MIPS_ABSOLUTE_JUMP ("%*j\t%l0%/"); } - [(set_attr "type" "jump")]) + [(set_attr "type" "branch")]) (define_insn "*jump_pic" [(set (pc)