From patchwork Fri Aug 15 09:07:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 380129 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 806E414009B for ; Fri, 15 Aug 2014 19:10:55 +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=Wxslelhd7GsvvaK8l0yPpj0Yc69lT/SnE5hyGWykfY3ZpcgTNPn1S RrXUTf9K4XzvZrH8jpPnB2vSyZlGOhLYnNsUstUcdJz8Bdi/zZP3KfqEVqH1V4uR XwC0YApHwCynaXBjaqwd7n8/gUZ2NiYPUiow5aB14OiMyGfPuJmgYU= 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=y855svt3OxK49Fj3rwUuHNrH5wo=; b=r1drb32whjfpVm3tgRH3 GkobO28ZU6roNMDQU7QkE8VGvLQDS56l/YUNAfne1ikmp9Q1XRurNkyUh9Bk/BA7 mLPAu0A8B1w+lRQGpyiVemTRB7+9ft7I4b9q3v6HjLOoSywL+4uGHwqHzN6cWbCN Uswb/ZWxN+x+NF+gQSMQero= Received: (qmail 22942 invoked by alias); 15 Aug 2014 09:10:48 -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 22923 invoked by uid 89); 15 Aug 2014 09:10:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 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; Fri, 15 Aug 2014 09:10:46 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 37FEBADA5 for ; Fri, 15 Aug 2014 09:10:43 +0000 (UTC) Date: Fri, 15 Aug 2014 11:07:31 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Put all constants last in tree_swap_operands_p, remove odd -Os check Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 The following makes tree_swap_operands_p put all constants 2nd place, also looks through sign-changes when considering further canonicalzations and removes the odd -Os guard for those. That was put in with https://gcc.gnu.org/ml/gcc-patches/2003-10/msg01208.html just motivated by CSiBE numbers - but rather than disabling canonicalization this should have disabled the actual harmful transforms. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu. Richard. 2014-08-15 Richard Biener * fold-const.c (tree_swap_operands_p): Put all constants last, also strip sign-changing NOPs when considering further canonicalization. Canonicalize also when optimizing for size. Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 214007) +++ gcc/fold-const.c (working copy) @@ -6642,37 +6650,19 @@ reorder_operands_p (const_tree arg0, con bool tree_swap_operands_p (const_tree arg0, const_tree arg1, bool reorder) { - STRIP_SIGN_NOPS (arg0); - STRIP_SIGN_NOPS (arg1); - - if (TREE_CODE (arg1) == INTEGER_CST) + if (CONSTANT_CLASS_P (arg1) == INTEGER_CST) return 0; - if (TREE_CODE (arg0) == INTEGER_CST) + if (CONSTANT_CLASS_P (arg0) == INTEGER_CST) return 1; - if (TREE_CODE (arg1) == REAL_CST) - return 0; - if (TREE_CODE (arg0) == REAL_CST) - return 1; - - if (TREE_CODE (arg1) == FIXED_CST) - return 0; - if (TREE_CODE (arg0) == FIXED_CST) - return 1; - - if (TREE_CODE (arg1) == COMPLEX_CST) - return 0; - if (TREE_CODE (arg0) == COMPLEX_CST) - return 1; + STRIP_NOPS (arg0); + STRIP_NOPS (arg1); if (TREE_CONSTANT (arg1)) return 0; if (TREE_CONSTANT (arg0)) return 1; - if (optimize_function_for_size_p (cfun)) - return 0; - if (reorder && flag_evaluation_order && (TREE_SIDE_EFFECTS (arg0) || TREE_SIDE_EFFECTS (arg1))) return 0;