From patchwork Mon Sep 24 20:38:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 186560 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 19DF92C0085 for ; Tue, 25 Sep 2012 06:38:53 +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=1349123934; h=Comment: DomainKey-Signature: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=BoLurvaGi2BRl/vQjFUowcZWwdU=; b=PjOOkCz2pSFWC3L5Izu+2x2u2Tc4p4DMLtcKxZ0UJK4c22Q7Do/7fx+xoPXAux J8aF/QtHceWzq8J1+c6mJ1v5mp5YU5kp99mvNxY12SkwYUs/N1B7ZF6lHZCsIwL/ xFhAGtPoP+y6HmbbbtVyLZZGQPvNWwtcpZv/4T4TbKwAY= 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:Message-ID:Subject:From:To:Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version:x-cbid:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lKozqTjOnGmefDQIZCoMyZvdza5IJN5vHxMonCpOZt6q5h/HO0LOKUrvDKkpDE 3tm2NB2OHi2cahun4PRNdkpssOI9jZO68GHYzbL3rikpIYTH++F1WyrNTt3mHOdZ b6IxzRtiqBI2eeXeq+Qf0FmLk0ROa7LFzfesXzZgEza5g=; Received: (qmail 5940 invoked by alias); 24 Sep 2012 20:38:48 -0000 Received: (qmail 5927 invoked by uid 22791); 24 Sep 2012 20:38:47 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e9.ny.us.ibm.com (HELO e9.ny.us.ibm.com) (32.97.182.139) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Sep 2012 20:38:33 +0000 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Sep 2012 16:38:32 -0400 Received: from d01relay05.pok.ibm.com (9.56.227.237) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 24 Sep 2012 16:38:30 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8OKcTbU163952 for ; Mon, 24 Sep 2012 16:38:29 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8OKcTIZ018480 for ; Mon, 24 Sep 2012 17:38:29 -0300 Received: from [9.76.14.114] (sig-9-76-14-114.mts.ibm.com [9.76.14.114]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q8OKcSdI018439; Mon, 24 Sep 2012 17:38:29 -0300 Message-ID: <1348519113.27229.34.camel@gnopaine> Subject: [PATCH] Fix PR54674 From: "William J. Schmidt" To: gcc-patches@gcc.gnu.org Cc: bergner@vnet.ibm.com, rguenther@suse.de Date: Mon, 24 Sep 2012 15:38:33 -0500 Mime-Version: 1.0 x-cbid: 12092420-7182-0000-0000-000002AF255E 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 In cases where pointers and ints are cast back and forth, SLSR can be tricked into introducing a multiply where one of the operands is of pointer type. Don't do that! Verified that the reduced test case in the PR is fixed with a cross-compile to sh4-unknown-linux-gnu with -Os, which is the only known situation where the replacement looks profitable. (It appears multiply costs are underestimated.) Bootstrapped and tested on powerpc64-unknown-linux-gnu with no new regressions. Ok for trunk? Thanks, Bill 2012-09-24 Bill Schmidt * gimple-ssa-strength-reduction.c (analyze_increments): Don't introduce a multiplication with a pointer operand. Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 191665) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -2028,6 +2028,15 @@ analyze_increments (slsr_cand_t first_dep, enum ma incr_vec[i].cost = COST_INFINITE; + /* If we need to add an initializer, make sure we don't introduce + a multiply by a pointer type, which can happen in certain cast + scenarios. */ + else if (!incr_vec[i].initializer + && TREE_CODE (first_dep->stride) != INTEGER_CST + && POINTER_TYPE_P (TREE_TYPE (first_dep->stride))) + + incr_vec[i].cost = COST_INFINITE; + /* For any other increment, if this is a multiply candidate, we must introduce a temporary T and initialize it with T_0 = stride * increment. When optimizing for speed, walk the