From patchwork Fri Aug 10 01:11:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 176305 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 BC9A42C007B for ; Fri, 10 Aug 2012 11:12:52 +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=1345165974; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Message-ID:Subject:From:To: Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=KRf6ZwyN03wJ+vPAARhe Dvris8U=; b=HEmDcaygyECKc48POkwq0ZwPemsS4fC9G9CQyAZlAO0gKPNxi4by OOtO/vUrHWY2SmiosYNWOb/krIjjjxFnRCFIX5MJEZYbIakr455TZ66HO1v4dFLk nwWBuERMKFtk3uTc/Fo8zde/aciXnjtGMsUlHp7RGFbPUGLOx0ZbrWM= 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:Received:Received:Received:Received:Received:Message-ID:Subject:From:To:Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version:X-Content-Scanned:x-cbid:X-IBM-ISS-SpamDetectors:X-IBM-ISS-DetailInfo:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=WZvNnqnsjgJSttkFtmeCS8AfYmJHHpWCro1IiE4//Zz/r4KWifUS6FJWbqgN2u fo86rQhOGv8dS3Lk7PLjAMVXZwi3f2fwg0+kel20qOVXCSMb/IDC1uFSI+Ihv8f1 VkempIoqYkEnECbiW3EPwiXLC41/g2VlY/ccecPxs46ZQ=; Received: (qmail 15118 invoked by alias); 10 Aug 2012 01:12:48 -0000 Received: (qmail 15105 invoked by uid 22791); 10 Aug 2012 01:12:46 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e34.co.us.ibm.com (HELO e34.co.us.ibm.com) (32.97.110.152) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Aug 2012 01:12:31 +0000 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Aug 2012 19:12:30 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Aug 2012 19:12:24 -0600 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id BAD1219D8040 for ; Fri, 10 Aug 2012 01:12:07 +0000 (WET) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7A1BglE081724 for ; Thu, 9 Aug 2012 19:11:57 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7A1BNnT032415 for ; Thu, 9 Aug 2012 19:11:23 -0600 Received: from [9.65.197.21] (sig-9-65-197-21.mts.ibm.com [9.65.197.21]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7A1BMr5032324; Thu, 9 Aug 2012 19:11:23 -0600 Message-ID: <1344561084.18792.11.camel@gnopaine> Subject: [PATCH] Fix PR54211 From: "William J. Schmidt" To: gcc-patches@gcc.gnu.org Cc: bergner@vnet.ibm.com, rguenther@suse.de Date: Thu, 09 Aug 2012 20:11:24 -0500 Mime-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12081001-1780-0000-0000-00000834985C X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000290; HX=3.00000194; KW=3.00000007; PH=3.00000001; SC=3.00000006; SDB=6.00163988; UDB=6.00037105; UTC=2012-08-10 01:12:28 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 Fix a thinko in strength reduction. I was checking the type of the wrong operand to determine whether address arithmetic should be used in replacing expressions. This produced a spurious POINTER_PLUS_EXPR when an address was converted to an unsigned long and back again. Bootstrapped and tested on powerpc64-unknown-linux-gnu with no new regressions. Ok for trunk? Thanks, Bill gcc: 2012-08-09 Bill Schmidt PR middle-end/54211 * gimple-ssa-strength-reduction.c (analyze_candidates_and_replace): Use cand_type to determine whether pointer arithmetic will be generated. gcc/testsuite: 2012-08-09 Bill Schmidt PR middle-end/54211 * gcc.dg/tree-ssa/pr54211.c: New test. Index: gcc/testsuite/gcc.dg/tree-ssa/pr54211.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pr54211.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/pr54211.c (revision 0) @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +int a, b; +unsigned char e; +void fn1 () +{ + unsigned char *c=0; + for (;; a++) + { + unsigned char d = *(c + b); + for (; &e<&d; c++) + goto Found_Top; + } +Found_Top: + if (0) + goto Empty_Bitmap; + for (;; a++) + { + unsigned char *e = c + b; + for (; c < e; c++) + goto Found_Bottom; + c -= b; + } +Found_Bottom: +Empty_Bitmap: + ; +} Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 190260) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -2534,7 +2534,7 @@ analyze_candidates_and_replace (void) /* Determine whether we'll be generating pointer arithmetic when replacing candidates. */ address_arithmetic_p = (c->kind == CAND_ADD - && POINTER_TYPE_P (TREE_TYPE (c->base_expr))); + && POINTER_TYPE_P (c->cand_type)); /* If all candidates have already been replaced under other interpretations, nothing remains to be done. */