From patchwork Thu Jul 13 08:51:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107623 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1934667qge; Thu, 13 Jul 2017 01:53:06 -0700 (PDT) X-Received: by 10.98.66.8 with SMTP id p8mr24173024pfa.4.1499935986221; Thu, 13 Jul 2017 01:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935986; cv=none; d=google.com; s=arc-20160816; b=D94mi+o6drmsNbj4tI1ReoX+Vld7atD8cfUS+Rrcst/WYfX/N4JWLVl4048GCjU+7G vK4zjyzKvMPsi9zHLykgkG6KGXCofLuk14uw6nCwPAvOGkhOFRfq39PgSGNUZHiefsh4 nGJ9CenySMqzejfcVksSsr2HCf6T7hpA8QbGjlUNTVV17mmOFNG9V19HhGcmnO/ewHVn jHf+VHPQpkTvmrL4s5h/6kloz4peYUV98EkTZkk9vY/V5/BEDYt8hIhLCmWWdeOtR1EW pwqGqlcxbY707qhPZcAAC6eH4kzm5++Qdrk04Qxr95uQyG3NKmSmutMJ7muTOZApFXrN NvoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=uH9flvFKMZeWXawRRhyyb7w+Ne3dJQxal9059pLsrTc=; b=VJUhCdRU00nYko8Of6ukC9oPzzGIgFdkEadPWtDYm+bxEV8M84rtwrkRtvaH0ZlKrM PBEMQAnuz/KBh7/+xu0Lcfx7DMmJkPUQXV0NxkONcTv3YHQ1aZLm9u3OYsaUb1sHqHNf jpsDracvdPpqXDYHxx6gESpDQM7Qy9kWiCYya6pS5qKgUzpgtV72CysNwnk5CO2YJneR DD+3RPGfTk/b7xQH0Jxuw/sWNNmh5Bakf0m8g5h7fFJpzhIXiK4awtnzNGcY2PMdqibX bF56C6ysfATYexIxJ4WnRruyQn+di0OqT14f+Jfh2Xuxz5zAUYV2Hj3kfPEkaUGo/Nzo P2yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=p+p2U3Oz; spf=pass (google.com: domain of gcc-patches-return-458028-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458028-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u11si3980618plm.353.2017.07.13.01.53.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458028-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=p+p2U3Oz; spf=pass (google.com: domain of gcc-patches-return-458028-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458028-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=YsgVEw4AnKi1YS/E/axLg816ZJfyV c/p+vkRitnjethp7yIpRGfe2lvggUyDiDT0aeGEJvSNu+n6a942O869Br0UFNlI+ wSiEDJS3A6uk0stSDSXX7++CIoYh6JMRCW0RFu7E0E7Ds9a949CkYsh13/jR82hk FbNJOs32EYc65I= 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:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=TwaN/dbedIp5ZGe6pBxooDkA3uw=; b=p+p 2U3OzbklAglZ7fyr+EV6R7mZ1mRvKPxYdT+J81/2SpMYI2P52jndQMBZixxMmqAD 9lPyH9SoFdjlzUPG2gcPjoL08we0iu0fy+2mnS9QKIvPVUoE3LNeVNbBp6ih3OZ6 Ho64m2oMgAEC+L5XVal/bSVNUcDCJZKTkuMu2xYU= Received: (qmail 31247 invoked by alias); 13 Jul 2017 08:51:58 -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 30147 invoked by uid 89); 13 Jul 2017 08:51:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f180.google.com Received: from mail-wr0-f180.google.com (HELO mail-wr0-f180.google.com) (209.85.128.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:51:52 +0000 Received: by mail-wr0-f180.google.com with SMTP id c11so49433931wrc.3 for ; Thu, 13 Jul 2017 01:51:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=uH9flvFKMZeWXawRRhyyb7w+Ne3dJQxal9059pLsrTc=; b=V6D5oFllTODXI+g7iULYXa/AbiXCE+E1qjAWWGdR7L1+I3WK9lwxGGk5sC0++v9TKx IYR7uhsFMmix65so0l26OtccFpD9TwoV8FkuFn8e1frIaKluqR3Y7wWsQyu8RMN1fU/q 7H1Q/rfEEEpKF38gis7VzWgZttLSatl3hi7j2c4voLTipewkqbgAADcC6C0z5tCF8fGu 7innT3Zy79RU3wPxjUSwW2QuDx/Mc1/mXnaPjP4iqWgGcWs9J4iDC4H7G2AYjNRIqz59 UzimV2sQhMvBw0QGXcqf904qkCOO1Z1qXE4Q2ITvoWpoduur7gwCvriYj5SbevvVB5z1 Wwcw== X-Gm-Message-State: AIVw110BUdchBWyZrALr/h3u8ozaEhGKOmJPOLeARpesrdjFhgxb5pGT kjbxdO1pJWModDQrIGtdEQ== X-Received: by 10.223.144.39 with SMTP id h36mr1069786wrh.114.1499935910157; Thu, 13 Jul 2017 01:51:50 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id l73sm7817616wma.27.2017.07.13.01.51.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:51:49 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [37/77] Use scalar_int_mode when emitting cstores References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:51:47 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87pod4hg7w.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 cstore patterns always have a scalar integer result, which has the value 0 for "false" and STORE_FLAG_VALUE for "true". This patch makes that explicit using scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * target.def (cstore_mode): Return a scalar_int_mode. * doc/tm.texi: Regenerate. * config/sparc/sparc.c (sparc_cstore_mode): Return a scalar_int_mode. * targhooks.h (default_cstore_mode): Likewise. * targhooks.c (default_cstore_mode): Likewise, using a forced conversion. * expmed.c (emit_cstore): Expect the target of the cstore to be a scalar_int_mode. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-07-13 09:18:27.468824773 +0100 +++ gcc/target.def 2017-07-13 09:18:40.785633267 +0100 @@ -5082,7 +5082,7 @@ DEFHOOK for the cstore being performed. Not definiting this hook is the same\ as accepting the mode encoded into operand 0 of the cstore expander\ patterns.", - machine_mode, (enum insn_code icode), + scalar_int_mode, (enum insn_code icode), default_cstore_mode) /* This target hook allows the backend to compute the register pressure Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-07-13 09:18:27.467824868 +0100 +++ gcc/doc/tm.texi 2017-07-13 09:18:40.783633435 +0100 @@ -2902,7 +2902,7 @@ This hook defines a class of registers w This hook should return @code{true} if given class of registers should be an allocno class in any way. Usually RA uses only one register class from all classes containing the same register set. In some complicated cases, you need to have two or more such classes as allocno ones for RA correct work. Not defining this hook is equivalent to returning @code{false} for all inputs. @end deftypefn -@deftypefn {Target Hook} machine_mode TARGET_CSTORE_MODE (enum insn_code @var{icode}) +@deftypefn {Target Hook} scalar_int_mode TARGET_CSTORE_MODE (enum insn_code @var{icode}) This hook defines the machine mode to use for the boolean result of conditional store patterns. The ICODE argument is the instruction code for the cstore being performed. Not definiting this hook is the same as accepting the mode encoded into operand 0 of the cstore expander patterns. @end deftypefn Index: gcc/config/sparc/sparc.c =================================================================== --- gcc/config/sparc/sparc.c 2017-07-13 09:18:30.899501876 +0100 +++ gcc/config/sparc/sparc.c 2017-07-13 09:18:40.782633518 +0100 @@ -670,7 +670,7 @@ static void sparc_print_operand_address static reg_class_t sparc_secondary_reload (bool, rtx, reg_class_t, machine_mode, secondary_reload_info *); -static machine_mode sparc_cstore_mode (enum insn_code icode); +static scalar_int_mode sparc_cstore_mode (enum insn_code icode); static void sparc_atomic_assign_expand_fenv (tree *, tree *, tree *); static bool sparc_fixed_condition_code_regs (unsigned int *, unsigned int *); static unsigned int sparc_min_arithmetic_precision (void); @@ -13158,7 +13158,7 @@ sparc_modes_tieable_p (machine_mode mode /* Implement TARGET_CSTORE_MODE. */ -static machine_mode +static scalar_int_mode sparc_cstore_mode (enum insn_code icode ATTRIBUTE_UNUSED) { return (TARGET_ARCH64 ? DImode : SImode); Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-07-13 09:18:27.468824773 +0100 +++ gcc/targhooks.h 2017-07-13 09:18:40.785633267 +0100 @@ -229,7 +229,7 @@ extern const char *default_pch_valid_p ( extern void default_asm_output_ident_directive (const char*); -extern machine_mode default_cstore_mode (enum insn_code); +extern scalar_int_mode default_cstore_mode (enum insn_code); extern bool default_member_type_forces_blk (const_tree, machine_mode); extern void default_atomic_assign_expand_fenv (tree *, tree *, tree *); extern tree build_va_arg_indirect_ref (tree); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:30.905501319 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:40.785633267 +0100 @@ -1831,10 +1831,10 @@ default_pch_valid_p (const void *data_p, /* Default version of cstore_mode. */ -machine_mode +scalar_int_mode default_cstore_mode (enum insn_code icode) { - return insn_data[(int) icode].operand[0].mode; + return as_a (insn_data[(int) icode].operand[0].mode); } /* Default version of member_type_forces_blk. */ Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:39.588733898 +0100 +++ gcc/expmed.c 2017-07-13 09:18:40.784633351 +0100 @@ -5235,7 +5235,8 @@ emit_cstore (rtx target, enum insn_code struct expand_operand ops[4]; rtx op0, comparison, subtarget; rtx_insn *last; - machine_mode result_mode = targetm.cstore_mode (icode); + scalar_int_mode result_mode = targetm.cstore_mode (icode); + scalar_int_mode int_target_mode; last = get_last_insn (); x = prepare_operand (icode, x, 2, mode, compare_mode, unsignedp); @@ -5247,9 +5248,11 @@ emit_cstore (rtx target, enum insn_code } if (target_mode == VOIDmode) - target_mode = result_mode; + int_target_mode = result_mode; + else + int_target_mode = as_a (target_mode); if (!target) - target = gen_reg_rtx (target_mode); + target = gen_reg_rtx (int_target_mode); comparison = gen_rtx_fmt_ee (code, result_mode, x, y); @@ -5265,20 +5268,20 @@ emit_cstore (rtx target, enum insn_code subtarget = ops[0].value; /* If we are converting to a wider mode, first convert to - TARGET_MODE, then normalize. This produces better combining + INT_TARGET_MODE, then normalize. This produces better combining opportunities on machines that have a SIGN_EXTRACT when we are testing a single bit. This mostly benefits the 68k. If STORE_FLAG_VALUE does not have the sign bit set when interpreted in MODE, we can do this conversion as unsigned, which is usually more efficient. */ - if (GET_MODE_SIZE (target_mode) > GET_MODE_SIZE (result_mode)) + if (GET_MODE_SIZE (int_target_mode) > GET_MODE_SIZE (result_mode)) { convert_move (target, subtarget, val_signbit_known_clear_p (result_mode, STORE_FLAG_VALUE)); op0 = target; - result_mode = target_mode; + result_mode = int_target_mode; } else op0 = subtarget; @@ -5314,7 +5317,7 @@ emit_cstore (rtx target, enum insn_code } /* If we were converting to a smaller mode, do the conversion now. */ - if (target_mode != result_mode) + if (int_target_mode != result_mode) { convert_move (target, op0, 0); return target;