From patchwork Thu Sep 11 12:09:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 388213 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 EE5551400D5 for ; Thu, 11 Sep 2014 22:13:29 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=GepW5StIXZzF9PXtQnaXcb4UIknK3XeRGh3UpHXHCjiY2H48fwChv f22Yw0Jt97ROM00EzcOOZgxYD8eNOMpNVMBXZOW1IM6gMLU5YVQCVU6TrBAhjiBt I5riJviJ43u8oWyBjrewNf2TN6bXLvtNTB5G56R3MMG1tb9BuV24Xw= 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:subject:message-id:mime-version:content-type; s= default; bh=kIIGjy4ykuyDve7ETQtNf9phiAg=; b=UoEoNfE5Ka5yK/k14Kmw hFKfmc7syKJ0wulkB0wehY03230Oz4c+NJuCujD1llE5fPcJBsSkzwsmF/CLt3sW nxH+MFka86RAtN+EFI91HxsDUIXjWIUhLr4fvFQO1uI98/qKC42iDFOnTvYSVkuL XqsIGeGahqFw6eN99MCTCj4= Received: (qmail 6311 invoked by alias); 11 Sep 2014 12:13:20 -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 6295 invoked by uid 89); 11 Sep 2014 12:13:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 11 Sep 2014 12:13:12 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7CFE2AC48 for ; Thu, 11 Sep 2014 12:13:09 +0000 (UTC) Date: Thu, 11 Sep 2014 14:09:37 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][match-and-simplify] Minor fixes to match-plusminus.pd Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 More closely match-up to tree-ssa-forwprop.c code. Committed. Richard. 2014-09-11 Richard Biener * match-plusminus.pd: More closely match tree-ssa-forwprop.c code. Index: gcc/match-plusminus.pd =================================================================== --- gcc/match-plusminus.pd (revision 215163) +++ gcc/match-plusminus.pd (working copy) @@ -61,21 +61,21 @@ along with GCC; see the file COPYING3. (for outer_op (plus minus) (for inner_op (plus minus) (simplify - (outer_op (inner_op @0 INTEGER_CST@1) INTEGER_CST@2) + (outer_op (inner_op @0 CONSTANT_CLASS_P@1) CONSTANT_CLASS_P@2) /* If the constant operation overflows we cannot do the transform as we would introduce undefined overflow, for example with (a - 1) + INT_MIN. */ - (with { tree cst = int_const_binop (outer_op == inner_op - ? PLUS_EXPR : MINUS_EXPR, @1, @2); } - (if (!TREE_OVERFLOW (cst)) + (with { tree cst = fold_binary (outer_op == inner_op + ? PLUS_EXPR : MINUS_EXPR, type, @1, @2); } + (if (cst && !TREE_OVERFLOW (cst)) (inner_op @0 { cst; } )))))) /* (CST - A) +- CST -> CST - A */ (for outer_op (plus minus) (simplify - (outer_op (minus INTEGER_CST@1 @0) INTEGER_CST@2) - (with { tree cst = int_const_binop (outer_op, @1, @2); } - (if (!TREE_OVERFLOW (cst)) + (outer_op (minus CONSTANT_CLASS_P@1 @0) CONSTANT_CLASS_P@2) + (with { tree cst = fold_binary (outer_op, type, @1, @2); } + (if (cst && !TREE_OVERFLOW (cst)) (minus { cst; } @0))))) /* ~A + A -> -1 */ @@ -85,7 +85,7 @@ along with GCC; see the file COPYING3. /* ~A + 1 -> -A */ (simplify - (plus (bit_not integral_op_p@0) integer_onep@1) + (plus (bit_not @0) integer_onep@1) (if (TREE_CODE (TREE_TYPE (@1)) != COMPLEX_TYPE || (TREE_CODE (@1) == COMPLEX_CST && integer_onep (TREE_REALPART (@1)) @@ -136,7 +136,9 @@ along with GCC; see the file COPYING3. (simplify (pointer_plus @0 (convert?@2 (minus@3 (convert @1) (convert @0)))) /* Conditionally look through a sign-changing conversion. */ - (if (TYPE_PRECISION (TREE_TYPE (@2)) == TYPE_PRECISION (TREE_TYPE (@3))) + (if (TYPE_PRECISION (TREE_TYPE (@2)) == TYPE_PRECISION (TREE_TYPE (@3)) + && ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@1)) + || (GENERIC && type == TREE_TYPE (@1))))) @1)) /* From tree-ssa-forwprop.c:associate_pointerplus_align. */