From patchwork Wed Oct 10 21:25:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 190758 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]) by ozlabs.org (Postfix) with SMTP id ADCE82C008A for ; Thu, 11 Oct 2012 08:26:03 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350509163; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:To:Subject:Message-Id:Date:From: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=VtSeXR19Dek3WEYnPMvr ymAJOKE=; b=BjCy2sYgnXYmUXK9yLO+0YODqZhCOMqNCyO975WkuIRcEZaMmir4 CSq/yYWQEtjmk1Bx5esucA74Czl/7iGMMS3AbhahKFzBwtk6plp7eqotycrOtXX0 EAWe70bgK+NiM/jiM4wDbPKp6BuaJGz1R1hLTAtIcwYU0yJfOndEnKg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dffM2gbrPO4Rdyw/NxuDt+RL4dX4luY2MzRnm8MVX40XkOkoj8y1cLvRJ8icii R9Tq4an2/Rl5+7pN7sEuLGZSJCCrhW0U2MKVr6JAkTdiydFPkynXvdGzlqquYkSX uY42+7kgei/ptgxt03YRrJQwoqBKo3QZJhaLUcHCqcwyE=; Received: (qmail 27378 invoked by alias); 10 Oct 2012 21:25:58 -0000 Received: (qmail 27364 invoked by uid 22791); 10 Oct 2012 21:25:54 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_DQ X-Spam-Check-By: sourceware.org Received: from mail-yh0-f73.google.com (HELO mail-yh0-f73.google.com) (209.85.213.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Oct 2012 21:25:45 +0000 Received: by mail-yh0-f73.google.com with SMTP id i33so124639yhi.2 for ; Wed, 10 Oct 2012 14:25:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=rRmHCkWQANqBwHWEtt4u2a+o1zFne99mDXuYMNyYTVM=; b=Cqq0t290EAq/zJGpp9dwY/FdYV3k4LRLda4+EinO+RSuqdOe23c3Gghutz9vSDPHXz mEHU/YQhL8URCVjVNnZTA4GjgfIIrv/gncab2Q+4feK9FNg5zTqwKHKdeyLpD13qt9pF X9DrU3R1QEBtYUv0MIhKMPh89tD3ov2Orv2GLbsGq2CBrbUGhT+0vJGc54EzrqL/pDYK 3BMxiW1DqKmtZbFzNFNaJmr3MRH8m+8jX8wOLW3ypSSzvv6UP2B4FARxht6Q+k0ACuyS 5YP+n32lVOSnSy+VtIkqDlgcd1irJpIsUMwjfu7HjwS7LMyFAJ7exsmadxvHHfzzNhjd 5D5Q== Received: by 10.236.175.7 with SMTP id y7mr18410267yhl.14.1349904344691; Wed, 10 Oct 2012 14:25:44 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id l20si243425yhi.2.2012.10.10.14.25.44 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 10 Oct 2012 14:25:44 -0700 (PDT) Received: from tjsboxrox.mtv.corp.google.com (tjsboxrox.mtv.corp.google.com [172.18.110.68]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 947EA1E0043; Wed, 10 Oct 2012 14:25:44 -0700 (PDT) Received: by tjsboxrox.mtv.corp.google.com (Postfix, from userid 147431) id 33D2A61472; Wed, 10 Oct 2012 14:25:44 -0700 (PDT) To: reply@codereview.appspotmail.com, davidxl@google.com, gcc-patches@gcc.gnu.org Subject: [PATCH] Reduce conservativeness in REE using machine model (issue6631066) Message-Id: <20121010212544.33D2A61472@tjsboxrox.mtv.corp.google.com> Date: Wed, 10 Oct 2012 14:25:44 -0700 (PDT) From: tejohnson@google.com (Teresa Johnson) X-Gm-Message-State: ALoCoQkXr8RXccZdFxVpTI2d8O/hRdahPuPsyNeJJrgA7xL00EjnGKPyOE/lQifqaiKW5z+6fwIE5uxlKMtCXit+9JQUFx+DI41rOBrvbs5vLFWKno1gYu/kCKvig9zxGf6KPBRTHCTgzEefNJ8cAdtdBt/dhgAxM8LH0UWNMHqYfYYJAnKYHyXIXDw9SeL9e5GiHM+UCEsy X-IsSubscribed: yes 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 This patch addresses conservative behavior in redundant extend elimination that was resulting in redundant extends not being removed. One of the checks is to ensure that the reaching definition doesn't feed another extension with a different machine mode. In this case, the extend we are trying to eliminate is a zero_extendqidi2, and the other extend the reaching def is feeding is a zero_extendqisi2. While these appear to be different because the dest modes are different (DI vs SI), in reality zero_extendqidi2 in the machine model has an SI attribute mode, which means that it does ultimately target an SI register: (define_insn "zero_extenddi2" [(set (match_operand:DI 0 "register_operand" "=r") (zero_extend:DI (match_operand:SWI12 1 "nonimmediate_operand" "m")))] "TARGET_64BIT" "movz{l|x}\t{%1, %k0|%k0, %1}" [(set_attr "type" "imovx") (set_attr "mode" "SI")]) What I did to address this is to call get_attr_mode from the machine model to get the actual mode of the insn. In this case, it returns MODE_SI. There doesn't seem to be any code that maps from the attr_mode (MODE_SI) to the machine_mode (SImode), so I am doing the mapping in ree.c before the comparison with the mode from the second extend. Bootstrapped and tested on x86_64-unknown-linux-gnu. Is this ok for trunk? Thanks, Teresa 2012-10-10 Teresa Johnson * ree.c (get_mode): New function. (add_removable_extension): Use get_mode to obtain the machine mode for comparison with other extends. --- This patch is available for review at http://codereview.appspot.com/6631066 Index: ree.c =================================================================== --- ree.c (revision 192265) +++ ree.c (working copy) @@ -240,6 +240,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "df.h" #include "cgraph.h" +#include "insn-attr.h" /* This structure represents a candidate for elimination. */ @@ -756,6 +757,41 @@ combine_reaching_defs (ext_cand *cand, const_rtx s return false; } +/* Given an INSN, obtain the attr_mode specified by the machine + model, and map it to the corresponding machine_mode. If the + attr_mode isn't available, return the machine mode for DEST. */ + +static enum machine_mode +get_mode (rtx insn, rtx dest) +{ + enum machine_mode mode; + +#ifdef HAVE_ATTR_mode + switch (get_attr_mode (insn)) + { + case MODE_QI: + mode = QImode; + break; + case MODE_HI: + mode = HImode; + break; + case MODE_SI: + mode = SImode; + break; + case MODE_DI: + mode = DImode; + break; + default: + mode = GET_MODE (dest); + break; + } +#else + mode = GET_MODE (dest); +#endif + + return mode; +} + /* Add an extension pattern that could be eliminated. */ static void @@ -775,7 +811,7 @@ add_removable_extension (const_rtx expr, rtx insn, src = SET_SRC (expr); code = GET_CODE (src); dest = SET_DEST (expr); - mode = GET_MODE (dest); + mode = get_mode (insn, dest); if (REG_P (dest) && (code == SIGN_EXTEND || code == ZERO_EXTEND)