From patchwork Tue Sep 23 08:28:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 392269 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 962A9140095 for ; Tue, 23 Sep 2014 18:31:53 +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=Vr5BmvMrkXVt5Un9enNgPOxoDxt//6MPzEnZ6n0NA6Pgjh1gq6yUU ztsi0lAwgaLov/RcgdsztZbaYbX/dC5jPIkBbbblVT6xJipef06EwENMyUygHIVU kANbuCuBFv5XO0h29My8Khjz4Ef1YifQfIA/m2ERODOsLyUkWix6L4= 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=YzcAsriA4s2vcaIhO5cubOnu9KY=; b=RVZT0Y6lkyK7tIkQr/JS jFV3pjyY6BBctH/HhtDEgMvijzs/4dWDxvlzpPbj8Gqwf2PGwaPQE6SANCoHCWYb m0t//tnLzipvQV2hCbqf9yVmIip0EUx5p8fwRBFuL7VnigzUEmn19c3JjDLXLMGo HiuS5jqtvxBSDx46aBQMvMs= Received: (qmail 4137 invoked by alias); 23 Sep 2014 08:31:46 -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 4125 invoked by uid 89); 23 Sep 2014 08:31:46 -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; Tue, 23 Sep 2014 08:31:45 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7B08CAB1D for ; Tue, 23 Sep 2014 08:31:42 +0000 (UTC) Date: Tue, 23 Sep 2014 10:28:01 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][match-and-simplify] Also canonicalize comparison ops Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2014-09-22 Richard Biener * gimple-match-head.c (gimple_resimplify2): Also swap comparison operands. (gimple_simplify): Likewise. Index: gcc/gimple-match-head.c =================================================================== --- gcc/gimple-match-head.c (revision 215450) +++ gcc/gimple-match-head.c (working copy) @@ -174,12 +174,15 @@ gimple_resimplify2 (gimple_seq *seq, /* Canonicalize operand order. */ bool canonicalized = false; if (res_code->is_tree_code () - && commutative_tree_code (*res_code) + && (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison + || commutative_tree_code (*res_code)) && tree_swap_operands_p (res_ops[0], res_ops[1], false)) { tree tem = res_ops[0]; res_ops[0] = res_ops[1]; res_ops[1] = tem; + if (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison) + *res_code = swap_tree_comparison (*res_code); canonicalized = true; } @@ -408,12 +411,15 @@ gimple_simplify (enum tree_code code, tr /* Canonicalize operand order both for matching and fallback stmt generation. */ - if (commutative_tree_code (code) + if ((commutative_tree_code (code) + || TREE_CODE_CLASS (code) == tcc_comparison) && tree_swap_operands_p (op0, op1, false)) { tree tem = op0; op0 = op1; op1 = tem; + if (TREE_CODE_CLASS (code) == tcc_comparison) + code = swap_tree_comparison (code); } code_helper rcode;