From patchwork Mon Jun 23 06:58:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 32322 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A7792055C for ; Mon, 23 Jun 2014 06:59:15 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id y10sf22425381pdj.9 for ; Sun, 22 Jun 2014 23:59:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :x-original-sender:x-original-authentication-results:content-type; bh=C992/xl6cHFbE2whLX/pjclV/EpEao4xor/4tEP7Ki4=; b=XXqSURAPAcSLWmGMpFa1IzblyycQBlliA7G3ElDK0AlECBe1iqwoJv59OubzVevfmV c6usi7ECrzpS8TNhyIQJecXBraqInqCYq6NYMecXb6hhQfP2Im/zvBF601FGZV73HIOi ngomidF5Agd+9uvMTKpGmpphdynNtkxFEdQZfT/GYayBWVeRT8CfBz4OzBVyCZXr3fWc NvB8qUdVWqViAPrvqjf7fsY1T9rFuEiVNfJ6poF74SEr1ug3pvbDvGdnhMFnTiMxI5XG MEpPW4tDYCzMJiHFfzgXoyZc6W1A2EYlStiuRXKYlkjD7VaYEFttL9o4SLImPyO81gJb PNkg== X-Gm-Message-State: ALoCoQmS6FcFz0HeYWbAywqCsPhcOakhqvr2mNRCMSWG6vYeFt9Voo1p5/rJk+923WKrFnm2LRZZ X-Received: by 10.66.218.105 with SMTP id pf9mr8703506pac.36.1403506754389; Sun, 22 Jun 2014 23:59:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.228 with SMTP id s91ls1781489qga.58.gmail; Sun, 22 Jun 2014 23:59:14 -0700 (PDT) X-Received: by 10.52.14.9 with SMTP id l9mr1402671vdc.41.1403506754284; Sun, 22 Jun 2014 23:59:14 -0700 (PDT) Received: from mail-ve0-x235.google.com (mail-ve0-x235.google.com [2607:f8b0:400c:c01::235]) by mx.google.com with ESMTPS id yk7si8501141vec.98.2014.06.22.23.59.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Jun 2014 23:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::235 as permitted sender) client-ip=2607:f8b0:400c:c01::235; Received: by mail-ve0-f181.google.com with SMTP id db11so5598330veb.26 for ; Sun, 22 Jun 2014 23:59:14 -0700 (PDT) X-Received: by 10.58.132.70 with SMTP id os6mr607267veb.36.1403506754159; Sun, 22 Jun 2014 23:59:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp109872vcb; Sun, 22 Jun 2014 23:59:13 -0700 (PDT) X-Received: by 10.69.31.235 with SMTP id kp11mr17809426pbd.59.1403506753419; Sun, 22 Jun 2014 23:59:13 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id tk10si20525043pab.212.2014.06.22.23.59.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jun 2014 23:59:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-370788-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 9515 invoked by alias); 23 Jun 2014 06:59:01 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 9491 invoked by uid 89); 23 Jun 2014 06:59:00 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f172.google.com Received: from mail-lb0-f172.google.com (HELO mail-lb0-f172.google.com) (209.85.217.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 23 Jun 2014 06:58:33 +0000 Received: by mail-lb0-f172.google.com with SMTP id c11so3934000lbj.3 for ; Sun, 22 Jun 2014 23:58:30 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.179.131 with SMTP id dg3mr15695932lac.21.1403506710253; Sun, 22 Jun 2014 23:58:30 -0700 (PDT) Received: by 10.112.13.36 with HTTP; Sun, 22 Jun 2014 23:58:30 -0700 (PDT) Date: Mon, 23 Jun 2014 14:58:30 +0800 Message-ID: Subject: [PATCH, 3/10] skip swapping operands used in ccmp From: Zhenqiang Chen To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes X-Original-Sender: zhenqiang.chen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, Swapping operands in a ccmp will lead to illegal instructions. So the patch disables it in simplify_while_replacing. The patch is separated from https://gcc.gnu.org/ml/gcc-patches/2014-02/msg01407.html. To make it clean. The patch adds two files: ccmp.{c,h} to hold all new ccmp related functions. OK for trunk? Thanks! -Zhenqiang ChangeLog: 2014-06-23 Zhenqiang Chen * Makefile.in: Add ccmp.o * ccmp.c: New file. * ccmp.h: New file. * recog.c (simplify_while_replacing): Check ccmp_insn_p. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5587b75..8757a30 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1169,6 +1169,7 @@ OBJS = \ builtins.o \ caller-save.o \ calls.o \ + ccmp.o \ cfg.o \ cfganal.o \ cfgbuild.o \ diff --git a/gcc/ccmp.c b/gcc/ccmp.c new file mode 100644 index 0000000..665c2a5 --- /dev/null +++ b/gcc/ccmp.c @@ -0,0 +1,62 @@ +/* Conditional compare related functions + Copyright (C) 2014-2014 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "rtl.h" +#include "tree.h" +#include "stringpool.h" +#include "regs.h" +#include "expr.h" +#include "optabs.h" +#include "tree-iterator.h" +#include "basic-block.h" +#include "tree-ssa-alias.h" +#include "internal-fn.h" +#include "gimple-expr.h" +#include "is-a.h" +#include "gimple.h" +#include "gimple-ssa.h" +#include "tree-ssanames.h" +#include "target.h" +#include "common/common-target.h" +#include "df.h" +#include "tree-ssa-live.h" +#include "tree-outof-ssa.h" +#include "cfgexpand.h" +#include "tree-phinodes.h" +#include "ssa-iterators.h" +#include "expmed.h" +#include "ccmp.h" + +bool +ccmp_insn_p (rtx object) +{ + rtx x = PATTERN (object); + if (targetm.gen_ccmp_first + && GET_CODE (x) == SET + && GET_CODE (XEXP (x, 1)) == COMPARE + && (GET_CODE (XEXP (XEXP (x, 1), 0)) == IOR + || GET_CODE (XEXP (XEXP (x, 1), 0)) == AND)) + return true; + return false; +} + diff --git a/gcc/ccmp.h b/gcc/ccmp.h new file mode 100644 index 0000000..7e139aa --- /dev/null +++ b/gcc/ccmp.h @@ -0,0 +1,25 @@ +/* Conditional comapre related functions. + Copyright (C) 2014-2014 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version.: + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_CCMP_H +#define GCC_CCMP_H + +extern bool ccmp_insn_p (rtx); + +#endif /* GCC_CCMP_H */ diff --git a/gcc/recog.c b/gcc/recog.c index 8d10a4f..b53a28c 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "df.h" #include "insn-codes.h" +#include "ccmp.h" #ifndef STACK_PUSH_CODE #ifdef STACK_GROWS_DOWNWARD @@ -577,7 +578,8 @@ simplify_while_replacing (rtx *loc, rtx to, rtx object, enum rtx_code code = GET_CODE (x); rtx new_rtx = NULL_RTX; - if (SWAPPABLE_OPERANDS_P (x) + /* Do not swap compares in conditional compare instruction. */ + if (SWAPPABLE_OPERANDS_P (x) && !ccmp_insn_p (object) && swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1))) { validate_unshare_change (object, loc,