From patchwork Thu Apr 24 16:20:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 342436 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 BA32414010E for ; Fri, 25 Apr 2014 02:20:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=K1k PNnvgCJLPE5KPd1tksvS+QkUECFwl++bLHypwZwBu8yXNXkhnglBmqFjunoaChhw EjdTdxhYnodVltwTSABXxlWc4qVA/9BFJg+a0det3muk7b5CFU39Xbi8/Rn2KfhU dtFgjMy0FZgz6bUyKRCdcUJzSM5rBTLM1Z2zhFZM= 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 :message-id:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; s=default; bh=++Ol4vyhY lgLpxAWpY4uY2DG4pQ=; b=ZyJ3i04AU83KlW4aeU0eTD05BsRcJppa4LaYPOhsN k1xs5jujIv0FejFNkF2UjoL5szo6I5qnipvUb7SWOQz0gi+GxMlslpOw8LOvJY97 oOo9iira1bRtdW7fORFPSjrqBmmhYEMUZGVj/TYuc8ZaIQQGjjNUskJT43P1fCUS EY= Received: (qmail 27054 invoked by alias); 24 Apr 2014 16:20:39 -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 27043 invoked by uid 89); 24 Apr 2014 16:20:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e9.ny.us.ibm.com Received: from e9.ny.us.ibm.com (HELO e9.ny.us.ibm.com) (32.97.182.139) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 24 Apr 2014 16:20:38 +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 ; Thu, 24 Apr 2014 12:20:36 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 Apr 2014 12:20:34 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 596AB6E802D for ; Thu, 24 Apr 2014 12:20:27 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp22034.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s3OGKYS4393726 for ; Thu, 24 Apr 2014 16:20:34 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s3OGKYsD010424 for ; Thu, 24 Apr 2014 12:20:34 -0400 Received: from [9.80.32.74] ([9.80.32.74]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s3OGKXg4010310; Thu, 24 Apr 2014 12:20:33 -0400 Message-ID: <1398356446.659.123.camel@gnopaine> Subject: [PATCH] Fix PR60930 From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de Date: Thu, 24 Apr 2014 11:20:46 -0500 Mime-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14042416-7182-0000-0000-00000A6CCF17 X-IsSubscribed: yes Hi, PR60930 exposes an SLSR problem with a fold. When multiplying two constants to create a new stride, the result must fit in the stride type for the computation or the fold is invalid. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. The same patch applies equally to 4.8, 4.9, and trunk. Is this ok for trunk (and for 4.8/4.9 after a suitable burn-in period)? Thanks, Bill [gcc] 2014-04-24 Bill Schmidt PR tree-optimization/60930 * gimple-ssa-strength-reduction.c (create_mul_imm_cand): Reject creating a multiply candidate by folding two constant multiplicands when the result overflows. [gcc/testsuite] 2014-04-24 Bill Schmidt PR tree-optimization/60930 * gcc.dg/torture/pr60930.c: New test. Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 209714) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -1114,15 +1114,18 @@ create_mul_imm_cand (gimple gs, tree base_in, tree X = Y * c ============================ X = (B + i') * (S * c) */ - base = base_cand->base_expr; - index = base_cand->index; temp = tree_to_double_int (base_cand->stride) * tree_to_double_int (stride_in); - stride = double_int_to_tree (TREE_TYPE (stride_in), temp); - ctype = base_cand->cand_type; - if (has_single_use (base_in)) - savings = (base_cand->dead_savings - + stmt_cost (base_cand->cand_stmt, speed)); + if (double_int_fits_to_tree_p (TREE_TYPE (stride_in), temp)) + { + base = base_cand->base_expr; + index = base_cand->index; + stride = double_int_to_tree (TREE_TYPE (stride_in), temp); + ctype = base_cand->cand_type; + if (has_single_use (base_in)) + savings = (base_cand->dead_savings + + stmt_cost (base_cand->cand_stmt, speed)); + } } else if (base_cand->kind == CAND_ADD && integer_onep (base_cand->stride)) { Index: gcc/testsuite/gcc.dg/torture/pr60930.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr60930.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr60930.c (working copy) @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +int x = 1; + +__attribute__((noinline, noclone)) void +foo (unsigned long long t) +{ + asm volatile ("" : : "r" (&t)); + if (t == 1) + __builtin_abort (); +} + +int +main () +{ + unsigned long long t = 0xffffffffffffffffULL * (0xffffffffUL * x); + if (t != 0xffffffff00000001ULL) + foo (t);; + return 0; +}