From patchwork Wed Sep 19 16:13:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 185103 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 822C42C00A7 for ; Thu, 20 Sep 2012 02:14:49 +1000 (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=1348676090; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:Date:To:Subject:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-ID:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=Jl5wkfuCiClDUXAGP3Pn03n1N3k=; b=ggkWKI0wTOGslhWCaqppfEAR38Ml4sfJ63i3pzts1+nVbDYWEpIeYtE38uRPdz bCTmOkf3iytQ18bCtukwfmZcNNLy3bl/tsJ4t6NdsAt8J/JSxVBXsyazLEUgY52y 2tJQbT3GDXFLbruT0mNIPUeY9nN9vzEuJsOZfzYvP5HG0= 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-M-MSG:Received:Received:Received:From:Date:To:Subject:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID:X-EMS-Proccessed:X-EMS-STAMP:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=yWsYrpiaywHsO86htGUjXW4qUdfo3YPxVGSODoyKUwDwskKVRiw3dsx8ANWE6v Vwo8HXEF2CRwYg8m33cLCZMw3iOuH7NxlOMWlp21XRTX+tz2J+h/o7Qg8g3oMmI0 RRbSafODscX1MRpHdWsYBJ/ADTnchqr6R8dAc6XzEbNeI=; Received: (qmail 13440 invoked by alias); 19 Sep 2012 16:14:44 -0000 Received: (qmail 13425 invoked by uid 22791); 19 Sep 2012 16:14:43 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from dns1.mips.com (HELO dns1.mips.com) (12.201.5.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Sep 2012 16:14:26 +0000 Received: from mailgate1.mips.com (mailgate1.mips.com [12.201.5.111]) by dns1.mips.com (8.13.8/8.13.8) with ESMTP id q8JGEPsD008440 for ; Wed, 19 Sep 2012 09:14:25 -0700 X-M-MSG: Received: from exchdb01.mips.com (unknown [192.168.36.84]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mailgate1.mips.com (Postfix) with ESMTP id 245D4364653 for ; Wed, 19 Sep 2012 09:13:45 -0700 (PDT) Received: from ubuntu-sellcey.mips.com (192.168.65.53) by exchhub01.mips.com (192.168.36.84) with Microsoft SMTP Server id 14.1.270.1; Wed, 19 Sep 2012 09:13:42 -0700 Received: by ubuntu-sellcey.mips.com (sSMTP sendmail emulation); Wed, 19 Sep 2012 09:13:43 -0700 From: "Steve Ellcey " Date: Wed, 19 Sep 2012 09:13:43 -0700 To: Subject: [patch, mips] Fix for PR 54619, GCC aborting with -O -mips16 User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Message-ID: <6db5176b-8592-4c9e-b43b-4fe183d7995b@EXCHHUB01.MIPS.com> X-EMS-Proccessed: 6LP3oGfGVdcdb8o1aBnt6w== X-EMS-STAMP: Qjnx7GDY2MWPp+zPTgOq9Q== 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 While building newlib with -O2 -mips16 I ran into a problem with GCC aborting due to the compiler trying to execute '0 % 0' in mips16_unextended_reference_p. The problem was that the code checked for BLKmode and skipped the modulo operation in that case because GET_MODE_SIZE (BLKmode) is zero but it didn't check for VOIDmode whose size is also zero. Rather then add a check for VOIDmode I changed the check to 'GET_MODE_SIZE (mode) != 0'. While looking at the code I also noticed that if offset was zero then we should return true even if mode is BLKmode or VOIDmode. Returning false would not generate bad code or cause problems but returning true would result in better costing model in mips_address_insns so I made that change too. Tested on a mips elf target, OK to checkin? Steve Ellcey sellcey@mips.com 2012-09-19 Steve Ellcey PR target/54619 * config/mips/mips.c (mips16_unextended_reference_p): Check for zero offset and zero size mode. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 7f9df4c..ecdb811 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -2230,7 +2230,10 @@ static bool mips16_unextended_reference_p (enum machine_mode mode, rtx base, unsigned HOST_WIDE_INT offset) { - if (mode != BLKmode && offset % GET_MODE_SIZE (mode) == 0) + if (offset == 0) + return true; + + if (GET_MODE_SIZE (mode) != 0 && offset % GET_MODE_SIZE (mode) == 0) { if (GET_MODE_SIZE (mode) == 4 && base == stack_pointer_rtx) return offset < 256U * GET_MODE_SIZE (mode);