From patchwork Thu Jul 13 08:36:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107588 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1922147qge; Thu, 13 Jul 2017 01:37:09 -0700 (PDT) X-Received: by 10.84.169.3 with SMTP id g3mr8828800plb.136.1499935029647; Thu, 13 Jul 2017 01:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935029; cv=none; d=google.com; s=arc-20160816; b=FMxp3wrO92pBI0q+3vtVu037gbYM7C4X/G152BNj0f/gR5sj1Ol43UgI0ey77fqLie 6HI+PYvZcmTGtp/KykgPPZR1ypXTi/x1adw5w0OIrD1MAWFFMQXb7WthrciqMSKcR4aw MqCtrxKvKpUdpI+osd6B7p+PzyPH5Rhn3/9FaAmzgwfXsMPyvUSGwuOttOq61JCDnQyg CSW3Dief/nhcVL187LNcMCQah/VAp00nl1BocgGT9jdDNbVgkkcebfsgoDYVqaiIWd0r 1fbsetUKsn3BxMoaZL+FZzetJY5ML56tslSblNf9dgmUrS/OZmyykyqVS1lTRdPQUwU1 gAOg== 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=ZHe0CiQrzrnEwVItrYJUD5GrzOKjB/1A7cGVGiTZaU4=; b=xyLllXtDqXGd3QTkmoUe0sa9AGoH8nbAVDpoNyKxClAgU29WOalmYoBjb2vOikVu0+ Mn66NWplCtyG3+9Nt9kecbnyIORZjEsYW1BRj5unkNB7Udu5mTI0+jPjLtU6A3gOdkja yVBwdw038zbYlxe1D0lLmv2pAohtlcoWXPmqPp3r3PDJqVJsJyLp4XPcY28S8XbVHjou UcRBqKzxgqk8ivXLMCG3d50Bz3E7n7ZSbjU12FtsUlEInCGoWvF85Vp/8Vleb6ZPsiwv u/yXxpVxhF+kuJTAsN8DXKK5+ACVF20PR2VFecBq5WyLRsUaCmmWH2vV4AB8ImV3sv/t ZlKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=t6znOn8Q; spf=pass (google.com: domain of gcc-patches-return-457991-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457991-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 a11si4000560plt.19.2017.07.13.01.37.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457991-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=t6znOn8Q; spf=pass (google.com: domain of gcc-patches-return-457991-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457991-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=c+zLCCyGyZeqaQ9KNUbJa8VbxtanN n5SFxLWIW5e51EKyJqlrdw3ihptYoMPl1xVmi4T5sbDf04QFuNWoEl/Z1KXNoeYJ 3P3CVpk5pIo6qFq+5NiMAmOSA4lDehcoX8bMp9qiA8J/2rkubjzePj29vt2GyUQ2 ZE4+VAem7BU0Vs= 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=qzzE3QfStf2eEXAp/JvbXgcpqM4=; b=t6z nOn8QqtqWxSOvIt5E+/UQqNrPfGbO7oUCQIxNfvaMGPstQf5jIykcWyqGqV/InuS zyH1VyVXDreQf2lnMijErGS/RZqG46lOfWEPIwMh7eugEBL/wPhF1eFzwt5/Rm9S rbDe2obv+Wfm5oJoQIb3ja7v9n80Srd/Be3XgfMY= Received: (qmail 107118 invoked by alias); 13 Jul 2017 08:36:51 -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 105971 invoked by uid 89); 13 Jul 2017 08:36:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, 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-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:36:46 +0000 Received: by mail-wm0-f50.google.com with SMTP id f67so17878491wmh.1 for ; Thu, 13 Jul 2017 01:36:46 -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=ZHe0CiQrzrnEwVItrYJUD5GrzOKjB/1A7cGVGiTZaU4=; b=KHfuBKITprsE1BPH9BR+kCL5A1V503h2trqvr8zRRQm95O7UaWBEAh2p0lJNe/mw3s YTeqQtLVvAHtnViByTuCV/f3if7MxFSctbBLIztIVcQG1KvgW7FYpy2SXVmDqXFiniQN Z55/augzvcsrqecSSRQxa7gEChEMaeLfN1PvJjsPVnyqP2fFaxDgzUzgoNVTQmrbbRdk wsxyST0uFnGGuYXotjQxeFolKvxfVKueQGdKByb4MT0d4rHlhSdP630GCtEtT8oReHaX IY/eYE9GSmXKlpaoksiJFKBWdojbPAZIw/n0fOgZn2Za1uKkI3VV01KFTuQiik3IOzBq IFyw== X-Gm-Message-State: AIVw110ZDU4LlGD53DgE/AGbw7b/EOecMkGILNnQ9HPQWOD8sk7Kg+cX s7r4ET4pzLExr+0/u+W+ng== X-Received: by 10.28.138.8 with SMTP id m8mr1205300wmd.40.1499935003548; Thu, 13 Jul 2017 01:36:43 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 13sm2789567wrl.57.2017.07.13.01.36.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:36:42 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [01/77] Add an E_ prefix to mode names References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:36:41 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <871spkohra.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Later patches will add wrapper types for specific classes of mode. E.g. SImode will be a scalar_int_mode, SFmode will be a scalar_float_mode, etc. This patch prepares for that change by adding an E_ prefix to the mode enum values. It also adds #defines that map the unprefixed names to the prefixed names; e.g: #define QImode E_QImode Later patches will change this to use things like scalar_int_mode where appropriate. The patch continues to use enum values to initialise static data. This isn't necessary for correctness, but it cuts down on the amount of load-time initialisation and shouldn't have any downsides. The patch also changes things like: cmp_mode == DImode ? DFmode : DImode to: cmp_mode == DImode ? E_DFmode : E_DImode This is because DImode and DFmode will eventually be different classes, so the original ?: wouldn't be well-formed. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * genmodes.c (mode_size_inline): Add an E_ prefix to mode names. (mode_nunits_inline): Likewise. (mode_inner_inline): Likewise. (mode_unit_size_inline): Likewise. (mode_unit_precision_inline): Likewise. (emit_insn_modes_h): Likewise. Also emit a #define of the unprefixed name. (emit_mode_wider): Add an E_ prefix to mode names. (emit_mode_complex): Likewise. (emit_mode_inner): Likewise. (emit_mode_adjustments): Likewise. (emit_mode_int_n): Likewise. * config/aarch64/aarch64-builtins.c (v8qi_UP, v4hi_UP, v4hf_UP) (v2si_UP, v2sf_UP, v1df_UP, di_UP, df_UP, v16qi_UP, v8hi_UP, v8hf_UP) (v4si_UP, v4sf_UP, v2di_UP, v2df_UP, ti_UP, oi_UP, ci_UP, xi_UP) (si_UP, sf_UP, hi_UP, hf_UP, qi_UP): Likewise. (CRC32_BUILTIN, ENTRY): Likewise. * config/aarch64/aarch64.c (aarch64_push_regs): Likewise. (aarch64_pop_regs): Likewise. (aarch64_process_components): Likewise. * config/alpha/alpha.c (alpha_emit_conditional_move): Likewise. * config/arm/arm-builtins.c (v8qi_UP, v4hi_UP, v4hf_UP, v2si_UP) (v2sf_UP, di_UP, v16qi_UP, v8hi_UP, v8hf_UP, v4si_UP, v4sf_UP) (v2di_UP, ti_UP, ei_UP, oi_UP, hf_UP, si_UP, void_UP): Likewise. * config/arm/arm.c (arm_init_libfuncs): Likewise. * config/i386/i386-builtin-types.awk (ix86_builtin_type_vect_mode): Likewise. * config/i386/i386-builtin.def (pcmpestr): Likewise. (pcmpistr): Likewise. * config/microblaze/microblaze.c (double_memory_operand): Likewise. * config/mmix/mmix.c (mmix_output_condition): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_init_hard_regno_mode_ok): Likewise. * config/rl78/rl78.c (mduc_regs): Likewise. * config/rs6000/rs6000.c (rs6000_init_hard_regno_mode_ok): Likewise. (htm_expand_builtin): Likewise. * config/sh/sh.h (REGISTER_NATURAL_MODE): Likewise. * config/sparc/sparc.c (emit_save_or_restore_regs): Likewise. * config/xtensa/xtensa.c (print_operand): Likewise. * expmed.h (NUM_MODE_PARTIAL_INT): Likewise. (NUM_MODE_VECTOR_INT): Likewise. * genoutput.c (null_operand): Likewise. (output_operand_data): Likewise. * genrecog.c (print_parameter_value): Likewise. * lra.c (debug_operand_data): Likewise. Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-02 10:05:20.996539436 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:17.576867543 +0100 @@ -983,7 +983,7 @@ mode_size_inline (machine_mode mode)\n\ for_all_modes (c, m) if (!m->need_bytesize_adj) - printf (" case %smode: return %u;\n", m->name, m->bytesize); + printf (" case E_%smode: return %u;\n", m->name, m->bytesize); puts ("\ default: return mode_size[mode];\n\ @@ -1013,7 +1013,7 @@ mode_nunits_inline (machine_mode mode)\n {"); for_all_modes (c, m) - printf (" case %smode: return %u;\n", m->name, m->ncomponents); + printf (" case E_%smode: return %u;\n", m->name, m->ncomponents); puts ("\ default: return mode_nunits[mode];\n\ @@ -1043,7 +1043,7 @@ mode_inner_inline (machine_mode mode)\n\ {"); for_all_modes (c, m) - printf (" case %smode: return %smode;\n", m->name, + printf (" case E_%smode: return E_%smode;\n", m->name, c != MODE_PARTIAL_INT && m->component ? m->component->name : m->name); @@ -1082,7 +1082,7 @@ mode_unit_size_inline (machine_mode mode if (c != MODE_PARTIAL_INT && m2->component) m2 = m2->component; if (!m2->need_bytesize_adj) - printf (" case %smode: return %u;\n", name, m2->bytesize); + printf (" case E_%smode: return %u;\n", name, m2->bytesize); } puts ("\ @@ -1117,9 +1117,9 @@ mode_unit_precision_inline (machine_mode struct mode_data *m2 = (c != MODE_PARTIAL_INT && m->component) ? m->component : m; if (m2->precision != (unsigned int)-1) - printf (" case %smode: return %u;\n", m->name, m2->precision); + printf (" case E_%smode: return %u;\n", m->name, m2->precision); else - printf (" case %smode: return %u*BITS_PER_UNIT;\n", + printf (" case E_%smode: return %u*BITS_PER_UNIT;\n", m->name, m2->bytesize); } @@ -1151,10 +1151,12 @@ enum machine_mode\n{"); for (c = 0; c < MAX_MODE_CLASS; c++) for (m = modes[c]; m; m = m->next) { - int count_ = printf (" %smode,", m->name); + int count_ = printf (" E_%smode,", m->name); printf ("%*s/* %s:%d */\n", 27 - count_, "", trim_filename (m->file), m->line); printf ("#define HAVE_%smode\n", m->name); + printf ("#define %smode E_%smode\n", + m->name, m->name); } puts (" MAX_MACHINE_MODE,\n"); @@ -1174,11 +1176,11 @@ enum machine_mode\n{"); first = first->next; if (first && last) - printf (" MIN_%s = %smode,\n MAX_%s = %smode,\n\n", + printf (" MIN_%s = E_%smode,\n MAX_%s = E_%smode,\n\n", mode_class_names[c], first->name, mode_class_names[c], last->name); else - printf (" MIN_%s = %smode,\n MAX_%s = %smode,\n\n", + printf (" MIN_%s = E_%smode,\n MAX_%s = E_%smode,\n\n", mode_class_names[c], void_mode->name, mode_class_names[c], void_mode->name); } @@ -1350,7 +1352,7 @@ emit_mode_wider (void) print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES"); for_all_modes (c, m) - tagged_printf ("%smode", + tagged_printf ("E_%smode", m->wider ? m->wider->name : void_mode->name, m->name); @@ -1397,7 +1399,7 @@ emit_mode_wider (void) } if (m2 == void_mode) m2 = 0; - tagged_printf ("%smode", + tagged_printf ("E_%smode", m2 ? m2->name : void_mode->name, m->name); } @@ -1414,7 +1416,7 @@ emit_mode_complex (void) print_decl ("unsigned char", "mode_complex", "NUM_MACHINE_MODES"); for_all_modes (c, m) - tagged_printf ("%smode", + tagged_printf ("E_%smode", m->complex ? m->complex->name : void_mode->name, m->name); @@ -1454,7 +1456,7 @@ emit_mode_inner (void) print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES"); for_all_modes (c, m) - tagged_printf ("%smode", + tagged_printf ("E_%smode", c != MODE_PARTIAL_INT && m->component ? m->component->name : m->name, m->name); @@ -1597,9 +1599,9 @@ emit_mode_adjustments (void) { printf ("\n /* %s:%d */\n s = %s;\n", a->file, a->line, a->adjustment); - printf (" mode_size[%smode] = s;\n", a->mode->name); - printf (" mode_unit_size[%smode] = s;\n", a->mode->name); - printf (" mode_base_align[%smode] = s & (~s + 1);\n", + printf (" mode_size[E_%smode] = s;\n", a->mode->name); + printf (" mode_unit_size[E_%smode] = s;\n", a->mode->name); + printf (" mode_base_align[E_%smode] = s & (~s + 1);\n", a->mode->name); for (m = a->mode->contained; m; m = m->next_cont) @@ -1608,9 +1610,9 @@ emit_mode_adjustments (void) { case MODE_COMPLEX_INT: case MODE_COMPLEX_FLOAT: - printf (" mode_size[%smode] = 2*s;\n", m->name); - printf (" mode_unit_size[%smode] = s;\n", m->name); - printf (" mode_base_align[%smode] = s & (~s + 1);\n", + printf (" mode_size[E_%smode] = 2*s;\n", m->name); + printf (" mode_unit_size[E_%smode] = s;\n", m->name); + printf (" mode_base_align[E_%smode] = s & (~s + 1);\n", m->name); break; @@ -1620,10 +1622,10 @@ emit_mode_adjustments (void) case MODE_VECTOR_UFRACT: case MODE_VECTOR_ACCUM: case MODE_VECTOR_UACCUM: - printf (" mode_size[%smode] = %d*s;\n", + printf (" mode_size[E_%smode] = %d*s;\n", m->name, m->ncomponents); - printf (" mode_unit_size[%smode] = s;\n", m->name); - printf (" mode_base_align[%smode] = (%d*s) & (~(%d*s)+1);\n", + printf (" mode_unit_size[E_%smode] = s;\n", m->name); + printf (" mode_base_align[E_%smode] = (%d*s) & (~(%d*s)+1);\n", m->name, m->ncomponents, m->ncomponents); break; @@ -1642,7 +1644,7 @@ emit_mode_adjustments (void) { printf ("\n /* %s:%d */\n s = %s;\n", a->file, a->line, a->adjustment); - printf (" mode_base_align[%smode] = s;\n", a->mode->name); + printf (" mode_base_align[E_%smode] = s;\n", a->mode->name); for (m = a->mode->contained; m; m = m->next_cont) { @@ -1650,7 +1652,7 @@ emit_mode_adjustments (void) { case MODE_COMPLEX_INT: case MODE_COMPLEX_FLOAT: - printf (" mode_base_align[%smode] = s;\n", m->name); + printf (" mode_base_align[E_%smode] = s;\n", m->name); break; case MODE_VECTOR_INT: @@ -1659,7 +1661,7 @@ emit_mode_adjustments (void) case MODE_VECTOR_UFRACT: case MODE_VECTOR_ACCUM: case MODE_VECTOR_UACCUM: - printf (" mode_base_align[%smode] = %d*s;\n", + printf (" mode_base_align[E_%smode] = %d*s;\n", m->name, m->ncomponents); break; @@ -1677,7 +1679,7 @@ emit_mode_adjustments (void) { printf ("\n /* %s:%d */\n s = %s;\n", a->file, a->line, a->adjustment); - printf (" mode_ibit[%smode] = s;\n", a->mode->name); + printf (" mode_ibit[E_%smode] = s;\n", a->mode->name); } /* Fbit adjustments don't have to propagate. */ @@ -1685,12 +1687,12 @@ emit_mode_adjustments (void) { printf ("\n /* %s:%d */\n s = %s;\n", a->file, a->line, a->adjustment); - printf (" mode_fbit[%smode] = s;\n", a->mode->name); + printf (" mode_fbit[E_%smode] = s;\n", a->mode->name); } /* Real mode formats don't have to propagate anywhere. */ for (a = adj_format; a; a = a->next) - printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (%smode) = %s;\n", + printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (E_%smode) = %s;\n", a->file, a->line, a->mode->name, a->adjustment); puts ("}"); @@ -1768,7 +1770,7 @@ emit_mode_int_n (void) m = mode_sort[i]; printf(" {\n"); tagged_printf ("%u", m->int_n, m->name); - printf ("%smode,", m->name); + printf ("E_%smode,", m->name); printf(" },\n"); } Index: gcc/config/aarch64/aarch64-builtins.c =================================================================== --- gcc/config/aarch64/aarch64-builtins.c 2017-07-05 16:29:19.581861907 +0100 +++ gcc/config/aarch64/aarch64-builtins.c 2017-07-13 09:18:17.560869355 +0100 @@ -41,30 +41,30 @@ #include "gimple-iterator.h" #include "case-cfn-macros.h" -#define v8qi_UP V8QImode -#define v4hi_UP V4HImode -#define v4hf_UP V4HFmode -#define v2si_UP V2SImode -#define v2sf_UP V2SFmode -#define v1df_UP V1DFmode -#define di_UP DImode -#define df_UP DFmode -#define v16qi_UP V16QImode -#define v8hi_UP V8HImode -#define v8hf_UP V8HFmode -#define v4si_UP V4SImode -#define v4sf_UP V4SFmode -#define v2di_UP V2DImode -#define v2df_UP V2DFmode -#define ti_UP TImode -#define oi_UP OImode -#define ci_UP CImode -#define xi_UP XImode -#define si_UP SImode -#define sf_UP SFmode -#define hi_UP HImode -#define hf_UP HFmode -#define qi_UP QImode +#define v8qi_UP E_V8QImode +#define v4hi_UP E_V4HImode +#define v4hf_UP E_V4HFmode +#define v2si_UP E_V2SImode +#define v2sf_UP E_V2SFmode +#define v1df_UP E_V1DFmode +#define di_UP E_DImode +#define df_UP E_DFmode +#define v16qi_UP E_V16QImode +#define v8hi_UP E_V8HImode +#define v8hf_UP E_V8HFmode +#define v4si_UP E_V4SImode +#define v4sf_UP E_V4SFmode +#define v2di_UP E_V2DImode +#define v2df_UP E_V2DFmode +#define ti_UP E_TImode +#define oi_UP E_OImode +#define ci_UP E_CImode +#define xi_UP E_XImode +#define si_UP E_SImode +#define sf_UP E_SFmode +#define hi_UP E_HImode +#define hf_UP E_HFmode +#define qi_UP E_QImode #define UP(X) X##_UP #define SIMD_MAX_BUILTIN_ARGS 5 @@ -385,7 +385,7 @@ enum aarch64_builtins #undef CRC32_BUILTIN #define CRC32_BUILTIN(N, M) \ - {"__builtin_aarch64_"#N, M##mode, CODE_FOR_aarch64_##N, AARCH64_BUILTIN_##N}, + {"__builtin_aarch64_"#N, E_##M##mode, CODE_FOR_aarch64_##N, AARCH64_BUILTIN_##N}, static aarch64_crc_builtin_datum aarch64_crc_builtin_data[] = { AARCH64_CRC32_BUILTINS @@ -464,7 +464,7 @@ struct aarch64_simd_type_info }; #define ENTRY(E, M, Q, G) \ - {E, "__" #E, #G "__" #E, NULL_TREE, NULL_TREE, M##mode, qualifier_##Q}, + {E, "__" #E, #G "__" #E, NULL_TREE, NULL_TREE, E_##M##mode, qualifier_##Q}, static struct aarch64_simd_type_info aarch64_simd_types [] = { #include "aarch64-simd-builtin-types.def" }; Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-08 11:37:45.755825991 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:17.561869242 +0100 @@ -3124,7 +3124,7 @@ aarch64_gen_storewb_pair (machine_mode m aarch64_push_regs (unsigned regno1, unsigned regno2, HOST_WIDE_INT adjustment) { rtx_insn *insn; - machine_mode mode = (regno1 <= R30_REGNUM) ? DImode : DFmode; + machine_mode mode = (regno1 <= R30_REGNUM) ? E_DImode : E_DFmode; if (regno2 == INVALID_REGNUM) return aarch64_pushwb_single_reg (mode, regno1, adjustment); @@ -3167,7 +3167,7 @@ aarch64_gen_loadwb_pair (machine_mode mo aarch64_pop_regs (unsigned regno1, unsigned regno2, HOST_WIDE_INT adjustment, rtx *cfi_ops) { - machine_mode mode = (regno1 <= R30_REGNUM) ? DImode : DFmode; + machine_mode mode = (regno1 <= R30_REGNUM) ? E_DImode : E_DFmode; rtx reg1 = gen_rtx_REG (mode, regno1); *cfi_ops = alloc_reg_note (REG_CFA_RESTORE, reg1, *cfi_ops); @@ -3505,7 +3505,7 @@ aarch64_process_components (sbitmap comp { /* AAPCS64 section 5.1.2 requires only the bottom 64 bits to be saved so DFmode for the vector registers is enough. */ - machine_mode mode = GP_REGNUM_P (regno) ? DImode : DFmode; + machine_mode mode = GP_REGNUM_P (regno) ? E_DImode : E_DFmode; rtx reg = gen_rtx_REG (mode, regno); HOST_WIDE_INT offset = cfun->machine->frame.reg_offset[regno]; if (!frame_pointer_needed) Index: gcc/config/alpha/alpha.c =================================================================== --- gcc/config/alpha/alpha.c 2017-05-24 11:10:23.194093438 +0100 +++ gcc/config/alpha/alpha.c 2017-07-13 09:18:17.562869128 +0100 @@ -2780,7 +2780,7 @@ alpha_emit_conditional_move (rtx cmp, ma emit_insn (gen_rtx_SET (tem, gen_rtx_fmt_ee (cmp_code, cmp_mode, op0, op1))); - cmp_mode = cmp_mode == DImode ? DFmode : DImode; + cmp_mode = cmp_mode == DImode ? E_DFmode : E_DImode; op0 = gen_lowpart (cmp_mode, tem); op1 = CONST0_RTX (cmp_mode); cmp = gen_rtx_fmt_ee (code, VOIDmode, op0, op1); Index: gcc/config/arm/arm-builtins.c =================================================================== --- gcc/config/arm/arm-builtins.c 2017-07-05 16:29:19.583661907 +0100 +++ gcc/config/arm/arm-builtins.c 2017-07-13 09:18:17.563869015 +0100 @@ -255,24 +255,24 @@ #define STORE1_QUALIFIERS (arm_store1_qu qualifier_none, qualifier_struct_load_store_lane_index }; #define STORE1LANE_QUALIFIERS (arm_storestruct_lane_qualifiers) -#define v8qi_UP V8QImode -#define v4hi_UP V4HImode -#define v4hf_UP V4HFmode -#define v2si_UP V2SImode -#define v2sf_UP V2SFmode -#define di_UP DImode -#define v16qi_UP V16QImode -#define v8hi_UP V8HImode -#define v8hf_UP V8HFmode -#define v4si_UP V4SImode -#define v4sf_UP V4SFmode -#define v2di_UP V2DImode -#define ti_UP TImode -#define ei_UP EImode -#define oi_UP OImode -#define hf_UP HFmode -#define si_UP SImode -#define void_UP VOIDmode +#define v8qi_UP E_V8QImode +#define v4hi_UP E_V4HImode +#define v4hf_UP E_V4HFmode +#define v2si_UP E_V2SImode +#define v2sf_UP E_V2SFmode +#define di_UP E_DImode +#define v16qi_UP E_V16QImode +#define v8hi_UP E_V8HImode +#define v8hf_UP E_V8HFmode +#define v4si_UP E_V4SImode +#define v4sf_UP E_V4SFmode +#define v2di_UP E_V2DImode +#define ti_UP E_TImode +#define ei_UP E_EImode +#define oi_UP E_OImode +#define hf_UP E_HFmode +#define si_UP E_SImode +#define void_UP E_VOIDmode #define UP(X) X##_UP Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-08 11:37:45.851016912 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:17.565868789 +0100 @@ -2552,52 +2552,52 @@ arm_init_libfuncs (void) { const arm_fixed_mode_set fixed_arith_modes[] = { - { QQmode, "qq" }, - { UQQmode, "uqq" }, - { HQmode, "hq" }, - { UHQmode, "uhq" }, - { SQmode, "sq" }, - { USQmode, "usq" }, - { DQmode, "dq" }, - { UDQmode, "udq" }, - { TQmode, "tq" }, - { UTQmode, "utq" }, - { HAmode, "ha" }, - { UHAmode, "uha" }, - { SAmode, "sa" }, - { USAmode, "usa" }, - { DAmode, "da" }, - { UDAmode, "uda" }, - { TAmode, "ta" }, - { UTAmode, "uta" } + { E_QQmode, "qq" }, + { E_UQQmode, "uqq" }, + { E_HQmode, "hq" }, + { E_UHQmode, "uhq" }, + { E_SQmode, "sq" }, + { E_USQmode, "usq" }, + { E_DQmode, "dq" }, + { E_UDQmode, "udq" }, + { E_TQmode, "tq" }, + { E_UTQmode, "utq" }, + { E_HAmode, "ha" }, + { E_UHAmode, "uha" }, + { E_SAmode, "sa" }, + { E_USAmode, "usa" }, + { E_DAmode, "da" }, + { E_UDAmode, "uda" }, + { E_TAmode, "ta" }, + { E_UTAmode, "uta" } }; const arm_fixed_mode_set fixed_conv_modes[] = { - { QQmode, "qq" }, - { UQQmode, "uqq" }, - { HQmode, "hq" }, - { UHQmode, "uhq" }, - { SQmode, "sq" }, - { USQmode, "usq" }, - { DQmode, "dq" }, - { UDQmode, "udq" }, - { TQmode, "tq" }, - { UTQmode, "utq" }, - { HAmode, "ha" }, - { UHAmode, "uha" }, - { SAmode, "sa" }, - { USAmode, "usa" }, - { DAmode, "da" }, - { UDAmode, "uda" }, - { TAmode, "ta" }, - { UTAmode, "uta" }, - { QImode, "qi" }, - { HImode, "hi" }, - { SImode, "si" }, - { DImode, "di" }, - { TImode, "ti" }, - { SFmode, "sf" }, - { DFmode, "df" } + { E_QQmode, "qq" }, + { E_UQQmode, "uqq" }, + { E_HQmode, "hq" }, + { E_UHQmode, "uhq" }, + { E_SQmode, "sq" }, + { E_USQmode, "usq" }, + { E_DQmode, "dq" }, + { E_UDQmode, "udq" }, + { E_TQmode, "tq" }, + { E_UTQmode, "utq" }, + { E_HAmode, "ha" }, + { E_UHAmode, "uha" }, + { E_SAmode, "sa" }, + { E_USAmode, "usa" }, + { E_DAmode, "da" }, + { E_UDAmode, "uda" }, + { E_TAmode, "ta" }, + { E_UTAmode, "uta" }, + { E_QImode, "qi" }, + { E_HImode, "hi" }, + { E_SImode, "si" }, + { E_DImode, "di" }, + { E_TImode, "ti" }, + { E_SFmode, "sf" }, + { E_DFmode, "df" } }; unsigned int i, j; Index: gcc/config/i386/i386-builtin-types.awk =================================================================== --- gcc/config/i386/i386-builtin-types.awk 2017-02-23 19:54:22.000000000 +0000 +++ gcc/config/i386/i386-builtin-types.awk 2017-07-13 09:18:17.565868789 +0100 @@ -187,7 +187,7 @@ END { printf ",\n " else printf ", " - printf vect_mode[i] "mode" + printf "E_" vect_mode[i] "mode" } print "\n};\n\n" Index: gcc/config/i386/i386-builtin.def =================================================================== --- gcc/config/i386/i386-builtin.def 2017-07-08 11:37:45.816948583 +0100 +++ gcc/config/i386/i386-builtin.def 2017-07-13 09:18:17.566868676 +0100 @@ -66,11 +66,11 @@ BDESC_END (COMI, PCMPESTR) BDESC_FIRST (pcmpestr, PCMPESTR, OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestri128", IX86_BUILTIN_PCMPESTRI128, UNKNOWN, 0) BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestrm128", IX86_BUILTIN_PCMPESTRM128, UNKNOWN, 0) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestria128", IX86_BUILTIN_PCMPESTRA128, UNKNOWN, (int) CCAmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestric128", IX86_BUILTIN_PCMPESTRC128, UNKNOWN, (int) CCCmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestrio128", IX86_BUILTIN_PCMPESTRO128, UNKNOWN, (int) CCOmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestris128", IX86_BUILTIN_PCMPESTRS128, UNKNOWN, (int) CCSmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestriz128", IX86_BUILTIN_PCMPESTRZ128, UNKNOWN, (int) CCZmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestria128", IX86_BUILTIN_PCMPESTRA128, UNKNOWN, (int) E_CCAmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestric128", IX86_BUILTIN_PCMPESTRC128, UNKNOWN, (int) E_CCCmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestrio128", IX86_BUILTIN_PCMPESTRO128, UNKNOWN, (int) E_CCOmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestris128", IX86_BUILTIN_PCMPESTRS128, UNKNOWN, (int) E_CCSmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpestr, "__builtin_ia32_pcmpestriz128", IX86_BUILTIN_PCMPESTRZ128, UNKNOWN, (int) E_CCZmode) BDESC_END (PCMPESTR, PCMPISTR) @@ -78,11 +78,11 @@ BDESC_END (PCMPESTR, PCMPISTR) BDESC_FIRST (pcmpistr, PCMPISTR, OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistri128", IX86_BUILTIN_PCMPISTRI128, UNKNOWN, 0) BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistrm128", IX86_BUILTIN_PCMPISTRM128, UNKNOWN, 0) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistria128", IX86_BUILTIN_PCMPISTRA128, UNKNOWN, (int) CCAmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistric128", IX86_BUILTIN_PCMPISTRC128, UNKNOWN, (int) CCCmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistrio128", IX86_BUILTIN_PCMPISTRO128, UNKNOWN, (int) CCOmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistris128", IX86_BUILTIN_PCMPISTRS128, UNKNOWN, (int) CCSmode) -BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistriz128", IX86_BUILTIN_PCMPISTRZ128, UNKNOWN, (int) CCZmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistria128", IX86_BUILTIN_PCMPISTRA128, UNKNOWN, (int) E_CCAmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistric128", IX86_BUILTIN_PCMPISTRC128, UNKNOWN, (int) E_CCCmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistrio128", IX86_BUILTIN_PCMPISTRO128, UNKNOWN, (int) E_CCOmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistris128", IX86_BUILTIN_PCMPISTRS128, UNKNOWN, (int) E_CCSmode) +BDESC (OPTION_MASK_ISA_SSE4_2, CODE_FOR_sse4_2_pcmpistr, "__builtin_ia32_pcmpistriz128", IX86_BUILTIN_PCMPISTRZ128, UNKNOWN, (int) E_CCZmode) BDESC_END (PCMPISTR, SPECIAL_ARGS) Index: gcc/config/microblaze/microblaze.c =================================================================== --- gcc/config/microblaze/microblaze.c 2017-07-05 16:29:19.589061906 +0100 +++ gcc/config/microblaze/microblaze.c 2017-07-13 09:18:17.567868562 +0100 @@ -374,7 +374,7 @@ double_memory_operand (rtx op, machine_m return 1; return memory_address_p ((GET_MODE_CLASS (mode) == MODE_INT - ? SImode : SFmode), + ? E_SImode : E_SFmode), plus_constant (Pmode, addr, 4)); } Index: gcc/config/mmix/mmix.c =================================================================== --- gcc/config/mmix/mmix.c 2017-02-23 19:54:26.000000000 +0000 +++ gcc/config/mmix/mmix.c 2017-07-13 09:18:17.567868562 +0100 @@ -2647,12 +2647,12 @@ #define CCEND {UNKNOWN, NULL, NULL} #undef CCEND static const struct cc_type_conv cc_convs[] - = {{CC_FUNmode, cc_fun_convs}, - {CC_FPmode, cc_fp_convs}, - {CC_FPEQmode, cc_fpeq_convs}, - {CC_UNSmode, cc_uns_convs}, - {CCmode, cc_signed_convs}, - {DImode, cc_di_convs}}; + = {{E_CC_FUNmode, cc_fun_convs}, + {E_CC_FPmode, cc_fp_convs}, + {E_CC_FPEQmode, cc_fpeq_convs}, + {E_CC_UNSmode, cc_uns_convs}, + {E_CCmode, cc_signed_convs}, + {E_DImode, cc_di_convs}}; size_t i; int j; Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-05 16:29:19.591761905 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:17.571868109 +0100 @@ -3543,67 +3543,67 @@ rs6000_init_hard_regno_mode_ok (bool glo }; static const struct fuse_insns addis_insns[] = { - { SFmode, DImode, RELOAD_REG_FPR, + { E_SFmode, E_DImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_di_sf_load, CODE_FOR_fusion_vsx_di_sf_store }, - { SFmode, SImode, RELOAD_REG_FPR, + { E_SFmode, E_SImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_si_sf_load, CODE_FOR_fusion_vsx_si_sf_store }, - { DFmode, DImode, RELOAD_REG_FPR, + { E_DFmode, E_DImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_di_df_load, CODE_FOR_fusion_vsx_di_df_store }, - { DFmode, SImode, RELOAD_REG_FPR, + { E_DFmode, E_SImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_si_df_load, CODE_FOR_fusion_vsx_si_df_store }, - { DImode, DImode, RELOAD_REG_FPR, + { E_DImode, E_DImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_di_di_load, CODE_FOR_fusion_vsx_di_di_store }, - { DImode, SImode, RELOAD_REG_FPR, + { E_DImode, E_SImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_si_di_load, CODE_FOR_fusion_vsx_si_di_store }, - { QImode, DImode, RELOAD_REG_GPR, + { E_QImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_qi_load, CODE_FOR_fusion_gpr_di_qi_store }, - { QImode, SImode, RELOAD_REG_GPR, + { E_QImode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_qi_load, CODE_FOR_fusion_gpr_si_qi_store }, - { HImode, DImode, RELOAD_REG_GPR, + { E_HImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_hi_load, CODE_FOR_fusion_gpr_di_hi_store }, - { HImode, SImode, RELOAD_REG_GPR, + { E_HImode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_hi_load, CODE_FOR_fusion_gpr_si_hi_store }, - { SImode, DImode, RELOAD_REG_GPR, + { E_SImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_si_load, CODE_FOR_fusion_gpr_di_si_store }, - { SImode, SImode, RELOAD_REG_GPR, + { E_SImode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_si_load, CODE_FOR_fusion_gpr_si_si_store }, - { SFmode, DImode, RELOAD_REG_GPR, + { E_SFmode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_sf_load, CODE_FOR_fusion_gpr_di_sf_store }, - { SFmode, SImode, RELOAD_REG_GPR, + { E_SFmode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_sf_load, CODE_FOR_fusion_gpr_si_sf_store }, - { DImode, DImode, RELOAD_REG_GPR, + { E_DImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_di_load, CODE_FOR_fusion_gpr_di_di_store }, - { DFmode, DImode, RELOAD_REG_GPR, + { E_DFmode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_df_load, CODE_FOR_fusion_gpr_di_df_store }, }; @@ -15456,7 +15456,7 @@ htm_expand_builtin (tree exp, rtx target if (nonvoid) { - machine_mode tmode = (uses_spr) ? insn_op->mode : SImode; + machine_mode tmode = (uses_spr) ? insn_op->mode : E_SImode; if (!target || GET_MODE (target) != tmode || (uses_spr && !(*insn_op->predicate) (target, tmode))) Index: gcc/config/rl78/rl78.c =================================================================== --- gcc/config/rl78/rl78.c 2017-07-05 16:29:19.592661905 +0100 +++ gcc/config/rl78/rl78.c 2017-07-13 09:18:17.571868109 +0100 @@ -86,12 +86,12 @@ struct mduc_reg_type struct mduc_reg_type mduc_regs[] = { - {0xf00e8, QImode}, - {0xffff0, HImode}, - {0xffff2, HImode}, - {0xf2224, HImode}, - {0xf00e0, HImode}, - {0xf00e2, HImode} + {0xf00e8, E_QImode}, + {0xffff0, E_HImode}, + {0xffff2, E_HImode}, + {0xf2224, E_HImode}, + {0xf00e0, E_HImode}, + {0xf00e2, E_HImode} }; struct GTY(()) machine_function Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:17:39.960572804 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:17.574867770 +0100 @@ -3499,67 +3499,67 @@ rs6000_init_hard_regno_mode_ok (bool glo }; static const struct fuse_insns addis_insns[] = { - { SFmode, DImode, RELOAD_REG_FPR, + { E_SFmode, E_DImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_di_sf_load, CODE_FOR_fusion_vsx_di_sf_store }, - { SFmode, SImode, RELOAD_REG_FPR, + { E_SFmode, E_SImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_si_sf_load, CODE_FOR_fusion_vsx_si_sf_store }, - { DFmode, DImode, RELOAD_REG_FPR, + { E_DFmode, E_DImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_di_df_load, CODE_FOR_fusion_vsx_di_df_store }, - { DFmode, SImode, RELOAD_REG_FPR, + { E_DFmode, E_SImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_si_df_load, CODE_FOR_fusion_vsx_si_df_store }, - { DImode, DImode, RELOAD_REG_FPR, + { E_DImode, E_DImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_di_di_load, CODE_FOR_fusion_vsx_di_di_store }, - { DImode, SImode, RELOAD_REG_FPR, + { E_DImode, E_SImode, RELOAD_REG_FPR, CODE_FOR_fusion_vsx_si_di_load, CODE_FOR_fusion_vsx_si_di_store }, - { QImode, DImode, RELOAD_REG_GPR, + { E_QImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_qi_load, CODE_FOR_fusion_gpr_di_qi_store }, - { QImode, SImode, RELOAD_REG_GPR, + { E_QImode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_qi_load, CODE_FOR_fusion_gpr_si_qi_store }, - { HImode, DImode, RELOAD_REG_GPR, + { E_HImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_hi_load, CODE_FOR_fusion_gpr_di_hi_store }, - { HImode, SImode, RELOAD_REG_GPR, + { E_HImode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_hi_load, CODE_FOR_fusion_gpr_si_hi_store }, - { SImode, DImode, RELOAD_REG_GPR, + { E_SImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_si_load, CODE_FOR_fusion_gpr_di_si_store }, - { SImode, SImode, RELOAD_REG_GPR, + { E_SImode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_si_load, CODE_FOR_fusion_gpr_si_si_store }, - { SFmode, DImode, RELOAD_REG_GPR, + { E_SFmode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_sf_load, CODE_FOR_fusion_gpr_di_sf_store }, - { SFmode, SImode, RELOAD_REG_GPR, + { E_SFmode, E_SImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_si_sf_load, CODE_FOR_fusion_gpr_si_sf_store }, - { DImode, DImode, RELOAD_REG_GPR, + { E_DImode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_di_load, CODE_FOR_fusion_gpr_di_di_store }, - { DFmode, DImode, RELOAD_REG_GPR, + { E_DFmode, E_DImode, RELOAD_REG_GPR, CODE_FOR_fusion_gpr_di_df_load, CODE_FOR_fusion_gpr_di_df_store }, }; @@ -14939,7 +14939,7 @@ htm_expand_builtin (tree exp, rtx target if (nonvoid) { - machine_mode tmode = (uses_spr) ? insn_op->mode : SImode; + machine_mode tmode = (uses_spr) ? insn_op->mode : E_SImode; if (!target || GET_MODE (target) != tmode || (uses_spr && !(*insn_op->predicate) (target, tmode))) Index: gcc/config/sh/sh.h =================================================================== --- gcc/config/sh/sh.h 2017-02-23 19:54:22.000000000 +0000 +++ gcc/config/sh/sh.h 2017-07-13 09:18:17.574867770 +0100 @@ -689,7 +689,8 @@ #define VALID_REGISTER_P(REGNO) \ /* The mode that should be generally used to store a register by itself in the stack, or to load it back. */ #define REGISTER_NATURAL_MODE(REGNO) \ - (FP_REGISTER_P (REGNO) ? SFmode : XD_REGISTER_P (REGNO) ? DFmode : SImode) + (FP_REGISTER_P (REGNO) ? E_SFmode \ + : XD_REGISTER_P (REGNO) ? E_DFmode : E_SImode) #define FIRST_PSEUDO_REGISTER 156 Index: gcc/config/sparc/sparc.c =================================================================== --- gcc/config/sparc/sparc.c 2017-07-12 14:49:07.993948709 +0100 +++ gcc/config/sparc/sparc.c 2017-07-13 09:18:17.575867657 +0100 @@ -5502,17 +5502,17 @@ emit_save_or_restore_regs (unsigned int if (reg0 && reg1) { - mode = SPARC_INT_REG_P (i) ? DImode : DFmode; + mode = SPARC_INT_REG_P (i) ? E_DImode : E_DFmode; regno = i; } else if (reg0) { - mode = SPARC_INT_REG_P (i) ? SImode : SFmode; + mode = SPARC_INT_REG_P (i) ? E_SImode : E_SFmode; regno = i; } else if (reg1) { - mode = SPARC_INT_REG_P (i) ? SImode : SFmode; + mode = SPARC_INT_REG_P (i) ? E_SImode : E_SFmode; regno = i + 1; offset += 4; } Index: gcc/config/xtensa/xtensa.c =================================================================== --- gcc/config/xtensa/xtensa.c 2017-06-16 07:49:01.164077421 +0100 +++ gcc/config/xtensa/xtensa.c 2017-07-13 09:18:17.576867543 +0100 @@ -2331,7 +2331,8 @@ print_operand (FILE *file, rtx x, int le if (GET_CODE (x) == MEM && (GET_MODE (x) == DFmode || GET_MODE (x) == DImode)) { - x = adjust_address (x, GET_MODE (x) == DFmode ? SFmode : SImode, 4); + x = adjust_address (x, GET_MODE (x) == DFmode ? E_SFmode : E_SImode, + 4); output_address (GET_MODE (x), XEXP (x, 0)); } else Index: gcc/expmed.h =================================================================== --- gcc/expmed.h 2017-07-05 16:29:19.597161905 +0100 +++ gcc/expmed.h 2017-07-13 09:18:17.576867543 +0100 @@ -136,10 +136,10 @@ #define NUM_ALG_HASH_ENTRIES 307 #define NUM_MODE_INT \ (MAX_MODE_INT - MIN_MODE_INT + 1) #define NUM_MODE_PARTIAL_INT \ - (MIN_MODE_PARTIAL_INT == VOIDmode ? 0 \ + (MIN_MODE_PARTIAL_INT == E_VOIDmode ? 0 \ : MAX_MODE_PARTIAL_INT - MIN_MODE_PARTIAL_INT + 1) #define NUM_MODE_VECTOR_INT \ - (MIN_MODE_VECTOR_INT == VOIDmode ? 0 \ + (MIN_MODE_VECTOR_INT == E_VOIDmode ? 0 \ : MAX_MODE_VECTOR_INT - MIN_MODE_VECTOR_INT + 1) #define NUM_MODE_IP_INT (NUM_MODE_INT + NUM_MODE_PARTIAL_INT) Index: gcc/genoutput.c =================================================================== --- gcc/genoutput.c 2017-02-23 19:54:03.000000000 +0000 +++ gcc/genoutput.c 2017-07-13 09:18:17.576867543 +0100 @@ -127,7 +127,7 @@ struct operand_data static struct operand_data null_operand = { - 0, 0, "", "", VOIDmode, 0, 0, 0, 0, 0 + 0, 0, "", "", E_VOIDmode, 0, 0, 0, 0, 0 }; static struct operand_data *odata = &null_operand; @@ -253,7 +253,7 @@ output_operand_data (void) printf (" \"%s\",\n", d->constraint ? d->constraint : ""); - printf (" %smode,\n", GET_MODE_NAME (d->mode)); + printf (" E_%smode,\n", GET_MODE_NAME (d->mode)); printf (" %d,\n", d->strict_low); Index: gcc/genrecog.c =================================================================== --- gcc/genrecog.c 2017-07-05 16:29:19.598061904 +0100 +++ gcc/genrecog.c 2017-07-13 09:18:17.577867430 +0100 @@ -4489,7 +4489,7 @@ print_parameter_value (const parameter & break; case parameter::MODE: - printf ("%smode", GET_MODE_NAME ((machine_mode) param.value)); + printf ("E_%smode", GET_MODE_NAME ((machine_mode) param.value)); break; case parameter::INT: Index: gcc/lra.c =================================================================== --- gcc/lra.c 2017-04-18 19:52:34.020571018 +0100 +++ gcc/lra.c 2017-07-13 09:18:17.577867430 +0100 @@ -596,7 +596,7 @@ static struct lra_operand_data debug_ope { NULL, /* alternative */ 0, /* early_clobber_alts */ - VOIDmode, /* We are not interesting in the operand mode. */ + E_VOIDmode, /* We are not interesting in the operand mode. */ OP_IN, 0, 0, 0, 0 }; From patchwork Thu Jul 13 08:38:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107589 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1923704qge; Thu, 13 Jul 2017 01:39:05 -0700 (PDT) X-Received: by 10.84.163.75 with SMTP id n11mr8814413plg.186.1499935145418; Thu, 13 Jul 2017 01:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935145; cv=none; d=google.com; s=arc-20160816; b=JZ2P+jdbQRhokA3GnTTzvjedu4XMocAcloxbnMB1eZ/4Zh7drh13qPpFkaMLajPUmi xZChq44aT21B7dxeCWEu3eKKw3F0GhSb9iLYxr0MOGU50no3e54txEl2ZThHXXusfhWh RXKyYX5BT0hNoxKzGU00EQgvxO0E3l72/gPhfnOX6HjyXrJyN/tKk2q9MEJWIYL+YN3c qDKDJ7I09Ah9lGdrdvU0Nscc1Y7JvLES7lX0Oj0/A/QHGDmfhTIIU5fmPbEUsVRp+qS+ 6/kZliHziXj9jqgOLmqDdhLP9L946vJMQI+pIsTF6MA2Kxx2BlBh5PjIkILc5SAqj9e2 xRPg== 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=nLIzZm5RUN/TM0Vmq7o+PM1eYPnT4NwUDETfssfJxzI=; b=ZIUhdfBGEyV0u5KkCM/dibxATRLqpK741jsKKOc3+uZldpCPlevsCthvpeFBxehwWP NKqkKvhI2zGSJLAhQkLC6O/NdURfS8zUwE3XjuT3YYpUpEgMrsRXNivh4n+4QYoMtumm YkpWsNb0F1YmppNThCt9Ckg7m242NoXntkqwwinu1ibUj21WB4Bq0J4x8rhiopmvqWwr O+O+1o8AB8vVtJ+YqiB3hBxuOJLbk1r884Xg49fHRmzNJUbtc0pX5Xu0GAmKmv7LEB0w 0w12cs2fZWe3s5SzmSMzegz8mum9IWHz98uZVAnzaN7JtI1DtVLGhB8opu3l5uWDT95v /Qaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=aaDwBkTm; spf=pass (google.com: domain of gcc-patches-return-457993-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457993-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 k22si3769147pfa.197.2017.07.13.01.39.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:39:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457993-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=aaDwBkTm; spf=pass (google.com: domain of gcc-patches-return-457993-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457993-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=j2ERbcdU8ZMSe3sHD02epMS5kjxTN cefloT2OlRA6quPzQ89D1sezEUeFaPtdKJzTJrfk6XcQ7i3zsPy+xeWgA28NKgco fvkcHVbdTry62e74DxzbIFnFZLvFFVw5Qdd5bWGFJDiXUhdyCkT9CSVYb21TXqmM 01bHWF5183g2cw= 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=9nHBBzK5FBDJGvBjP7xU3mPtSYc=; b=aaD wBkTmOb2Gf/+X51ZTbjeJIOJ1Ypt5EgADkTb2J5lfqEDyUvl7WnOQ+95VvQ6cSZ/ 0+YRIcDKg7Dj9G9+Tau4WQdLWORUkGO43Q1MQLlUgn4qRg4TUgSgW6bxfJJJ0+Gh nQemVxmg9bHkMC8jdrKIgYDq8Y+y/xeL5SAkO+ks= Received: (qmail 71444 invoked by alias); 13 Jul 2017 08:38:52 -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 66455 invoked by uid 89); 13 Jul 2017 08:38:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=foldable, 20170612, 21051 X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:38:45 +0000 Received: by mail-wm0-f53.google.com with SMTP id f67so17933070wmh.1 for ; Thu, 13 Jul 2017 01:38:45 -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=nLIzZm5RUN/TM0Vmq7o+PM1eYPnT4NwUDETfssfJxzI=; b=qhj8ebLwTBfVdigI2y5eIzuYqWhQHwI2dYhwN2qovZWLFNDyG5vBeSfqim/YBurtMH W8xHWxad2X840HDev6L9OFMyjCQtuHesguVTStd6BxiyGXe2FnU4/THbKShtMK8Bdoem mjsueBgfQRtmd7MNWQ0mF+Xh2O6AzhSIRJBy0nYHKfYXZ3CoR2wAsqq8JuH8VBAEvN6N E5kURR39ea3Zi992QcgD/4uq8SxYZ2K64oulZkc1q0PRLxLv1JH7cC/yTg0sybN9jFs3 dcf7tIaNTKg//+bix4h8IuFEBhZYG4IGjdwz1jEmp4/2pW3kpGiERS/8lqsFt9IOwh5c bcUw== X-Gm-Message-State: AIVw112dgrFNGN1VEM1+KZdv5/Jvf/Lk+BbuFNDoK0uxaSH9b9oVjO21 uoxV9KBLsUHG12jMfk5WSg== X-Received: by 10.28.11.21 with SMTP id 21mr1227526wml.105.1499935123127; Thu, 13 Jul 2017 01:38:43 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b195sm2133589wmf.0.2017.07.13.01.38.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:38:42 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [03/77] Allow machine modes to be classes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:38:40 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87shi0n33j.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes various changes that allow modes like SImode to be classes rather than enums. Firstly, it adds inline functions for all mode size properties, with the macros being simple wrappers around them. This is necessary for the __builtin_constant_p trick to continue working effectively when the mode arguments are slightly more complex (but still foldable at compile time). These inline functions are trivial and heavily used. There's not much point keeping them out-of-line at -O0: if anything it would make debugging harder rather than easier, and it would also slow things down. The patch therefore marks them as "always_inline", if that's available. Later patches use this approach too. Using inline functions means that it's no longer possible to pass an int to GET_MODE_PRECISION etc. The Fortran and powerpcspe-c.c parts are needed to avoid instances of that. The patch continues to use enums for gencondmd.c, so that more mode comparisons are integer constant expressions when checking for always-true or always-false conditions. This is the only intended use of USE_ENUM_MODES. The patch also enforces the previous replacement of case statements by defining modes as: #define FOOmode ((void) 0, E_FOOmode) This adds no overhead but makes sure that new uses of "case FOOmode:" don't accidentally creep in when FOOmode has no specific class associated with it. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * genconditions.c (write_header): Add a "#define USE_ENUM_MODES". * genmodes.c (emit_insn_modes_h): Define FOOmode to E_FOOmode if USE_ENUM_MODES is defined and to ((void) 0, E_FOOmode) otherwise. * machmode.h (mode_size): Move earlier in file. (mode_precision): Likewise. (mode_inner): Likewise. (mode_nunits): Likewise. (mode_unit_size): Likewise. (unit_unit_precision): Likewise. (mode_wider): Likewise. (mode_2xwider): Likewise. (machine_mode): New class. (mode_to_bytes): New function. (mode_to_bits): Likewise. (mode_to_precision): Likewise. (mode_to_inner): Likewise. (mode_to_unit_size): Likewise. (mode_to_unit_precision): Likewise. (mode_to_nunits): Likewise. (GET_MODE_SIZE): Use mode_to_bytes. (GET_MODE_BITSIZE): Use mode_to_bits. (GET_MODE_PRECISION): Use mode_to_precision. (GET_MODE_INNER): Use mode_to_inner. (GET_MODE_UNIT_SIZE): Use mode_to_unit_size. (GET_MODE_UNIT_PRECISION): Use mode_to_unit_precision. (GET_MODE_NUNITS): Use mode_to_nunits. * system.h (ALWAYS_INLINE): New macro. * config/powerpcspe/powerpcspe-c.c (altivec_resolve_overloaded_builtin): Use machine_mode instead of int for arg1_mode and arg2_mode. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use machine_mode instead of int for "mode". Index: gcc/genconditions.c =================================================================== --- gcc/genconditions.c 2017-02-23 19:54:12.000000000 +0000 +++ gcc/genconditions.c 2017-07-13 09:18:20.866501621 +0100 @@ -67,6 +67,7 @@ #define CHECKING_P 0\n\ #undef ENABLE_RTL_FLAG_CHECKING\n\ #undef ENABLE_GC_CHECKING\n\ #undef ENABLE_GC_ALWAYS_COLLECT\n\ +#define USE_ENUM_MODES\n\ \n\ #include \"coretypes.h\"\n\ #include \"tm.h\"\n\ Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:17.576867543 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:20.866501621 +0100 @@ -1155,8 +1155,12 @@ enum machine_mode\n{"); printf ("%*s/* %s:%d */\n", 27 - count_, "", trim_filename (m->file), m->line); printf ("#define HAVE_%smode\n", m->name); - printf ("#define %smode E_%smode\n", + printf ("#ifdef USE_ENUM_MODES\n"); + printf ("#define %smode E_%smode\n", m->name, m->name); + printf ("#else\n"); + printf ("#define %smode ((void) 0, E_%smode)\n", m->name, m->name); + printf ("#endif\n"); } puts (" MAX_MACHINE_MODE,\n"); Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-02 10:05:20.996539436 +0100 +++ gcc/machmode.h 2017-07-13 09:18:20.866501621 +0100 @@ -20,6 +20,15 @@ Software Foundation; either version 3, o #ifndef HAVE_MACHINE_MODES #define HAVE_MACHINE_MODES +extern CONST_MODE_SIZE unsigned short mode_size[NUM_MACHINE_MODES]; +extern const unsigned short mode_precision[NUM_MACHINE_MODES]; +extern const unsigned char mode_inner[NUM_MACHINE_MODES]; +extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; +extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; +extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; +extern const unsigned char mode_wider[NUM_MACHINE_MODES]; +extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; + /* Get the name of mode MODE as a string. */ extern const char * const mode_name[NUM_MACHINE_MODES]; @@ -174,22 +183,98 @@ #define CLASS_HAS_WIDER_MODES_P(CLASS) #define POINTER_BOUNDS_MODE_P(MODE) \ (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS) -/* Get the size in bytes and bits of an object of mode MODE. */ +/* Return the base GET_MODE_SIZE value for MODE. */ -extern CONST_MODE_SIZE unsigned short mode_size[NUM_MACHINE_MODES]; +ALWAYS_INLINE unsigned short +mode_to_bytes (machine_mode mode) +{ +#if GCC_VERSION >= 4001 + return (__builtin_constant_p (mode) + ? mode_size_inline (mode) : mode_size[mode]); +#else + return mode_size[mode]; +#endif +} + +/* Return the base GET_MODE_BITSIZE value for MODE. */ + +ALWAYS_INLINE unsigned short +mode_to_bits (machine_mode mode) +{ + return mode_to_bytes (mode) * BITS_PER_UNIT; +} + +/* Return the base GET_MODE_PRECISION value for MODE. */ + +ALWAYS_INLINE unsigned short +mode_to_precision (machine_mode mode) +{ + return mode_precision[mode]; +} + +/* Return the base GET_MODE_INNER value for MODE. */ + +ALWAYS_INLINE machine_mode +mode_to_inner (machine_mode mode) +{ +#if GCC_VERSION >= 4001 + return (machine_mode) (__builtin_constant_p (mode) + ? mode_inner_inline (mode) : mode_inner[mode]); +#else + return (machine_mode) mode_inner[mode]; +#endif +} + +/* Return the base GET_MODE_UNIT_SIZE value for MODE. */ + +ALWAYS_INLINE unsigned char +mode_to_unit_size (machine_mode mode) +{ #if GCC_VERSION >= 4001 -#define GET_MODE_SIZE(MODE) \ - ((unsigned short) (__builtin_constant_p (MODE) \ - ? mode_size_inline (MODE) : mode_size[MODE])) + return (__builtin_constant_p (mode) + ? mode_unit_size_inline (mode) : mode_unit_size[mode]); #else -#define GET_MODE_SIZE(MODE) ((unsigned short) mode_size[MODE]) + return mode_unit_size[mode]; #endif -#define GET_MODE_BITSIZE(MODE) \ - ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT)) +} + +/* Return the base GET_MODE_UNIT_PRECISION value for MODE. */ + +ALWAYS_INLINE unsigned short +mode_to_unit_precision (machine_mode mode) +{ +#if GCC_VERSION >= 4001 + return (__builtin_constant_p (mode) + ? mode_unit_precision_inline (mode) : mode_unit_precision[mode]); +#else + return mode_unit_precision[mode]; +#endif +} + +/* Return the base GET_MODE_NUNITS value for MODE. */ + +ALWAYS_INLINE unsigned short +mode_to_nunits (machine_mode mode) +{ +#if GCC_VERSION >= 4001 + return (__builtin_constant_p (mode) + ? mode_nunits_inline (mode) : mode_nunits[mode]); +#else + return mode_nunits[mode]; +#endif +} + +/* Get the size in bytes of an object of mode MODE. */ + +#define GET_MODE_SIZE(MODE) (mode_to_bytes (MODE)) + +/* Get the size in bits of an object of mode MODE. */ + +#define GET_MODE_BITSIZE(MODE) (mode_to_bits (MODE)) /* Get the number of value bits of an object of mode MODE. */ -extern const unsigned short mode_precision[NUM_MACHINE_MODES]; -#define GET_MODE_PRECISION(MODE) mode_precision[MODE] + +#define GET_MODE_PRECISION(MODE) (mode_to_precision (MODE)) /* Get the number of integral bits of an object of mode MODE. */ extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES]; @@ -210,51 +295,22 @@ #define GET_MODE_MASK(MODE) mode_mask_ar mode of the vector elements. For complex modes it is the mode of the real and imaginary parts. For other modes it is MODE itself. */ -extern const unsigned char mode_inner[NUM_MACHINE_MODES]; -#if GCC_VERSION >= 4001 -#define GET_MODE_INNER(MODE) \ - ((machine_mode) (__builtin_constant_p (MODE) \ - ? mode_inner_inline (MODE) : mode_inner[MODE])) -#else -#define GET_MODE_INNER(MODE) ((machine_mode) mode_inner[MODE]) -#endif +#define GET_MODE_INNER(MODE) (mode_to_inner (MODE)) /* Get the size in bytes or bits of the basic parts of an object of mode MODE. */ -extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; -#if GCC_VERSION >= 4001 -#define GET_MODE_UNIT_SIZE(MODE) \ - ((unsigned char) (__builtin_constant_p (MODE) \ - ? mode_unit_size_inline (MODE) : mode_unit_size[MODE])) -#else -#define GET_MODE_UNIT_SIZE(MODE) mode_unit_size[MODE] -#endif +#define GET_MODE_UNIT_SIZE(MODE) mode_to_unit_size (MODE) #define GET_MODE_UNIT_BITSIZE(MODE) \ ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)) -extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; -#if GCC_VERSION >= 4001 -#define GET_MODE_UNIT_PRECISION(MODE) \ - ((unsigned short) (__builtin_constant_p (MODE) \ - ? mode_unit_precision_inline (MODE)\ - : mode_unit_precision[MODE])) -#else -#define GET_MODE_UNIT_PRECISION(MODE) mode_unit_precision[MODE] -#endif - +#define GET_MODE_UNIT_PRECISION(MODE) (mode_to_unit_precision (MODE)) -/* Get the number of units in the object. */ +/* Get the number of units in an object of mode MODE. This is 2 for + complex modes and the number of elements for vector modes. */ -extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; -#if GCC_VERSION >= 4001 -#define GET_MODE_NUNITS(MODE) \ - ((unsigned char) (__builtin_constant_p (MODE) \ - ? mode_nunits_inline (MODE) : mode_nunits[MODE])) -#else -#define GET_MODE_NUNITS(MODE) mode_nunits[MODE] -#endif +#define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE)) /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ Index: gcc/system.h =================================================================== --- gcc/system.h 2017-06-12 17:05:23.281759459 +0100 +++ gcc/system.h 2017-07-13 09:18:20.866501621 +0100 @@ -745,6 +745,12 @@ #define gcc_checking_assert(EXPR) gcc_as #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR))) #endif +#if GCC_VERSION >= 4000 +#define ALWAYS_INLINE inline __attribute__ ((always_inline)) +#else +#define ALWAYS_INLINE inline +#endif + /* Use gcc_unreachable() to mark unreachable locations (like an unreachable default case of a switch. Do not use gcc_assert(0). */ #if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING Index: gcc/config/powerpcspe/powerpcspe-c.c =================================================================== --- gcc/config/powerpcspe/powerpcspe-c.c 2017-07-13 09:18:19.088697749 +0100 +++ gcc/config/powerpcspe/powerpcspe-c.c 2017-07-13 09:18:20.865501731 +0100 @@ -6504,8 +6504,8 @@ altivec_resolve_overloaded_builtin (loca if (fcode == P6_OV_BUILTIN_CMPB) { int overloaded_code; - int arg1_mode = TYPE_MODE (types[0]); - int arg2_mode = TYPE_MODE (types[1]); + machine_mode arg1_mode = TYPE_MODE (types[0]); + machine_mode arg2_mode = TYPE_MODE (types[1]); if (nargs != 2) { Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c 2017-05-03 08:46:30.890861653 +0100 +++ gcc/fortran/trans-types.c 2017-07-13 09:18:20.865501731 +0100 @@ -362,22 +362,23 @@ #define NAMED_SUBROUTINE(a,b,c,d) \ void gfc_init_kinds (void) { - unsigned int mode; + machine_mode mode; int i_index, r_index, kind; bool saw_i4 = false, saw_i8 = false; bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false; - for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT; mode++) + for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT; + mode = (machine_mode) ((int) mode + 1)) { int kind, bitsize; - if (!targetm.scalar_mode_supported_p ((machine_mode) mode)) + if (!targetm.scalar_mode_supported_p (mode)) continue; /* The middle end doesn't support constants larger than 2*HWI. Perhaps the target hook shouldn't have accepted these either, but just to be safe... */ - bitsize = GET_MODE_BITSIZE ((machine_mode) mode); + bitsize = GET_MODE_BITSIZE (mode); if (bitsize > 2*HOST_BITS_PER_WIDE_INT) continue; @@ -417,15 +418,16 @@ gfc_init_kinds (void) /* Set the maximum integer kind. Used with at least BOZ constants. */ gfc_max_integer_kind = gfc_integer_kinds[i_index - 1].kind; - for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT; mode++) + for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT; + mode = (machine_mode) ((int) mode + 1)) { const struct real_format *fmt = - REAL_MODE_FORMAT ((machine_mode) mode); + REAL_MODE_FORMAT (mode); int kind; if (fmt == NULL) continue; - if (!targetm.scalar_mode_supported_p ((machine_mode) mode)) + if (!targetm.scalar_mode_supported_p (mode)) continue; /* Only let float, double, long double and __float128 go through. From patchwork Thu Jul 13 08:39:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107590 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1924253qge; Thu, 13 Jul 2017 01:39:50 -0700 (PDT) X-Received: by 10.99.127.76 with SMTP id p12mr8188349pgn.258.1499935190279; Thu, 13 Jul 2017 01:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935190; cv=none; d=google.com; s=arc-20160816; b=piVPFL3hUDHTp587nibC71kiVXXu2zdXKjZFDGV9KowWrVQ4VQVAzZIw34V/QunvG2 cqAV5FwJ2s7/TFxOA1DFQjcN99KwibC070gKvmwbwyErsrvScFTbl2AmhqCvxHbxLbQb kOaT6+80igClfJjHW+EjSSY5t8BnmLjir/dRsryX1kLAg/PH0swNcu4r69JKrG/n/cKA 1ftWIJbdCV+aCKP5zkaLMIvM3Bdg8HV1NEVce9e+LuY1PNPjXGxViCRFIjBuKyBB8Kdo ufLjAViPRfR2RFiEwSvUVb803312cZ6uB6GTN9K7srI6+bG5R1J9/dLLYL4Bw9kc0PdA PAug== 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=Nib5la228Y83cLAVQTlVwdMz4aQHjhidJv94f++KsKM=; b=Xoq6SMmyL+G/TPyPaEpfAT2CF7bzpuhZJ46Y2sZtjycAZAFHMddTK8osqC1wyeuz1F 5RHLGFtOfSK32PZU6kaMHdlQvm26cfrPhB256DbrfKnKZLkGmcmlOqXFSyX9+pdeDOBF 3/J9eb4qCaLeKUZnhbM3bOSx78ZnpJdZTXfXvz8h6DvCvzzFCLYXVdwQnExLpyz2nc7S 0CIXrWpCPJDdWfVPtTjQNbfoHWYaKihonJKEdeIySkw5fVeYZO6+zKYyGZqcxcv31Qy4 UgMYew03NhNLrNRxy9SqvP40C6B+4VSvbIwnT/KnTgSB7s/JYb4s2RT09kO6K9XaivIk kVZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=ZWHLEcal; spf=pass (google.com: domain of gcc-patches-return-457994-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457994-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 e1si2189416ple.74.2017.07.13.01.39.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:39:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457994-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=ZWHLEcal; spf=pass (google.com: domain of gcc-patches-return-457994-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457994-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=EbbPTo4HmpzeMRGa3kKnnSBMN0n/I 6aBoSbyfQed7IgC44gdhYvgc+UJCo6+hjNNXDPxyGd8aALGJK0nKMMLfuIiAaC+M FBqYucA2r7mJlmpsSiUx7e+Ex5a31VTR7IcXLgahH4XMP/h5zimdvZgPyhkZoH0O QQQXFCj4Hxg5a4= 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=6e3CyVKxJ1NhRQDGEfytkFJ1lRQ=; b=ZWH LEcalbAoFpjnqJVw0yJV07Go8U6SGRXlJsi4aVnSG7/q53y5u9pBS0aFxi5Mn/oA ws8w9ZPubQrJRuY/oW1sEEizzMcTCzeWOnswVKpfC7rIgQzwnS3huuE/yDdVr/Au MbqUjU55UvvUgKK3UEi/Tkvf7GO6iRmW8SDt4lUg= Received: (qmail 111023 invoked by alias); 13 Jul 2017 08:39:29 -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 109834 invoked by uid 89); 13 Jul 2017 08:39:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Properties X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:39:22 +0000 Received: by mail-wm0-f54.google.com with SMTP id 62so16365755wmw.1 for ; Thu, 13 Jul 2017 01:39:21 -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=Nib5la228Y83cLAVQTlVwdMz4aQHjhidJv94f++KsKM=; b=HVUFsyD0L33piVl803YSf5KnRaIVfWQc7zCVDabOBlsFifPw6yZsBh6IBJwKAmQPJr WS3tTLlIkFA5qTPtPOlIHqoEQEiOFjGJarpCwGYzshqdK6XCV4lENKqQoz9vY3iiTKwC 7XaZ+FW34/H7e1n814NHTIGKLbcjmrLG+F7iSpPSG6+nFL44F4q1WZHa7rMkCCqXG3dE VXKxZpVe7Gc6rrd/UzQ2BMdCrV4iqO6dfeeiCIk8JCQZocs9gPEq1/ujp4PST7qe2AXq JzpdQAwjuLg148MDZrq3HxMTbW9iVXZRVIjKxTTkixfs8AYnyT8u2VokM+G0m+pcdKbf KM5Q== X-Gm-Message-State: AIVw110m6stsFwzIwPwmmUkkOd+NYMhFTY8LxjB0HJD9oB3WdwpsHtTa FKeMIw0gHTICvjQwAgrNAw== X-Received: by 10.28.136.143 with SMTP id k137mr1161932wmd.62.1499935159034; Thu, 13 Jul 2017 01:39:19 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 185sm5588179wmn.33.2017.07.13.01.39.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:39:18 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [04/77] Add FOR_EACH iterators for modes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:39:16 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87o9son32j.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The new iterators are: - FOR_EACH_MODE_IN_CLASS: iterate over all the modes in a mode class. - FOR_EACH_MODE_FROM: iterate over all the modes in a class, starting at a given mode. - FOR_EACH_WIDER_MODE: iterate over all the modes in a class, starting at the next widest mode after a given mode. - FOR_EACH_2XWIDER_MODE: same, but considering only modes that are two times wider than the previous mode. - FOR_EACH_MODE_UNTIL: iterate over all the modes in a class until a given mode is reached. - FOR_EACH_MODE: iterate over all the modes in a class between two given modes, inclusive of the first but not the second. These help with the stronger type checking added by later patches, since every new mode will be in the same class as the previous one. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (mode_traits): New structure. (get_narrowest_mode): New function. (mode_iterator::start): Likewise. (mode_iterator::iterate_p): Likewise. (mode_iterator::get_wider): Likewise. (mode_iterator::get_known_wider): Likewise. (mode_iterator::get_2xwider): Likewise. (FOR_EACH_MODE_IN_CLASS): New mode iterator. (FOR_EACH_MODE): Likewise. (FOR_EACH_MODE_FROM): Likewise. (FOR_EACH_MODE_UNTIL): Likewise. (FOR_EACH_WIDER_MODE): Likewise. (FOR_EACH_2XWIDER_MODE): Likewise. * builtins.c (expand_builtin_strlen): Use new mode iterators. * combine.c (simplify_comparison): Likewise * config/i386/i386.c (type_natural_mode): Likewise. * cse.c (cse_insn): Likewise. * dse.c (find_shift_sequence): Likewise. * emit-rtl.c (init_derived_machine_modes): Likewise. (init_emit_once): Likewise. * explow.c (hard_function_value): Likewise. * expmed.c (init_expmed_one_mode): Likewise. (extract_fixed_bit_field_1): Likewise. (extract_bit_field_1): Likewise. (expand_divmod): Likewise. (emit_store_flag_1): Likewise. * expr.c (init_expr_target): Likewise. (convert_move): Likewise. (alignment_for_piecewise_move): Likewise. (widest_int_mode_for_size): Likewise. (emit_block_move_via_movmem): Likewise. (copy_blkmode_to_reg): Likewise. (set_storage_via_setmem): Likewise. (compress_float_constant): Likewise. * omp-low.c (omp_clause_aligned_alignment): Likewise. * optabs-query.c (get_best_extraction_insn): Likewise. * optabs.c (expand_binop): Likewise. (expand_twoval_unop): Likewise. (expand_twoval_binop): Likewise. (widen_leading): Likewise. (widen_bswap): Likewise. (expand_parity): Likewise. (expand_unop): Likewise. (prepare_cmp_insn): Likewise. (prepare_float_lib_cmp): Likewise. (expand_float): Likewise. (expand_fix): Likewise. (expand_sfix_optab): Likewise. * postreload.c (move2add_use_add2_insn): Likewise. * reg-stack.c (reg_to_stack): Likewise. * reginfo.c (choose_hard_reg_mode): Likewise. * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise. * stmt.c (emit_case_decision_tree): Likewise. * stor-layout.c (mode_for_size): Likewise. (smallest_mode_for_size): Likewise. (mode_for_vector): Likewise. (finish_bitfield_representative): Likewise. * tree-ssa-math-opts.c (target_supports_divmod_p): Likewise. * tree-vect-generic.c (type_for_widest_vector_mode): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. gcc/ada/ * gcc-interface/misc.c (fp_prec_to_size): Use new mode iterators. (fp_size_to_prec): Likewise. gcc/c-family/ * c-common.c (c_common_fixed_point_type_for_size): Use new mode iterators. * c-cppbuiltin.c (c_cpp_builtins): Likewise. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:20.866501621 +0100 +++ gcc/machmode.h 2017-07-13 09:18:21.533429040 +0100 @@ -29,6 +29,44 @@ #define HAVE_MACHINE_MODES extern const unsigned char mode_wider[NUM_MACHINE_MODES]; extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; +template +struct mode_traits +{ + /* For use by the machmode support code only. + + There are cases in which the machmode support code needs to forcibly + convert a machine_mode to a specific mode class T, and in which the + context guarantees that this is valid without the need for an assert. + This can be done using: + + return typename mode_traits::from_int (mode); + + when returning a T and: + + res = T (typename mode_traits::from_int (mode)); + + when assigning to a value RES that must be assignment-compatible + with (but possibly not the same as) T. + + Here we use an enum type distinct from machine_mode but with the + same range as machine_mode. T should have a constructor that + accepts this enum type; it should not have a constructor that + accepts machine_mode. + + We use this somewhat indirect approach to avoid too many constructor + calls when the compiler is built with -O0. For example, even in + unoptimized code, the return statement above would construct the + returned T directly from the numerical value of MODE. */ + enum from_int { dummy = MAX_MACHINE_MODE }; +}; + +template<> +struct mode_traits +{ + /* machine_mode itself needs no conversion. */ + typedef machine_mode from_int; +}; + /* Get the name of mode MODE as a string. */ extern const char * const mode_name[NUM_MACHINE_MODES]; @@ -395,6 +433,16 @@ #define GET_MODE_ALIGNMENT(MODE) get_mod #define GET_CLASS_NARROWEST_MODE(CLASS) \ ((machine_mode) class_narrowest_mode[CLASS]) +/* Return the narrowest mode in T's class. */ + +template +inline T +get_narrowest_mode (T mode) +{ + return typename mode_traits::from_int + (class_narrowest_mode[GET_MODE_CLASS (mode)]); +} + /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD and the mode whose class is Pmode and whose size is POINTER_SIZE. */ @@ -425,4 +473,95 @@ struct int_n_data_t { extern bool int_n_enabled_p[NUM_INT_N_ENTS]; extern const int_n_data_t int_n_data[NUM_INT_N_ENTS]; +namespace mode_iterator +{ + /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ + + inline void + start (machine_mode *iter, enum mode_class mclass) + { + *iter = GET_CLASS_NARROWEST_MODE (mclass); + } + + /* Return true if mode iterator *ITER has not reached the end. */ + + inline bool + iterate_p (machine_mode *iter) + { + return *iter != E_VOIDmode; + } + + /* Set mode iterator *ITER to the next widest mode in the same class, + if any. */ + + inline void + get_wider (machine_mode *iter) + { + *iter = GET_MODE_WIDER_MODE (*iter); + } + + /* Set mode iterator *ITER to the next widest mode in the same class. + Such a mode is known to exist. */ + + inline void + get_known_wider (machine_mode *iter) + { + *iter = GET_MODE_WIDER_MODE (*iter); + gcc_checking_assert (*iter != VOIDmode); + } + + /* Set mode iterator *ITER to the mode that is two times wider than the + current one, if such a mode exists. */ + + inline void + get_2xwider (machine_mode *iter) + { + *iter = GET_MODE_2XWIDER_MODE (*iter); + } +} + +/* Make ITERATOR iterate over all the modes in mode class CLASS, + from narrowest to widest. */ +#define FOR_EACH_MODE_IN_CLASS(ITERATOR, CLASS) \ + for (mode_iterator::start (&(ITERATOR), CLASS); \ + mode_iterator::iterate_p (&(ITERATOR)); \ + mode_iterator::get_wider (&(ITERATOR))) + +/* Make ITERATOR iterate over all the modes in the range [START, END), + in order of increasing width. */ +#define FOR_EACH_MODE(ITERATOR, START, END) \ + for ((ITERATOR) = (START); \ + (ITERATOR) != (END); \ + mode_iterator::get_known_wider (&(ITERATOR))) + +/* Make ITERATOR iterate over START and all wider modes in the same + class, in order of increasing width. */ +#define FOR_EACH_MODE_FROM(ITERATOR, START) \ + for ((ITERATOR) = (START); \ + mode_iterator::iterate_p (&(ITERATOR)); \ + mode_iterator::get_wider (&(ITERATOR))) + +/* Make ITERATOR iterate over modes in the range [NARROWEST, END) + in order of increasing width, where NARROWEST is the narrowest mode + in END's class. */ +#define FOR_EACH_MODE_UNTIL(ITERATOR, END) \ + FOR_EACH_MODE (ITERATOR, get_narrowest_mode (END), END) + +/* Make ITERATOR iterate over modes in the same class as MODE, in order + of increasing width. Start at the first mode wider than START, + or don't iterate at all if there is no wider mode. */ +#define FOR_EACH_WIDER_MODE(ITERATOR, START) \ + for ((ITERATOR) = (START), mode_iterator::get_wider (&(ITERATOR)); \ + mode_iterator::iterate_p (&(ITERATOR)); \ + mode_iterator::get_wider (&(ITERATOR))) + +/* Make ITERATOR iterate over modes in the same class as MODE, in order + of increasing width, and with each mode being twice the width of the + previous mode. Start at the mode that is two times wider than START, + or don't iterate at all if there is no such mode. */ +#define FOR_EACH_2XWIDER_MODE(ITERATOR, START) \ + for ((ITERATOR) = (START), mode_iterator::get_2xwider (&(ITERATOR)); \ + mode_iterator::iterate_p (&(ITERATOR)); \ + mode_iterator::get_2xwider (&(ITERATOR))) + #endif /* not HAVE_MACHINE_MODES */ Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2017-07-13 09:17:38.381630186 +0100 +++ gcc/builtins.c 2017-07-13 09:18:21.522430235 +0100 @@ -2790,7 +2790,7 @@ expand_builtin_strlen (tree exp, rtx tar tree src = CALL_EXPR_ARG (exp, 0); rtx src_reg; rtx_insn *before_strlen; - machine_mode insn_mode = target_mode; + machine_mode insn_mode; enum insn_code icode = CODE_FOR_nothing; unsigned int align; @@ -2818,13 +2818,11 @@ expand_builtin_strlen (tree exp, rtx tar return NULL_RTX; /* Bail out if we can't compute strlen in the right mode. */ - while (insn_mode != VOIDmode) + FOR_EACH_MODE_FROM (insn_mode, target_mode) { icode = optab_handler (strlen_optab, insn_mode); if (icode != CODE_FOR_nothing) break; - - insn_mode = GET_MODE_WIDER_MODE (insn_mode); } if (insn_mode == VOIDmode) return NULL_RTX; Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-05 16:29:19.580961907 +0100 +++ gcc/combine.c 2017-07-13 09:18:21.524430018 +0100 @@ -11852,9 +11852,7 @@ simplify_comparison (enum rtx_code code, } else if (c0 == c1) - for (tmode = GET_CLASS_NARROWEST_MODE - (GET_MODE_CLASS (GET_MODE (op0))); - tmode != GET_MODE (op0); tmode = GET_MODE_WIDER_MODE (tmode)) + FOR_EACH_MODE_UNTIL (tmode, GET_MODE (op0)) if ((unsigned HOST_WIDE_INT) c0 == GET_MODE_MASK (tmode)) { op0 = gen_lowpart_or_truncate (tmode, inner_op0); @@ -12727,75 +12725,81 @@ simplify_comparison (enum rtx_code code, if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) < UNITS_PER_WORD && ! have_insn_for (COMPARE, mode)) - for (tmode = GET_MODE_WIDER_MODE (mode); - (tmode != VOIDmode && HWI_COMPUTABLE_MODE_P (tmode)); - tmode = GET_MODE_WIDER_MODE (tmode)) - if (have_insn_for (COMPARE, tmode)) - { - int zero_extended; - - /* If this is a test for negative, we can make an explicit - test of the sign bit. Test this first so we can use - a paradoxical subreg to extend OP0. */ - - if (op1 == const0_rtx && (code == LT || code == GE) - && HWI_COMPUTABLE_MODE_P (mode)) - { - unsigned HOST_WIDE_INT sign - = HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (mode) - 1); - op0 = simplify_gen_binary (AND, tmode, - gen_lowpart (tmode, op0), - gen_int_mode (sign, tmode)); - code = (code == LT) ? NE : EQ; - break; - } - - /* If the only nonzero bits in OP0 and OP1 are those in the - narrower mode and this is an equality or unsigned comparison, - we can use the wider mode. Similarly for sign-extended - values, in which case it is true for all comparisons. */ - zero_extended = ((code == EQ || code == NE - || code == GEU || code == GTU - || code == LEU || code == LTU) - && (nonzero_bits (op0, tmode) - & ~GET_MODE_MASK (mode)) == 0 - && ((CONST_INT_P (op1) - || (nonzero_bits (op1, tmode) - & ~GET_MODE_MASK (mode)) == 0))); - - if (zero_extended - || ((num_sign_bit_copies (op0, tmode) - > (unsigned int) (GET_MODE_PRECISION (tmode) - - GET_MODE_PRECISION (mode))) - && (num_sign_bit_copies (op1, tmode) - > (unsigned int) (GET_MODE_PRECISION (tmode) - - GET_MODE_PRECISION (mode))))) - { - /* If OP0 is an AND and we don't have an AND in MODE either, - make a new AND in the proper mode. */ - if (GET_CODE (op0) == AND - && !have_insn_for (AND, mode)) + FOR_EACH_WIDER_MODE (tmode, mode) + { + if (!HWI_COMPUTABLE_MODE_P (tmode)) + break; + if (have_insn_for (COMPARE, tmode)) + { + int zero_extended; + + /* If this is a test for negative, we can make an explicit + test of the sign bit. Test this first so we can use + a paradoxical subreg to extend OP0. */ + + if (op1 == const0_rtx && (code == LT || code == GE) + && HWI_COMPUTABLE_MODE_P (mode)) + { + unsigned HOST_WIDE_INT sign + = HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (mode) - 1); op0 = simplify_gen_binary (AND, tmode, - gen_lowpart (tmode, - XEXP (op0, 0)), - gen_lowpart (tmode, - XEXP (op0, 1))); - else - { - if (zero_extended) - { - op0 = simplify_gen_unary (ZERO_EXTEND, tmode, op0, mode); - op1 = simplify_gen_unary (ZERO_EXTEND, tmode, op1, mode); - } - else - { - op0 = simplify_gen_unary (SIGN_EXTEND, tmode, op0, mode); - op1 = simplify_gen_unary (SIGN_EXTEND, tmode, op1, mode); - } - break; - } - } - } + gen_lowpart (tmode, op0), + gen_int_mode (sign, tmode)); + code = (code == LT) ? NE : EQ; + break; + } + + /* If the only nonzero bits in OP0 and OP1 are those in the + narrower mode and this is an equality or unsigned comparison, + we can use the wider mode. Similarly for sign-extended + values, in which case it is true for all comparisons. */ + zero_extended = ((code == EQ || code == NE + || code == GEU || code == GTU + || code == LEU || code == LTU) + && (nonzero_bits (op0, tmode) + & ~GET_MODE_MASK (mode)) == 0 + && ((CONST_INT_P (op1) + || (nonzero_bits (op1, tmode) + & ~GET_MODE_MASK (mode)) == 0))); + + if (zero_extended + || ((num_sign_bit_copies (op0, tmode) + > (unsigned int) (GET_MODE_PRECISION (tmode) + - GET_MODE_PRECISION (mode))) + && (num_sign_bit_copies (op1, tmode) + > (unsigned int) (GET_MODE_PRECISION (tmode) + - GET_MODE_PRECISION (mode))))) + { + /* If OP0 is an AND and we don't have an AND in MODE either, + make a new AND in the proper mode. */ + if (GET_CODE (op0) == AND + && !have_insn_for (AND, mode)) + op0 = simplify_gen_binary (AND, tmode, + gen_lowpart (tmode, + XEXP (op0, 0)), + gen_lowpart (tmode, + XEXP (op0, 1))); + else + { + if (zero_extended) + { + op0 = simplify_gen_unary (ZERO_EXTEND, tmode, + op0, mode); + op1 = simplify_gen_unary (ZERO_EXTEND, tmode, + op1, mode); + } + else + { + op0 = simplify_gen_unary (SIGN_EXTEND, tmode, + op0, mode); + op1 = simplify_gen_unary (SIGN_EXTEND, tmode, + op1, mode); + } + break; + } + } + } + } /* We may have changed the comparison operands. Re-canonicalize. */ if (swap_commutative_operands_p (op0, op1)) Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-07-13 09:18:19.062700632 +0100 +++ gcc/config/i386/i386.c 2017-07-13 09:18:21.528429583 +0100 @@ -9034,7 +9034,7 @@ type_natural_mode (const_tree type, cons mode = MIN_MODE_VECTOR_INT; /* Get the mode which has this inner mode and number of units. */ - for (; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_FROM (mode, mode) if (GET_MODE_NUNITS (mode) == TYPE_VECTOR_SUBPARTS (type) && GET_MODE_INNER (mode) == innermode) { Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-03-28 16:19:22.000000000 +0100 +++ gcc/cse.c 2017-07-13 09:18:21.529429475 +0100 @@ -4845,12 +4845,11 @@ cse_insn (rtx_insn *insn) { machine_mode wider_mode; - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode - && GET_MODE_PRECISION (wider_mode) <= BITS_PER_WORD - && src_related == 0; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { + if (GET_MODE_PRECISION (wider_mode) > BITS_PER_WORD) + break; + struct table_elt *const_elt = lookup (src_const, HASH (src_const, wider_mode), wider_mode); @@ -4864,6 +4863,9 @@ cse_insn (rtx_insn *insn) src_related = gen_lowpart (mode, const_elt->exp); break; } + + if (src_related != 0) + break; } } @@ -4880,10 +4882,11 @@ cse_insn (rtx_insn *insn) machine_mode tmode; rtx new_and = gen_rtx_AND (VOIDmode, NULL_RTX, XEXP (src, 1)); - for (tmode = GET_MODE_WIDER_MODE (mode); - GET_MODE_SIZE (tmode) <= UNITS_PER_WORD; - tmode = GET_MODE_WIDER_MODE (tmode)) + FOR_EACH_WIDER_MODE (tmode, mode) { + if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) + break; + rtx inner = gen_lowpart (tmode, XEXP (src, 0)); struct table_elt *larger_elt; @@ -4930,12 +4933,13 @@ cse_insn (rtx_insn *insn) PUT_CODE (memory_extend_rtx, extend_op); XEXP (memory_extend_rtx, 0) = src; - for (tmode = GET_MODE_WIDER_MODE (mode); - GET_MODE_SIZE (tmode) <= UNITS_PER_WORD; - tmode = GET_MODE_WIDER_MODE (tmode)) + FOR_EACH_WIDER_MODE (tmode, mode) { struct table_elt *larger_elt; + if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) + break; + PUT_MODE (memory_extend_rtx, tmode); larger_elt = lookup (memory_extend_rtx, HASH (memory_extend_rtx, tmode), tmode); Index: gcc/dse.c =================================================================== --- gcc/dse.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/dse.c 2017-07-13 09:18:21.530429366 +0100 @@ -1583,15 +1583,17 @@ find_shift_sequence (int access_size, justify the value we want to read but is available in one insn on the machine. */ - for (new_mode = smallest_mode_for_size (access_size * BITS_PER_UNIT, - MODE_INT); - GET_MODE_BITSIZE (new_mode) <= BITS_PER_WORD; - new_mode = GET_MODE_WIDER_MODE (new_mode)) + FOR_EACH_MODE_FROM (new_mode, + smallest_mode_for_size (access_size * BITS_PER_UNIT, + MODE_INT)) { rtx target, new_reg, new_lhs; rtx_insn *shift_seq, *insn; int cost; + if (GET_MODE_BITSIZE (new_mode) > BITS_PER_WORD) + break; + /* If a constant was stored into memory, try to simplify it here, otherwise the cost of the shift might preclude this optimization e.g. at -Os, even when no actual shift will be needed. */ Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-05-04 11:58:11.115865939 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:21.530429366 +0100 @@ -5873,9 +5873,8 @@ init_derived_machine_modes (void) byte_mode = VOIDmode; word_mode = VOIDmode; - for (machine_mode mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + machine_mode mode; + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) { if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT && byte_mode == VOIDmode) @@ -5957,23 +5956,17 @@ init_emit_once (void) const REAL_VALUE_TYPE *const r = (i == 0 ? &dconst0 : i == 1 ? &dconst1 : &dconst2); - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) const_tiny_rtx[i][(int) mode] = const_double_from_real_value (*r, mode); - for (mode = GET_CLASS_NARROWEST_MODE (MODE_DECIMAL_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_DECIMAL_FLOAT) const_tiny_rtx[i][(int) mode] = const_double_from_real_value (*r, mode); const_tiny_rtx[i][(int) VOIDmode] = GEN_INT (i); - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) const_tiny_rtx[i][(int) mode] = GEN_INT (i); for (mode = MIN_MODE_PARTIAL_INT; @@ -5984,52 +5977,40 @@ init_emit_once (void) const_tiny_rtx[3][(int) VOIDmode] = constm1_rtx; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) const_tiny_rtx[3][(int) mode] = constm1_rtx; for (mode = MIN_MODE_PARTIAL_INT; mode <= MAX_MODE_PARTIAL_INT; mode = (machine_mode)((int)(mode) + 1)) const_tiny_rtx[3][(int) mode] = constm1_rtx; - - for (mode = GET_CLASS_NARROWEST_MODE (MODE_COMPLEX_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + + FOR_EACH_MODE_IN_CLASS (mode, MODE_COMPLEX_INT) { rtx inner = const_tiny_rtx[0][(int)GET_MODE_INNER (mode)]; const_tiny_rtx[0][(int) mode] = gen_rtx_CONCAT (mode, inner, inner); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_COMPLEX_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_COMPLEX_FLOAT) { rtx inner = const_tiny_rtx[0][(int)GET_MODE_INNER (mode)]; const_tiny_rtx[0][(int) mode] = gen_rtx_CONCAT (mode, inner, inner); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT) { const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0); const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1); const_tiny_rtx[3][(int) mode] = gen_const_vector (mode, 3); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FLOAT) { const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0); const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FRACT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FRACT) { FCONST0 (mode).data.high = 0; FCONST0 (mode).data.low = 0; @@ -6038,9 +6019,7 @@ init_emit_once (void) FCONST0 (mode), mode); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_UFRACT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_UFRACT) { FCONST0 (mode).data.high = 0; FCONST0 (mode).data.low = 0; @@ -6049,9 +6028,7 @@ init_emit_once (void) FCONST0 (mode), mode); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_ACCUM); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_ACCUM) { FCONST0 (mode).data.high = 0; FCONST0 (mode).data.low = 0; @@ -6071,9 +6048,7 @@ init_emit_once (void) FCONST1 (mode), mode); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_UACCUM); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_UACCUM) { FCONST0 (mode).data.high = 0; FCONST0 (mode).data.low = 0; @@ -6093,31 +6068,23 @@ init_emit_once (void) FCONST1 (mode), mode); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FRACT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FRACT) { const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_UFRACT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_UFRACT) { const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_ACCUM); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_ACCUM) { const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0); const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1); } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_UACCUM); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_UACCUM) { const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0); const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1); @@ -6131,9 +6098,7 @@ init_emit_once (void) if (STORE_FLAG_VALUE == 1) const_tiny_rtx[1][(int) BImode] = const1_rtx; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_POINTER_BOUNDS); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_POINTER_BOUNDS) { wide_int wi_zero = wi::zero (GET_MODE_PRECISION (mode)); const_tiny_rtx[0][mode] = immed_wide_int_const (wi_zero, mode); Index: gcc/explow.c =================================================================== --- gcc/explow.c 2017-06-30 12:50:38.436653781 +0100 +++ gcc/explow.c 2017-07-13 09:18:21.531429258 +0100 @@ -1912,9 +1912,7 @@ hard_function_value (const_tree valtype, since the value of bytes will then be large enough that no mode will match anyway. */ - for (tmpmode = GET_CLASS_NARROWEST_MODE (MODE_INT); - tmpmode != VOIDmode; - tmpmode = GET_MODE_WIDER_MODE (tmpmode)) + FOR_EACH_MODE_IN_CLASS (tmpmode, MODE_INT) { /* Have we found a large enough mode? */ if (GET_MODE_SIZE (tmpmode) >= bytes) Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:17:39.972572368 +0100 +++ gcc/expmed.c 2017-07-13 09:18:21.531429258 +0100 @@ -204,8 +204,7 @@ init_expmed_one_mode (struct init_expmed if (SCALAR_INT_MODE_P (mode)) { - for (mode_from = MIN_MODE_INT; mode_from <= MAX_MODE_INT; - mode_from = (machine_mode)(mode_from + 1)) + FOR_EACH_MODE_IN_CLASS (mode_from, MODE_INT) init_expmed_one_conv (all, mode, mode_from, speed); } if (GET_MODE_CLASS (mode) == MODE_INT) @@ -1586,7 +1585,7 @@ extract_bit_field_1 (rtx str_rtx, unsign else new_mode = MIN_MODE_VECTOR_INT; - for (; new_mode != VOIDmode ; new_mode = GET_MODE_WIDER_MODE (new_mode)) + FOR_EACH_MODE_FROM (new_mode, new_mode) if (GET_MODE_SIZE (new_mode) == GET_MODE_SIZE (GET_MODE (op0)) && GET_MODE_UNIT_SIZE (new_mode) == GET_MODE_SIZE (tmode) && targetm.vector_mode_supported_p (new_mode)) @@ -2029,8 +2028,7 @@ extract_fixed_bit_field_1 (machine_mode /* Find the narrowest integer mode that contains the field. */ - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) if (GET_MODE_BITSIZE (mode) >= bitsize + bitnum) { op0 = convert_to_mode (mode, op0, 0); @@ -4094,15 +4092,13 @@ expand_divmod (int rem_flag, enum tree_c optab2 = (op1_is_pow2 ? optab1 : (unsignedp ? udivmod_optab : sdivmod_optab)); - for (compute_mode = mode; compute_mode != VOIDmode; - compute_mode = GET_MODE_WIDER_MODE (compute_mode)) + FOR_EACH_MODE_FROM (compute_mode, mode) if (optab_handler (optab1, compute_mode) != CODE_FOR_nothing || optab_handler (optab2, compute_mode) != CODE_FOR_nothing) break; if (compute_mode == VOIDmode) - for (compute_mode = mode; compute_mode != VOIDmode; - compute_mode = GET_MODE_WIDER_MODE (compute_mode)) + FOR_EACH_MODE_FROM (compute_mode, mode) if (optab_libfunc (optab1, compute_mode) || optab_libfunc (optab2, compute_mode)) break; @@ -5504,8 +5500,7 @@ emit_store_flag_1 (rtx target, enum rtx_ } mclass = GET_MODE_CLASS (mode); - for (compare_mode = mode; compare_mode != VOIDmode; - compare_mode = GET_MODE_WIDER_MODE (compare_mode)) + FOR_EACH_MODE_FROM (compare_mode, mode) { machine_mode optab_mode = mclass == MODE_CC ? CCmode : compare_mode; icode = optab_handler (cstore_optab, optab_mode); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-06-30 12:50:38.246662537 +0100 +++ gcc/expr.c 2017-07-13 09:18:21.532429149 +0100 @@ -177,12 +177,10 @@ init_expr_target (void) mem = gen_rtx_MEM (VOIDmode, gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1)); - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) { machine_mode srcmode; - for (srcmode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); srcmode != mode; - srcmode = GET_MODE_WIDER_MODE (srcmode)) + FOR_EACH_MODE_UNTIL (srcmode, mode) { enum insn_code ic; @@ -549,8 +547,7 @@ convert_move (rtx to, rtx from, int unsi int shift_amount; /* Search for a mode to convert via. */ - for (intermediate = from_mode; intermediate != VOIDmode; - intermediate = GET_MODE_WIDER_MODE (intermediate)) + FOR_EACH_MODE_FROM (intermediate, from_mode) if (((can_extend_p (to_mode, intermediate, unsignedp) != CODE_FOR_nothing) || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate) @@ -702,12 +699,14 @@ alignment_for_piecewise_move (unsigned i { machine_mode tmode, xmode; - for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT), xmode = tmode; - tmode != VOIDmode; - xmode = tmode, tmode = GET_MODE_WIDER_MODE (tmode)) - if (GET_MODE_SIZE (tmode) > max_pieces - || SLOW_UNALIGNED_ACCESS (tmode, align)) - break; + xmode = GET_CLASS_NARROWEST_MODE (MODE_INT); + FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) + { + if (GET_MODE_SIZE (tmode) > max_pieces + || SLOW_UNALIGNED_ACCESS (tmode, align)) + break; + xmode = tmode; + } align = MAX (align, GET_MODE_ALIGNMENT (xmode)); } @@ -723,8 +722,7 @@ widest_int_mode_for_size (unsigned int s { machine_mode tmode, mode = VOIDmode; - for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); - tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) + FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) if (GET_MODE_SIZE (tmode) < size) mode = tmode; @@ -1728,8 +1726,7 @@ emit_block_move_via_movmem (rtx x, rtx y including more than one in the machine description unless the more limited one has some advantage. */ - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) { enum insn_code code = direct_optab_handler (movmem_optab, mode); @@ -2790,9 +2787,7 @@ copy_blkmode_to_reg (machine_mode mode, { /* Find the smallest integer mode large enough to hold the entire structure. */ - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) /* Have we found a large enough mode? */ if (GET_MODE_SIZE (mode) >= bytes) break; @@ -3048,8 +3043,7 @@ set_storage_via_setmem (rtx object, rtx expected_size = min_size; } - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) { enum insn_code code = direct_optab_handler (setmem_optab, mode); @@ -3788,9 +3782,7 @@ compress_float_constant (rtx x, rtx y) else oldcost = set_src_cost (force_const_mem (dstmode, y), dstmode, speed); - for (srcmode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (orig_srcmode)); - srcmode != orig_srcmode; - srcmode = GET_MODE_WIDER_MODE (srcmode)) + FOR_EACH_MODE_UNTIL (srcmode, orig_srcmode) { enum insn_code ic; rtx trunc_y; Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c 2017-07-05 16:29:19.600761904 +0100 +++ gcc/omp-low.c 2017-07-13 09:18:21.533429040 +0100 @@ -3445,9 +3445,7 @@ omp_clause_aligned_alignment (tree claus static enum mode_class classes[] = { MODE_INT, MODE_VECTOR_INT, MODE_FLOAT, MODE_VECTOR_FLOAT }; for (int i = 0; i < 4; i += 2) - for (mode = GET_CLASS_NARROWEST_MODE (classes[i]); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, classes[i]) { vmode = targetm.vectorize.preferred_simd_mode (mode); if (GET_MODE_CLASS (vmode) != classes[i + 1]) Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/optabs-query.c 2017-07-13 09:18:21.534428932 +0100 @@ -194,21 +194,20 @@ get_best_extraction_insn (extraction_ins machine_mode field_mode) { machine_mode mode = smallest_mode_for_size (struct_bits, MODE_INT); - while (mode != VOIDmode) + FOR_EACH_MODE_FROM (mode, mode) { if (get_extraction_insn (insn, pattern, type, mode)) { - while (mode != VOIDmode - && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (field_mode) - && !TRULY_NOOP_TRUNCATION_MODES_P (insn->field_mode, - field_mode)) + FOR_EACH_MODE_FROM (mode, mode) { + if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (field_mode) + || TRULY_NOOP_TRUNCATION_MODES_P (insn->field_mode, + field_mode)) + break; get_extraction_insn (insn, pattern, type, mode); - mode = GET_MODE_WIDER_MODE (mode); } return true; } - mode = GET_MODE_WIDER_MODE (mode); } return false; } Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-02 09:32:32.142745257 +0100 +++ gcc/optabs.c 2017-07-13 09:18:21.534428932 +0100 @@ -1250,9 +1250,7 @@ expand_binop (machine_mode mode, optab b if (CLASS_HAS_WIDER_MODES_P (mclass) && methods != OPTAB_DIRECT && methods != OPTAB_LIB) - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing || (binoptab == smul_optab @@ -1793,9 +1791,7 @@ expand_binop (machine_mode mode, optab b if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (find_widening_optab_handler (binoptab, wider_mode, mode, 1) != CODE_FOR_nothing @@ -1951,9 +1947,7 @@ expand_twoval_unop (optab unoptab, rtx o if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { @@ -2034,9 +2028,7 @@ expand_twoval_binop (optab binoptab, rtx if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing) { @@ -2138,9 +2130,7 @@ widen_leading (machine_mode mode, rtx op if (CLASS_HAS_WIDER_MODES_P (mclass)) { machine_mode wider_mode; - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { @@ -2310,9 +2300,7 @@ widen_bswap (machine_mode mode, rtx op0, if (!CLASS_HAS_WIDER_MODES_P (mclass)) return NULL_RTX; - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) if (optab_handler (bswap_optab, wider_mode) != CODE_FOR_nothing) goto found; return NULL_RTX; @@ -2374,8 +2362,7 @@ expand_parity (machine_mode mode, rtx op if (CLASS_HAS_WIDER_MODES_P (mclass)) { machine_mode wider_mode; - for (wider_mode = mode; wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_MODE_FROM (wider_mode, mode) { if (optab_handler (popcount_optab, wider_mode) != CODE_FOR_nothing) { @@ -2827,9 +2814,7 @@ expand_unop (machine_mode mode, optab un } if (CLASS_HAS_WIDER_MODES_P (mclass)) - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { @@ -2996,9 +2981,7 @@ expand_unop (machine_mode mode, optab un if (CLASS_HAS_WIDER_MODES_P (mclass)) { - for (wider_mode = GET_MODE_WIDER_MODE (mode); - wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_WIDER_MODE (wider_mode, mode) { if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing || optab_libfunc (unoptab, wider_mode)) @@ -3799,9 +3782,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx /* Try to use a memory block compare insn - either cmpstr or cmpmem will do. */ - for (cmp_mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - cmp_mode != VOIDmode; - cmp_mode = GET_MODE_WIDER_MODE (cmp_mode)) + FOR_EACH_MODE_IN_CLASS (cmp_mode, MODE_INT) { cmp_code = direct_optab_handler (cmpmem_optab, cmp_mode); if (cmp_code == CODE_FOR_nothing) @@ -3863,9 +3844,8 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx mclass = GET_MODE_CLASS (mode); test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y); - cmp_mode = mode; - do - { + FOR_EACH_MODE_FROM (cmp_mode, mode) + { enum insn_code icode; icode = optab_handler (cbranch_optab, cmp_mode); if (icode != CODE_FOR_nothing @@ -3889,9 +3869,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx if (methods == OPTAB_DIRECT || !CLASS_HAS_WIDER_MODES_P (mclass)) break; - cmp_mode = GET_MODE_WIDER_MODE (cmp_mode); } - while (cmp_mode != VOIDmode); if (methods != OPTAB_LIB_WIDEN) goto fail; @@ -4074,9 +4052,7 @@ prepare_float_lib_cmp (rtx x, rtx y, enu bool reversed_p = false; cmp_mode = targetm.libgcc_cmp_return_mode (); - for (mode = orig_mode; - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_FROM (mode, orig_mode) { if (code_to_optab (comparison) && (libfunc = optab_libfunc (code_to_optab (comparison), mode))) @@ -4649,10 +4625,8 @@ expand_float (rtx to, rtx from, int unsi wider mode. If the integer mode is wider than the mode of FROM, we can do the conversion signed even if the input is unsigned. */ - for (fmode = GET_MODE (to); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) - for (imode = GET_MODE (from); imode != VOIDmode; - imode = GET_MODE_WIDER_MODE (imode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (to)) + FOR_EACH_MODE_FROM (imode, GET_MODE (from)) { int doing_unsigned = unsignedp; @@ -4699,8 +4673,7 @@ expand_float (rtx to, rtx from, int unsi least as wide as the target. Using FMODE will avoid rounding woes with unsigned values greater than the signed maximum value. */ - for (fmode = GET_MODE (to); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (to)) if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_BITSIZE (fmode) && can_float_p (fmode, GET_MODE (from), 0) != CODE_FOR_nothing) break; @@ -4847,10 +4820,8 @@ expand_fix (rtx to, rtx from, int unsign this conversion. If the integer mode is wider than the mode of TO, we can do the conversion either signed or unsigned. */ - for (fmode = GET_MODE (from); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) - for (imode = GET_MODE (to); imode != VOIDmode; - imode = GET_MODE_WIDER_MODE (imode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) + FOR_EACH_MODE_FROM (imode, GET_MODE (to)) { int doing_unsigned = unsignedp; @@ -4910,8 +4881,7 @@ expand_fix (rtx to, rtx from, int unsign simply clears out that bit. The rest is trivial. */ if (unsignedp && GET_MODE_PRECISION (GET_MODE (to)) <= HOST_BITS_PER_WIDE_INT) - for (fmode = GET_MODE (from); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) if (CODE_FOR_nothing != can_fix_p (GET_MODE (to), fmode, 0, &must_trunc) && (!DECIMAL_FLOAT_MODE_P (fmode) || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (GET_MODE (to)))) @@ -5112,10 +5082,8 @@ expand_sfix_optab (rtx to, rtx from, con this conversion. If the integer mode is wider than the mode of TO, we can do the conversion either signed or unsigned. */ - for (fmode = GET_MODE (from); fmode != VOIDmode; - fmode = GET_MODE_WIDER_MODE (fmode)) - for (imode = GET_MODE (to); imode != VOIDmode; - imode = GET_MODE_WIDER_MODE (imode)) + FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) + FOR_EACH_MODE_FROM (imode, GET_MODE (to)) { icode = convert_optab_handler (tab, imode, fmode); if (icode != CODE_FOR_nothing) Index: gcc/postreload.c =================================================================== --- gcc/postreload.c 2017-02-23 19:54:03.000000000 +0000 +++ gcc/postreload.c 2017-07-13 09:18:21.535428823 +0100 @@ -1770,10 +1770,7 @@ move2add_use_add2_insn (rtx reg, rtx sym else if (sym == NULL_RTX && GET_MODE (reg) != BImode) { machine_mode narrow_mode; - for (narrow_mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - narrow_mode != VOIDmode - && narrow_mode != GET_MODE (reg); - narrow_mode = GET_MODE_WIDER_MODE (narrow_mode)) + FOR_EACH_MODE_UNTIL (narrow_mode, GET_MODE (reg)) { if (have_insn_for (STRICT_LOW_PART, narrow_mode) && ((reg_offset[regno] & ~GET_MODE_MASK (narrow_mode)) Index: gcc/reg-stack.c =================================================================== --- gcc/reg-stack.c 2017-02-23 19:54:20.000000000 +0000 +++ gcc/reg-stack.c 2017-07-13 09:18:21.535428823 +0100 @@ -3315,13 +3315,9 @@ reg_to_stack (void) for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++) { machine_mode mode; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) FP_MODE_REG (i, mode) = gen_rtx_REG (mode, i); - for (mode = GET_CLASS_NARROWEST_MODE (MODE_COMPLEX_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_COMPLEX_FLOAT) FP_MODE_REG (i, mode) = gen_rtx_REG (mode, i); } Index: gcc/reginfo.c =================================================================== --- gcc/reginfo.c 2017-03-28 16:19:28.000000000 +0100 +++ gcc/reginfo.c 2017-07-13 09:18:21.535428823 +0100 @@ -632,36 +632,28 @@ choose_hard_reg_mode (unsigned int regno held in REGNO. If none, we look for the largest floating-point mode. If we still didn't find a valid mode, try CCmode. */ - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) if ((unsigned) hard_regno_nregs[regno][mode] == nregs && HARD_REGNO_MODE_OK (regno, mode) && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) found_mode = mode; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) if ((unsigned) hard_regno_nregs[regno][mode] == nregs && HARD_REGNO_MODE_OK (regno, mode) && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) found_mode = mode; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FLOAT) if ((unsigned) hard_regno_nregs[regno][mode] == nregs && HARD_REGNO_MODE_OK (regno, mode) && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode)) found_mode = mode; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT) if ((unsigned) hard_regno_nregs[regno][mode] == nregs && HARD_REGNO_MODE_OK (regno, mode) && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)) Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-02 09:32:32.142745257 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:21.536428715 +0100 @@ -5663,10 +5663,8 @@ init_num_sign_bit_copies_in_rep (void) { machine_mode mode, in_mode; - for (in_mode = GET_CLASS_NARROWEST_MODE (MODE_INT); in_mode != VOIDmode; - in_mode = GET_MODE_WIDER_MODE (mode)) - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != in_mode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (in_mode, MODE_INT) + FOR_EACH_MODE_UNTIL (mode, in_mode) { machine_mode i; @@ -5677,7 +5675,7 @@ init_num_sign_bit_copies_in_rep (void) /* We are in in_mode. Count how many bits outside of mode have to be copies of the sign-bit. */ - for (i = mode; i != in_mode; i = GET_MODE_WIDER_MODE (i)) + FOR_EACH_MODE (i, mode, in_mode) { machine_mode wider = GET_MODE_WIDER_MODE (i); Index: gcc/stmt.c =================================================================== --- gcc/stmt.c 2017-06-30 12:50:38.965629405 +0100 +++ gcc/stmt.c 2017-07-13 09:18:21.536428715 +0100 @@ -868,8 +868,7 @@ emit_case_decision_tree (tree index_expr { int unsignedp = TYPE_UNSIGNED (index_type); machine_mode wider_mode; - for (wider_mode = GET_MODE (index); wider_mode != VOIDmode; - wider_mode = GET_MODE_WIDER_MODE (wider_mode)) + FOR_EACH_MODE_FROM (wider_mode, GET_MODE (index)) if (have_insn_for (COMPARE, wider_mode)) { index = convert_to_mode (wider_mode, index, unsignedp); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-05-18 07:51:11.855803833 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:21.536428715 +0100 @@ -306,8 +306,7 @@ mode_for_size (unsigned int size, enum m return BLKmode; /* Get the first mode which has this size, in the specified class. */ - for (mode = GET_CLASS_NARROWEST_MODE (mclass); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, mclass) if (GET_MODE_PRECISION (mode) == size) return mode; @@ -348,8 +347,7 @@ smallest_mode_for_size (unsigned int siz /* Get the first mode which has at least this size, in the specified class. */ - for (mode = GET_CLASS_NARROWEST_MODE (mclass); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, mclass) if (GET_MODE_PRECISION (mode) >= size) break; @@ -501,7 +499,7 @@ mode_for_vector (machine_mode innermode, /* Do not check vector_mode_supported_p here. We'll do that later in vector_type_mode. */ - for (; mode != VOIDmode ; mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_FROM (mode, mode) if (GET_MODE_NUNITS (mode) == nunits && GET_MODE_INNER (mode) == innermode) break; @@ -1895,8 +1893,7 @@ finish_bitfield_representative (tree rep gcc_assert (maxbitsize % BITS_PER_UNIT == 0); /* Find the smallest nice mode to use. */ - for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) if (GET_MODE_BITSIZE (mode) >= bitsize) break; if (mode != VOIDmode Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-07-05 16:29:19.601661904 +0100 +++ gcc/tree-ssa-math-opts.c 2017-07-13 09:18:21.537428606 +0100 @@ -3824,9 +3824,8 @@ target_supports_divmod_p (optab divmod_o { /* If optab_handler exists for div_optab, perhaps in a wider mode, we don't want to use the libfunc even if it exists for given mode. */ - for (machine_mode div_mode = mode; - div_mode != VOIDmode; - div_mode = GET_MODE_WIDER_MODE (div_mode)) + machine_mode div_mode; + FOR_EACH_MODE_FROM (div_mode, mode) if (optab_handler (div_optab, div_mode) != CODE_FOR_nothing) return false; Index: gcc/tree-vect-generic.c =================================================================== --- gcc/tree-vect-generic.c 2017-03-28 16:19:28.000000000 +0100 +++ gcc/tree-vect-generic.c 2017-07-13 09:18:21.537428606 +0100 @@ -1154,7 +1154,7 @@ type_for_widest_vector_mode (tree type, else mode = MIN_MODE_VECTOR_INT; - for (; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_FROM (mode, mode) if (GET_MODE_INNER (mode) == inner_mode && GET_MODE_NUNITS (mode) > best_nunits && optab_handler (op, mode) != CODE_FOR_nothing) Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-05 16:29:19.602561904 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:21.538428497 +0100 @@ -4228,12 +4228,12 @@ vectorizable_conversion (gimple *stmt, g <= GET_MODE_SIZE (TYPE_MODE (rhs_type)))) goto unsupported; - rhs_mode = TYPE_MODE (rhs_type); fltsz = GET_MODE_SIZE (TYPE_MODE (lhs_type)); - for (rhs_mode = GET_MODE_2XWIDER_MODE (TYPE_MODE (rhs_type)); - rhs_mode != VOIDmode && GET_MODE_SIZE (rhs_mode) <= fltsz; - rhs_mode = GET_MODE_2XWIDER_MODE (rhs_mode)) + FOR_EACH_2XWIDER_MODE (rhs_mode, TYPE_MODE (rhs_type)) { + if (GET_MODE_SIZE (rhs_mode) > fltsz) + break; + cvt_type = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), 0); cvt_type = get_same_sized_vectype (cvt_type, vectype_in); Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-05-24 09:25:11.592569829 +0100 +++ gcc/var-tracking.c 2017-07-13 09:18:21.539428389 +0100 @@ -6306,13 +6306,14 @@ prepare_call_arguments (basic_block bb, else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT || GET_MODE_CLASS (GET_MODE (x)) == MODE_PARTIAL_INT) { - machine_mode mode = GET_MODE (x); + machine_mode mode; - while ((mode = GET_MODE_WIDER_MODE (mode)) != VOIDmode - && GET_MODE_BITSIZE (mode) <= BITS_PER_WORD) + FOR_EACH_WIDER_MODE (mode, GET_MODE (x)) { - rtx reg = simplify_subreg (mode, x, GET_MODE (x), 0); + if (GET_MODE_BITSIZE (mode) > BITS_PER_WORD) + break; + rtx reg = simplify_subreg (mode, x, GET_MODE (x), 0); if (reg == NULL_RTX || !REG_P (reg)) continue; val = cselib_lookup (reg, mode, 0, VOIDmode); Index: gcc/ada/gcc-interface/misc.c =================================================================== --- gcc/ada/gcc-interface/misc.c 2017-05-03 08:46:30.761861657 +0100 +++ gcc/ada/gcc-interface/misc.c 2017-07-13 09:18:21.521430343 +0100 @@ -1313,8 +1313,7 @@ fp_prec_to_size (int prec) { machine_mode mode; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) if (GET_MODE_PRECISION (mode) == prec) return GET_MODE_BITSIZE (mode); @@ -1328,8 +1327,7 @@ fp_size_to_prec (int size) { machine_mode mode; - for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) if (GET_MODE_BITSIZE (mode) == size) return GET_MODE_PRECISION (mode); Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2017-07-08 11:37:46.129575607 +0100 +++ gcc/c-family/c-common.c 2017-07-13 09:18:21.523430126 +0100 @@ -2149,13 +2149,14 @@ c_common_type_for_size (unsigned int bit c_common_fixed_point_type_for_size (unsigned int ibit, unsigned int fbit, int unsignedp, int satp) { - machine_mode mode; + enum mode_class mclass; if (ibit == 0) - mode = unsignedp ? UQQmode : QQmode; + mclass = unsignedp ? MODE_UFRACT : MODE_FRACT; else - mode = unsignedp ? UHAmode : HAmode; + mclass = unsignedp ? MODE_UACCUM : MODE_ACCUM; - for (; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) + machine_mode mode; + FOR_EACH_MODE_IN_CLASS (mode, mclass) if (GET_MODE_IBIT (mode) >= ibit && GET_MODE_FBIT (mode) >= fbit) break; Index: gcc/c-family/c-cppbuiltin.c =================================================================== --- gcc/c-family/c-cppbuiltin.c 2017-07-13 09:18:19.010706397 +0100 +++ gcc/c-family/c-cppbuiltin.c 2017-07-13 09:18:21.523430126 +0100 @@ -1186,9 +1186,8 @@ c_cpp_builtins (cpp_reader *pfile) if (flag_building_libgcc) { /* Properties of floating-point modes for libgcc2.c. */ - for (machine_mode mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT); - mode != VOIDmode; - mode = GET_MODE_WIDER_MODE (mode)) + machine_mode mode; + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) { const char *name = GET_MODE_NAME (mode); char *macro_name From patchwork Thu Jul 13 08:39:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107591 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1924444qge; Thu, 13 Jul 2017 01:40:06 -0700 (PDT) X-Received: by 10.84.130.76 with SMTP id 70mr8752243plc.138.1499935206149; Thu, 13 Jul 2017 01:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935206; cv=none; d=google.com; s=arc-20160816; b=B5J5q89r+68hb/yiGj6OqmqGWTwRghtyMOoVAPGpQfGhxL8/Grp981z0ld/ZwYFhM1 dDbEr0X1u735xEY/EvacWLTG84v8kfS0j6h2vaKJyG43PunD39QvPgcsDSwYTldlKS6Z 3GX58Ig7QO/CPPYumOB7NyoYDmQY3+YOJ9eGWFopQrS+XzxJx2chZg/1Rat6Ma4X2xA3 2gOiNnKWwkyk3auLqCMSH79DKdY/VayYeEsM66l+AYxZElJWxxoJI6sw+mJthzkvJzzR DKg5hXA5QUO3wFD+Uk82Nh5z/loVgvP9AXRytsl5y9hCbGT2c0pS5AxpYlpyPs3LKYG6 uFFw== 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=z4H15vHlVbbi2ls6tjlDmCNkKbiZrGq+N05CDDAn9mE=; b=yOuInONJJEOTBY5pyxsXn1umeLobRtAMvIrCN/iDVrTXmF+WRYAmtABoAQr7Y5Qcg3 lxu18aAu/C+2ynfS/ask6uOiPOgzeYBf6zukiiQ4VUnmRgKJ2orBXWqEVeAdhItuxJlN utxHP8cj5pqn0EYmJHZdjmqdZRUTooIVtkfRRepIliKBCbtY9Pz2+0vqta4yn+zHmBTb mtDTVAJlM95EjaPu6ZTF3cOH8hNZm9A4qayC1Um4Al79+3fn4RkCqOpCGsmb03rO+xIp UC/0FjaZdS6NIQnRLDzB70mP+6OqL6DroKcToYMjrboNYMCketwNPNXD8CJhrCOIjMMu EkwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=fAs66004; spf=pass (google.com: domain of gcc-patches-return-457995-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457995-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 u6si4126981pld.97.2017.07.13.01.40.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457995-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=fAs66004; spf=pass (google.com: domain of gcc-patches-return-457995-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457995-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=aAwJq+I6QgGYiRfzssguqt4kjNtxU BH4UVj5YV4Has8T0OveQnMf3XqWCfVtNbFS2/+t3GQQYKEBgVuYU5y96adnLJVZU 2DzDQ1luph8eAnxQT+DqZeUWDsgD1JyuXlerGsngxcB5LVdh3/1UM7OZDumF8zGJ CUDTrjPHtw1TU4= 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=zXyavFCDq7u53bh/hTvuD+0J2Ks=; b=fAs 660048LCnQq2tvg/v5Dk/pOsA88fQ9lUFxA2e5ZGwh6o5ifvhX1GJmuom4NZXvaU CA+7d7wanrYNlTXHmwEciVfbWJPpK/rgPFh8vUWVON3yo5yQB3XT8CUjjBvzTm8h Qgz/yCcQpRvwut0HqgIwq7n18bMsV8Jjji4iGWfM= Received: (qmail 121196 invoked by alias); 13 Jul 2017 08:39:47 -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 120826 invoked by uid 89); 13 Jul 2017 08:39:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=10877 X-HELO: mail-wr0-f181.google.com Received: from mail-wr0-f181.google.com (HELO mail-wr0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:39:44 +0000 Received: by mail-wr0-f181.google.com with SMTP id r103so49397640wrb.0 for ; Thu, 13 Jul 2017 01:39:43 -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=z4H15vHlVbbi2ls6tjlDmCNkKbiZrGq+N05CDDAn9mE=; b=ZgoC0u4shNiz1YjZoOMz6asLU8nmU0XuTjMAuggyFKWwxCdo09bEn0KUQ7FK7Kbe0N XPfTwuFi5YUNEO2iWdSdL7YT3BV4w6q+dSOhy8eBdC3fSNfFYuDCSsMmjlFHshFqwJ2e sNT0jW7eOd/1vdevad7mx65ajQl9KjS6f/oxGeLikeB7Usevl3aC21IroxpsA1Lqom+y ZiEpzGbkSwH1nxnl1f26Q5DMuAaWeAeqg++DWUUvDwlzSkhqbNoCx28DLqc2TPZRbykG U5asDDuFZFDT4SE9MaHms12xWh+JAVQTXwKrwP0OmHU+fuYHTxz157uyyqQtlGFLWrFZ +CvQ== X-Gm-Message-State: AIVw113bgxRhyO48wg+Oe2bQVosfbw5N2p/ECENSN1J6bX7cFqea5a00 BK6BhM1bft6KoRxv0jqiew== X-Received: by 10.223.145.227 with SMTP id 90mr824460wri.171.1499935182097; Thu, 13 Jul 2017 01:39:42 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 32sm5610185wry.31.2017.07.13.01.39.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:39:41 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [05/77] Small tweak to array_value_type References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:39:39 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87k23cn31w.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Store the type mode in a variable so that a later, more mechanical patch can change its type. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-switch-conversion.c (array_value_type): Only read TYPE_MODE once. Use get_narrowest_mode instead of GET_CLASS_NARROWEST_MODE. Index: gcc/tree-switch-conversion.c =================================================================== --- gcc/tree-switch-conversion.c 2017-06-30 12:50:38.647644058 +0100 +++ gcc/tree-switch-conversion.c 2017-07-13 09:18:22.307345334 +0100 @@ -1034,7 +1034,6 @@ array_value_type (gswitch *swtch, tree t { unsigned int i, len = vec_safe_length (info->constructors[num]); constructor_elt *elt; - machine_mode mode; int sign = 0; tree smaller_type; @@ -1048,8 +1047,9 @@ array_value_type (gswitch *swtch, tree t if (!INTEGRAL_TYPE_P (type)) return type; - mode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (TYPE_MODE (type))); - if (GET_MODE_SIZE (TYPE_MODE (type)) <= GET_MODE_SIZE (mode)) + machine_mode type_mode = TYPE_MODE (type); + machine_mode mode = get_narrowest_mode (type_mode); + if (GET_MODE_SIZE (type_mode) <= GET_MODE_SIZE (mode)) return type; if (len < (optimize_bb_for_size_p (gimple_bb (swtch)) ? 2 : 32)) @@ -1087,7 +1087,7 @@ array_value_type (gswitch *swtch, tree t mode = GET_MODE_WIDER_MODE (mode); if (mode == VOIDmode - || GET_MODE_SIZE (mode) >= GET_MODE_SIZE (TYPE_MODE (type))) + || GET_MODE_SIZE (mode) >= GET_MODE_SIZE (type_mode)) return type; } } From patchwork Thu Jul 13 08:40:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107592 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1924824qge; Thu, 13 Jul 2017 01:40:33 -0700 (PDT) X-Received: by 10.84.217.22 with SMTP id o22mr9012809pli.19.1499935233222; Thu, 13 Jul 2017 01:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935233; cv=none; d=google.com; s=arc-20160816; b=LfRsZ+/3LzKNXhoG3HSmdo8wFrIz+w+ApG73sAmytnTCYe0I5ABrQ/eIlqDdcNcKDE og7kGPRZqPGdBTfQl35M4jSaMN4fAczy6XFIUu4i+kqO3slfMqkNQ67oBYbTW6c7BSms BpdqaJj9X6oNs3979dM0mzo5JbWVUJAD0nkpnhuMgW1T7GgsqWMHNS9DYyUIIh6N7YA2 g8bDFtYzLFR6j7yqHY4PS1wCk+hX/0b763xDqRJsKNk5XpuvxEKjusEpst/2VyXSH1Pu BcEKuRkxuYq9FxnlS8eWz/L+UQKFjxS2jcFU3ZoEbzacpImrH4KfRi/TmWUSlgeRZk7u 1yPw== 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=xpBnUOoGUOiduIJQyTDpbim6y/JWTWgZ9A6Owvd3PnU=; b=D3oDZwBM+QycvSxxYg9rIk87gX+lY/9RTHyazxRk3qjaotAJ8uPgXFU62wMDgYDlgB QaOsHI0m9rWpwJ7WiplJSLxNRFzcQQ1zBe2/51FvBhDGlXSXQNl+5AMl7vvT1SW3lxmX d+4tkBKb0U9+pB8IZhCJXfpcztukcKeoM+cE7doBsrc5oM2Oj3YER/EM/KMfbGzpvghV BXuotxR0JMu1N2eTNP96YMJePHGcnwJHHNoRYr3EA6hYscAt5X+v7xsvk/OKsQXPlus1 MwJVBcIMsjWlR3eVPgGOdzdFpaXQfRdgEUP8myQu672ZiU46TZzguJJkY9o3oeJPt7cO kojA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=j0bfj7S+; spf=pass (google.com: domain of gcc-patches-return-457996-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457996-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 e13si3839596pgu.2.2017.07.13.01.40.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457996-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=j0bfj7S+; spf=pass (google.com: domain of gcc-patches-return-457996-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457996-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=VP+lBGJm1rI7o9ODNBuPXj7If2hke 4jC0WupgRB1KXhhHZ/uOrbzv937bZ3NBCChLVo5zZjLQfdWqn5uEZOLjrrMMr2ZX Fo9wYKf1PC0fc8QqgEkLN85qj7lsDttU+pZqScjqpT59dh90WR/yt2DL5+YuDQ5b X6paVkcFLkUsRA= 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=gOC0YY6ZCfv6gZ4/DshpT+UX3Ck=; b=j0b fj7S+K6hoFOUBZIu9oZ3naRm+7w9tjnTUiTYy/qch3vB5ZM8cqgttLhu/Me2Wcya meuu9F/wF49ysoUbRwhnt6CvstJ4OQdHLcy/At/qkAHkIlPGo2awuRni6SNhD2MR ezLD/n+En7e7oQDS57QfV7jaX5bs2x6HaRvKGZsA= Received: (qmail 14871 invoked by alias); 13 Jul 2017 08:40:15 -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 14194 invoked by uid 89); 13 Jul 2017 08:40:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:40:10 +0000 Received: by mail-wm0-f48.google.com with SMTP id t70so2145061wmt.0 for ; Thu, 13 Jul 2017 01:40:09 -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=xpBnUOoGUOiduIJQyTDpbim6y/JWTWgZ9A6Owvd3PnU=; b=UM2e5DgOucOI1S0Iev1iavHlY1U6fbo7TJVsb3EQXR04zlDvZqkglZgivLhSTBPwa+ t4HolbpNP4Ypt2HQ2qGJG5D6zDGqoMU6Hk34/GZY9sl0I3faIFarLp+7FDP861xZ7mZI fiwsU3GwCOgNEdM/vb6OfuH6/dT8x/Sbsawy/C5B0Mg3C/luR6/yu9tYL2HlW2+VqE0v 07iRjV3aLSL/dqdj/St/iSLpG0ti4OeUuHHoIj96deO5ezS8fPn2hsqTYoGvBi4T/jAT rPaAyHWg6yb0iwZgEWdzc4gL0LAikS8g+20hqlYDeO3L+5vLStBeT0Z51ybYgu2V9k58 zQzQ== X-Gm-Message-State: AIVw113riSfLVRBqH9A0rraF8Uh4Xlx0FS3ZWVLOfeK3QEWUpRd5Hds9 xwcSR5Bm9ED4Fhziv06rJA== X-Received: by 10.28.194.137 with SMTP id s131mr1073585wmf.111.1499935206995; Thu, 13 Jul 2017 01:40:06 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id i22sm4339389wrb.30.2017.07.13.01.40.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:40:06 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [06/77] Make GET_MODE_WIDER return an opt_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:40:04 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87fue0n317.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 GET_MODE_WIDER previously returned VOIDmode if no wider mode existed. That would cause problems with stricter mode classes, since VOIDmode isn't for example a valid scalar integer or floating-point mode. This patch instead makes it return a new opt_mode class, which holds either a T or nothing. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (opt_mode): New class. * machmode.h (opt_mode): Likewise. (opt_mode::else_void): New function. (opt_mode::operator *): Likewise. (opt_mode::exists): Likewise. (GET_MODE_WIDER_MODE): Turn into a function and return an opt_mode. (GET_MODE_2XWIDER_MODE): Likewise. (mode_iterator::get_wider): Update accordingly. (mode_iterator::get_2xwider): Likewise. (mode_iterator::get_known_wider): Likewise, turning into a template. * combine.c (make_extraction): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. * config/cr16/cr16.h (LONG_REG_P): Likewise. * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise. * config/c6x/c6x.c (c6x_rtx_costs): Update use of GET_MODE_2XWIDER_MODE, forcing a wider mode to exist. * lower-subreg.c (init_lower_subreg): Likewise. * optabs-libfuncs.c (init_sync_libfuncs_1): Likewise, but not on the final iteration. * config/i386/i386.c (ix86_expand_set_or_movmem): Check whether a wider mode exists before asking for a move pattern. (get_mode_wider_vector): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. (expand_vselect_vconcat): Update use of GET_MODE_2XWIDER_MODE, returning false if no such mode exists. * config/ia64/ia64.c (expand_vselect_vconcat): Likewise. * config/mips/mips.c (mips_expand_vselect_vconcat): Likewise. * expmed.c (init_expmed_one_mode): Update use of GET_MODE_WIDER_MODE. Avoid checking for a MODE_INT if we already know the mode is not a SCALAR_INT_MODE_P. (extract_high_half): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. (expmed_mult_highpart_optab): Likewise. (expmed_mult_highpart): Likewise. * expr.c (expand_expr_real_2): Update use of GET_MODE_WIDER_MODE, using else_void. * lto-streamer-in.c (lto_input_mode_table): Likewise. * optabs-query.c (find_widening_optab_handler_and_mode): Likewise. * stor-layout.c (bit_field_mode_iterator::next_mode): Likewise. * internal-fn.c (expand_mul_overflow): Update use of GET_MODE_2XWIDER_MODE. * omp-low.c (omp_clause_aligned_alignment): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): Update use of GET_MODE_WIDER_MODE. (convert_plusminus_to_widen): Likewise. * tree-switch-conversion.c (array_value_type): Likewise. * var-tracking.c (emit_note_insn_var_location): Likewise. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. Return false inside rather than outside the loop if no wider mode exists * optabs.c (expand_binop): Update use of GET_MODE_WIDER_MODE and GET_MODE_2XWIDER_MODE (can_compare_p): Use else_void. * gdbhooks.py (OptMachineModePrinter): New class. (build_pretty_printer): Use it for opt_mode. gcc/ada/ * gcc-interface/decl.c (validate_size): Update use of GET_MODE_WIDER_MODE, forcing a wider mode to exist. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-02 10:05:20.995639436 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:22.924279021 +0100 @@ -55,6 +55,7 @@ typedef const struct simple_bitmap_def * struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; +template class opt_mode; /* Subclasses of rtx_def, using indentation to show the class hierarchy, along with the relevant invariant. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:21.533429040 +0100 +++ gcc/machmode.h 2017-07-13 09:18:22.930278376 +0100 @@ -221,6 +221,72 @@ #define CLASS_HAS_WIDER_MODES_P(CLASS) #define POINTER_BOUNDS_MODE_P(MODE) \ (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS) +/* An optional T (i.e. a T or nothing), where T is some form of mode class. + operator * gives the T value. */ +template +class opt_mode +{ +public: + enum from_int { dummy = MAX_MACHINE_MODE }; + + ALWAYS_INLINE opt_mode () : m_mode (E_VOIDmode) {} + ALWAYS_INLINE opt_mode (const T &m) : m_mode (m) {} + ALWAYS_INLINE opt_mode (from_int m) : m_mode (machine_mode (m)) {} + + machine_mode else_void () const; + T operator * () const; + + bool exists () const; + template bool exists (U *) const; + +private: + machine_mode m_mode; +}; + +/* If the object contains a T, return its enum value, otherwise return + E_VOIDmode. */ + +template +ALWAYS_INLINE machine_mode +opt_mode::else_void () const +{ + return m_mode; +} + +/* Assert that the object contains a T and return it. */ + +template +inline T +opt_mode::operator * () const +{ + gcc_checking_assert (m_mode != E_VOIDmode); + return typename mode_traits::from_int (m_mode); +} + +/* Return true if the object contains a T rather than nothing. */ + +template +ALWAYS_INLINE bool +opt_mode::exists () const +{ + return m_mode != E_VOIDmode; +} + +/* Return true if the object contains a T, storing it in *MODE if so. */ + +template +template +inline bool +opt_mode::exists (U *mode) const +{ + if (m_mode != E_VOIDmode) + { + *mode = T (typename mode_traits::from_int (m_mode)); + return true; + } + return false; +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -352,13 +418,22 @@ #define GET_MODE_NUNITS(MODE) (mode_to_n /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ -extern const unsigned char mode_wider[NUM_MACHINE_MODES]; -#define GET_MODE_WIDER_MODE(MODE) ((machine_mode) mode_wider[MODE]) +template +ALWAYS_INLINE opt_mode +GET_MODE_WIDER_MODE (const T &m) +{ + return typename opt_mode::from_int (mode_wider[m]); +} /* For scalars, this is a mode with twice the precision. For vectors, this is a mode with the same inner mode but with twice the elements. */ -extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; -#define GET_MODE_2XWIDER_MODE(MODE) ((machine_mode) mode_2xwider[MODE]) + +template +ALWAYS_INLINE opt_mode +GET_MODE_2XWIDER_MODE (const T &m) +{ + return typename opt_mode::from_int (mode_2xwider[m]); +} /* Get the complex mode from the component mode. */ extern const unsigned char mode_complex[NUM_MACHINE_MODES]; @@ -497,17 +572,17 @@ struct int_n_data_t { inline void get_wider (machine_mode *iter) { - *iter = GET_MODE_WIDER_MODE (*iter); + *iter = GET_MODE_WIDER_MODE (*iter).else_void (); } /* Set mode iterator *ITER to the next widest mode in the same class. Such a mode is known to exist. */ + template inline void - get_known_wider (machine_mode *iter) + get_known_wider (T *iter) { - *iter = GET_MODE_WIDER_MODE (*iter); - gcc_checking_assert (*iter != VOIDmode); + *iter = *GET_MODE_WIDER_MODE (*iter); } /* Set mode iterator *ITER to the mode that is two times wider than the @@ -516,7 +591,7 @@ struct int_n_data_t { inline void get_2xwider (machine_mode *iter) { - *iter = GET_MODE_2XWIDER_MODE (*iter); + *iter = GET_MODE_2XWIDER_MODE (*iter).else_void (); } } Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:21.524430018 +0100 +++ gcc/combine.c 2017-07-13 09:18:22.914280096 +0100 @@ -7617,10 +7617,7 @@ make_extraction (machine_mode mode, rtx wanted_inner_mode = smallest_mode_for_size (len, MODE_INT); while (pos % GET_MODE_BITSIZE (wanted_inner_mode) + len > GET_MODE_BITSIZE (wanted_inner_mode)) - { - wanted_inner_mode = GET_MODE_WIDER_MODE (wanted_inner_mode); - gcc_assert (wanted_inner_mode != VOIDmode); - } + wanted_inner_mode = *GET_MODE_WIDER_MODE (wanted_inner_mode); } orig_pos = pos; Index: gcc/config/cr16/cr16.h =================================================================== --- gcc/config/cr16/cr16.h 2017-04-18 19:52:36.663792154 +0100 +++ gcc/config/cr16/cr16.h 2017-07-13 09:18:22.915279989 +0100 @@ -197,9 +197,7 @@ #define CALL_USED_REGISTERS /* Returns 1 if the register is longer than word size, 0 otherwise. */ #define LONG_REG_P(REGNO) \ - (HARD_REGNO_NREGS (REGNO, \ - GET_MODE_WIDER_MODE (smallest_mode_for_size \ - (BITS_PER_WORD, MODE_INT))) == 1) + (HARD_REGNO_NREGS (REGNO, *GET_MODE_WIDER_MODE (word_mode)) == 1) #define HARD_REGNO_NREGS(REGNO, MODE) \ ((REGNO >= CR16_FIRST_DWORD_REGISTER) \ Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:21.536428715 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:22.937277624 +0100 @@ -5671,13 +5671,15 @@ init_num_sign_bit_copies_in_rep (void) /* Currently, it is assumed that TARGET_MODE_REP_EXTENDED extends to the next widest mode. */ gcc_assert (targetm.mode_rep_extended (mode, in_mode) == UNKNOWN - || GET_MODE_WIDER_MODE (mode) == in_mode); + || *GET_MODE_WIDER_MODE (mode) == in_mode); /* We are in in_mode. Count how many bits outside of mode have to be copies of the sign-bit. */ FOR_EACH_MODE (i, mode, in_mode) { - machine_mode wider = GET_MODE_WIDER_MODE (i); + /* This must always exist (for the last iteration it will be + IN_MODE). */ + machine_mode wider = *GET_MODE_WIDER_MODE (i); if (targetm.mode_rep_extended (i, wider) == SIGN_EXTEND /* We can only check sign-bit copies starting from the Index: gcc/config/c6x/c6x.c =================================================================== --- gcc/config/c6x/c6x.c 2017-07-13 09:18:19.037703403 +0100 +++ gcc/config/c6x/c6x.c 2017-07-13 09:18:22.915279989 +0100 @@ -6065,7 +6065,7 @@ c6x_rtx_costs (rtx x, machine_mode mode, /* Recognize a mult_highpart operation. */ if ((mode == HImode || mode == SImode) && GET_CODE (XEXP (x, 0)) == LSHIFTRT - && GET_MODE (XEXP (x, 0)) == GET_MODE_2XWIDER_MODE (mode) + && GET_MODE (XEXP (x, 0)) == *GET_MODE_2XWIDER_MODE (mode) && GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT && INTVAL (XEXP (XEXP (x, 0), 1)) == GET_MODE_BITSIZE (mode)) Index: gcc/lower-subreg.c =================================================================== --- gcc/lower-subreg.c 2017-05-18 07:51:11.882801135 +0100 +++ gcc/lower-subreg.c 2017-07-13 09:18:22.929278484 +0100 @@ -266,7 +266,7 @@ init_lower_subreg (void) memset (this_target_lower_subreg, 0, sizeof (*this_target_lower_subreg)); - twice_word_mode = GET_MODE_2XWIDER_MODE (word_mode); + twice_word_mode = *GET_MODE_2XWIDER_MODE (word_mode); rtxes.target = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 1); rtxes.source = gen_rtx_REG (word_mode, LAST_VIRTUAL_REGISTER + 2); Index: gcc/optabs-libfuncs.c =================================================================== --- gcc/optabs-libfuncs.c 2017-02-23 19:54:04.000000000 +0000 +++ gcc/optabs-libfuncs.c 2017-07-13 09:18:22.933278054 +0100 @@ -918,9 +918,10 @@ init_sync_libfuncs_1 (optab tab, const c mode = QImode; for (i = 1; i <= max; i *= 2) { + if (i > 1) + mode = *GET_MODE_2XWIDER_MODE (mode); buf[len + 1] = '0' + i; set_optab_libfunc (tab, mode, buf); - mode = GET_MODE_2XWIDER_MODE (mode); } } Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-07-13 09:18:21.528429583 +0100 +++ gcc/config/i386/i386.c 2017-07-13 09:18:22.921279344 +0100 @@ -28388,6 +28388,7 @@ ix86_expand_set_or_movmem (rtx dst, rtx bool need_zero_guard = false; bool noalign; machine_mode move_mode = VOIDmode; + machine_mode wider_mode; int unroll_factor = 1; /* TODO: Once value ranges are available, fill in proper data. */ unsigned HOST_WIDE_INT min_size = 0; @@ -28481,9 +28482,9 @@ ix86_expand_set_or_movmem (rtx dst, rtx unroll_factor = 4; /* Find the widest supported mode. */ move_mode = word_mode; - while (optab_handler (mov_optab, GET_MODE_WIDER_MODE (move_mode)) - != CODE_FOR_nothing) - move_mode = GET_MODE_WIDER_MODE (move_mode); + while (GET_MODE_WIDER_MODE (move_mode).exists (&wider_mode) + && optab_handler (mov_optab, wider_mode) != CODE_FOR_nothing) + move_mode = wider_mode; /* Find the corresponding vector mode with the same size as MOVE_MODE. MOVE_MODE is an integer mode at the moment (SI, DI, TI, etc.). */ @@ -43337,7 +43338,7 @@ static bool expand_vec_perm_palignr (str get_mode_wider_vector (machine_mode o) { /* ??? Rely on the ordering that genmodes.c gives to vectors. */ - machine_mode n = GET_MODE_WIDER_MODE (o); + machine_mode n = *GET_MODE_WIDER_MODE (o); gcc_assert (GET_MODE_NUNITS (o) == GET_MODE_NUNITS (n) * 2); gcc_assert (GET_MODE_SIZE (o) == GET_MODE_SIZE (n)); return n; @@ -46605,7 +46606,8 @@ expand_vselect_vconcat (rtx target, rtx if (vselect_insn == NULL_RTX) init_vselect_insn (); - v2mode = GET_MODE_2XWIDER_MODE (GET_MODE (op0)); + if (!GET_MODE_2XWIDER_MODE (GET_MODE (op0)).exists (&v2mode)) + return false; x = XEXP (SET_SRC (PATTERN (vselect_insn)), 0); PUT_MODE (x, v2mode); XEXP (x, 0) = op0; Index: gcc/config/ia64/ia64.c =================================================================== --- gcc/config/ia64/ia64.c 2017-07-13 09:18:19.067700078 +0100 +++ gcc/config/ia64/ia64.c 2017-07-13 09:18:22.922279236 +0100 @@ -11297,7 +11297,8 @@ expand_vselect_vconcat (rtx target, rtx machine_mode v2mode; rtx x; - v2mode = GET_MODE_2XWIDER_MODE (GET_MODE (op0)); + if (!GET_MODE_2XWIDER_MODE (GET_MODE (op0)).exists (&v2mode)) + return false; x = gen_rtx_VEC_CONCAT (v2mode, op0, op1); return expand_vselect (target, x, perm, nelt); } Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2017-07-13 09:18:19.076699080 +0100 +++ gcc/config/mips/mips.c 2017-07-13 09:18:22.924279021 +0100 @@ -21105,7 +21105,8 @@ mips_expand_vselect_vconcat (rtx target, machine_mode v2mode; rtx x; - v2mode = GET_MODE_2XWIDER_MODE (GET_MODE (op0)); + if (!GET_MODE_2XWIDER_MODE (GET_MODE (op0)).exists (&v2mode)) + return false; x = gen_rtx_VEC_CONCAT (v2mode, op0, op1); return mips_expand_vselect (target, x, perm, nelt); } Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:21.531429258 +0100 +++ gcc/expmed.c 2017-07-13 09:18:22.925278914 +0100 @@ -206,11 +206,10 @@ init_expmed_one_mode (struct init_expmed { FOR_EACH_MODE_IN_CLASS (mode_from, MODE_INT) init_expmed_one_conv (all, mode, mode_from, speed); - } - if (GET_MODE_CLASS (mode) == MODE_INT) - { - machine_mode wider_mode = GET_MODE_WIDER_MODE (mode); - if (wider_mode != VOIDmode) + + machine_mode wider_mode; + if (GET_MODE_CLASS (mode) == MODE_INT + && GET_MODE_WIDER_MODE (mode).exists (&wider_mode)) { PUT_MODE (all->zext, wider_mode); PUT_MODE (all->wide_mult, wider_mode); @@ -3588,7 +3587,7 @@ extract_high_half (machine_mode mode, rt gcc_assert (!SCALAR_FLOAT_MODE_P (mode)); - wider_mode = GET_MODE_WIDER_MODE (mode); + wider_mode = *GET_MODE_WIDER_MODE (mode); op = expand_shift (RSHIFT_EXPR, wider_mode, op, GET_MODE_BITSIZE (mode), 0, 1); return convert_modes (mode, wider_mode, op, 0); @@ -3610,7 +3609,7 @@ expmed_mult_highpart_optab (machine_mode gcc_assert (!SCALAR_FLOAT_MODE_P (mode)); - wider_mode = GET_MODE_WIDER_MODE (mode); + wider_mode = *GET_MODE_WIDER_MODE (mode); size = GET_MODE_BITSIZE (mode); /* Firstly, try using a multiplication insn that only generates the needed @@ -3716,7 +3715,7 @@ expmed_mult_highpart_optab (machine_mode expmed_mult_highpart (machine_mode mode, rtx op0, rtx op1, rtx target, int unsignedp, int max_cost) { - machine_mode wider_mode = GET_MODE_WIDER_MODE (mode); + machine_mode wider_mode = *GET_MODE_WIDER_MODE (mode); unsigned HOST_WIDE_INT cnst1; int extra_cost; bool sign_adjust = false; Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:21.532429149 +0100 +++ gcc/expr.c 2017-07-13 09:18:22.928278591 +0100 @@ -9153,7 +9153,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b if (code == LSHIFT_EXPR && target && REG_P (target) - && mode == GET_MODE_WIDER_MODE (word_mode) + && mode == GET_MODE_WIDER_MODE (word_mode).else_void () && GET_MODE_SIZE (mode) == 2 * GET_MODE_SIZE (word_mode) && TREE_CONSTANT (treeop1) && TREE_CODE (treeop0) == SSA_NAME) Index: gcc/lto-streamer-in.c =================================================================== --- gcc/lto-streamer-in.c 2017-06-30 12:50:38.331658620 +0100 +++ gcc/lto-streamer-in.c 2017-07-13 09:18:22.930278376 +0100 @@ -1593,7 +1593,7 @@ lto_input_mode_table (struct lto_file_de : GET_CLASS_NARROWEST_MODE (mclass); pass ? mr < MAX_MACHINE_MODE : mr != VOIDmode; pass ? mr = (machine_mode) (mr + 1) - : mr = GET_MODE_WIDER_MODE (mr)) + : mr = GET_MODE_WIDER_MODE (mr).else_void ()) if (GET_MODE_CLASS (mr) != mclass || GET_MODE_SIZE (mr) != size || GET_MODE_PRECISION (mr) != prec Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-07-13 09:18:21.534428932 +0100 +++ gcc/optabs-query.c 2017-07-13 09:18:22.934277946 +0100 @@ -425,7 +425,7 @@ find_widening_optab_handler_and_mode (op for (; (permit_non_widening || from_mode != to_mode) && GET_MODE_SIZE (from_mode) <= GET_MODE_SIZE (to_mode) && from_mode != VOIDmode; - from_mode = GET_MODE_WIDER_MODE (from_mode)) + from_mode = GET_MODE_WIDER_MODE (from_mode).else_void ()) { enum insn_code handler = widening_optab_handler (op, to_mode, from_mode); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:21.536428715 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:22.938277517 +0100 @@ -2719,7 +2719,8 @@ fixup_unsigned_type (tree type) bool bit_field_mode_iterator::next_mode (machine_mode *out_mode) { - for (; m_mode != VOIDmode; m_mode = GET_MODE_WIDER_MODE (m_mode)) + for (; m_mode != VOIDmode; + m_mode = GET_MODE_WIDER_MODE (m_mode).else_void ()) { unsigned int unit = GET_MODE_BITSIZE (m_mode); @@ -2756,7 +2757,7 @@ bit_field_mode_iterator::next_mode (mach break; *out_mode = m_mode; - m_mode = GET_MODE_WIDER_MODE (m_mode); + m_mode = GET_MODE_WIDER_MODE (m_mode).else_void (); m_count++; return true; } Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2017-07-08 11:37:46.037390715 +0100 +++ gcc/internal-fn.c 2017-07-13 09:18:22.929278484 +0100 @@ -1446,14 +1446,14 @@ expand_mul_overflow (location_t loc, tre struct separate_ops ops; int prec = GET_MODE_PRECISION (mode); machine_mode hmode = mode_for_size (prec / 2, MODE_INT, 1); + machine_mode wmode; ops.op0 = make_tree (type, op0); ops.op1 = make_tree (type, op1); ops.op2 = NULL_TREE; ops.location = loc; - if (GET_MODE_2XWIDER_MODE (mode) != VOIDmode - && targetm.scalar_mode_supported_p (GET_MODE_2XWIDER_MODE (mode))) + if (GET_MODE_2XWIDER_MODE (mode).exists (&wmode) + && targetm.scalar_mode_supported_p (wmode)) { - machine_mode wmode = GET_MODE_2XWIDER_MODE (mode); ops.code = WIDEN_MULT_EXPR; ops.type = build_nonstandard_integer_type (GET_MODE_PRECISION (wmode), uns); Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c 2017-07-13 09:18:21.533429040 +0100 +++ gcc/omp-low.c 2017-07-13 09:18:22.933278054 +0100 @@ -3452,8 +3452,8 @@ omp_clause_aligned_alignment (tree claus continue; while (vs && GET_MODE_SIZE (vmode) < vs - && GET_MODE_2XWIDER_MODE (vmode) != VOIDmode) - vmode = GET_MODE_2XWIDER_MODE (vmode); + && GET_MODE_2XWIDER_MODE (vmode).exists ()) + vmode = *GET_MODE_2XWIDER_MODE (vmode); tree type = lang_hooks.types.type_for_mode (mode, 1); if (type == NULL_TREE || TYPE_MODE (type) != mode) Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-07-13 09:18:21.537428606 +0100 +++ gcc/tree-ssa-math-opts.c 2017-07-13 09:18:22.939277409 +0100 @@ -3160,8 +3160,8 @@ convert_mult_to_widen (gimple *stmt, gim || (TYPE_UNSIGNED (type2) && TYPE_PRECISION (type2) == GET_MODE_PRECISION (from_mode))) { - from_mode = GET_MODE_WIDER_MODE (from_mode); - if (GET_MODE_SIZE (to_mode) <= GET_MODE_SIZE (from_mode)) + if (!GET_MODE_WIDER_MODE (from_mode).exists (&from_mode) + || GET_MODE_SIZE (to_mode) <= GET_MODE_SIZE (from_mode)) return false; } @@ -3342,8 +3342,8 @@ convert_plusminus_to_widen (gimple_stmt_ || (from_unsigned2 && TYPE_PRECISION (type2) == GET_MODE_PRECISION (from_mode))) { - from_mode = GET_MODE_WIDER_MODE (from_mode); - if (GET_MODE_SIZE (from_mode) >= GET_MODE_SIZE (to_mode)) + if (!GET_MODE_WIDER_MODE (from_mode).exists (&from_mode) + || GET_MODE_SIZE (from_mode) >= GET_MODE_SIZE (to_mode)) return false; } Index: gcc/tree-switch-conversion.c =================================================================== --- gcc/tree-switch-conversion.c 2017-07-13 09:18:22.307345334 +0100 +++ gcc/tree-switch-conversion.c 2017-07-13 09:18:22.939277409 +0100 @@ -1085,8 +1085,7 @@ array_value_type (gswitch *swtch, tree t if (sign == 1) sign = 0; - mode = GET_MODE_WIDER_MODE (mode); - if (mode == VOIDmode + if (!GET_MODE_WIDER_MODE (mode).exists (&mode) || GET_MODE_SIZE (mode) >= GET_MODE_SIZE (type_mode)) return type; } Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-07-13 09:18:21.539428389 +0100 +++ gcc/var-tracking.c 2017-07-13 09:18:22.945276764 +0100 @@ -8706,12 +8706,11 @@ emit_note_insn_var_location (variable ** last_limit = offsets[n_var_parts] + GET_MODE_SIZE (mode); /* Attempt to merge adjacent registers or memory. */ - wider_mode = GET_MODE_WIDER_MODE (mode); for (j = i + 1; j < var->n_var_parts; j++) if (last_limit <= VAR_PART_OFFSET (var, j)) break; if (j < var->n_var_parts - && wider_mode != VOIDmode + && GET_MODE_WIDER_MODE (mode).exists (&wider_mode) && var->var_part[j].cur_loc && mode == GET_MODE (var->var_part[j].cur_loc) && (REG_P (loc[n_var_parts]) || MEM_P (loc[n_var_parts])) Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c 2017-07-05 16:25:08.469709143 +0100 +++ gcc/tree-vrp.c 2017-07-13 09:18:22.943276979 +0100 @@ -10115,7 +10115,7 @@ simplify_float_conversion_using_ranges ( else { mode = GET_CLASS_NARROWEST_MODE (MODE_INT); - do + for (;;) { /* If we cannot do a signed conversion to float from mode or if the value-range does not fit in the signed type @@ -10124,15 +10124,12 @@ simplify_float_conversion_using_ranges ( && range_fits_type_p (vr, GET_MODE_PRECISION (mode), SIGNED)) break; - mode = GET_MODE_WIDER_MODE (mode); /* But do not widen the input. Instead leave that to the optabs expansion code. */ - if (GET_MODE_PRECISION (mode) > TYPE_PRECISION (TREE_TYPE (rhs1))) + if (!GET_MODE_WIDER_MODE (mode).exists (&mode) + || GET_MODE_PRECISION (mode) > TYPE_PRECISION (TREE_TYPE (rhs1))) return false; } - while (mode != VOIDmode); - if (mode == VOIDmode) - return false; } /* It works, insert a truncation or sign-change before the Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:21.534428932 +0100 +++ gcc/optabs.c 2017-07-13 09:18:22.935277839 +0100 @@ -1185,13 +1185,13 @@ expand_binop (machine_mode mode, optab b takes operands of this mode and makes a wider mode. */ if (binoptab == smul_optab - && GET_MODE_2XWIDER_MODE (mode) != VOIDmode - && (widening_optab_handler ((unsignedp ? umul_widen_optab - : smul_widen_optab), - GET_MODE_2XWIDER_MODE (mode), mode) - != CODE_FOR_nothing)) + && GET_MODE_2XWIDER_MODE (mode).exists (&wider_mode) + && (convert_optab_handler ((unsignedp + ? umul_widen_optab + : smul_widen_optab), + wider_mode, mode) != CODE_FOR_nothing)) { - temp = expand_binop (GET_MODE_2XWIDER_MODE (mode), + temp = expand_binop (wider_mode, unsignedp ? umul_widen_optab : smul_widen_optab, op0, op1, NULL_RTX, unsignedp, OPTAB_DIRECT); @@ -1252,14 +1252,14 @@ expand_binop (machine_mode mode, optab b && methods != OPTAB_DIRECT && methods != OPTAB_LIB) FOR_EACH_WIDER_MODE (wider_mode, mode) { + machine_mode next_mode; if (optab_handler (binoptab, wider_mode) != CODE_FOR_nothing || (binoptab == smul_optab - && GET_MODE_WIDER_MODE (wider_mode) != VOIDmode + && GET_MODE_WIDER_MODE (wider_mode).exists (&next_mode) && (find_widening_optab_handler ((unsignedp ? umul_widen_optab : smul_widen_optab), - GET_MODE_WIDER_MODE (wider_mode), - mode, 0) + next_mode, mode, 0) != CODE_FOR_nothing))) { rtx xop0 = op0, xop1 = op1; @@ -3701,7 +3701,7 @@ can_compare_p (enum rtx_code code, machi && optab_handler (cmov_optab, mode) != CODE_FOR_nothing) return 1; - mode = GET_MODE_WIDER_MODE (mode); + mode = GET_MODE_WIDER_MODE (mode).else_void (); PUT_MODE (test, mode); } while (mode != VOIDmode); Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-02-23 19:54:12.000000000 +0000 +++ gcc/gdbhooks.py 2017-07-13 09:18:22.928278591 +0100 @@ -422,6 +422,18 @@ class VecPrinter: ###################################################################### +class OptMachineModePrinter: + def __init__(self, gdbval): + self.gdbval = gdbval + + def to_string (self): + name = str(self.gdbval['m_mode']) + if name == 'E_VOIDmode': + return '' + return name[2:] if name.startswith('E_') else name + +###################################################################### + # TODO: # * hashtab # * location_t @@ -518,6 +530,9 @@ def build_pretty_printer(): 'vec', VecPrinter) + pp.add_printer_for_regex(r'opt_mode<(\S+)>', + 'opt_mode', OptMachineModePrinter) + return pp gdb.printing.register_pretty_printer( Index: gcc/ada/gcc-interface/decl.c =================================================================== --- gcc/ada/gcc-interface/decl.c 2017-06-22 12:22:56.063377521 +0100 +++ gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:22.913280204 +0100 @@ -8576,7 +8576,7 @@ validate_size (Uint uint_size, tree gnu_ { machine_mode p_mode = GET_CLASS_NARROWEST_MODE (MODE_INT); while (!targetm.valid_pointer_mode (p_mode)) - p_mode = GET_MODE_WIDER_MODE (p_mode); + p_mode = *GET_MODE_WIDER_MODE (p_mode); type_size = bitsize_int (GET_MODE_BITSIZE (p_mode)); } From patchwork Thu Jul 13 08:40:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107593 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1925049qge; Thu, 13 Jul 2017 01:40:51 -0700 (PDT) X-Received: by 10.99.120.132 with SMTP id t126mr7845762pgc.276.1499935251117; Thu, 13 Jul 2017 01:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935251; cv=none; d=google.com; s=arc-20160816; b=0d3HmNh/1kluKFQDB2gDe/+hV8TvyGcHF+E9ETUBevZNHivFV1WmcFJccBM8FfhAPP jd5yn6vnaLqeVb1jXyjibyPEYvOkAsE3Z/iy0Lx9GSENC4CoLhfbXvW9QJGjfz+EdSOZ JRU0b5w3ZYjVjVwdckPLoFJdLFEatxmglbbSyDUMIScS6J6j4c3TGT0iwRMOoWOdGPTe UJMl8684vJ5C9hoWpnEUwInvF89Vodg0Ih6YLo/ZDF6uLl6I1etwAJMLOrdzWQqvY9/S xx2YtQ4F+vHwxTfy5uMJlXXzflHzWRXq9lGEPT9KZIbf5Em1sfukQbxnzcAjFYjYh2y0 lphQ== 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=0o6XNEOUF0D3ZNO9a19m/MfRjQptQQoL/Zjd2eEToBI=; b=FCpVhQAiMx0xAFrhqweXg5eyraKYmgrVCIUm1AiZvjbGSM/syf78wdqMwLNzsOTTjT nrYZ6W5y2KVCWSbdDRVZHzwMb/TsFelBq8j0yQbXyVZrH4zFcjrx8G5O2ykVr2XOoL6v PRT/YRCBpcYtvWWCnbRpF7SpTXpo+P+xWNZsFL57dQgjmFZVyHRB19/Z9ySCIeO2DqC8 cI6YoRhE4hT3cxCVoMFxPE79IZvxbG1QsYax3yDnmH1nJ6Eceblgk3EbN2f/oapW14Xb ukEf84HakBZs/ykLylQWu4MjNrG+Hn3sc6xVP2caLQAuo8pKeId299HRRi75Mn0HEuDd Qslg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=kHhTtmZc; spf=pass (google.com: domain of gcc-patches-return-457997-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457997-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 q6si3770665pgq.8.2017.07.13.01.40.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457997-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=kHhTtmZc; spf=pass (google.com: domain of gcc-patches-return-457997-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457997-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=WXQO1kGVkK7vBkQirWHlNVYnvHHla MebdjBugouPqp2dhs8GJng3V0eYEkaFJZpu+7GyojKPA7UO0q57TsZCG6ozRNi2V f1hBsHUxYZ451f+9rRjsYhjNWOiRDEsk1Q8OTc9E9mHT2omm1nQnhxMb0eMgGX5z ZUtoEGVxJ40K3I= 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=SwmoqeN8DTWecavRe9HsAD/1mmk=; b=kHh TtmZcC9PbEiP64Ph3+xRrmf37akxBtoouJ65pL+NU9Gj13NJl3rvmef9sPobsl0n Yxqi++AkGWiBRvMvIg3130bPm3ft+Sl/NqDgh8l8AJKNXDE1iQiCKOyntQsoAx6a pP2dRmH/enNgfVro8EQzv/cHgg7jmNuM5/M/iCSg= Received: (qmail 24491 invoked by alias); 13 Jul 2017 08:40:35 -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 24223 invoked by uid 89); 13 Jul 2017 08:40:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:40:29 +0000 Received: by mail-wr0-f179.google.com with SMTP id r103so49407622wrb.0 for ; Thu, 13 Jul 2017 01:40:29 -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=0o6XNEOUF0D3ZNO9a19m/MfRjQptQQoL/Zjd2eEToBI=; b=b8SEMmr8TP4Lpnvutzh7jS43PrSKqIQwKb3Pq9MpNz1iZg3Bfs4wsk6XSEEKgfVxWm St7OutoVXvw5FVbZYTPOaW3uuj5PPhCPqVO08jDlbObKfD0dc6Qizwc9piSTjYngIBtj eAlXDzeW7yAr2vc2C/EU9f/iV8q6/6B3pTQrkCDwmME3pSfjCXH4xGpjRpTkuYflw3Jj gtQOOjxKIs0Hkh8Y/zHjiAHVTFXaGAIIwcZ4shofRm+YEq75c+JOZYEeUHwZjSVFMXU5 Ef0coxuo6JEvDEIXyvG9mydcyYSajhVu6spg6/mBdIN+4JF/HRAGSVG3kC9+igi1SbYY br+w== X-Gm-Message-State: AIVw1104zFSeYHiqGbK/bb3AQuhQNmFAAjzjudDtQQ/INwkB40UPnmTY jlatJXwAPbCCe3nQbrm7mQ== X-Received: by 10.223.128.42 with SMTP id 39mr1043737wrk.175.1499935227089; Thu, 13 Jul 2017 01:40:27 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id w96sm4077166wrc.33.2017.07.13.01.40.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:40:26 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [07/77] Add scalar_float_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:40:24 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87bmoon30n.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a scalar_float_mode class, which wraps a mode enum that is known to satisfy SCALAR_FLOAT_MODE_P. Things like "SFmode" now give a scalar_float_mode object instead of a machine_mode. This in turn needs a change to the real.h format_helper, so that it can accept both machine_modes and scalar_float_modes. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (scalar_float_mode): New type. * machmode.h (mode_traits::from_int): Use machine_mode if USE_ENUM_MODES is defined. (is_a): New function. (as_a): Likewise. (dyn_cast): Likewise. (scalar_float_mode): New class. (scalar_float_mode::includes_p): New function. (is_float_mode): Likewise. * gdbhooks.py (MachineModePrinter): New class. (build_pretty_printer): Use it for scalar_float_mode. * real.h (FLOAT_MODE_FORMAT): Use as_a . (format_helper::format_helper): Turn into a template. * genmodes.c (get_mode_class): New function. (emit_insn_modes_h): Give modes the class returned by get_mode_class, or machine_mode if none. * config/aarch64/aarch64.c (aarch64_simd_valid_immediate): Use as_a . * dwarf2out.c (mem_loc_descriptor): Likewise. (insert_float): Likewise. (add_const_value_attribute): Likewise. * simplify-rtx.c (simplify_immed_subreg): Likewise. * optabs.c (expand_absneg_bit): Take a scalar_float_mode. (expand_unop): Update accordingly. (expand_abs_nojump): Likewise. (expand_copysign_absneg): Take a scalar_float_mode. (expand_copysign_bit): Likewise. (expand_copysign): Update accordingly. gcc/ada/ * gcc-interface/utils.c (gnat_type_for_mode): Use is_a instead of SCALAR_FLOAT_MODE_P. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_float_mode. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:22.924279021 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:23.795186280 +0100 @@ -55,6 +55,7 @@ typedef const struct simple_bitmap_def * struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; +class scalar_float_mode; template class opt_mode; /* Subclasses of rtx_def, using indentation to show the class @@ -311,6 +312,8 @@ #define rtx_insn struct _dont_use_rtx_in #define tree union _dont_use_tree_here_ * #define const_tree union _dont_use_tree_here_ * +typedef struct scalar_float_mode scalar_float_mode; + #endif /* Classes of functions that compiler needs to check Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:22.930278376 +0100 +++ gcc/machmode.h 2017-07-13 09:18:23.798185961 +0100 @@ -46,9 +46,15 @@ struct mode_traits res = T (typename mode_traits::from_int (mode)); when assigning to a value RES that must be assignment-compatible - with (but possibly not the same as) T. - - Here we use an enum type distinct from machine_mode but with the + with (but possibly not the same as) T. */ +#ifdef USE_ENUM_MODES + /* Allow direct conversion of enums to specific mode classes only + when USE_ENUM_MODES is defined. This is only intended for use + by gencondmd, so that it can tell more easily when .md conditions + are always false. */ + typedef machine_mode from_int; +#else + /* Here we use an enum type distinct from machine_mode but with the same range as machine_mode. T should have a constructor that accepts this enum type; it should not have a constructor that accepts machine_mode. @@ -58,6 +64,7 @@ struct mode_traits unoptimized code, the return statement above would construct the returned T directly from the numerical value of MODE. */ enum from_int { dummy = MAX_MACHINE_MODE }; +#endif }; template<> @@ -287,6 +294,75 @@ opt_mode::exists (U *mode) const return false; } +/* Return true if mode M has type T. */ + +template +inline bool +is_a (machine_mode m) +{ + return T::includes_p (m); +} + +/* Assert that mode M has type T, and return it in that form. */ + +template +inline T +as_a (machine_mode m) +{ + gcc_checking_assert (T::includes_p (m)); + return typename mode_traits::from_int (m); +} + +/* Convert M to an opt_mode. */ + +template +inline opt_mode +dyn_cast (machine_mode m) +{ + if (T::includes_p (m)) + return T (typename mode_traits::from_int (m)); + return opt_mode (); +} + +/* Return true if mode M has type T, storing it as a T in *RESULT + if so. */ + +template +inline bool +is_a (machine_mode m, U *result) +{ + if (T::includes_p (m)) + { + *result = T (typename mode_traits::from_int (m)); + return true; + } + return false; +} + +/* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ +class scalar_float_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE scalar_float_mode () {} + ALWAYS_INLINE scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M is a scalar_float_mode. */ + +inline bool +scalar_float_mode::includes_p (machine_mode m) +{ + return SCALAR_FLOAT_MODE_P (m); +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -548,6 +624,21 @@ struct int_n_data_t { extern bool int_n_enabled_p[NUM_INT_N_ENTS]; extern const int_n_data_t int_n_data[NUM_INT_N_ENTS]; +/* Return true if MODE has class MODE_FLOAT, storing it as a + scalar_float_mode in *FLOAT_MODE if so. */ + +template +inline bool +is_float_mode (machine_mode mode, T *float_mode) +{ + if (GET_MODE_CLASS (mode) == MODE_FLOAT) + { + *float_mode = scalar_float_mode (scalar_float_mode::from_int (mode)); + return true; + } + return false; +} + namespace mode_iterator { /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:22.928278591 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:23.798185961 +0100 @@ -422,6 +422,16 @@ class VecPrinter: ###################################################################### +class MachineModePrinter: + def __init__(self, gdbval): + self.gdbval = gdbval + + def to_string (self): + name = str(self.gdbval['m_mode']) + return name[2:] if name.startswith('E_') else name + +###################################################################### + class OptMachineModePrinter: def __init__(self, gdbval): self.gdbval = gdbval @@ -532,6 +542,8 @@ def build_pretty_printer(): pp.add_printer_for_regex(r'opt_mode<(\S+)>', 'opt_mode', OptMachineModePrinter) + pp.add_printer_for_types(['scalar_float_mode'], + 'scalar_float_mode', MachineModePrinter) return pp Index: gcc/real.h =================================================================== --- gcc/real.h 2017-06-12 17:05:22.266750229 +0100 +++ gcc/real.h 2017-07-13 09:18:23.799185854 +0100 @@ -183,8 +183,7 @@ #define REAL_MODE_FORMAT(MODE) \ : (gcc_unreachable (), 0)]) #define FLOAT_MODE_FORMAT(MODE) \ - (REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \ - : GET_MODE_INNER (MODE))) + (REAL_MODE_FORMAT (as_a (GET_MODE_INNER (MODE)))) /* The following macro determines whether the floating point format is composite, i.e. may contain non-consecutive mantissa bits, in which @@ -212,7 +211,7 @@ #define MODE_HAS_SIGN_DEPENDENT_ROUNDING { public: format_helper (const real_format *format) : m_format (format) {} - format_helper (machine_mode m); + template format_helper (const T &); const real_format *operator-> () const { return m_format; } operator const real_format *() const { return m_format; } @@ -222,7 +221,8 @@ #define MODE_HAS_SIGN_DEPENDENT_ROUNDING const real_format *m_format; }; -inline format_helper::format_helper (machine_mode m) +template +inline format_helper::format_helper (const T &m) : m_format (m == VOIDmode ? 0 : REAL_MODE_FORMAT (m)) {} Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:20.866501621 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:23.798185961 +0100 @@ -1129,6 +1129,23 @@ mode_unit_precision_inline (machine_mode }\n"); } +/* Return the best machine mode class for MODE, or null if machine_mode + should be used. */ + +static const char * +get_mode_class (struct mode_data *mode) +{ + switch (mode->cl) + { + case MODE_FLOAT: + case MODE_DECIMAL_FLOAT: + return "scalar_float_mode"; + + default: + return NULL; + } +} + static void emit_insn_modes_h (void) { @@ -1158,8 +1175,12 @@ enum machine_mode\n{"); printf ("#ifdef USE_ENUM_MODES\n"); printf ("#define %smode E_%smode\n", m->name, m->name); printf ("#else\n"); - printf ("#define %smode ((void) 0, E_%smode)\n", - m->name, m->name); + if (const char *mode_class = get_mode_class (m)) + printf ("#define %smode (%s ((%s::from_int) E_%smode))\n", + m->name, mode_class, mode_class, m->name); + else + printf ("#define %smode ((void) 0, E_%smode)\n", + m->name, m->name); printf ("#endif\n"); } Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:19.014705954 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:23.795186280 +0100 @@ -11354,8 +11354,12 @@ #define CHECK(STRIDE, ELSIZE, CLASS, TES if (info) { - info->value = CONST_VECTOR_ELT (op, 0); - info->element_width = GET_MODE_BITSIZE (GET_MODE (info->value)); + rtx elt = CONST_VECTOR_ELT (op, 0); + scalar_float_mode elt_mode + = as_a (GET_MODE (elt)); + + info->value = elt; + info->element_width = GET_MODE_BITSIZE (elt_mode); info->mvn = false; info->shift = 0; } Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:17:39.971572405 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:23.797186067 +0100 @@ -15242,7 +15242,8 @@ mem_loc_descriptor (rtx rtl, machine_mod else #endif { - unsigned int length = GET_MODE_SIZE (mode); + scalar_float_mode float_mode = as_a (mode); + unsigned int length = GET_MODE_SIZE (float_mode); unsigned char *array = ggc_vec_alloc (length); insert_float (rtl, array); @@ -18539,11 +18540,12 @@ insert_float (const_rtx rtl, unsigned ch { long val[4]; int i; + scalar_float_mode mode = as_a (GET_MODE (rtl)); - real_to_target (val, CONST_DOUBLE_REAL_VALUE (rtl), GET_MODE (rtl)); + real_to_target (val, CONST_DOUBLE_REAL_VALUE (rtl), mode); /* real_to_target puts 32-bit pieces in each long. Pack them. */ - for (i = 0; i < GET_MODE_SIZE (GET_MODE (rtl)) / 4; i++) + for (i = 0; i < GET_MODE_SIZE (mode) / 4; i++) { insert_int (val[i], 4, array); array += 4; @@ -18587,21 +18589,19 @@ add_const_value_attribute (dw_die_ref di floating-point constant. A CONST_DOUBLE is used whenever the constant requires more than one word in order to be adequately represented. */ - { - machine_mode mode = GET_MODE (rtl); - - if (TARGET_SUPPORTS_WIDE_INT == 0 && !SCALAR_FLOAT_MODE_P (mode)) - add_AT_double (die, DW_AT_const_value, - CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl)); - else - { - unsigned int length = GET_MODE_SIZE (mode); - unsigned char *array = ggc_vec_alloc (length); + if (TARGET_SUPPORTS_WIDE_INT == 0 + && !SCALAR_FLOAT_MODE_P (GET_MODE (rtl))) + add_AT_double (die, DW_AT_const_value, + CONST_DOUBLE_HIGH (rtl), CONST_DOUBLE_LOW (rtl)); + else + { + scalar_float_mode mode = as_a (GET_MODE (rtl)); + unsigned int length = GET_MODE_SIZE (mode); + unsigned char *array = ggc_vec_alloc (length); - insert_float (rtl, array); - add_AT_vec (die, DW_AT_const_value, length / 4, 4, array); - } - } + insert_float (rtl, array); + add_AT_vec (die, DW_AT_const_value, length / 4, 4, array); + } return true; case CONST_VECTOR: Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-05 16:29:19.600761904 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:23.800185748 +0100 @@ -5802,9 +5802,11 @@ simplify_immed_subreg (machine_mode oute { /* This is big enough for anything on the platform. */ long tmp[MAX_BITSIZE_MODE_ANY_MODE / 32]; - int bitsize = GET_MODE_BITSIZE (GET_MODE (el)); + scalar_float_mode el_mode; + + el_mode = as_a (GET_MODE (el)); + int bitsize = GET_MODE_BITSIZE (el_mode); - gcc_assert (SCALAR_FLOAT_MODE_P (GET_MODE (el))); gcc_assert (bitsize <= elem_bitsize); gcc_assert (bitsize % value_bit == 0); Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:22.935277839 +0100 +++ gcc/optabs.c 2017-07-13 09:18:23.799185854 +0100 @@ -2551,7 +2551,7 @@ lowpart_subreg_maybe_copy (machine_mode logical operation on the sign bit. */ static rtx -expand_absneg_bit (enum rtx_code code, machine_mode mode, +expand_absneg_bit (enum rtx_code code, scalar_float_mode mode, rtx op0, rtx target) { const struct real_format *fmt; @@ -2697,6 +2697,7 @@ expand_unop (machine_mode mode, optab un { enum mode_class mclass = GET_MODE_CLASS (mode); machine_mode wider_mode; + scalar_float_mode float_mode; rtx temp; rtx libfunc; @@ -2887,9 +2888,9 @@ expand_unop (machine_mode mode, optab un if (optab_to_code (unoptab) == NEG) { /* Try negating floating point values by flipping the sign bit. */ - if (SCALAR_FLOAT_MODE_P (mode)) + if (is_a (mode, &float_mode)) { - temp = expand_absneg_bit (NEG, mode, op0, target); + temp = expand_absneg_bit (NEG, float_mode, op0, target); if (temp) return temp; } @@ -3086,9 +3087,10 @@ expand_abs_nojump (machine_mode mode, rt return temp; /* For floating point modes, try clearing the sign bit. */ - if (SCALAR_FLOAT_MODE_P (mode)) + scalar_float_mode float_mode; + if (is_a (mode, &float_mode)) { - temp = expand_absneg_bit (ABS, mode, op0, target); + temp = expand_absneg_bit (ABS, float_mode, op0, target); if (temp) return temp; } @@ -3243,7 +3245,7 @@ expand_one_cmpl_abs_nojump (machine_mode and not playing with subregs so much, will help the register allocator. */ static rtx -expand_copysign_absneg (machine_mode mode, rtx op0, rtx op1, rtx target, +expand_copysign_absneg (scalar_float_mode mode, rtx op0, rtx op1, rtx target, int bitpos, bool op0_is_abs) { machine_mode imode; @@ -3327,7 +3329,7 @@ expand_copysign_absneg (machine_mode mod is true if op0 is known to have its sign bit clear. */ static rtx -expand_copysign_bit (machine_mode mode, rtx op0, rtx op1, rtx target, +expand_copysign_bit (scalar_float_mode mode, rtx op0, rtx op1, rtx target, int bitpos, bool op0_is_abs) { machine_mode imode; @@ -3425,12 +3427,12 @@ expand_copysign_bit (machine_mode mode, rtx expand_copysign (rtx op0, rtx op1, rtx target) { - machine_mode mode = GET_MODE (op0); + scalar_float_mode mode; const struct real_format *fmt; bool op0_is_abs; rtx temp; - gcc_assert (SCALAR_FLOAT_MODE_P (mode)); + mode = as_a (GET_MODE (op0)); gcc_assert (GET_MODE (op1) == mode); /* First try to do it with a special instruction. */ Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c 2017-06-22 12:22:56.060377637 +0100 +++ gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:23.793186493 +0100 @@ -3464,8 +3464,10 @@ gnat_type_for_mode (machine_mode mode, i if (COMPLEX_MODE_P (mode)) return NULL_TREE; - if (SCALAR_FLOAT_MODE_P (mode)) - return float_type_for_precision (GET_MODE_PRECISION (mode), mode); + scalar_float_mode float_mode; + if (is_a (mode, &float_mode)) + return float_type_for_precision (GET_MODE_PRECISION (float_mode), + float_mode); if (SCALAR_INT_MODE_P (mode)) return gnat_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); Index: gcc/go/go-lang.c =================================================================== --- gcc/go/go-lang.c 2017-06-12 17:05:23.068757522 +0100 +++ gcc/go/go-lang.c 2017-07-13 09:18:23.798185961 +0100 @@ -382,12 +382,13 @@ go_langhook_type_for_mode (machine_mode return NULL_TREE; } + scalar_float_mode fmode; enum mode_class mc = GET_MODE_CLASS (mode); if (mc == MODE_INT) return go_langhook_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); - else if (mc == MODE_FLOAT) + else if (is_float_mode (mode, &fmode)) { - switch (GET_MODE_BITSIZE (mode)) + switch (GET_MODE_BITSIZE (fmode)) { case 32: return float_type_node; @@ -396,7 +397,7 @@ go_langhook_type_for_mode (machine_mode default: // We have to check for long double in order to support // i386 excess precision. - if (mode == TYPE_MODE(long_double_type_node)) + if (fmode == TYPE_MODE(long_double_type_node)) return long_double_type_node; } } From patchwork Thu Jul 13 08:40:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107594 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1925364qge; Thu, 13 Jul 2017 01:41:15 -0700 (PDT) X-Received: by 10.98.48.69 with SMTP id w66mr43620389pfw.214.1499935275826; Thu, 13 Jul 2017 01:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935275; cv=none; d=google.com; s=arc-20160816; b=TvfA/JBhcaDyZ3ZXDDpPndF0moGQfXN+tzLYq6+vs3lPQFb4zvloY5h12WPZJxTD5n qh1n2Mc8+jdlL3JBZ01lrTqgvmycMuqjVnXyjvl87X1ESzTv7j3t/YH7YleFJqMrI25t 3btFiwgiWZvJJvVJs98aGJF2wsYp+7ZSXd8t7xHH6t1Q5Tf8kWzHNyW4ykOXsbMsklk7 w3nImw0O9btc7tCvNTIWMOLSkN29BG28T4zH0riKRMBF2jmm+h7WvuwXsKo9fouIxwFT cHHzWGnKguW/4z/J+9OZLUSS1oFnuvgkvoZ07T/wcJ9UouNy5PIrcuRMPBPG402t5JT/ shyQ== 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=WjXmUOBEktcNO5C24OqXRdNIsjgGXmUCdVIz9TmkPcM=; b=MQXvpOsGd+7lRF/LHDMVmeriJUmUUzsiY4+CF3DniSocNWj/1fE7JM2CGKT/QQx/ME Wk//CbAKJtxd1v+Gg2Kled2Gly+8MGmDsu6n6bJWMpH/c/geLGTRLfUs+Cn5ELuMrQlY 2cCfIMIQSHrxbjrs55wiPA3fH6EWg8G3Sqei7Xgf96nXgLw3JWjIm2V0Ktvzs6LQB/Ov smURkUpenR3LVG+y69l1B6KlJtg5/OAo1IS8UrstepjnC8Ka77DMvVDF8WxNlzGW0re7 Ur34kLOqk30AXGzvnwChWFs5QbR/DduIc31Zh8Ln4GQC9vHbjFMDDWXPgYqhaNYmIs9q 74HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=Bjsom4OW; spf=pass (google.com: domain of gcc-patches-return-457998-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457998-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 l2si3945717pln.468.2017.07.13.01.41.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457998-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=Bjsom4OW; spf=pass (google.com: domain of gcc-patches-return-457998-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457998-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=VcrqlKJeD/4+zJQCmRygDqu9GBnNy Vj41UA4P7luQK7DYWCf0H/FlhB4MHivUdtEcbox+b0DZRYAtJYhzrd/KVsSM1dWi dp06dpxWIjSm9tjbS+h9HkLbef+m+9LTgPaHy6bU9Sta3TxmS2oVNfg5/RwOJMZa Ha4cxVAJ2pRig4= 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=suOV0Cih5fupNFnCXaZQGr9dRLI=; b=Bjs om4OWrHWEZG+Np4jlQJkJh24GISSW1r4KKlwzbZHGwC+NYBhfFHOhkMAaB/DmN9N WIs+N0bUFjmYnTHE+jZNaxfnw9XHMQKZ/4kHgvcVLzbbd99A0oJCOh9NY0IC9SWZ CuRbh9UQ/lEzeTqKXHz9/tSZ7stUFdp/Hi+4R0cs= Received: (qmail 34308 invoked by alias); 13 Jul 2017 08:41:01 -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 34007 invoked by uid 89); 13 Jul 2017 08:41:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3712 X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:40:59 +0000 Received: by mail-wm0-f51.google.com with SMTP id w126so16366205wme.0 for ; Thu, 13 Jul 2017 01:40:59 -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=WjXmUOBEktcNO5C24OqXRdNIsjgGXmUCdVIz9TmkPcM=; b=uBDLbIuyTVMzhkM3l7QK1OHmxAOEqRvCkznCy1sW49dj+FzicvN/iErj9mjgHVWhFC TQUE9bfWWjhtjrYxD4477GhsGW36kKlSpibJ98aMfsLeS+TuIH0iMz7PFT7h6CSRPbdm VTOAGp9oTT7/a5m7RJGFzu6AzM/8O9tPJ3+9i2aDXLoVPXuIYB1SO/bpVsACeu2qB1C0 pnE0pLIEVc+w4iRligwCjRwJ5/vwvOTK0korTr7OT6MW90xVpmmcl4YX2I+CDS+o1RYV TzpAb6sVwenoOeoreVTHNXhR/wtsk4m0k5hrpQV4jv1/IryZaGr/5WsA48dZWkpVdKVq 2u4g== X-Gm-Message-State: AIVw1125VNuimgFuZExB6VwUa4NNxETn1Hm6UJQu/HomcsJirQY+AOZD hMlela09tFGXg6VKMXkgqw== X-Received: by 10.28.71.133 with SMTP id m5mr1097076wmi.97.1499935257375; Thu, 13 Jul 2017 01:40:57 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id f45sm7182105wrf.2.2017.07.13.01.40.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:40:56 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [08/77] Simplify gen_trunc/extend_conv_libfunc References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:40:55 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <877ezcn2zs.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Replace checks of: GET_MODE_CLASS (fmode) != MODE_FLOAT && !DECIMAL_FLOAT_MODE_P (fmode) with !is_a and use MODE_CLASS equality/inequality instead of: (GET_MODE_CLASS (tmode) == MODE_FLOAT && DECIMAL_FLOAT_MODE_P (fmode)) || (GET_MODE_CLASS (fmode) == MODE_FLOAT && DECIMAL_FLOAT_MODE_P (tmode)) and: (GET_MODE_CLASS (tmode) == MODE_FLOAT && GET_MODE_CLASS (fmode) == MODE_FLOAT) || (DECIMAL_FLOAT_MODE_P (fmode) && DECIMAL_FLOAT_MODE_P (tmode)) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * optabs-libfuncs.c (gen_trunc_conv_libfunc): Use is_a . Simplify. (gen_extend_conv_libfunc): Likewise. Index: gcc/optabs-libfuncs.c =================================================================== --- gcc/optabs-libfuncs.c 2017-07-13 09:18:22.933278054 +0100 +++ gcc/optabs-libfuncs.c 2017-07-13 09:18:24.309132693 +0100 @@ -579,24 +579,20 @@ gen_trunc_conv_libfunc (convert_optab ta machine_mode tmode, machine_mode fmode) { - if (GET_MODE_CLASS (tmode) != MODE_FLOAT && !DECIMAL_FLOAT_MODE_P (tmode)) - return; - if (GET_MODE_CLASS (fmode) != MODE_FLOAT && !DECIMAL_FLOAT_MODE_P (fmode)) - return; - if (tmode == fmode) + scalar_float_mode float_tmode, float_fmode; + if (!is_a (fmode, &float_fmode) + || !is_a (tmode, &float_tmode) + || float_tmode == float_fmode) return; - if ((GET_MODE_CLASS (tmode) == MODE_FLOAT && DECIMAL_FLOAT_MODE_P (fmode)) - || (GET_MODE_CLASS (fmode) == MODE_FLOAT && DECIMAL_FLOAT_MODE_P (tmode))) - gen_interclass_conv_libfunc (tab, opname, tmode, fmode); + if (GET_MODE_CLASS (float_tmode) != GET_MODE_CLASS (float_fmode)) + gen_interclass_conv_libfunc (tab, opname, float_tmode, float_fmode); - if (GET_MODE_PRECISION (fmode) <= GET_MODE_PRECISION (tmode)) + if (GET_MODE_PRECISION (float_fmode) <= GET_MODE_PRECISION (float_tmode)) return; - if ((GET_MODE_CLASS (tmode) == MODE_FLOAT - && GET_MODE_CLASS (fmode) == MODE_FLOAT) - || (DECIMAL_FLOAT_MODE_P (fmode) && DECIMAL_FLOAT_MODE_P (tmode))) - gen_intraclass_conv_libfunc (tab, opname, tmode, fmode); + if (GET_MODE_CLASS (float_tmode) == GET_MODE_CLASS (float_fmode)) + gen_intraclass_conv_libfunc (tab, opname, float_tmode, float_fmode); } /* Pick proper libcall for extend_optab. We need to chose if we do @@ -608,23 +604,19 @@ gen_extend_conv_libfunc (convert_optab t machine_mode tmode, machine_mode fmode) { - if (GET_MODE_CLASS (tmode) != MODE_FLOAT && !DECIMAL_FLOAT_MODE_P (tmode)) - return; - if (GET_MODE_CLASS (fmode) != MODE_FLOAT && !DECIMAL_FLOAT_MODE_P (fmode)) - return; - if (tmode == fmode) + scalar_float_mode float_tmode, float_fmode; + if (!is_a (fmode, &float_fmode) + || !is_a (tmode, &float_tmode) + || float_tmode == float_fmode) return; - if ((GET_MODE_CLASS (tmode) == MODE_FLOAT && DECIMAL_FLOAT_MODE_P (fmode)) - || (GET_MODE_CLASS (fmode) == MODE_FLOAT && DECIMAL_FLOAT_MODE_P (tmode))) - gen_interclass_conv_libfunc (tab, opname, tmode, fmode); + if (GET_MODE_CLASS (float_tmode) != GET_MODE_CLASS (float_fmode)) + gen_interclass_conv_libfunc (tab, opname, float_tmode, float_fmode); - if (GET_MODE_PRECISION (fmode) > GET_MODE_PRECISION (tmode)) + if (GET_MODE_PRECISION (float_fmode) > GET_MODE_PRECISION (float_tmode)) return; - if ((GET_MODE_CLASS (tmode) == MODE_FLOAT - && GET_MODE_CLASS (fmode) == MODE_FLOAT) - || (DECIMAL_FLOAT_MODE_P (fmode) && DECIMAL_FLOAT_MODE_P (tmode))) + if (GET_MODE_CLASS (float_tmode) == GET_MODE_CLASS (float_fmode)) gen_intraclass_conv_libfunc (tab, opname, tmode, fmode); } From patchwork Thu Jul 13 08:41:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107595 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1925791qge; Thu, 13 Jul 2017 01:41:48 -0700 (PDT) X-Received: by 10.84.136.70 with SMTP id 64mr8738564plk.50.1499935308246; Thu, 13 Jul 2017 01:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935308; cv=none; d=google.com; s=arc-20160816; b=gFvURbq5DUsIpUS0a33rw8QVrk0YGDvixLPWv0WGQpibg9vKTYetdKvQKSYE2BPTyf pP8jekJeDF+OHiok35R5+ddLN915CU/SwU8YxsiDJ97t2aJkC97w//JbouGF8MlLY6b1 FVKGt7vG9z9HQGIkKArjMGoUAJwDoILECFAUc8fKhale2jwXqq/bC49R7JZOce3n1ddz bg7p/affoktusQw4IpDf1vLPNUcsLC67HTTgsV4MyG+PNkBskUtheua2QdFR6BVzNlip uWZZDWT0cypvQAYliGP+QDrKwkCORapc6Uv4G89K15VnOaQBJNQVO46S8UvKgcKDz9Fv AQFw== 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=fTFcJ/p5NbtDdkFKtaSZpglRdXA4SL44mZErTok/7fg=; b=hiOlvz2Ytofuj3yQh0ncMY0Qrhf30fjLYepSTmN8ZMhojPSoiKxbtPMmtq+qJp71LP lw7N1rimyx1kohg5fuWI2o5apItzNQmGtU/NesodE+oUCXdg0iTZCGKuTjpvkwXisr3C sj7cKZn2rIS4Pvk51x+PIey+eHSDEQ7fzWyZENM/cj/8TXZni3QB3bT+KJR01smSdL7W TShsSoZF5x1zf+CQnfmykayUlR5Gj6bWPHDVTgi7iYRkM4i59Fu8ltxBOVRZ5KOIqSNE KVtB0N8KRx9nmW0SwwCSV9uZZ4DLKpNJ0c+FunPzsrVjVQ1QyNUg6Nf1OCu+N5hFUjwo jwkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=bX7U6OV6; spf=pass (google.com: domain of gcc-patches-return-457999-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457999-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 v2si3812139pgq.403.2017.07.13.01.41.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457999-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=bX7U6OV6; spf=pass (google.com: domain of gcc-patches-return-457999-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457999-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=DPbuDt9vj/oLI3eAl6DO6H+A7Wr+w kR4GauzunkGmfpcK2EiLBNRFo4nFE7BZkiV5P/FlmXqgv3H21OkbKkjWyteU1B7q xQYlleNGJXaM9Z07wkAg3berpHzw818Eqk4PwEgJBYbSxFZ4rgfZCSXjRrbVT4Yc nSqORsPtIECUZg= 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=XxNzHmnG7QCEN30dw+39GRz9U2o=; b=bX7 U6OV6pLKygzBHWws9r4cGlSoEgUtVVGInli4wb3vl1Bccrg7nf++cpQ3Q/75z7RB HcVYb8nJo17fek/8tvvuUKp5+Ek6yks/s48L4fFgQbGaszaruDeYcsUGSKNDU+Ms fWT7HHctcOTyeXHOFXotC1Poy6Y5orgjy+/IqmDo= Received: (qmail 52196 invoked by alias); 13 Jul 2017 08:41:33 -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 51113 invoked by uid 89); 13 Jul 2017 08:41:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:41:31 +0000 Received: by mail-wm0-f44.google.com with SMTP id f67so18007621wmh.1 for ; Thu, 13 Jul 2017 01:41:30 -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=fTFcJ/p5NbtDdkFKtaSZpglRdXA4SL44mZErTok/7fg=; b=qLuA4QTklThtEUxcycjo9aWg/sRefIAPhX2impu29JJ8zTEgxrBwUZyzIvM3vz/JJU JZunaTrEM76woXItZF+cxMbBpXOrh6ryCh8eWlqwUKS1FSJA7l60XqjInzQ3U+PtI5X3 LL77fSjupE9Y9raB/OtmqE2tBIgosCIvPwNPQBIMRGDJKzgOj3dMS5zRLtdankxMJlED ZaKHkDJAh0CwNCKJ9T7wqRIyp9bZLUIoXX0JDoxrs6f1jPAmLDV0O4Xn6fbv7r6Ltp62 EV2m+2ecaK49LaUqZ723ieJX5BCzM5qc40vM5D1T+J0sSFSi8pnceY+4uJW9Jp3Nc/Z0 jzEQ== X-Gm-Message-State: AIVw113rNdU6IMuf1qhv86RCUux/h2RoQey7WNpwB7qkXPcQHKcveFOu R5gRpem8nPTElog90GD6mg== X-Received: by 10.28.136.129 with SMTP id k123mr1136552wmd.14.1499935288900; Thu, 13 Jul 2017 01:41:28 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 32sm5615294wry.31.2017.07.13.01.41.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:41:28 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [09/77] Add SCALAR_FLOAT_TYPE_MODE References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:41:26 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8737a0n2yx.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a macro that extracts the TYPE_MODE and forcibly converts it to a scalar_float_mode. The forcible conversion includes a gcc_checking_assert that the mode is a SCALAR_FLOAT_MODE_P. This becomes important as more static type checking is added by later patches. It has the additional benefit of bypassing the VECTOR_TYPE_P (...) ? vector_type_mode (...) : ... condition in TYPE_MODE; in release builds the new macro is a simple field access. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (SCALAR_FLOAT_TYPE_MODE): New macro. * builtins.c (expand_builtin_signbit): Use it instead of TYPE_MODE. * fold-const.c (fold_convert_const_real_from_fixed): Likewise. (native_encode_real): Likewise. (native_interpret_real): Likewise. * hsa-brig.c (emit_immediate_scalar_to_buffer): Likewise. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. gcc/cp/ * mangle.c (write_real_cst): Use SCALAR_FLOAT_TYPE_MODE instead of TYPE_MODE. gcc/fortran/ * target-memory.c (size_float): Use SCALAR_FLOAT_TYPE_MODE instead of TYPE_MODE. gcc/objc/ * objc-encoding.c (encode_type): Use SCALAR_FLOAT_TYPE_MODE instead of TYPE_MODE. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-06-30 12:50:37.494697187 +0100 +++ gcc/tree.h 2017-07-13 09:18:24.776086502 +0100 @@ -1852,6 +1852,8 @@ #define TYPE_MODE_RAW(NODE) (TYPE_CHECK #define TYPE_MODE(NODE) \ (VECTOR_TYPE_P (TYPE_CHECK (NODE)) \ ? vector_type_mode (NODE) : (NODE)->type_common.mode) +#define SCALAR_FLOAT_TYPE_MODE(NODE) \ + (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SET_TYPE_MODE(NODE, MODE) \ (TYPE_CHECK (NODE)->type_common.mode = (MODE)) Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2017-07-13 09:18:21.522430235 +0100 +++ gcc/builtins.c 2017-07-13 09:18:24.772086898 +0100 @@ -5365,7 +5365,8 @@ expand_builtin_adjust_descriptor (tree e expand_builtin_signbit (tree exp, rtx target) { const struct real_format *fmt; - machine_mode fmode, imode, rmode; + scalar_float_mode fmode; + machine_mode imode, rmode; tree arg; int word, bitpos; enum insn_code icode; @@ -5376,7 +5377,7 @@ expand_builtin_signbit (tree exp, rtx ta return NULL_RTX; arg = CALL_EXPR_ARG (exp, 0); - fmode = TYPE_MODE (TREE_TYPE (arg)); + fmode = SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (arg)); rmode = TYPE_MODE (TREE_TYPE (exp)); fmt = REAL_MODE_FORMAT (fmode); Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-06-30 12:50:37.496697095 +0100 +++ gcc/fold-const.c 2017-07-13 09:18:24.774086700 +0100 @@ -2040,7 +2040,8 @@ fold_convert_const_real_from_fixed (tree REAL_VALUE_TYPE value; tree t; - real_convert_from_fixed (&value, TYPE_MODE (type), &TREE_FIXED_CST (arg1)); + real_convert_from_fixed (&value, SCALAR_FLOAT_TYPE_MODE (type), + &TREE_FIXED_CST (arg1)); t = build_real (type, value); TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1); @@ -7145,7 +7146,7 @@ native_encode_fixed (const_tree expr, un native_encode_real (const_tree expr, unsigned char *ptr, int len, int off) { tree type = TREE_TYPE (expr); - int total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); + int total_bytes = GET_MODE_SIZE (SCALAR_FLOAT_TYPE_MODE (type)); int byte, offset, word, words, bitpos; unsigned char value; @@ -7390,7 +7391,7 @@ native_interpret_fixed (tree type, const static tree native_interpret_real (tree type, const unsigned char *ptr, int len) { - machine_mode mode = TYPE_MODE (type); + scalar_float_mode mode = SCALAR_FLOAT_TYPE_MODE (type); int total_bytes = GET_MODE_SIZE (mode); unsigned char value; /* There are always 32 bits in each long, no matter the size of Index: gcc/hsa-brig.c =================================================================== --- gcc/hsa-brig.c 2017-06-07 07:42:16.638117371 +0100 +++ gcc/hsa-brig.c 2017-07-13 09:18:24.774086700 +0100 @@ -910,7 +910,7 @@ emit_immediate_scalar_to_buffer (tree va "operands"); return 2; } - unsigned int_len = GET_MODE_SIZE (TYPE_MODE (type)); + unsigned int_len = GET_MODE_SIZE (SCALAR_FLOAT_TYPE_MODE (type)); /* There are always 32 bits in each long, no matter the size of the hosts long. */ long tmp[6]; Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c 2017-07-13 09:18:22.943276979 +0100 +++ gcc/tree-vrp.c 2017-07-13 09:18:24.776086502 +0100 @@ -10089,7 +10089,8 @@ simplify_float_conversion_using_ranges ( { tree rhs1 = gimple_assign_rhs1 (stmt); value_range *vr = get_value_range (rhs1); - machine_mode fltmode = TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))); + scalar_float_mode fltmode + = SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))); machine_mode mode; tree tem; gassign *conv; Index: gcc/cp/mangle.c =================================================================== --- gcc/cp/mangle.c 2017-07-02 09:32:32.533745269 +0100 +++ gcc/cp/mangle.c 2017-07-13 09:18:24.773086799 +0100 @@ -1788,7 +1788,7 @@ write_real_cst (const tree value) int i, limit, dir; tree type = TREE_TYPE (value); - int words = GET_MODE_BITSIZE (TYPE_MODE (type)) / 32; + int words = GET_MODE_BITSIZE (SCALAR_FLOAT_TYPE_MODE (type)) / 32; real_to_target (target_real, &TREE_REAL_CST (value), TYPE_MODE (type)); Index: gcc/fortran/target-memory.c =================================================================== --- gcc/fortran/target-memory.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/fortran/target-memory.c 2017-07-13 09:18:24.774086700 +0100 @@ -46,7 +46,7 @@ size_integer (int kind) static size_t size_float (int kind) { - return GET_MODE_SIZE (TYPE_MODE (gfc_get_real_type (kind)));; + return GET_MODE_SIZE (SCALAR_FLOAT_TYPE_MODE (gfc_get_real_type (kind))); } Index: gcc/objc/objc-encoding.c =================================================================== --- gcc/objc/objc-encoding.c 2017-07-13 09:18:19.145691430 +0100 +++ gcc/objc/objc-encoding.c 2017-07-13 09:18:24.775086601 +0100 @@ -664,7 +664,7 @@ encode_type (tree type, int curtype, int { char c; /* Floating point types. */ - switch (GET_MODE_BITSIZE (TYPE_MODE (type))) + switch (GET_MODE_BITSIZE (SCALAR_FLOAT_TYPE_MODE (type))) { case 32: c = 'f'; break; case 64: c = 'd'; break; From patchwork Thu Jul 13 08:41:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107596 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1926204qge; Thu, 13 Jul 2017 01:42:20 -0700 (PDT) X-Received: by 10.98.23.3 with SMTP id 3mr60158413pfx.55.1499935340400; Thu, 13 Jul 2017 01:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935340; cv=none; d=google.com; s=arc-20160816; b=oNhsrnim5eHO9RNvAf3eh+N/zEq713rgBi8WatPghlBa9aQkWl5Ifhw9h5gBMRKmQy lOqUO6Cpx1e3SRW4//WqAR01qwfok8HvlQxLSpRuFK6Hixh2x987qM9LDFCum80AtjTr irboKU5BvXsOTsnIgqxzv+C3egr9nif4SfoasRUlzWFG34pGTD/VTI+goU1SPNNIDqDv BnxqytLwq3l5HUMg9ftANXLsu2goCXrYiia4AkZmjrYc2gXjpbAwnm5Gyjjg3mCdn2F6 dicJTlBtuSXSwyaI8n7+6vVug8omZHYrw3NWaanIJStFXHrazZ2yL19ZgmHEltNzzjZA oLhA== 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=/QtbBeLApNce57myQENfqquVVPfTlPo11c0BWfMKlrk=; b=gIG9hHe2S28v5qzuS/6pHXp03AcMvKWVE2JCeZ3zrs4dnsIjsVE1msVV6N/CXKW1CC J2SjZJOvN5HVv5OPkaUT96887RgRncJMM32ZGpraRJs3ihVkAvLUQadm/hkHvbWTkhN4 qCd+HjALdirVyyewXut98nhvMOLwOFbzwaF5f0hcFZ4SxBcjDoFXrWDvx7qotBMHmUM4 +Re/yHz1bv3UuLkjIsq0LUiTSU90QPKNPz2lSTKbJMHC4WSY3NPYFIfGpPaZvHkpmDyR Z877Gisgeh8h98G1esLEbPmX+NXWsntkn7FGs3bUcnp6xJAnpIx4l1Fq3Fye1Atr9u80 iIPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=sLPdRRbl; spf=pass (google.com: domain of gcc-patches-return-458000-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458000-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 i7si4049831plk.473.2017.07.13.01.42.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:42:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458000-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=sLPdRRbl; spf=pass (google.com: domain of gcc-patches-return-458000-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458000-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=bpaGFlTd1X6ZUtjuxXXkIknPZfXS0 OzEZzOtKPP7xvkg+/UfNuOIxyfSUnswJPvoKKuRRwZhQlRyLi0O8TSP9CNcZaawQ oZzv+KGVOFK2wSBkcwQY4BqVbhLUz5i+xflD+TT22YSlP4egIfSBiCg5mO53uj+y 9lkHQySY0taq/0= 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=xeQNPERO6cpQolheXCjGdEvPcXM=; b=sLP dRRblUUKXWzbOwSalpXeljrBtOa3WGHaIF3P8R4l+HweBHKRO49S2rl2ez58eO/e shp9uZtzKIuoY2YfoZI7IHmADKuj72xb9tBhap1zSvcI1Q0v7jghMiiFaGagh3w0 pJWjMgfR/KYe6L8mnVuav8+ZlnFOwVHBT5bMKgEg= Received: (qmail 92853 invoked by alias); 13 Jul 2017 08:42:05 -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 91400 invoked by uid 89); 13 Jul 2017 08:42:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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=assemble, HIGH, SEC, REVERSE X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:42:03 +0000 Received: by mail-wm0-f44.google.com with SMTP id t70so2156387wmt.0 for ; Thu, 13 Jul 2017 01:42:02 -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=/QtbBeLApNce57myQENfqquVVPfTlPo11c0BWfMKlrk=; b=RA4+OiaiFWlHH0I4Ol0QYfXin+BvDONRFOVj8G2M6LolZR+y/2TRY4Y0OeLVGYZFHA T5ZSBudhQ13/2Hk/8TrDugZy96GRXKSK86xj53ohfe9LM0qgdHbX0YpVKpNGbw4uht4O 9y77hwA+pGzr3w3eNsCJY7PNCCnFBX6ra3YSxAvNOZLTy/rbZ4CQVbf6bins5aHah5Wm Z/eWVXGxtcNHyu5tNB6NIoRUsyT7B07W3CRt99j3NEtlV6+v0lUmqL4sH/p/yIFKdyGr 992ioY+Xy2aNsLSPrirUBVohq9WKp4e4zesDO8AaLAhbEdWlLuppM7GsS1wWo4viZV21 BvtA== X-Gm-Message-State: AIVw11014PmTQoeSbVQdp6ErK++y2N/14mU+Cvc4C8HuN3Rvb2aeGss1 UkdnWdRf/4aBKLNGsPfpBA== X-Received: by 10.28.191.134 with SMTP id o6mr1071101wmi.11.1499935320694; Thu, 13 Jul 2017 01:42:00 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id n205sm3435855wmf.21.2017.07.13.01.41.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:41:59 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [10/77] Make assemble_real take a scalar_float_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:41:58 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87y3rslodl.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 As per subject. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * output.h (assemble_real): Take a scalar_float_mode. * config/arm/arm.c (arm_assemble_integer): Update accordingly. * config/arm/arm.md (consttable_4): Likewise. (consttable_8): Likewise. (consttable_16): Likewise. * config/mips/mips.md (consttable_float): Likewise. * config/s390/s390.c (s390_output_pool_entry): Likewise. * varasm.c (assemble_real): Take a scalar_float_mode. (output_constant_pool_2): Update accordingly. (output_constant): Likewise. Index: gcc/output.h =================================================================== --- gcc/output.h 2017-02-23 19:54:20.000000000 +0000 +++ gcc/output.h 2017-07-13 09:18:25.330032056 +0100 @@ -281,7 +281,7 @@ #define assemble_aligned_integer(SIZE, V /* Assemble the floating-point constant D into an object of size MODE. ALIGN is the alignment of the constant in bits. If REVERSE is true, D is output in reverse storage order. */ -extern void assemble_real (REAL_VALUE_TYPE, machine_mode, unsigned, +extern void assemble_real (REAL_VALUE_TYPE, scalar_float_mode, unsigned, bool = false); /* Write the address of the entity given by SYMBOL to SEC. */ Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-13 09:18:19.034703736 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:25.327032350 +0100 @@ -22664,8 +22664,9 @@ arm_assemble_integer (rtx x, unsigned in for (i = 0; i < units; i++) { rtx elt = CONST_VECTOR_ELT (x, i); - assemble_real - (*CONST_DOUBLE_REAL_VALUE (elt), GET_MODE_INNER (mode), + assemble_real + (*CONST_DOUBLE_REAL_VALUE (elt), + as_a (GET_MODE_INNER (mode)), i == 0 ? BIGGEST_ALIGNMENT : size * BITS_PER_UNIT); } Index: gcc/config/arm/arm.md =================================================================== --- gcc/config/arm/arm.md 2017-06-16 10:02:37.333681715 +0100 +++ gcc/config/arm/arm.md 2017-07-13 09:18:25.328032252 +0100 @@ -11232,13 +11232,11 @@ (define_insn "consttable_4" { rtx x = operands[0]; making_const_table = TRUE; - switch (GET_MODE_CLASS (GET_MODE (x))) + scalar_float_mode float_mode; + if (is_a (GET_MODE (x), &float_mode)) + assemble_real (*CONST_DOUBLE_REAL_VALUE (x), float_mode, BITS_PER_WORD); + else { - case MODE_FLOAT: - assemble_real (*CONST_DOUBLE_REAL_VALUE (x), GET_MODE (x), - BITS_PER_WORD); - break; - default: /* XXX: Sometimes gcc does something really dumb and ends up with a HIGH in a constant pool entry, usually because it's trying to load into a VFP register. We know this will always be used in @@ -11248,7 +11246,6 @@ (define_insn "consttable_4" x = XEXP (x, 0); assemble_integer (x, 4, BITS_PER_WORD, 1); mark_symbol_refs_as_used (x); - break; } return \"\"; }" @@ -11262,16 +11259,12 @@ (define_insn "consttable_8" "* { making_const_table = TRUE; - switch (GET_MODE_CLASS (GET_MODE (operands[0]))) - { - case MODE_FLOAT: - assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]), - GET_MODE (operands[0]), BITS_PER_WORD); - break; - default: - assemble_integer (operands[0], 8, BITS_PER_WORD, 1); - break; - } + scalar_float_mode float_mode; + if (is_a (GET_MODE (operands[0]), &float_mode)) + assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]), + float_mode, BITS_PER_WORD); + else + assemble_integer (operands[0], 8, BITS_PER_WORD, 1); return \"\"; }" [(set_attr "length" "8") @@ -11284,16 +11277,12 @@ (define_insn "consttable_16" "* { making_const_table = TRUE; - switch (GET_MODE_CLASS (GET_MODE (operands[0]))) - { - case MODE_FLOAT: - assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]), - GET_MODE (operands[0]), BITS_PER_WORD); - break; - default: - assemble_integer (operands[0], 16, BITS_PER_WORD, 1); - break; - } + scalar_float_mode float_mode; + if (is_a (GET_MODE (operands[0]), &float_mode)) + assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]), + float_mode, BITS_PER_WORD); + else + assemble_integer (operands[0], 16, BITS_PER_WORD, 1); return \"\"; }" [(set_attr "length" "16") Index: gcc/config/mips/mips.md =================================================================== --- gcc/config/mips/mips.md 2017-07-13 09:18:19.078698858 +0100 +++ gcc/config/mips/mips.md 2017-07-13 09:18:25.329032154 +0100 @@ -7358,7 +7358,7 @@ (define_insn "consttable_float" { gcc_assert (GET_CODE (operands[0]) == CONST_DOUBLE); assemble_real (*CONST_DOUBLE_REAL_VALUE (operands[0]), - GET_MODE (operands[0]), + as_a (GET_MODE (operands[0])), GET_MODE_BITSIZE (GET_MODE (operands[0]))); return ""; } Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:19.123693869 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:25.330032056 +0100 @@ -9494,7 +9494,8 @@ s390_output_pool_entry (rtx exp, machine case MODE_DECIMAL_FLOAT: gcc_assert (GET_CODE (exp) == CONST_DOUBLE); - assemble_real (*CONST_DOUBLE_REAL_VALUE (exp), mode, align); + assemble_real (*CONST_DOUBLE_REAL_VALUE (exp), + as_a (mode), align); break; case MODE_INT: Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-06-12 17:05:23.276759414 +0100 +++ gcc/varasm.c 2017-07-13 09:18:25.331031958 +0100 @@ -2759,7 +2759,7 @@ assemble_integer (rtx x, unsigned int si in reverse storage order. */ void -assemble_real (REAL_VALUE_TYPE d, machine_mode mode, unsigned int align, +assemble_real (REAL_VALUE_TYPE d, scalar_float_mode mode, unsigned int align, bool reverse) { long data[4] = {0, 0, 0, 0}; @@ -3829,7 +3829,8 @@ output_constant_pool_2 (machine_mode mod case MODE_DECIMAL_FLOAT: { gcc_assert (CONST_DOUBLE_AS_FLOAT_P (x)); - assemble_real (*CONST_DOUBLE_REAL_VALUE (x), mode, align, false); + assemble_real (*CONST_DOUBLE_REAL_VALUE (x), + as_a (mode), align, false); break; } @@ -4811,7 +4812,8 @@ output_constant (tree exp, unsigned HOST if (TREE_CODE (exp) != REAL_CST) error ("initializer for floating value is not a floating constant"); else - assemble_real (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)), + assemble_real (TREE_REAL_CST (exp), + SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (exp)), align, reverse); break; From patchwork Thu Jul 13 08:42:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107597 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1926546qge; Thu, 13 Jul 2017 01:42:44 -0700 (PDT) X-Received: by 10.98.163.88 with SMTP id s85mr59945581pfe.217.1499935364256; Thu, 13 Jul 2017 01:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935364; cv=none; d=google.com; s=arc-20160816; b=g/QiHQd+3C3mmqKH5IFa+S4DoE3AO8uckXgGJJ5EmDJaDHmP2RP5AAz/Jf84gUC3XV zPx9jmEC825CIAwTGt3K9xwO3j3ThE74T2pLYo/8HXb/9lSoa93NC62MsICGkGxX1YUG 8LDrRR33lXPzWbaau5p0pYJndd9WNitNNlsojzds84+a5t57nweYVjnJbMFrJDNnbsiD +P3mnXeIYxWx4lnGMmPO0BvsO0mvwvm6eM1DlcuNM0P5L/bvtHCyaqVxjdIYJ1Exoz43 X/8m7Dvx4oiaUF07ezuSWyQkJzZN/U1XZWtOd3Tu7OK5UHzBLsXDTW05PejZQrU7e86h GwDQ== 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=/mxNGxKRxj3mIWRX0CX59mVVkoKopdn1vMSCsORfizE=; b=IkA4Xu89UKuBZzd91BnPTmm+qrjIRXIfPlGSOzg346LJvby9NSmFV6cJMr/yzq43zF uMQinb96XmstgjIaqjKmq3mZCFvaTSl9/M9mIz0Dj/Iu2XmqqQX+l90749eMrINuu3I8 3LYqIUJPMxtNNtFnLNBkx5rseNESzjs8NnpYAIffwWS4TyR0PVwFGLrdz5WUvIjo3ona SbsHcjbxembnkuxiz+R1l60MKgQnFS6DWNvDeE0Hwbmz8+1uGnEUf9fcgXZRCLU3RpW9 CTTSI73cDKH3x+axA6DaSx0Rm8fiZUoNuVjpMqRxrI+qQJB8PQskvxtU+K41S5SMvwWl 7v4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=pY75F5wd; spf=pass (google.com: domain of gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458001-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 x187si3891454pgx.147.2017.07.13.01.42.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458001-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=pY75F5wd; spf=pass (google.com: domain of gcc-patches-return-458001-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458001-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=JcunSsNjJVquM/qsfYLht/1urmSBi lycuw71+KhU+gSgAWlRUYWTsZaauZk9h/TeG3py96T52DHXqhzaGBlChG+wzj21i 2cMR1odIyIi1tYjzMkyyBbeXDlZNbs9qAVb9+HWPXHUPbCLTCI+buGCF+IBxbWtt TwkU4B2SiAf9wU= 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=xwn3423t1wB7woPmc4rDXxdh4oA=; b=pY7 5F5wd3yYKxUUL5tzNyKWn6U7yvO1DFzH/lRPjFzLAwnXNhuoyzQ8MbjGOW6ZDwgF QF4hAxzqfPu0OA1EloYy3ERi+MkCyxegwHc4s35nAKKSty/5fOD9Hm2VeHWoFo97 Rlbinh0Dn50VlhgGjYFuwRRCj1SVQVsx10aduLMc= Received: (qmail 112258 invoked by alias); 13 Jul 2017 08:42:26 -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 111170 invoked by uid 89); 13 Jul 2017 08:42:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:42:24 +0000 Received: by mail-wm0-f44.google.com with SMTP id i127so18003598wma.0 for ; Thu, 13 Jul 2017 01:42:24 -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=/mxNGxKRxj3mIWRX0CX59mVVkoKopdn1vMSCsORfizE=; b=OwACebKFxnzW7T7f8xtGBRIty3DqEDB//Oop+X49guRq12h8BKuZX54ltpfSseefDx I+BJpuoX+h3mn5ehu5RnaTk5Nm9ixrEnoTmfIrbkpKgMoUwlyQLNgaMeODz0+pIpA2us SZ7eRBsywuMi1w1cFZRvA4FtR/PexA72FQfxzdONCPPPc6EdWJekAdieNtnTJ4ljz4VA kKn1GlA6DWoJPgKp0IkB7iGWCF7NtEfsUwqf775sOlMJm8TOFJxzsg65K9+e+RkJw/fx JbMxjJx6ECFtgDv4Tyoj8IUSqP019qwoKlI46BhLyOeZGBL0AxjPSQrHIaOLaFRFZLc3 2t3g== X-Gm-Message-State: AIVw110/3gM5LV+Hvod+3crNM+0b8CZuefFD6NmHG7/rs/7nPIY+rhp2 i3sZy2HZZ7S6BAHroIPeRA== X-Received: by 10.28.68.132 with SMTP id r126mr1077111wma.118.1499935342604; Thu, 13 Jul 2017 01:42:22 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id q70sm4570198wrb.3.2017.07.13.01.42.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:42:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [11/77] Add a float_mode_for_size helper function References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:42:20 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87tw2glocz.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This provides a type-safe way to ask for a float mode and get it as a scalar_float_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (opt_scalar_float_mode): New typedef. * machmode.h (float_mode_for_size): New function. * emit-rtl.c (double_mode): Delete. (init_emit_once): Use float_mode_for_size. * stor-layout.c (layout_type): Likewise. * gdbhooks.py (build_pretty_printer): Handle opt_scalar_float_mode. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:23.795186280 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:25.915974717 +0100 @@ -57,6 +57,7 @@ typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; class scalar_float_mode; template class opt_mode; +typedef opt_mode opt_scalar_float_mode; /* Subclasses of rtx_def, using indentation to show the class hierarchy, along with the relevant invariant. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:23.798185961 +0100 +++ gcc/machmode.h 2017-07-13 09:18:25.916974620 +0100 @@ -521,7 +521,16 @@ #define GET_MODE_COMPLEX_MODE(MODE) ((ma extern machine_mode mode_for_size (unsigned int, enum mode_class, int); -/* Similar, but find the smallest mode for a given width. */ +/* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one + exists. */ + +inline opt_scalar_float_mode +float_mode_for_size (unsigned int size) +{ + return dyn_cast (mode_for_size (size, MODE_FLOAT, 0)); +} + +/* Similar to mode_for_size, but find the smallest mode for a given width. */ extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class); Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:21.530429366 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:25.916974620 +0100 @@ -71,7 +71,6 @@ #define initial_regno_reg_rtx (this_targ machine_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */ machine_mode word_mode; /* Mode whose width is BITS_PER_WORD. */ -machine_mode double_mode; /* Mode whose width is DOUBLE_TYPE_SIZE. */ machine_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */ /* Datastructures maintained for currently processed function in RTL form. */ @@ -5895,7 +5894,7 @@ init_emit_once (void) { int i; machine_mode mode; - machine_mode double_mode; + scalar_float_mode double_mode; /* Initialize the CONST_INT, CONST_WIDE_INT, CONST_DOUBLE, CONST_FIXED, and memory attribute hash tables. */ @@ -5939,7 +5938,7 @@ init_emit_once (void) else const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE); - double_mode = mode_for_size (DOUBLE_TYPE_SIZE, MODE_FLOAT, 0); + double_mode = *float_mode_for_size (DOUBLE_TYPE_SIZE); real_from_integer (&dconst0, double_mode, 0, SIGNED); real_from_integer (&dconst1, double_mode, 1, SIGNED); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:22.938277517 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:25.916974620 +0100 @@ -2142,14 +2142,16 @@ layout_type (tree type) break; case REAL_TYPE: - /* Allow the caller to choose the type mode, which is how decimal - floats are distinguished from binary ones. */ - if (TYPE_MODE (type) == VOIDmode) - SET_TYPE_MODE (type, - mode_for_size (TYPE_PRECISION (type), MODE_FLOAT, 0)); - TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); - break; + { + /* Allow the caller to choose the type mode, which is how decimal + floats are distinguished from binary ones. */ + if (TYPE_MODE (type) == VOIDmode) + SET_TYPE_MODE (type, *float_mode_for_size (TYPE_PRECISION (type))); + scalar_float_mode mode = as_a (TYPE_MODE (type)); + TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); + TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); + break; + } case FIXED_POINT_TYPE: /* TYPE_MODE (type) has been set already. */ Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:23.798185961 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:25.916974620 +0100 @@ -542,6 +542,8 @@ def build_pretty_printer(): pp.add_printer_for_regex(r'opt_mode<(\S+)>', 'opt_mode', OptMachineModePrinter) + pp.add_printer_for_types(['opt_scalar_float_mode'], + 'opt_mode', OptMachineModePrinter) pp.add_printer_for_types(['scalar_float_mode'], 'scalar_float_mode', MachineModePrinter) From patchwork Thu Jul 13 08:42:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107598 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1926932qge; Thu, 13 Jul 2017 01:43:15 -0700 (PDT) X-Received: by 10.98.204.194 with SMTP id j63mr59454693pfk.137.1499935395782; Thu, 13 Jul 2017 01:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935395; cv=none; d=google.com; s=arc-20160816; b=sl409snK6DcXdeSbZdDw2C1YJpDqAo23/69zxyTyP0ZTE81A522ciKAijsMXNUFwhd mFotFIge2kbhrTGhOyXEI9pwXBzbANHEN6OVW/li9AnejyTDnCfRW3oC/X8HXjtZgPIm dJCaG7udN22VAbOnLUKJe5SI9tJ7M8L1FJP57ohr6pSFPLS1xiZY08amVcgNLCPfnF6y YHBLLZBUa385EnAyuo73czwP589T+gNydh5Wt6M74Qhnks2qmFFIBOchpCfVZPAJ02J4 bPjlm+692T+DTeB4REK3yKkKuHOogBXoP3pYTiFztgp2xxgeMRX8FimukwPn/AUz35M1 +bsg== 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=jCyLiFcBAADywL7i+teezl8j0wSODIHhGbfrImBdGPc=; b=v+kgVDeN0V0UWtjkqTMdQIJLHMdUkkhMnVeB78fbxJ//vgykP42wHUv2hneg0xV8o9 +ZYNLuzjj+1C/Rgrkg7cOfFVUWib7cwQccVGhTR7M+PxEveXFcc9oy7Dv8tD7UU3ycNK Zo5U6WQt3JOc0Mx30auHjNg4KFN5NiuYvrdxg8NvQQpkNPbhPMGQbh/ig4IM3dwMyCNP bEDOIzDZYgQklZ3Qdl/FTtPSaFkwfyVH15i7Qj2nOHA0uWlUjwdoR5rtUet27ufcqlUf UqboN8zjWSm7s4BFBOqRqi6WVjn54GUs8i+roLOMAiC0zZnzUuKF6TMBBxc6hcWCZ+Vl IXLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=GIy8s5KA; spf=pass (google.com: domain of gcc-patches-return-458002-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458002-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 v11si3726385pfd.94.2017.07.13.01.43.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:43:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458002-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=GIy8s5KA; spf=pass (google.com: domain of gcc-patches-return-458002-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458002-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=TegtCRpsdCH1dVxPfrxPqlRWiI0yh cMhi3H3+2sXVXDzqGs3aHVcxe+fS4aza+7OyKGpCQ6uNxmtqWFBS0F8iv4j2lpAp GCritMw/Argc+cZCbJHX7jyTHNhbJQ4JAK9cf/yld0PK0hInJsJ9Sny/bLX/zEWm cMmz2faHHEJZeg= 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=0FFLJp6Mc2eJXamqtMv0AW2SSoo=; b=GIy 8s5KAlHMeA1J7EgeeAQAhYE8HXQl+OK/04NVP7FKp0deYj0rpLgEulGqfOtkMdix lsxXAuqGCkcmvw9Zvj8jKqIy7F4qbP5q7KuxCZhWswiEtUV8QgFeNh47tRrwXria b4Ju5TBmZ4MuqZpjNYqyVrRNfVkK9XPJpOkUN2O8= Received: (qmail 1580 invoked by alias); 13 Jul 2017 08:42:53 -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 387 invoked by uid 89); 13 Jul 2017 08:42:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, 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-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:42:50 +0000 Received: by mail-wm0-f41.google.com with SMTP id f67so18042518wmh.1 for ; Thu, 13 Jul 2017 01:42:50 -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=jCyLiFcBAADywL7i+teezl8j0wSODIHhGbfrImBdGPc=; b=mWCOqVg9WjBBrzTNH97sLlFOKZrxP2/8MyrVTIaJniQWvN/iGdaIYTy6FyO02XKFDY IqQaBNkVr4LnAZN5b8By8gfi05Muh2/dFi8vXIfW+Rq7BNJdT6MOpPanO1YxsqpsBSUU uPFrM/DLZ5Ef2fjpVPDjUihOu4c0xbnn5jRFkue+DWQjOv4Y2FbVFhK4iib+5zFdnPhH icUHY4gyvShdtANuTprXaDnVKfzejPJMCYkrVQEUpYiX2qG57xikcwfv+hRQior7dHmC K5LxhYGY5yBpijguZXbP01zSeAFiL9DaUM1/VEtPpGKSmWJOca9wJTDWM/8/4vxQefad B3uA== X-Gm-Message-State: AIVw111j1TzLMcGjCU3njddwjXW69lc/+qpgd3uLXm2l2eZVgIrW+APs oCUIxA/f4CcgTFTaxkUfcg== X-Received: by 10.28.138.13 with SMTP id m13mr1073542wmd.97.1499935368177; Thu, 13 Jul 2017 01:42:48 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id r200sm4323355wmd.20.2017.07.13.01.42.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:42:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [12/77] Use opt_scalar_float_mode when iterating over float modes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:42:45 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87pod4loca.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This means that we know when accessing the modes that the size is a compile-time constant, even for SVE. It also enables stricter type safety in later patches. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (mode_iterator::start): Provide overload for opt_modes. (mode_iterator::iterate_p): Likewise. (mode_iterator::get_wider): Likewise. * expr.c (init_expr_target): Use opt_scalar_float_mode. gcc/ada/ * gcc-interface/misc.c (fp_prec_to_size): Use opt_scalar_float_mode. (fp_size_to_prec): Likewise. gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Use opt_scalar_float_mode. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use opt_scalar_float_mode and FOR_EACH_MODE_IN_CLASS. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:25.916974620 +0100 +++ gcc/machmode.h 2017-07-13 09:18:26.363931259 +0100 @@ -652,6 +652,16 @@ is_float_mode (machine_mode mode, T *flo { /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */ + template + inline void + start (opt_mode *iter, enum mode_class mclass) + { + if (GET_CLASS_NARROWEST_MODE (mclass) == E_VOIDmode) + *iter = opt_mode (); + else + *iter = as_a (GET_CLASS_NARROWEST_MODE (mclass)); + } + inline void start (machine_mode *iter, enum mode_class mclass) { @@ -660,6 +670,13 @@ is_float_mode (machine_mode mode, T *flo /* Return true if mode iterator *ITER has not reached the end. */ + template + inline bool + iterate_p (opt_mode *iter) + { + return iter->exists (); + } + inline bool iterate_p (machine_mode *iter) { @@ -669,6 +686,13 @@ is_float_mode (machine_mode mode, T *flo /* Set mode iterator *ITER to the next widest mode in the same class, if any. */ + template + inline void + get_wider (opt_mode *iter) + { + *iter = GET_MODE_WIDER_MODE (**iter); + } + inline void get_wider (machine_mode *iter) { Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:22.928278591 +0100 +++ gcc/expr.c 2017-07-13 09:18:26.362931356 +0100 @@ -112,7 +112,6 @@ static HOST_WIDE_INT int_expr_size (tree init_expr_target (void) { rtx pat; - machine_mode mode; int num_clobbers; rtx mem, mem1; rtx reg; @@ -131,7 +130,7 @@ init_expr_target (void) pat = gen_rtx_SET (NULL_RTX, NULL_RTX); PATTERN (insn) = pat; - for (mode = VOIDmode; (int) mode < NUM_MACHINE_MODES; + for (machine_mode mode = VOIDmode; (int) mode < NUM_MACHINE_MODES; mode = (machine_mode) ((int) mode + 1)) { int regno; @@ -177,9 +176,11 @@ init_expr_target (void) mem = gen_rtx_MEM (VOIDmode, gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1)); - FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) + opt_scalar_float_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_FLOAT) { - machine_mode srcmode; + scalar_float_mode mode = *mode_iter; + scalar_float_mode srcmode; FOR_EACH_MODE_UNTIL (srcmode, mode) { enum insn_code ic; Index: gcc/ada/gcc-interface/misc.c =================================================================== --- gcc/ada/gcc-interface/misc.c 2017-07-13 09:18:21.521430343 +0100 +++ gcc/ada/gcc-interface/misc.c 2017-07-13 09:18:26.361931453 +0100 @@ -1311,11 +1311,11 @@ enumerate_modes (void (*f) (const char * int fp_prec_to_size (int prec) { - machine_mode mode; + opt_scalar_float_mode mode; FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) - if (GET_MODE_PRECISION (mode) == prec) - return GET_MODE_BITSIZE (mode); + if (GET_MODE_PRECISION (*mode) == prec) + return GET_MODE_BITSIZE (*mode); gcc_unreachable (); } @@ -1325,11 +1325,11 @@ fp_prec_to_size (int prec) int fp_size_to_prec (int size) { - machine_mode mode; + opt_scalar_float_mode mode; FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) - if (GET_MODE_BITSIZE (mode) == size) - return GET_MODE_PRECISION (mode); + if (GET_MODE_BITSIZE (*mode) == size) + return GET_MODE_PRECISION (*mode); gcc_unreachable (); } Index: gcc/c-family/c-cppbuiltin.c =================================================================== --- gcc/c-family/c-cppbuiltin.c 2017-07-13 09:18:21.523430126 +0100 +++ gcc/c-family/c-cppbuiltin.c 2017-07-13 09:18:26.361931453 +0100 @@ -1186,9 +1186,10 @@ c_cpp_builtins (cpp_reader *pfile) if (flag_building_libgcc) { /* Properties of floating-point modes for libgcc2.c. */ - machine_mode mode; - FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) + opt_scalar_float_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_FLOAT) { + scalar_float_mode mode = *mode_iter; const char *name = GET_MODE_NAME (mode); char *macro_name = (char *) alloca (strlen (name) Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c 2017-07-13 09:18:20.865501731 +0100 +++ gcc/fortran/trans-types.c 2017-07-13 09:18:26.363931259 +0100 @@ -363,6 +363,7 @@ #define NAMED_SUBROUTINE(a,b,c,d) \ gfc_init_kinds (void) { machine_mode mode; + opt_scalar_float_mode float_mode_iter; int i_index, r_index, kind; bool saw_i4 = false, saw_i8 = false; bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false; @@ -418,11 +419,11 @@ gfc_init_kinds (void) /* Set the maximum integer kind. Used with at least BOZ constants. */ gfc_max_integer_kind = gfc_integer_kinds[i_index - 1].kind; - for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT; - mode = (machine_mode) ((int) mode + 1)) + r_index = 0; + FOR_EACH_MODE_IN_CLASS (float_mode_iter, MODE_FLOAT) { - const struct real_format *fmt = - REAL_MODE_FORMAT (mode); + scalar_float_mode mode = *float_mode_iter; + const struct real_format *fmt = REAL_MODE_FORMAT (mode); int kind; if (fmt == NULL) @@ -433,8 +434,7 @@ gfc_init_kinds (void) /* Only let float, double, long double and __float128 go through. Runtime support for others is not provided, so they would be useless. */ - if (!targetm.libgcc_floating_mode_supported_p ((machine_mode) - mode)) + if (!targetm.libgcc_floating_mode_supported_p (mode)) continue; if (mode != TYPE_MODE (float_type_node) && (mode != TYPE_MODE (double_type_node)) From patchwork Thu Jul 13 08:43:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107599 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1927167qge; Thu, 13 Jul 2017 01:43:34 -0700 (PDT) X-Received: by 10.99.114.73 with SMTP id c9mr8218138pgn.267.1499935414245; Thu, 13 Jul 2017 01:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935414; cv=none; d=google.com; s=arc-20160816; b=pQVjE1RmoKYRKM1VuVKRB9rVqvwBHsUtiNP6p1bE0ibzhc2fUrMl4+b4hehDuTOHcB vLYZufHmpQVJpJHi7Cv6cCaSuD8CgWaqmj0TGrhl8b/f8tE9RCj95Q+cMBY8BZkFOto+ V/+pzLNzWtuHqE39X0GY6/qIHBeLgNin2xe4GOZtzY3vTSLh/RQBM/0F6uYatxTasz/v IK4jhvOtPaEAnOdNQjufia1hO3hDkGTkjj97tBn7w+gNsp/7q1huVS5TeAiDeekoeSgs +UmyOEZtvFqKtGom6d2ch/cZ7BTATMglop/M6MSpFOad+cxhzcDu5DmzUYXSqMZOzZP0 KrZA== 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=yJbwjzRGAIw6UwkT19goiKXGyj5LTOf1uR/FSYjWZms=; b=kWAzuQgw5HSogQJWQHSK9npDkxawLEN5yA0gX014EjRtFn28BRRLm+iMTFZ2n4XA6Q l7IqY6+9F+xoTDMwrYtqoT4Y5jefltMLQRb28WuD53TyKQECXEzBA7Vnv8hhty1bhnc8 PGLQm0vm3mxFtobnT0CyoXtLlBAAPKmdmMWJ6WsLNN+420j776dYgQcujb4SxgNnUgRe lErGNTCMcId4Xx3X5QZtNyXNDBTiSGazL5Yk6gRpM8JGAvOpj1T9KHGaWtad5b6ljrWL Yoy0shmxbTGlzZ84m+H/6hNjuWmT0vVDJyHP9nq5iTVOLp0cWHWG++9Cs0c9V/t633wy j3QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=krtXhVfN; spf=pass (google.com: domain of gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458003-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 o4si3845859pgf.492.2017.07.13.01.43.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:43:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458003-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=krtXhVfN; spf=pass (google.com: domain of gcc-patches-return-458003-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458003-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=jXrrqrCAP0D2ILllp0eJiWhyHQRHR sOgVj+5SRl8q7vgU3oARzArpRMlj91b8ddZ/l7CyKO7Hc46eRyjpAx6nNUMA59iY hR+z8GTceXxGA+t1vG906AehLY4hYqtQLgzxJHNikCpp+qgW6DDk5qCoqqxxnhFg ZxtwZ5JX7+jbXQ= 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=Pl326g/Ku/29q9Hgjnin5OjaDD0=; b=krt XhVfNeHXifAMTBmvaKJh3ORwvj2BurzHqTDx06RWz51s4URQ4ma4Pm5Zr+1ShJbE EOku4zPLD6IzfjI7VM8QXrv5J8JTCxDDaKerwMEvwqxD9hyzcJpoHd790ITKMJuJ tWInSEt7F/RRIVfHU8M0KbXMXZtZnr854TKOtwgg= Received: (qmail 12653 invoked by alias); 13 Jul 2017 08:43:17 -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 12316 invoked by uid 89); 13 Jul 2017 08:43:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:43:12 +0000 Received: by mail-wm0-f41.google.com with SMTP id f67so18052197wmh.1 for ; Thu, 13 Jul 2017 01:43:11 -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=yJbwjzRGAIw6UwkT19goiKXGyj5LTOf1uR/FSYjWZms=; b=uEO1LyyQSsflSmUyCkA5K4h+DH6Sv9cjGBt0Sm3FpuAcMHtRaxII50jafs16Bj4QXv ZIH0RjRbEsgxuivhKH8lvdOA6pQRq9c6okvlFuF8X/+CkGT5eBVt0yvMVJosAZ3Zyhlc ZY5vuGMwN/sOL9C1fqJM48iu/qsFGN2AVMnBx1A8jMcQS8oGx3zRBJUChk4/kEmdleId p29udq66vCvqh7aIlYOw5zuT0Dkixye2hY1YtReHmp4HtBsJ78Rlfqg4DirX5ojH5OP5 ZYCmtlz+98AqGbEsvAJjSDqLBFObe7EFnIFIr8k588/Fhx6fSlHR97Bs92x/OWa+ziSZ hbeA== X-Gm-Message-State: AIVw111VxsaTSLOUAkLqZ042qrcHhdLnQiMTMbH8ntghg/T+dBu+QHgY 76bmLG+xwrIhf6tcuJuPEA== X-Received: by 10.28.49.7 with SMTP id x7mr1246886wmx.57.1499935389461; Thu, 13 Jul 2017 01:43:09 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 35sm2874411wrp.63.2017.07.13.01.43.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:43:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [13/77] Make floatn_mode return an opt_scalar_float_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:43:07 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87lgnslobo.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 As per subject. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * target.def (default_floatn_mode): Return an opt_scalar_float_mode. * doc/tm.texi: Regenerate. * config/arm/arm.c (arm_floatn_mode): Return an opt_scalar_float_mode. * config/powerpcspe/powerpcspe.c (rs6000_floatn_mode): Likewise. * config/rs6000/rs6000.c (rs6000_floatn_mode): Likewise. * targhooks.h (default_floatn_mode): Likewise. * targhooks.c (default_floatn_mode): Likewise. * tree.c (build_common_tree_nodes): Update accordingly. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-07-05 16:29:19.600761904 +0100 +++ gcc/target.def 2017-07-13 09:18:26.916877727 +0100 @@ -3374,20 +3374,20 @@ DEFHOOK (floatn_mode, "Define this to return the machine mode to use for the type \n\ @code{_Float@var{n}}, if @var{extended} is false, or the type \n\ -@code{_Float@var{n}x}, if @var{extended} is true. If such a type \n\ -is not supported, return @code{VOIDmode}. The default version of this \n\ -hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for \n\ +@code{_Float@var{n}x}, if @var{extended} is true. If such a type is not\n\ +supported, return @code{opt_scalar_float_mode ()}. The default version of\n\ +this hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for\n\ @code{_Float64} and @code{_Float32x} and @code{TFmode} for \n\ @code{_Float128}, if those modes exist and satisfy the requirements for \n\ those types and pass @code{TARGET_SCALAR_MODE_SUPPORTED_P} and \n\ @code{TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P}; for @code{_Float64x}, it \n\ returns the first of @code{XFmode} and @code{TFmode} that exists and \n\ satisfies the same requirements; for other types, it returns \n\ -@code{VOIDmode}. The hook is only called for values of @var{n} and \n\ -@var{extended} that are valid according to ISO/IEC TS 18661-3:2015; that \n\ -is, @var{n} is one of 32, 64, 128, or, if @var{extended} is false, 16 or \n\ -greater than 128 and a multiple of 32.", - machine_mode, (int n, bool extended), +@code{opt_scalar_float_mode ()}. The hook is only called for values\n\ +of @var{n} and @var{extended} that are valid according to\n\ +ISO/IEC TS 18661-3:2015; that is, @var{n} is one of 32, 64, 128, or,\n\ +if @var{extended} is false, 16 or greater than 128 and a multiple of 32.", + opt_scalar_float_mode, (int n, bool extended), default_floatn_mode) /* Compute cost of moving data from a register of class FROM to one of Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-07-05 16:29:19.597161905 +0100 +++ gcc/doc/tm.texi 2017-07-13 09:18:26.914877921 +0100 @@ -4267,22 +4267,22 @@ hook returns true for all of @code{SFmod @code{XFmode} and @code{TFmode}, if such modes exist. @end deftypefn -@deftypefn {Target Hook} machine_mode TARGET_FLOATN_MODE (int @var{n}, bool @var{extended}) +@deftypefn {Target Hook} opt_scalar_float_mode TARGET_FLOATN_MODE (int @var{n}, bool @var{extended}) Define this to return the machine mode to use for the type @code{_Float@var{n}}, if @var{extended} is false, or the type -@code{_Float@var{n}x}, if @var{extended} is true. If such a type -is not supported, return @code{VOIDmode}. The default version of this -hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for +@code{_Float@var{n}x}, if @var{extended} is true. If such a type is not +supported, return @code{opt_scalar_float_mode ()}. The default version of +this hook returns @code{SFmode} for @code{_Float32}, @code{DFmode} for @code{_Float64} and @code{_Float32x} and @code{TFmode} for @code{_Float128}, if those modes exist and satisfy the requirements for those types and pass @code{TARGET_SCALAR_MODE_SUPPORTED_P} and @code{TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P}; for @code{_Float64x}, it returns the first of @code{XFmode} and @code{TFmode} that exists and satisfies the same requirements; for other types, it returns -@code{VOIDmode}. The hook is only called for values of @var{n} and -@var{extended} that are valid according to ISO/IEC TS 18661-3:2015; that -is, @var{n} is one of 32, 64, 128, or, if @var{extended} is false, 16 or -greater than 128 and a multiple of 32. +@code{opt_scalar_float_mode ()}. The hook is only called for values +of @var{n} and @var{extended} that are valid according to +ISO/IEC TS 18661-3:2015; that is, @var{n} is one of 32, 64, 128, or, +if @var{extended} is false, 16 or greater than 128 and a multiple of 32. @end deftypefn @deftypefn {Target Hook} bool TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P (machine_mode @var{mode}) Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-13 09:18:25.327032350 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:26.899879373 +0100 @@ -311,7 +311,7 @@ static bool arm_asm_elf_flags_numeric (u static unsigned int arm_elf_section_type_flags (tree decl, const char *name, int reloc); static void arm_expand_divmod_libfunc (rtx, machine_mode, rtx, rtx, rtx *, rtx *); -static machine_mode arm_floatn_mode (int, bool); +static opt_scalar_float_mode arm_floatn_mode (int, bool); /* Table of machine attributes. */ static const struct attribute_spec arm_attribute_table[] = @@ -23653,11 +23653,15 @@ arm_excess_precision (enum excess_precis /* Implement TARGET_FLOATN_MODE. Make very sure that we don't provide _Float16 if we are using anything other than ieee format for 16-bit floating point. Otherwise, punt to the default implementation. */ -static machine_mode +static opt_scalar_float_mode arm_floatn_mode (int n, bool extended) { if (!extended && n == 16) - return arm_fp16_format == ARM_FP16_FORMAT_IEEE ? HFmode : VOIDmode; + { + if (arm_fp16_format == ARM_FP16_FORMAT_IEEE) + return HFmode; + return opt_scalar_float_mode (); + } return default_floatn_mode (n, extended); } Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:19.102696197 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:26.902879083 +0100 @@ -39201,7 +39201,7 @@ rs6000_vector_mode_supported_p (machine_ } /* Target hook for floatn_mode. */ -static machine_mode +static opt_scalar_float_mode rs6000_floatn_mode (int n, bool extended) { if (extended) @@ -39215,10 +39215,10 @@ rs6000_floatn_mode (int n, bool extended if (TARGET_FLOAT128_KEYWORD) return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; else - return VOIDmode; + return opt_scalar_float_mode (); case 128: - return VOIDmode; + return opt_scalar_float_mode (); default: /* Those are the only valid _FloatNx types. */ @@ -39239,10 +39239,10 @@ rs6000_floatn_mode (int n, bool extended if (TARGET_FLOAT128_KEYWORD) return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; else - return VOIDmode; + return opt_scalar_float_mode (); default: - return VOIDmode; + return opt_scalar_float_mode (); } } Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:19.117694534 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:26.909878405 +0100 @@ -36202,7 +36202,7 @@ rs6000_vector_mode_supported_p (machine_ } /* Target hook for floatn_mode. */ -static machine_mode +static opt_scalar_float_mode rs6000_floatn_mode (int n, bool extended) { if (extended) @@ -36216,10 +36216,10 @@ rs6000_floatn_mode (int n, bool extended if (TARGET_FLOAT128_KEYWORD) return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; else - return VOIDmode; + return opt_scalar_float_mode (); case 128: - return VOIDmode; + return opt_scalar_float_mode (); default: /* Those are the only valid _FloatNx types. */ @@ -36240,10 +36240,10 @@ rs6000_floatn_mode (int n, bool extended if (TARGET_FLOAT128_KEYWORD) return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; else - return VOIDmode; + return opt_scalar_float_mode (); default: - return VOIDmode; + return opt_scalar_float_mode (); } } Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-07-05 16:29:19.601661904 +0100 +++ gcc/targhooks.h 2017-07-13 09:18:26.917877631 +0100 @@ -73,7 +73,7 @@ extern tree default_mangle_assembler_nam extern bool default_scalar_mode_supported_p (machine_mode); extern bool default_libgcc_floating_mode_supported_p (machine_mode); -extern machine_mode default_floatn_mode (int, bool); +extern opt_scalar_float_mode default_floatn_mode (int, bool); extern bool targhook_words_big_endian (void); extern bool targhook_float_words_big_endian (void); extern bool default_float_exceptions_rounding_supported_p (void); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:19.145691430 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:26.917877631 +0100 @@ -468,12 +468,12 @@ default_libgcc_floating_mode_supported_p /* Return the machine mode to use for the type _FloatN, if EXTENDED is false, or _FloatNx, if EXTENDED is true, or VOIDmode if not supported. */ -machine_mode +opt_scalar_float_mode default_floatn_mode (int n, bool extended) { if (extended) { - machine_mode cand1 = VOIDmode, cand2 = VOIDmode; + opt_scalar_float_mode cand1, cand2; switch (n) { case 32: @@ -498,20 +498,20 @@ default_floatn_mode (int n, bool extende /* Those are the only valid _FloatNx types. */ gcc_unreachable (); } - if (cand1 != VOIDmode - && REAL_MODE_FORMAT (cand1)->ieee_bits > n - && targetm.scalar_mode_supported_p (cand1) - && targetm.libgcc_floating_mode_supported_p (cand1)) + if (cand1.exists () + && REAL_MODE_FORMAT (*cand1)->ieee_bits > n + && targetm.scalar_mode_supported_p (*cand1) + && targetm.libgcc_floating_mode_supported_p (*cand1)) return cand1; - if (cand2 != VOIDmode - && REAL_MODE_FORMAT (cand2)->ieee_bits > n - && targetm.scalar_mode_supported_p (cand2) - && targetm.libgcc_floating_mode_supported_p (cand2)) + if (cand2.exists () + && REAL_MODE_FORMAT (*cand2)->ieee_bits > n + && targetm.scalar_mode_supported_p (*cand2) + && targetm.libgcc_floating_mode_supported_p (*cand2)) return cand2; } else { - machine_mode cand = VOIDmode; + opt_scalar_float_mode cand; switch (n) { case 16: @@ -544,13 +544,13 @@ default_floatn_mode (int n, bool extende default: break; } - if (cand != VOIDmode - && REAL_MODE_FORMAT (cand)->ieee_bits == n - && targetm.scalar_mode_supported_p (cand) - && targetm.libgcc_floating_mode_supported_p (cand)) + if (cand.exists () + && REAL_MODE_FORMAT (*cand)->ieee_bits == n + && targetm.scalar_mode_supported_p (*cand) + && targetm.libgcc_floating_mode_supported_p (*cand)) return cand; } - return VOIDmode; + return opt_scalar_float_mode (); } /* Make some target macros useable by target-independent code. */ Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-06-30 12:50:37.494697187 +0100 +++ gcc/tree.c 2017-07-13 09:18:26.920877340 +0100 @@ -10474,8 +10474,8 @@ build_common_tree_nodes (bool signed_cha { int n = floatn_nx_types[i].n; bool extended = floatn_nx_types[i].extended; - machine_mode mode = targetm.floatn_mode (n, extended); - if (mode == VOIDmode) + scalar_float_mode mode; + if (!targetm.floatn_mode (n, extended).exists (&mode)) continue; int precision = GET_MODE_PRECISION (mode); /* Work around the rs6000 KFmode having precision 113 not From patchwork Thu Jul 13 08:43:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107600 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1927500qge; Thu, 13 Jul 2017 01:43:56 -0700 (PDT) X-Received: by 10.84.178.37 with SMTP id y34mr8975083plb.223.1499935436278; Thu, 13 Jul 2017 01:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935436; cv=none; d=google.com; s=arc-20160816; b=uLuR9FiDsdn1x/Nq1xfDqHfNtHJ0xCCcnM1ih8IMj/d5+ncTUau4bByvpXOiTOBd7k hLzQFJetMPIoMea+/Puttef3sWgnBu84wwIaf38eC5EPBbgqBXlgrf0x4QpSraIY++75 MQs4lmMTNDUaUxNaFeuaurcihrR47pjnXEx7kYm7AqZ66F6U1qrTx8A0/mN26B5UFYOt 4K7Mj9IR4dKr0Lofv9hkicn++pkiMHm6M8LGc6oQjo860/niV1MaAvL8WY9HzFZ326vX CI0TczJ2hBeczMr64zQ10CwFXh3LSy+srrVXj4u1Fima6nMcleaH8gCDsHC5E0ZkmSBW ilmQ== 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=wxCJlOAf7D27vd8dcbs4U9n6vGHhE0gP2b4smakuVGU=; b=MweLpNLAFtlhZh3vkRq30cGaF+qckPmfgWPReI3qD1LwDkWOCvyxt5zGA3BYxB1dd1 WjCgTFBuA8FW1QHc0cqkt4tuEYm2hHrt3AV7NESet7aS8rffUMjdQnUCAem6ITNblbOq CMtUINRWQ0geG46/DF7JpShITXSobdd0FAr77u1mpMNYDLfcMPBc7Vgl9peIIksPUZ/M EHjUaPpPqkgTkxOpsBDABFvYnVPFu+EUFC2rM0FC4I+B8qpXHHvZbEmQnxk5ZibbQ/VS QdH1pbKog0Ieg8/WwD4J0WcrzdARQpWU6uKLdGfxx4uztpLpf5ok42QGxQppUUrACfze twWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=HZBFCgf7; spf=pass (google.com: domain of gcc-patches-return-458004-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458004-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 y16si3752863pfk.142.2017.07.13.01.43.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:43:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458004-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=HZBFCgf7; spf=pass (google.com: domain of gcc-patches-return-458004-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458004-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=giwpe0vTdtbPDkGwEIkKImNueYFOJ sOz7802xVlD/sldJ5SoWtOEQv1r6npqYbCeTgHYGjCM6bM5/mUcmmN03t/v1ELSl KDFTtRANLg/FTtS2XFlg1CX5go7x380ZgAtDpMQerKxXplD7xGLvGExj4Gv5jTCg cE3ANdETcdzz2E= 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=fjFVSqV40qLY8GjEuUntIsRJ7Io=; b=HZB FCgf7HQN9C7nbE5JRdmo0r2nTvoiLPLqz3EGs+1YoTB9Z64StEAHhf08V5Gdf8lA Ul6yhPkehFESedqOJyhQhesjcFbYPZNtevQ8UNSvi9vQg8eLJk0CfpS+KC+rOQ32 OnvtzNvxyqu/yP34PWJX2YI3/Pd81k5pPwEIBMVk= Received: (qmail 26381 invoked by alias); 13 Jul 2017 08:43:38 -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 25473 invoked by uid 89); 13 Jul 2017 08:43:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:43:36 +0000 Received: by mail-wr0-f174.google.com with SMTP id r103so49445998wrb.0 for ; Thu, 13 Jul 2017 01:43:36 -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=wxCJlOAf7D27vd8dcbs4U9n6vGHhE0gP2b4smakuVGU=; b=tPexpDs5GqS/TqMF9xsnq5WUWK39pvLxPY1GPnsqKimPqiDhnEndzYuxfW0fxsDO6t OtPl3j0TTmmrfQGRlKivKqLth/YpBlmZhOMvzKPmIfyLJgbR/paPZxTzeIbiy1P4GL+8 I7k4oQL44Vsy2TCCpvEfRxXt5dw2aWz1brmgDP5jIm1Ia/hNZJ+b2dYSv3mJzvs+mP9/ BUHubGQcX9yeegD+BUD8mBLYTR7swl0LQCHgKEGlhvD7pucYz0BCm/RJN6pNJP/DIDFu PNFh1Qwi8uLfGkPhKPLTUhTTGoOhk4+oZWKlRZOxbisY4gh3IxRIYMFNFlk/s66L+YVE PwaA== X-Gm-Message-State: AIVw112MoKU/7gEdmcsScNvWCGybZabD0VUOLadMhF5vwXd+tafvfYeV PxDw3DJGQU+hPgWOwcIPJQ== X-Received: by 10.223.135.210 with SMTP id c18mr990703wrc.109.1499935414253; Thu, 13 Jul 2017 01:43:34 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id i136sm4382392wmf.33.2017.07.13.01.43.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:43:33 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [14/77] Make libgcc_floating_mode_supported_p take a scalar_float_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:43:31 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87h8yglob0.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 As per subject. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * target.def (libgcc_floating_mode_supported_p): Take a scalar_float_mode. * doc/tm.texi: Regenerate. * targhooks.h (default_libgcc_floating_mode_supported_p): Take a scalar_float_mode. * targhooks.c (default_libgcc_floating_mode_supported_p): Likewise. * config/aarch64/aarch64.c (aarch64_libgcc_floating_mode_supported_p): Likewise. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-07-13 09:18:26.916877727 +0100 +++ gcc/target.def 2017-07-13 09:18:27.468824773 +0100 @@ -3367,7 +3367,7 @@ floating-point mode @var{mode}, which is @code{TARGET_SCALAR_MODE_SUPPORTED_P}. The default version of this \n\ hook returns true for all of @code{SFmode}, @code{DFmode}, \n\ @code{XFmode} and @code{TFmode}, if such modes exist.", - bool, (machine_mode mode), + bool, (scalar_float_mode mode), default_libgcc_floating_mode_supported_p) DEFHOOK Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-07-13 09:18:26.914877921 +0100 +++ gcc/doc/tm.texi 2017-07-13 09:18:27.467824868 +0100 @@ -4259,7 +4259,7 @@ If this hook allows @code{val} to have a @code{int8x8x3_t}s in registers rather than forcing them onto the stack. @end deftypefn -@deftypefn {Target Hook} bool TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P (machine_mode @var{mode}) +@deftypefn {Target Hook} bool TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P (scalar_float_mode @var{mode}) Define this to return nonzero if libgcc provides support for the floating-point mode @var{mode}, which is known to pass @code{TARGET_SCALAR_MODE_SUPPORTED_P}. The default version of this Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-07-13 09:18:26.917877631 +0100 +++ gcc/targhooks.h 2017-07-13 09:18:27.468824773 +0100 @@ -72,7 +72,7 @@ extern bool default_print_operand_punct_ extern tree default_mangle_assembler_name (const char *); extern bool default_scalar_mode_supported_p (machine_mode); -extern bool default_libgcc_floating_mode_supported_p (machine_mode); +extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode); extern opt_scalar_float_mode default_floatn_mode (int, bool); extern bool targhook_words_big_endian (void); extern bool targhook_float_words_big_endian (void); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:26.917877631 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:27.468824773 +0100 @@ -442,7 +442,7 @@ default_scalar_mode_supported_p (machine be supported as a scalar mode). */ bool -default_libgcc_floating_mode_supported_p (machine_mode mode) +default_libgcc_floating_mode_supported_p (scalar_float_mode mode) { switch (mode) { Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:23.795186280 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:27.465825060 +0100 @@ -15019,7 +15019,7 @@ aarch64_optab_supported_p (int op, machi if MODE is HFmode, and punt to the generic implementation otherwise. */ static bool -aarch64_libgcc_floating_mode_supported_p (machine_mode mode) +aarch64_libgcc_floating_mode_supported_p (scalar_float_mode mode) { return (mode == HFmode ? true From patchwork Thu Jul 13 08:43:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107601 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1928034qge; Thu, 13 Jul 2017 01:44:34 -0700 (PDT) X-Received: by 10.84.232.197 with SMTP id x5mr8901290plm.159.1499935474194; Thu, 13 Jul 2017 01:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935474; cv=none; d=google.com; s=arc-20160816; b=BJUutjm+H68hciO+YqbbDKU1B+uWCacS5NrTA5SROKzUbBA0WJww8S7TyApNup4xBB 8uKJy5rR7XvL3A7LzosM3hkxCU1ND53+XruofPASiq1URnPebkXgyTYUKJUqxEv3blKq rcNiE3kw5eq4F1XhvLczKu1+AmpkRNhepJZvVT8dr+Qsm0pEh+C3HsYuWBGQ4EWIcfnC 7zI6syKVbZ2haWrlneYbNd/9BpkHlmuHKlk+GK8MjlMF8GybqNfcIcOfP5LQ03T2UNNM EnSFegk+2KDWx7goCFXAYawPUWxxDkeLkMM+Ofn9kTsrdaBHLJedntwS8hrKssVtusSE sbLg== 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=Qk0/qm4bSbjU0bUzlfQvPakH6AgYcq5a7vapBZmODNA=; b=FtDuKH61P5wI7vvk8qLSJpYuvgGLf/B1vs/XrmlVpTApwbG2M4t9sV63RclIuK7VdW 7zrieFp3y2QkqFt94F1Fn6aZsqPhdpqR4MnN3CI7T8i1lpc8IenpcQxBcb9BIdnOhQgZ Wvy+XmbdvffOLeAl8yMYmXQI9mGsX6p7UYbE4UBzqA7J6BwLQqL8YN6IPhsOJEx0hUev 9/tH1RRNmyQPDBAg6yTl55VrxkecOyKfoyUZSSW+UhOSd3lKA688w1whm85WmlyPsTuq LGf62lFGtPHjOgqEIcZ4tengacS29yAH/TfPL/i1ET3RZ0q2Axvk3ZZPjgpZO0fhnpo5 ytyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=jnHB/kEl; spf=pass (google.com: domain of gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458005-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 g193si3785115pfb.20.2017.07.13.01.44.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458005-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=jnHB/kEl; spf=pass (google.com: domain of gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458005-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=dvcGuPKGtxpM6GljjCaRqQtTBT6CV ifhmnv+ZhqC5A0sj0ngv10ph/mqNVnJ7f7HOHvB2D5U93ZQXxlCvzX/R7qP8O1w4 5/9Lp3NMa0QTtlo1Vc+qU14/3kswqQptoO5zxF7yH2JmKARZIifyYdMmkP4PDAux khnMBYn0Fdk0Cs= 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=7vkYSmcC0Vr31uaHZhtcXbgYaZg=; b=jnH B/kEldXBBkPZhMnrf7MFM4EX1Poto4VQQpnMPO1mjvfmi3AmOhgaAF3V5zyaAF+9 uiVwUOc108vjI4wJx99QJHIfK61brkYzDgfz5n46GM4BupyMKYT5dTBGHqRsZf+y 546gjjky4JtMkL2GqA8RIl+7o0KiFGEdHSp4I92U= Received: (qmail 46575 invoked by alias); 13 Jul 2017 08:44:07 -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 45917 invoked by uid 89); 13 Jul 2017 08:44:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:44:03 +0000 Received: by mail-wr0-f171.google.com with SMTP id 77so49565660wrb.1 for ; Thu, 13 Jul 2017 01:44:03 -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=Qk0/qm4bSbjU0bUzlfQvPakH6AgYcq5a7vapBZmODNA=; b=Ex3A/cQiCIr3j2+kO0+brMFvkiRx0Vervp/H3bGTDuP9F1wD4Z1WzQy3b9XriTbWvX 7SupUHQkuxVin7DIpj12cjtxsDK5xDxKKyF2G93V/TrGhZI5Fomu/b4964llgmI3c2eb /ETRmGAxd59ry9rhmziJRwu5dgo04X7oBClLQXVMmqjriVMb2b1hiistRgmt7j0utolR 9R4Wr8s4naHPwsYXO8DtTkacuHENSGQjsyRJJT7TIaFspDDr/MqE3R7FnIaZu3s2BEq+ +sqGxzTnarQ2B7CeMfDLFNvu7suTIpijGPhbYOrrLr7C8+V2fqzt0VILHT1uT+HDRtqq 5I7g== X-Gm-Message-State: AIVw1125X2zEIFzR+BmW1H8O/nFyYCAHZ0H2sYEG92sKwen9tTWXFcOn MR8E5R4EWiJKnYzwpss7Lg== X-Received: by 10.223.180.67 with SMTP id v3mr1089686wrd.0.1499935441251; Thu, 13 Jul 2017 01:44:01 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id o6sm4824709wrc.48.2017.07.13.01.44.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:44:00 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [15/77] Add scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:43:59 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87d194loa8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Similar to the previous scalar_float_mode patch, but for modes that satisfy SCALAR_INT_MODE_P. There are very many uses of scalar integers, so this patch only makes a token change to the types of byte_mode, word_mode, ptr_mode and rs6000_pmode. The next patches in the series gradually replace more uses. The patch also removes and adds casts to some target-specific code due to the new types of SImode, DImode and Pmode. The as_a goes away in a later patch. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * config/powerpcspe/powerpcspe.h (rs6000_pmode): Change type from machine_mode to scalar_int_mode. * config/powerpcspe/powerpcspe.c (rs6000_pmode): Likewise. (rs6000_option_override_internal): Remove cast to int. * config/rs6000/rs6000.h (rs6000_pmode): Change type from machine_mode to scalar_int_mode. * config/rs6000/rs6000.c (rs6000_pmode): Likewise. (rs6000_option_override_internal): Remove cast to int. * config/s390/s390.h (Pmode): Remove cast to machine_mode. * config/epiphany/epiphany.h (RTX_OK_FOR_OFFSET_P): Add cast to machine_mode. * config/s390/s390.c (s390_expand_builtin): Likewise. * coretypes.h (scalar_int_mode): New type. (opt_scalar_int_mode): New typedef. * machmode.h (scalar_int_mode): New class. (scalar_int_mode::includes_p): New function. (byte_mode): Change type to scalar_int_mode. (word_mode): Likewise. (ptr_mode): Likewise. * emit-rtl.c (byte_mode): Likewise. (word_mode): Likewise. (ptr_mode): Likewise. (init_derived_machine_modes): Update accordingly. * genmodes.c (get_mode_class): Return scalar_int_mode for MODE_INT and MODE_PARTIAL_INT. * gdbhooks.py (build_pretty_printer): Handle scalar_int_mode and opt_scalar_int_mode. Index: gcc/config/powerpcspe/powerpcspe.h =================================================================== --- gcc/config/powerpcspe/powerpcspe.h 2017-05-31 10:02:30.662209641 +0100 +++ gcc/config/powerpcspe/powerpcspe.h 2017-07-13 09:18:28.018772114 +0100 @@ -2220,8 +2220,8 @@ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ -extern unsigned rs6000_pmode; -#define Pmode ((machine_mode)rs6000_pmode) +extern scalar_int_mode rs6000_pmode; +#define Pmode rs6000_pmode /* Supply definition of STACK_SIZE_MODE for allocate_dynamic_stack_space. */ #define STACK_SIZE_MODE (TARGET_32BIT ? SImode : DImode) Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:26.902879083 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:28.017772208 +0100 @@ -185,9 +185,8 @@ int fixuplabelno = 0; /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects - of this machine mode. The type is unsigned since not all things that - include powerpcspe.h also include machmode.h. */ -unsigned rs6000_pmode; + of this machine mode. */ +scalar_int_mode rs6000_pmode; /* Width in bits of a pointer. */ unsigned rs6000_pointer_size; @@ -4037,12 +4036,12 @@ rs6000_option_override_internal (bool gl /* Set the pointer size. */ if (TARGET_64BIT) { - rs6000_pmode = (int)DImode; + rs6000_pmode = DImode; rs6000_pointer_size = 64; } else { - rs6000_pmode = (int)SImode; + rs6000_pmode = SImode; rs6000_pointer_size = 32; } Index: gcc/config/rs6000/rs6000.h =================================================================== --- gcc/config/rs6000/rs6000.h 2017-06-16 07:49:01.468066725 +0100 +++ gcc/config/rs6000/rs6000.h 2017-07-13 09:18:28.021771829 +0100 @@ -2130,8 +2130,8 @@ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ -extern unsigned rs6000_pmode; -#define Pmode ((machine_mode)rs6000_pmode) +extern scalar_int_mode rs6000_pmode; +#define Pmode rs6000_pmode /* Supply definition of STACK_SIZE_MODE for allocate_dynamic_stack_space. */ #define STACK_SIZE_MODE (TARGET_32BIT ? SImode : DImode) Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:26.909878405 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:28.021771829 +0100 @@ -181,9 +181,8 @@ int fixuplabelno = 0; /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects - of this machine mode. The type is unsigned since not all things that - include rs6000.h also include machmode.h. */ -unsigned rs6000_pmode; + of this machine mode. */ +scalar_int_mode rs6000_pmode; /* Width in bits of a pointer. */ unsigned rs6000_pointer_size; @@ -3987,12 +3986,12 @@ rs6000_option_override_internal (bool gl /* Set the pointer size. */ if (TARGET_64BIT) { - rs6000_pmode = (int)DImode; + rs6000_pmode = DImode; rs6000_pointer_size = 64; } else { - rs6000_pmode = (int)SImode; + rs6000_pmode = SImode; rs6000_pointer_size = 32; } Index: gcc/config/s390/s390.h =================================================================== --- gcc/config/s390/s390.h 2017-06-30 12:50:38.649643966 +0100 +++ gcc/config/s390/s390.h 2017-07-13 09:18:28.023771640 +0100 @@ -1053,7 +1053,7 @@ #define TRULY_NOOP_TRUNCATION(OUTPREC, I /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ -#define Pmode ((machine_mode) (TARGET_64BIT ? DImode : SImode)) +#define Pmode (TARGET_64BIT ? DImode : SImode) /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */ #define POINTERS_EXTEND_UNSIGNED -1 Index: gcc/config/epiphany/epiphany.h =================================================================== --- gcc/config/epiphany/epiphany.h 2017-02-23 19:54:23.000000000 +0000 +++ gcc/config/epiphany/epiphany.h 2017-07-13 09:18:28.013772588 +0100 @@ -641,7 +641,8 @@ #define CONSTANT_ADDRESS_P(X) \ #define RTX_OK_FOR_OFFSET_P(MODE, X) \ RTX_OK_FOR_OFFSET_1 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ - && epiphany_vect_align == 4 ? SImode : (MODE), X) + && epiphany_vect_align == 4 \ + ? (machine_mode) SImode : (machine_mode) (MODE), X) #define RTX_OK_FOR_OFFSET_1(MODE, X) \ (GET_CODE (X) == CONST_INT \ && !(INTVAL (X) & (GET_MODE_SIZE (MODE) - 1)) \ Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:25.330032056 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:28.023771640 +0100 @@ -995,7 +995,7 @@ #define MAX_ARGS 6 so we cannot use this. */ machine_mode target_mode = (insn_op->predicate == address_operand - ? Pmode : insn_op->mode); + ? (machine_mode) Pmode : insn_op->mode); op[arity] = copy_to_mode_reg (target_mode, op[arity]); } Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:25.915974717 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:28.023771640 +0100 @@ -55,8 +55,10 @@ typedef const struct simple_bitmap_def * struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; +class scalar_int_mode; class scalar_float_mode; template class opt_mode; +typedef opt_mode opt_scalar_int_mode; typedef opt_mode opt_scalar_float_mode; /* Subclasses of rtx_def, using indentation to show the class @@ -313,6 +315,7 @@ #define rtx_insn struct _dont_use_rtx_in #define tree union _dont_use_tree_here_ * #define const_tree union _dont_use_tree_here_ * +typedef struct scalar_int_mode scalar_int_mode; typedef struct scalar_float_mode scalar_float_mode; #endif Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:26.363931259 +0100 +++ gcc/machmode.h 2017-07-13 09:18:28.024771545 +0100 @@ -339,6 +339,30 @@ is_a (machine_mode m, U *result) return false; } +/* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */ +class scalar_int_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE scalar_int_mode () {} + ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M is a scalar_int_mode. */ + +inline bool +scalar_int_mode::includes_p (machine_mode m) +{ + return SCALAR_INT_MODE_P (m); +} + /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ class scalar_float_mode { @@ -606,9 +630,9 @@ get_narrowest_mode (T mode) /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD and the mode whose class is Pmode and whose size is POINTER_SIZE. */ -extern machine_mode byte_mode; -extern machine_mode word_mode; -extern machine_mode ptr_mode; +extern scalar_int_mode byte_mode; +extern scalar_int_mode word_mode; +extern scalar_int_mode ptr_mode; /* Target-dependent machine mode initialization - in insn-modes.c. */ extern void init_adjust_machine_modes (void); Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:25.916974620 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:28.024771545 +0100 @@ -69,9 +69,9 @@ #define initial_regno_reg_rtx (this_targ /* Commonly used modes. */ -machine_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */ -machine_mode word_mode; /* Mode whose width is BITS_PER_WORD. */ -machine_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */ +scalar_int_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */ +scalar_int_mode word_mode; /* Mode whose width is BITS_PER_WORD. */ +scalar_int_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */ /* Datastructures maintained for currently processed function in RTL form. */ @@ -5869,22 +5869,24 @@ init_emit_regs (void) void init_derived_machine_modes (void) { - byte_mode = VOIDmode; - word_mode = VOIDmode; - - machine_mode mode; - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) + opt_scalar_int_mode mode_iter, opt_byte_mode, opt_word_mode; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + scalar_int_mode mode = *mode_iter; + if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT - && byte_mode == VOIDmode) - byte_mode = mode; + && !opt_byte_mode.exists ()) + opt_byte_mode = mode; if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD - && word_mode == VOIDmode) - word_mode = mode; + && !opt_word_mode.exists ()) + opt_word_mode = mode; } - ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0); + byte_mode = *opt_byte_mode; + word_mode = *opt_word_mode; + ptr_mode = as_a (mode_for_size (POINTER_SIZE, + MODE_INT, 0)); } /* Create some permanent unique rtl objects shared between all functions. */ Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:23.798185961 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:28.024771545 +0100 @@ -1137,6 +1137,10 @@ get_mode_class (struct mode_data *mode) { switch (mode->cl) { + case MODE_INT: + case MODE_PARTIAL_INT: + return "scalar_int_mode"; + case MODE_FLOAT: case MODE_DECIMAL_FLOAT: return "scalar_float_mode"; Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:25.916974620 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:28.024771545 +0100 @@ -542,10 +542,11 @@ def build_pretty_printer(): pp.add_printer_for_regex(r'opt_mode<(\S+)>', 'opt_mode', OptMachineModePrinter) - pp.add_printer_for_types(['opt_scalar_float_mode'], + pp.add_printer_for_types(['opt_scalar_int_mode', + 'opt_scalar_float_mode'], 'opt_mode', OptMachineModePrinter) - pp.add_printer_for_types(['scalar_float_mode'], - 'scalar_float_mode', MachineModePrinter) + for mode in 'scalar_int_mode', 'scalar_float_mode': + pp.add_printer_for_types([mode], mode, MachineModePrinter) return pp From patchwork Thu Jul 13 08:44:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107602 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1928185qge; Thu, 13 Jul 2017 01:44:46 -0700 (PDT) X-Received: by 10.98.193.197 with SMTP id i188mr59514250pfg.215.1499935486472; Thu, 13 Jul 2017 01:44:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935486; cv=none; d=google.com; s=arc-20160816; b=FRCgwHvRJGUI63Gp85/5j+dZ/OFqjxEiTHd6tRn3vn39UswmcM8OQfqUZuSqcVjMD5 ZIE7JuTLdDML3SgH6ozC3gHnlmawbBZXr2mHsMuBPN5gldw2eUcOBzGzGbtN1usYTbfK CGSAlwxH00r57rZ/o7OOmfdgueAlSO3In4jy8YRbSxV+32VFjaqCUQT8QXv3X/PTPyC0 il9RcSvmKsNZkpmI6TuB6aCyE7BY8jf3cPjEAI1djAhGM9qHfOJ2Amd4coxr5USlSTuN nVDdJjjecNU9nqzY3sHoUJloMK57NQWs5zfqL8iRNlr9dm7zs9VlB5CkmUS31lhR2wuE r2GQ== 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=lQK04C0E1H1zdFkE3WH+UA1Ow6/s7hiqhYtRMdfFCjE=; b=A8aOrg4bwSAhNQmGOexmZ60x8hkgGdgk7kY2qT4Qi7C6aDcA5QtN22ua+88ryLPfJz 3v0jU+tMuv+ZBvDlGQK1VuEeDkvw6vv/SpTMoEsupcZSAaGQayWprqqCCMkaeqVhIbCO yiUk8fcYH+3CS5YB3azG1unYKzLy4DtsbeEbYJAx1XCBrppsesIGE1NFNODObLuIQmFd ELZ75U7yPZ/dI4uliAuTyyf0VzZ42nY/KP24eyD9BEGu+KBrw3D4wdm0OpspFmfEuTnI UAztyo/o3obIrWR0vvLidaIExClxZ3GH8gjfXTQsjdA1VqkS64m6O2J01OPgr/JQ6PvE 0kpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=cIhXSmM5; spf=pass (google.com: domain of gcc-patches-return-458006-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458006-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 z44si4027090plh.218.2017.07.13.01.44.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:44:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458006-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=cIhXSmM5; spf=pass (google.com: domain of gcc-patches-return-458006-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458006-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=QPM1NTm+x5UeSSUDfRk4EfR/3WpzX LQWDfxhOyOwGmO8+DxwBq6PktyArjxNMikxf2JXDhk7XLVi+xNnzBV3dku7REA69 u3M+PCh2Sdg7PR2Flo6op5koQ4gatM4IOXjFjdKQ3vHjx8ZJ6Fmewo5AMrvUC6zo HM7iDanR9+/LIQ= 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=tkLH2vOFzGvJpYcsuCEjJ/LVsD8=; b=cIh XSmM5bXoTtPNN+m89hIj5ybZBVfbf6hpYAUhF9OThqNPFb0nZFsramrHlmoI+xdf KnNKJ1qOYi0cNqO+Nyc7QbxMt3X6nhl70g6evWyurdhkWO1V/TW/qRAVXUb7IyBy 2DZcs/oWk33JoDogsJSaZN4d+Etf73fEnSEEfQPA= Received: (qmail 58074 invoked by alias); 13 Jul 2017 08:44:28 -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 57651 invoked by uid 89); 13 Jul 2017 08:44:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=6487 X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:44:23 +0000 Received: by mail-wr0-f179.google.com with SMTP id 77so49569817wrb.1 for ; Thu, 13 Jul 2017 01:44:23 -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=lQK04C0E1H1zdFkE3WH+UA1Ow6/s7hiqhYtRMdfFCjE=; b=eFB9PHTpdIm1TDzGT57P1x5cKJFIVBDeeRIiq48gOnVsei3FgkicMmivfoMRPZylhw VX/Bcw2RqrZk/mMHpe6LZWXNOFV9O893J4YecZRmjIYkIRsk8HOfzryjm0kac6rvk7+1 9fYFxqmYIoJGaRikUrPTCVORhTyZp3mfOrpwQIL+HqNsbREZuLrF82wTN5FvM5OkRh8q wRfic1NBEzoCmPA2wzHv61gLuTvxgMU+VHnXOpce1doqRyXBlo3eB766gMg9SPXB5jc4 xf6VibdKfIJF90aouzDbk34A76gmlYDU/coSTqvEiKALZdLfVbSDFlDmoy7t7kglsk50 3Lgg== X-Gm-Message-State: AIVw110o8d6LHi+O1SObDUBqosNcQKwShIPBg++9AOqQobecrUqQIAdl l8vSwa353UUgklRdkQj5+Q== X-Received: by 10.223.142.143 with SMTP id q15mr862865wrb.180.1499935461342; Thu, 13 Jul 2017 01:44:21 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id h6sm4665373wmf.31.2017.07.13.01.44.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:44:20 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [16/77] Add scalar_int_mode_pod References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:44:19 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <878tjslo9o.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a POD class for scalar integers, as an instance of a new pod_mode template. Later patches will use pod_mode in situations that really do need to be POD; this patch is simply using PODs to remove load-time initialisation. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (pod_mode): New type. (scalar_int_mode_pod): New typedef. * machmode.h (pod_mode): New class. (int_n_data_t::m): Change type to scalar_int_mode_pod. * genmodes.c (emit_mode_int_n): Update accordingly. * lower-subreg.h (target_lower_subreg): Change type to scalar_int_mode_pod. * gdbhooks.py (build_pretty_printer): Handle pod_mode and scalar_int_mode_pod. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:28.023771640 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:28.587718194 +0100 @@ -60,6 +60,8 @@ typedef const struct rtx_def *const_rtx; template class opt_mode; typedef opt_mode opt_scalar_int_mode; typedef opt_mode opt_scalar_float_mode; +template class pod_mode; +typedef pod_mode scalar_int_mode_pod; /* Subclasses of rtx_def, using indentation to show the class hierarchy, along with the relevant invariant. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:28.024771545 +0100 +++ gcc/machmode.h 2017-07-13 09:18:28.588718099 +0100 @@ -294,6 +294,19 @@ opt_mode::exists (U *mode) const return false; } +/* A POD version of mode class T. */ + +template +struct pod_mode +{ + typedef typename mode_traits::from_int from_int; + + machine_mode m_mode; + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + ALWAYS_INLINE operator T () const { return from_int (m_mode); } + ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; } +}; + /* Return true if mode M has type T. */ template @@ -648,7 +661,7 @@ #define HWI_COMPUTABLE_MODE_P(MODE) \ struct int_n_data_t { /* These parts are initailized by genmodes output */ unsigned int bitsize; - machine_mode m; + scalar_int_mode_pod m; /* RID_* is RID_INTN_BASE + index into this array */ }; Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:28.024771545 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:28.587718194 +0100 @@ -1799,7 +1799,7 @@ emit_mode_int_n (void) m = mode_sort[i]; printf(" {\n"); tagged_printf ("%u", m->int_n, m->name); - printf ("E_%smode,", m->name); + printf ("{ E_%smode },", m->name); printf(" },\n"); } Index: gcc/lower-subreg.h =================================================================== --- gcc/lower-subreg.h 2017-02-23 19:54:15.000000000 +0000 +++ gcc/lower-subreg.h 2017-07-13 09:18:28.588718099 +0100 @@ -43,7 +43,7 @@ struct lower_subreg_choices { /* Target-specific information for the subreg lowering pass. */ struct target_lower_subreg { /* An integer mode that is twice as wide as word_mode. */ - machine_mode x_twice_word_mode; + scalar_int_mode_pod x_twice_word_mode; /* What we have decided to do when optimizing for size (index 0) and speed (index 1). */ Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:28.024771545 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:28.587718194 +0100 @@ -545,6 +545,10 @@ def build_pretty_printer(): pp.add_printer_for_types(['opt_scalar_int_mode', 'opt_scalar_float_mode'], 'opt_mode', OptMachineModePrinter) + pp.add_printer_for_regex(r'pod_mode<(\S+)>', + 'pod_mode', MachineModePrinter) + pp.add_printer_for_types(['scalar_int_mode_pod'], + 'pod_mode', MachineModePrinter) for mode in 'scalar_int_mode', 'scalar_float_mode': pp.add_printer_for_types([mode], mode, MachineModePrinter) From patchwork Thu Jul 13 08:44:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107603 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1928477qge; Thu, 13 Jul 2017 01:45:09 -0700 (PDT) X-Received: by 10.84.176.100 with SMTP id u91mr8675192plb.182.1499935509121; Thu, 13 Jul 2017 01:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935509; cv=none; d=google.com; s=arc-20160816; b=EkhUFmJMKs12EzdEDiBLlb2Jzg7ebpOTZPWFlBP/uL1DO/IhPfJXgNQ+0hRqNI10ah 9eINHYxB0vI9jOB2BxbL3hm9oQVltjmxY92P1felxg3P/fjk9KnGLdMx5/oCrWVSrfpV mWx739+VB152QlemYuoEAjMCqjaDoS3XR5LYxoVnsiwfweMDE53/rxngMWFF8ozDUkj8 k5aOPGAYXyvPRrJse+GqFTpdOe98oB/sw01TeTp2ocJ5TmvpVx+0VWaCCEl8EpVR7ZER dXSUjkLUHhh2NDRoT/zJpSPL1boiDZZBm6ic1Y5G2REFvi+bwYYiouzjmdydVzWpYPXF UAJQ== 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=24omHiq7VkJ0AAlSKkAT63m4tZU5sWPQQrdPb/T+azU=; b=GeBirQhSpxIIN4O/shX/PRzL+2Bgyyz39fnS8/rQG+8bzUy+DORtMS+W15JixU+Pyu DSvSV8JVWba0zatXxN9zT9gyqEK+Wvv1cF0MuGYmXxARfStbzvf++F+oAU5WlvoJJoje GmLGjGO8dq8fWT9Sur5D+tmC5syk870ot3ntQ8YxiF6l3D7tapl2BR0ALEI+gZDxOf4j UZT9zZl5T2ejOF/8hybmzu3oWL5cp4nQl6NsXehtV2oQQ7ZYLBEwz7zUqAm1mwnvxWna i+XEFXfyJWPeZMwwjnQsAs40l5QFJFJCXrcpp4Rxq9Lac7QIcad8D/pqbC55yTJGPhP2 IeDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=RxsIXz+3; spf=pass (google.com: domain of gcc-patches-return-458007-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458007-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 r7si3994382ple.505.2017.07.13.01.45.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458007-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=RxsIXz+3; spf=pass (google.com: domain of gcc-patches-return-458007-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458007-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=EvM3i4TpFRnJ1LIVpL0Eq/2x+xa8i xGYcnIjzpGt+D+9bQ0HSo+m380gOw74OGKxVR6k00J+T6lr3CRppgoqD/GRZXHgN Zw7R0rCqduWj1BMI7VinulVDYgaoGLOqr/7Wrv9eEhmo0Jq0hlvQqoF8CjxeTiSl unNFOO6eFM4qqY= 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=ym7WXefWQ3eFz95ryz11xvQnsnU=; b=Rxs IXz+31YEF6HxMjpzl2OViFHNtCq2UoNiCPAShN0bXn1avl9EVpGK6/jSRf+5uxPM UyykpIte6elYqWU4oZkFeyiQhDLih18vH4gB/Zi3kG3a7AurOOUWzk1rjPe/DK/0 XeTWppPVNoUE2LCIQZeTKPw4gYn3x0jG7CeI6IG4= Received: (qmail 75878 invoked by alias); 13 Jul 2017 08:44:52 -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 74584 invoked by uid 89); 13 Jul 2017 08:44:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:44:48 +0000 Received: by mail-wr0-f171.google.com with SMTP id r103so49461229wrb.0 for ; Thu, 13 Jul 2017 01:44:47 -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=24omHiq7VkJ0AAlSKkAT63m4tZU5sWPQQrdPb/T+azU=; b=MJmGy25+Kke1P6UQYXjZkfWodNXgvPnT25uEAMLgOiDO6h1ABS1zrBML1yrIbqF5Ys soOOFVhAWUqwXlmi/qzrZTRD+srW/TXVrCtp37xUxKgwNU1H+qWOGdn1PWt6Y7+XjZo5 RSulDGrmLf+m+PA/EJDL+pXIkZ7qRps4FKm65F7nbki5TpIagOKYVBTyzDJQ8T4SW6Ic I8khbG7FLJWt1NVRaYo9YLT9dX7VXxVsKQTfaQEIvLwvLFclCkwgItES/Fu1YRD2M76V c7nLP684LwnQ/sozkhz5ItY83tE+cLX8KN0ijo/VgvycGyF0lvNg6fcCC53UVmpTsEYW 47YA== X-Gm-Message-State: AIVw110T+emKbxfuz6BCvM5rgyGOIgKTkX10w3UEuOTSl66RG3S/v1Hx 0vc2XYIk5UefHlnt/KWgfg== X-Received: by 10.223.179.65 with SMTP id k1mr1002034wrd.5.1499935485297; Thu, 13 Jul 2017 01:44:45 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id r200sm4328744wmd.20.2017.07.13.01.44.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:44:44 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [17/77] Add an int_mode_for_size helper function References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:44:42 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <874luglo91.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a wrapper around mode_for_size for cases in which the mode class is MODE_INT (the commonest case). The return type can then be an opt_scalar_int_mode instead of a machine_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (int_mode_for_size): New function. * builtins.c (set_builtin_user_assembler_name): Use int_mode_for_size instead of mode_for_size. * calls.c (save_fixed_argument_area): Likewise. Make use of BLKmode explicit. * combine.c (expand_field_assignment): Use int_mode_for_size instead of mode_for_size. (make_extraction): Likewise. (simplify_shift_const_1): Likewise. (simplify_comparison): Likewise. * dojump.c (do_jump): Likewise. * dwarf2out.c (mem_loc_descriptor): Likewise. * emit-rtl.c (init_derived_machine_modes): Likewise. * expmed.c (flip_storage_order): Likewise. (convert_extracted_bit_field): Likewise. * expr.c (copy_blkmode_from_reg): Likewise. * graphite-isl-ast-to-gimple.c (max_mode_int_precision): Likewise. * internal-fn.c (expand_mul_overflow): Likewise. * lower-subreg.c (simple_move): Likewise. * optabs-libfuncs.c (init_optabs): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. * stor-layout.c (vector_type_mode): Likewise. * tree-ssa-strlen.c (handle_builtin_memcmp): Likewise. * tree-vect-data-refs.c (vect_lanes_optab_supported_p): Likewise. * tree-vect-generic.c (expand_vector_parallel): Likewise. * tree-vect-stmts.c (vectorizable_load): Likewise. gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Use int_mode_for_size instead of mode_for_size. (gnat_to_gnu_subprog_type): Likewise. * gcc-interface/utils.c (make_type_from_size): Likewise. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:28.588718099 +0100 +++ gcc/machmode.h 2017-07-13 09:18:29.217658709 +0100 @@ -558,6 +558,16 @@ #define GET_MODE_COMPLEX_MODE(MODE) ((ma extern machine_mode mode_for_size (unsigned int, enum mode_class, int); +/* Return the machine mode to use for a MODE_INT of SIZE bits, if one + exists. If LIMIT is nonzero, modes wider than MAX_FIXED_MODE_SIZE + will not be used. */ + +inline opt_scalar_int_mode +int_mode_for_size (unsigned int size, int limit) +{ + return dyn_cast (mode_for_size (size, MODE_INT, limit)); +} + /* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one exists. */ Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2017-07-13 09:18:24.772086898 +0100 +++ gcc/builtins.c 2017-07-13 09:18:29.209659459 +0100 @@ -10429,9 +10429,9 @@ set_builtin_user_assembler_name (tree de if (DECL_FUNCTION_CODE (decl) == BUILT_IN_FFS && INT_TYPE_SIZE < BITS_PER_WORD) { + scalar_int_mode mode = *int_mode_for_size (INT_TYPE_SIZE, 0); set_user_assembler_libfunc ("ffs", asmspec); - set_optab_libfunc (ffs_optab, mode_for_size (INT_TYPE_SIZE, MODE_INT, 0), - "ffs"); + set_optab_libfunc (ffs_optab, mode, "ffs"); } } Index: gcc/calls.c =================================================================== --- gcc/calls.c 2017-06-12 17:05:23.274759395 +0100 +++ gcc/calls.c 2017-07-13 09:18:29.210659365 +0100 @@ -1045,12 +1045,15 @@ save_fixed_argument_area (int reg_parm_s *high_to_save = high; num_to_save = high - low + 1; - save_mode = mode_for_size (num_to_save * BITS_PER_UNIT, MODE_INT, 1); /* If we don't have the required alignment, must do this in BLKmode. */ - if ((low & (MIN (GET_MODE_SIZE (save_mode), - BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1))) + scalar_int_mode imode; + if (int_mode_for_size (num_to_save * BITS_PER_UNIT, 1).exists (&imode) + && (low & (MIN (GET_MODE_SIZE (imode), + BIGGEST_ALIGNMENT / UNITS_PER_WORD) - 1)) == 0) + save_mode = imode; + else save_mode = BLKmode; if (ARGS_GROW_DOWNWARD) Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:22.914280096 +0100 +++ gcc/combine.c 2017-07-13 09:18:29.211659271 +0100 @@ -7308,19 +7308,16 @@ expand_field_assignment (const_rtx x) /* Don't attempt bitwise arithmetic on non scalar integer modes. */ if (! SCALAR_INT_MODE_P (compute_mode)) { - machine_mode imode; - /* Don't do anything for vector or complex integral types. */ if (! FLOAT_MODE_P (compute_mode)) break; /* Try to find an integral mode to pun with. */ - imode = mode_for_size (GET_MODE_BITSIZE (compute_mode), MODE_INT, 0); - if (imode == BLKmode) + if (!int_mode_for_size (GET_MODE_BITSIZE (compute_mode), 0) + .exists (&compute_mode)) break; - compute_mode = imode; - inner = gen_lowpart (imode, inner); + inner = gen_lowpart (compute_mode, inner); } /* Compute a mask of LEN bits, if we can do this on the host machine. */ @@ -7391,7 +7388,6 @@ make_extraction (machine_mode mode, rtx machine_mode wanted_inner_reg_mode = word_mode; machine_mode pos_mode = word_mode; machine_mode extraction_mode = word_mode; - machine_mode tmode = mode_for_size (len, MODE_INT, 1); rtx new_rtx = 0; rtx orig_pos_rtx = pos_rtx; HOST_WIDE_INT orig_pos; @@ -7439,7 +7435,8 @@ make_extraction (machine_mode mode, rtx For MEM, we can avoid an extract if the field starts on an appropriate boundary and we can change the mode of the memory reference. */ - if (tmode != BLKmode + scalar_int_mode tmode; + if (int_mode_for_size (len, 1).exists (&tmode) && ((pos_rtx == 0 && (pos % BITS_PER_WORD) == 0 && !MEM_P (inner) && (pos == 0 || REG_P (inner)) @@ -10466,8 +10463,8 @@ simplify_shift_const_1 (enum rtx_code co && ! mode_dependent_address_p (XEXP (varop, 0), MEM_ADDR_SPACE (varop)) && ! MEM_VOLATILE_P (varop) - && (tmode = mode_for_size (GET_MODE_BITSIZE (mode) - count, - MODE_INT, 1)) != BLKmode) + && (int_mode_for_size (GET_MODE_BITSIZE (mode) - count, 1) + .exists (&tmode))) { new_rtx = adjust_address_nv (varop, tmode, BYTES_BIG_ENDIAN ? 0 @@ -12394,7 +12391,7 @@ simplify_comparison (enum rtx_code code, & GET_MODE_MASK (mode)) + 1)) >= 0 && const_op >> i == 0 - && (tmode = mode_for_size (i, MODE_INT, 1)) != BLKmode) + && int_mode_for_size (i, 1).exists (&tmode)) { op0 = gen_lowpart_or_truncate (tmode, XEXP (op0, 0)); continue; @@ -12554,8 +12551,8 @@ simplify_comparison (enum rtx_code code, && CONST_INT_P (XEXP (op0, 1)) && GET_CODE (XEXP (op0, 0)) == ASHIFT && XEXP (op0, 1) == XEXP (XEXP (op0, 0), 1) - && (tmode = mode_for_size (mode_width - INTVAL (XEXP (op0, 1)), - MODE_INT, 1)) != BLKmode + && (int_mode_for_size (mode_width - INTVAL (XEXP (op0, 1)), 1) + .exists (&tmode)) && (((unsigned HOST_WIDE_INT) const_op + (GET_MODE_MASK (tmode) >> 1) + 1) <= GET_MODE_MASK (tmode))) @@ -12573,8 +12570,8 @@ simplify_comparison (enum rtx_code code, && CONST_INT_P (XEXP (XEXP (op0, 0), 1)) && GET_CODE (XEXP (XEXP (op0, 0), 0)) == ASHIFT && XEXP (op0, 1) == XEXP (XEXP (XEXP (op0, 0), 0), 1) - && (tmode = mode_for_size (mode_width - INTVAL (XEXP (op0, 1)), - MODE_INT, 1)) != BLKmode + && (int_mode_for_size (mode_width - INTVAL (XEXP (op0, 1)), 1) + .exists (&tmode)) && (((unsigned HOST_WIDE_INT) const_op + (GET_MODE_MASK (tmode) >> 1) + 1) <= GET_MODE_MASK (tmode))) Index: gcc/dojump.c =================================================================== --- gcc/dojump.c 2017-06-30 12:50:38.242662721 +0100 +++ gcc/dojump.c 2017-07-13 09:18:29.212659178 +0100 @@ -594,7 +594,7 @@ do_jump (tree exp, rtx_code_label *if_fa && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT && (i = tree_floor_log2 (TREE_OPERAND (exp, 1))) >= 0 - && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode + && int_mode_for_size (i + 1, 0).exists (&mode) && (type = lang_hooks.types.type_for_mode (mode, 1)) != 0 && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)) && have_insn_for (COMPARE, TYPE_MODE (type))) Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:23.797186067 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:29.214658990 +0100 @@ -15169,13 +15169,12 @@ mem_loc_descriptor (rtx rtl, machine_mod || GET_MODE_BITSIZE (mode) == HOST_BITS_PER_DOUBLE_INT)) { dw_die_ref type_die = base_type_for_mode (mode, 1); - machine_mode amode; + scalar_int_mode amode; if (type_die == NULL) return NULL; - amode = mode_for_size (DWARF2_ADDR_SIZE * BITS_PER_UNIT, - MODE_INT, 0); if (INTVAL (rtl) >= 0 - && amode != BLKmode + && (int_mode_for_size (DWARF2_ADDR_SIZE * BITS_PER_UNIT, 0) + .exists (&amode)) && trunc_int_for_mode (INTVAL (rtl), amode) == INTVAL (rtl) /* const DW_OP_convert vs. DW_OP_const_type . */ Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:28.024771545 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:29.215658896 +0100 @@ -5885,8 +5885,7 @@ init_derived_machine_modes (void) byte_mode = *opt_byte_mode; word_mode = *opt_word_mode; - ptr_mode = as_a (mode_for_size (POINTER_SIZE, - MODE_INT, 0)); + ptr_mode = *int_mode_for_size (POINTER_SIZE, 0); } /* Create some permanent unique rtl objects shared between all functions. */ Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:22.925278914 +0100 +++ gcc/expmed.c 2017-07-13 09:18:29.215658896 +0100 @@ -363,7 +363,7 @@ check_reverse_float_storage_order_suppor rtx flip_storage_order (machine_mode mode, rtx x) { - machine_mode int_mode; + scalar_int_mode int_mode; rtx result; if (mode == QImode) @@ -383,16 +383,13 @@ flip_storage_order (machine_mode mode, r if (__builtin_expect (reverse_storage_order_supported < 0, 0)) check_reverse_storage_order_support (); - if (SCALAR_INT_MODE_P (mode)) - int_mode = mode; - else + if (!is_a (mode, &int_mode)) { if (FLOAT_MODE_P (mode) && __builtin_expect (reverse_float_storage_order_supported < 0, 0)) check_reverse_float_storage_order_support (); - int_mode = mode_for_size (GET_MODE_PRECISION (mode), MODE_INT, 0); - if (int_mode == BLKmode) + if (!int_mode_for_size (GET_MODE_PRECISION (mode), 0).exists (&int_mode)) { sorry ("reverse storage order for %smode", GET_MODE_NAME (mode)); return x; @@ -1428,11 +1425,10 @@ convert_extracted_bit_field (rtx x, mach value via a SUBREG. */ if (!SCALAR_INT_MODE_P (tmode)) { - machine_mode smode; - - smode = mode_for_size (GET_MODE_BITSIZE (tmode), MODE_INT, 0); - x = convert_to_mode (smode, x, unsignedp); - x = force_reg (smode, x); + scalar_int_mode int_mode + = *int_mode_for_size (GET_MODE_BITSIZE (tmode), 0); + x = convert_to_mode (int_mode, x, unsignedp); + x = force_reg (int_mode, x); return gen_lowpart (tmode, x); } Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:26.362931356 +0100 +++ gcc/expr.c 2017-07-13 09:18:29.216658803 +0100 @@ -2671,9 +2671,9 @@ copy_blkmode_from_reg (rtx target, rtx s copy_mode = word_mode; if (MEM_P (target)) { - machine_mode mem_mode = mode_for_size (bitsize, MODE_INT, 1); - if (mem_mode != BLKmode) - copy_mode = mem_mode; + opt_scalar_int_mode mem_mode = int_mode_for_size (bitsize, 1); + if (mem_mode.exists ()) + copy_mode = *mem_mode; } else if (REG_P (target) && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD) copy_mode = tmode; Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c 2017-05-31 10:02:28.656477076 +0100 +++ gcc/graphite-isl-ast-to-gimple.c 2017-07-13 09:18:29.217658709 +0100 @@ -61,7 +61,7 @@ #define INCLUDE_MAP should use isl to derive the optimal type for each subexpression. */ static int max_mode_int_precision = - GET_MODE_PRECISION (mode_for_size (MAX_FIXED_MODE_SIZE, MODE_INT, 0)); + GET_MODE_PRECISION (*int_mode_for_size (MAX_FIXED_MODE_SIZE, 0)); static int graphite_expression_type_precision = 128 <= max_mode_int_precision ? 128 : max_mode_int_precision; Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2017-07-13 09:18:22.929278484 +0100 +++ gcc/internal-fn.c 2017-07-13 09:18:29.217658709 +0100 @@ -1445,7 +1445,7 @@ expand_mul_overflow (location_t loc, tre { struct separate_ops ops; int prec = GET_MODE_PRECISION (mode); - machine_mode hmode = mode_for_size (prec / 2, MODE_INT, 1); + scalar_int_mode hmode; machine_mode wmode; ops.op0 = make_tree (type, op0); ops.op1 = make_tree (type, op1); @@ -1481,7 +1481,8 @@ expand_mul_overflow (location_t loc, tre profile_probability::very_likely ()); } } - else if (hmode != BLKmode && 2 * GET_MODE_PRECISION (hmode) == prec) + else if (int_mode_for_size (prec / 2, 1).exists (&hmode) + && 2 * GET_MODE_PRECISION (hmode) == prec) { rtx_code_label *large_op0 = gen_label_rtx (); rtx_code_label *small_op0_large_op1 = gen_label_rtx (); Index: gcc/lower-subreg.c =================================================================== --- gcc/lower-subreg.c 2017-07-13 09:18:22.929278484 +0100 +++ gcc/lower-subreg.c 2017-07-13 09:18:29.217658709 +0100 @@ -349,8 +349,7 @@ simple_move (rtx_insn *insn, bool speed_ size. */ mode = GET_MODE (SET_DEST (set)); if (!SCALAR_INT_MODE_P (mode) - && (mode_for_size (GET_MODE_SIZE (mode) * BITS_PER_UNIT, MODE_INT, 0) - == BLKmode)) + && !int_mode_for_size (GET_MODE_BITSIZE (mode), 0).exists ()) return NULL_RTX; /* Reject PARTIAL_INT modes. They are used for processor specific Index: gcc/optabs-libfuncs.c =================================================================== --- gcc/optabs-libfuncs.c 2017-07-13 09:18:24.309132693 +0100 +++ gcc/optabs-libfuncs.c 2017-07-13 09:18:29.218658615 +0100 @@ -858,8 +858,10 @@ init_optabs (void) /* The ffs function operates on `int'. Fall back on it if we do not have a libgcc2 function for that width. */ if (INT_TYPE_SIZE < BITS_PER_WORD) - set_optab_libfunc (ffs_optab, mode_for_size (INT_TYPE_SIZE, MODE_INT, 0), - "ffs"); + { + scalar_int_mode mode = *int_mode_for_size (INT_TYPE_SIZE, 0); + set_optab_libfunc (ffs_optab, mode, "ffs"); + } /* Explicitly initialize the bswap libfuncs since we need them to be valid for things other than word_mode. */ Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:23.800185748 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:29.218658615 +0100 @@ -1484,12 +1484,11 @@ simplify_unary_operation_1 (enum rtx_cod && XEXP (XEXP (op, 0), 1) == XEXP (op, 1) && GET_MODE_BITSIZE (GET_MODE (op)) > INTVAL (XEXP (op, 1))) { - machine_mode tmode - = mode_for_size (GET_MODE_BITSIZE (GET_MODE (op)) - - INTVAL (XEXP (op, 1)), MODE_INT, 1); + scalar_int_mode tmode; gcc_assert (GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (GET_MODE (op))); - if (tmode != BLKmode) + if (int_mode_for_size (GET_MODE_BITSIZE (GET_MODE (op)) + - INTVAL (XEXP (op, 1)), 1).exists (&tmode)) { rtx inner = rtl_hooks.gen_lowpart_no_emit (tmode, XEXP (XEXP (op, 0), 0)); @@ -1601,10 +1600,9 @@ simplify_unary_operation_1 (enum rtx_cod && XEXP (XEXP (op, 0), 1) == XEXP (op, 1) && GET_MODE_PRECISION (GET_MODE (op)) > INTVAL (XEXP (op, 1))) { - machine_mode tmode - = mode_for_size (GET_MODE_PRECISION (GET_MODE (op)) - - INTVAL (XEXP (op, 1)), MODE_INT, 1); - if (tmode != BLKmode) + scalar_int_mode tmode; + if (int_mode_for_size (GET_MODE_PRECISION (GET_MODE (op)) + - INTVAL (XEXP (op, 1)), 1).exists (&tmode)) { rtx inner = rtl_hooks.gen_lowpart_no_emit (tmode, XEXP (XEXP (op, 0), 0)); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:25.916974620 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:29.219658521 +0100 @@ -2454,10 +2454,11 @@ vector_type_mode (const_tree t) /* For integers, try mapping it to a same-sized scalar mode. */ if (GET_MODE_CLASS (innermode) == MODE_INT) { - mode = mode_for_size (TYPE_VECTOR_SUBPARTS (t) - * GET_MODE_BITSIZE (innermode), MODE_INT, 0); - - if (mode != VOIDmode && have_regs_of_mode[mode]) + unsigned int size = (TYPE_VECTOR_SUBPARTS (t) + * GET_MODE_BITSIZE (innermode)); + scalar_int_mode mode; + if (int_mode_for_size (size, 0).exists (&mode) + && have_regs_of_mode[mode]) return mode; } Index: gcc/tree-ssa-strlen.c =================================================================== --- gcc/tree-ssa-strlen.c 2017-07-04 12:48:28.889063149 +0100 +++ gcc/tree-ssa-strlen.c 2017-07-13 09:18:29.219658521 +0100 @@ -2122,8 +2122,8 @@ handle_builtin_memcmp (gimple_stmt_itera unsigned align1 = get_pointer_alignment (arg1); unsigned align2 = get_pointer_alignment (arg2); unsigned align = MIN (align1, align2); - machine_mode mode = mode_for_size (leni, MODE_INT, 1); - if (mode != BLKmode + scalar_int_mode mode; + if (int_mode_for_size (leni, 1).exists (&mode) && (align >= leni || !SLOW_UNALIGNED_ACCESS (mode, align))) { location_t loc = gimple_location (stmt2); Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2017-07-13 09:17:19.693324483 +0100 +++ gcc/tree-vect-data-refs.c 2017-07-13 09:18:29.220658428 +0100 @@ -59,15 +59,14 @@ Software Foundation; either version 3, o vect_lanes_optab_supported_p (const char *name, convert_optab optab, tree vectype, unsigned HOST_WIDE_INT count) { - machine_mode mode, array_mode; + machine_mode mode; + scalar_int_mode array_mode; bool limit_p; mode = TYPE_MODE (vectype); limit_p = !targetm.array_mode_supported_p (mode, count); - array_mode = mode_for_size (count * GET_MODE_BITSIZE (mode), - MODE_INT, limit_p); - - if (array_mode == BLKmode) + if (!int_mode_for_size (count * GET_MODE_BITSIZE (mode), + limit_p).exists (&array_mode)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, Index: gcc/tree-vect-generic.c =================================================================== --- gcc/tree-vect-generic.c 2017-07-13 09:18:21.537428606 +0100 +++ gcc/tree-vect-generic.c 2017-07-13 09:18:29.220658428 +0100 @@ -288,7 +288,6 @@ expand_vector_parallel (gimple_stmt_iter enum tree_code code) { tree result, compute_type; - machine_mode mode; int n_words = tree_to_uhwi (TYPE_SIZE_UNIT (type)) / UNITS_PER_WORD; location_t loc = gimple_location (gsi_stmt (*gsi)); @@ -312,7 +311,8 @@ expand_vector_parallel (gimple_stmt_iter else { /* Use a single scalar operation with a mode no wider than word_mode. */ - mode = mode_for_size (tree_to_uhwi (TYPE_SIZE (type)), MODE_INT, 0); + scalar_int_mode mode + = *int_mode_for_size (tree_to_uhwi (TYPE_SIZE (type)), 0); compute_type = lang_hooks.types.type_for_mode (mode, 1); result = f (gsi, compute_type, a, b, NULL_TREE, NULL_TREE, code, type); warning_at (loc, OPT_Wvector_operation_performance, Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-13 09:18:21.538428497 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:29.221658334 +0100 @@ -7007,7 +7007,7 @@ vectorizable_load (gimple *stmt, gimple_ to a larger load. */ unsigned lsize = group_size * TYPE_PRECISION (TREE_TYPE (vectype)); - machine_mode elmode = mode_for_size (lsize, MODE_INT, 0); + scalar_int_mode elmode = *int_mode_for_size (lsize, 0); machine_mode vmode = mode_for_vector (elmode, nunits / group_size); /* If we can't construct such a vector fall back to Index: gcc/ada/gcc-interface/decl.c =================================================================== --- gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:22.913280204 +0100 +++ gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:29.208659553 +0100 @@ -3625,11 +3625,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entit /* True if we make a dummy type here. */ bool made_dummy = false; /* The mode to be used for the pointer type. */ - machine_mode p_mode = mode_for_size (esize, MODE_INT, 0); + scalar_int_mode p_mode; /* The GCC type used for the designated type. */ tree gnu_desig_type = NULL_TREE; - if (!targetm.valid_pointer_mode (p_mode)) + if (!int_mode_for_size (esize, 0).exists (&p_mode) + || !targetm.valid_pointer_mode (p_mode)) p_mode = ptr_mode; /* If either the designated type or its full view is an unconstrained @@ -5939,12 +5940,11 @@ gnat_to_gnu_subprog_type (Entity_Id gnat unsigned int size = TREE_INT_CST_LOW (TYPE_SIZE (gnu_cico_return_type)); unsigned int i = BITS_PER_UNIT; - machine_mode mode; + scalar_int_mode mode; while (i < size) i <<= 1; - mode = mode_for_size (i, MODE_INT, 0); - if (mode != BLKmode) + if (int_mode_for_size (i, 0).exists (&mode)) { SET_TYPE_MODE (gnu_cico_return_type, mode); SET_TYPE_ALIGN (gnu_cico_return_type, Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:23.793186493 +0100 +++ gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:29.208659553 +0100 @@ -1166,8 +1166,9 @@ make_type_from_size (tree type, tree siz may need to return the thin pointer. */ if (TYPE_FAT_POINTER_P (type) && size < POINTER_SIZE * 2) { - machine_mode p_mode = mode_for_size (size, MODE_INT, 0); - if (!targetm.valid_pointer_mode (p_mode)) + scalar_int_mode p_mode; + if (!int_mode_for_size (size, 0).exists (&p_mode) + || !targetm.valid_pointer_mode (p_mode)) p_mode = ptr_mode; return build_pointer_type_for_mode From patchwork Thu Jul 13 08:45:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107604 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1929259qge; Thu, 13 Jul 2017 01:46:08 -0700 (PDT) X-Received: by 10.98.149.12 with SMTP id p12mr60902114pfd.174.1499935568342; Thu, 13 Jul 2017 01:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935568; cv=none; d=google.com; s=arc-20160816; b=M+HBHrSl1iuwKcNRNKNtNfNlh6jWEMDQFR/iUgiyP2afyq5EFLO91JuiBhVeq6mMH8 zAgLScJy6iJlvbTBrRxnAbm3XGXGdNIwRTWL74mm9EJHJS2jp5XBTypiK4UEZX0tIiN7 N1gpvgLi9Uc+4BticRL+XiH3lCZlu1clSItJjrCsCIwyCnb0ZyJFC8Mz1Z0u2UrsetZl MVbEp1W8yxr8Y3yQd/Rtsgzl3L9lLFrQrC4DZmUbAFTKaBpjtNFt9soIteReQTeQkGzl UMZ3cSL4DFt8jtrekP6A7hx/Gc0meCiPitct6dY17esfKHW2w180KDyYvQaIuoHmkFMr BzIA== 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=LHVAcIkXk8WTgBpVUcWUV3wGy5cjYQmcya4volEoJK4=; b=KOkzW/BB+l1ENSubB/EayHLOBcb38+V67LWw6acQN0A8myVnrVa8AhljObSKy+LHh9 HhlJmuI4McU35SeuCCTX43LYuIZK3g/t5DC5y3SKIhIcu+CFD+hm3zHgMxdR2u6teVCj Jm1sf1VZSNH5LKSV6yxiSxhzjQRcR7biQ2zHCRiMqeCxP/toHBa8VJowt17ZK8r2Ngk6 cMoOEMEC7o06OIrs9SqIoa3MGvc1LBeS6qtMwBsrItJ3K6VosVqigx1VrFoQBQETNSjA Bb0IOcdJ8TR5mO7TWYrhuTBitqXg2aXvdgVuxR+ejbDmjxZiE2ur4HL2CMlUFR2JVfny 7Hpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=yJ8hTUmL; spf=pass (google.com: domain of gcc-patches-return-458008-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458008-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 o6si4111271plh.495.2017.07.13.01.46.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:46:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458008-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=yJ8hTUmL; spf=pass (google.com: domain of gcc-patches-return-458008-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458008-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=CNj95MtsrKgzesbd5ACrlLSnONYuK d/95V49ndUPFeXa7JVZK4cYCy+ydTZyIbw3AKZIUR8P6MgEBLfeDtT4yW1Bw54sf fbMqoDwK2gfuhExBpULUnIys273CF1PB2HB/WGbRUEpOpSiwMmu7bWtlcbqVo4RI 85sVVlOObZKDQA= 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=OEKjIKBSLUSZYLKirXDbloI3TOY=; b=yJ8 hTUmLDbt6SAPy2pFanmRUO7VVrlNv0GWpczwT1O8zLCdUEBU21sn+qUVRQafY0JL l8zGKxrqtAChclRo/u/Zs778/31tVLTYTVJCii5l2vD2MyUp27GB3n78pcw5l0Dy bfUH1v779A63YD9BttAdQE04h1wdQZLotFRM7NaM= Received: (qmail 17759 invoked by alias); 13 Jul 2017 08:45: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 130219 invoked by uid 89); 13 Jul 2017 08:45:36 -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-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:45:19 +0000 Received: by mail-wm0-f46.google.com with SMTP id f67so18107933wmh.1 for ; Thu, 13 Jul 2017 01:45:14 -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=LHVAcIkXk8WTgBpVUcWUV3wGy5cjYQmcya4volEoJK4=; b=ViReiyFd/4HjFzz+wqe1nCBDx2yLmQgLyo4xsg96XACQK2Eu66Z7O31YlPgQuW0hu/ FNFIr9wzQ3hgLvfshnY+h/UfGNUQdpNj3zMjVo+3kdgFAHF0RSaAKog6esFeb4NAgTIE q3vh/F/ohVIsP+lAjlIlzkVlUw7+/52WqbjICBFmzJr8KEJQoPYqZdNve59BeB9BTFhq lheDepyf3wUf74u5bwmpZT5eyyDX6AJ2Hs3Giqw9YOENwwahVAttct54BSasRXrQ60Zk TfHvAycaWL3IlGW4l9WnTHmSFhwg/0UffGD6FDRrWL153C/11lC/kinkC61+S2iXivdw OBrA== X-Gm-Message-State: AIVw112E5CQ7yQj70gIglwQb6a4G4bGcfXqGOJzeiwv/kJKyWCxXB3QH ZWI38ec5xDe+xL363jKc3Q== X-Received: by 10.28.139.204 with SMTP id n195mr1115014wmd.14.1499935512175; Thu, 13 Jul 2017 01:45:12 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id v102sm5881587wrc.53.2017.07.13.01.45.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:45:11 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [18/77] Make int_mode_for_mode return an opt_scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:45:09 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87zic8k9nu.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Also use int_mode_for_mode instead of (int_)mode_for_size in cases where the requested size was the bitsize of an existing mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (opt_mode::else_blk): New function. (int_mode_for_mode): Declare. * stor-layout.c (int_mode_for_mode): Return an opt_scalar_int_mode. * builtins.c (expand_builtin_signbit): Adjust for new int_mode_for_mode return type. * cfgexpand.c (expand_debug_expr): Likewise. * combine.c (gen_lowpart_or_truncate): Likewise. (gen_lowpart_for_combine): Likewise. * config/aarch64/aarch64.c (aarch64_emit_approx_sqrt): Likewise. * config/avr/avr.c (avr_to_int_mode): Likewise. (avr_out_plus_1): Likewise. (avr_out_plus): Likewise. (avr_out_round): Likewise. * config/i386/i386.c (ix86_split_to_parts): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_do_expand_vec_perm): Likewise. * config/rs6000/rs6000.c (rs6000_do_expand_vec_perm): Likewise. * config/s390/s390.c (s390_expand_vec_compare_cc): Likewise. (s390_expand_vcond): Likewise. * config/spu/spu.c (spu_split_immediate): Likewise. (spu_expand_mov): Likewise. * dse.c (get_stored_val): Likewise. * expmed.c (store_bit_field_1): Likewise. (convert_extracted_bit_field): Use int_mode_for_mode instead of int_mode_for_size. (extract_bit_field_1): Adjust for new int_mode_for_mode return type. (extract_low_bits): Likewise. * expr.c (emit_group_load_1): Likewise. Separate out the BLKmode handling rather than repeating the check. (emit_group_store): Likewise. (emit_move_via_integer): Adjust for new int_mode_for_mode return type. * optabs.c (expand_absneg_bit): Likewise. (expand_copysign_absneg): Likewise. (expand_copysign_bit): Likewise. * tree-if-conv.c (ifcvt_can_use_mask_load_store): Likewise. * tree-vect-slp.c (vect_transform_slp_perm_load): Likewise. * tree-vect-stmts.c (vect_gen_perm_mask_any): Likewise. * var-tracking.c (prepare_call_arguments): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_do_expand_vec_perm): Use int_mode_for_mode instead of mode_for_size. * config/rs6000/rs6000.c (rs6000_do_expand_vec_perm): Likewise. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:29.217658709 +0100 +++ gcc/machmode.h 2017-07-13 09:18:30.083577588 +0100 @@ -241,6 +241,7 @@ #define POINTER_BOUNDS_MODE_P(MODE) ALWAYS_INLINE opt_mode (from_int m) : m_mode (machine_mode (m)) {} machine_mode else_void () const; + machine_mode else_blk () const; T operator * () const; bool exists () const; @@ -260,6 +261,15 @@ opt_mode::else_void () const return m_mode; } +/* If the T exists, return its enum value, otherwise return E_BLKmode. */ + +template +inline machine_mode +opt_mode::else_blk () const +{ + return m_mode == E_VOIDmode ? E_BLKmode : m_mode; +} + /* Assert that the object contains a T and return it. */ template @@ -583,10 +593,9 @@ extern machine_mode smallest_mode_for_si enum mode_class); -/* Return an integer mode of the exact same size as the input mode, - or BLKmode on failure. */ +/* Return an integer mode of exactly the same size as the input mode. */ -extern machine_mode int_mode_for_mode (machine_mode); +extern opt_scalar_int_mode int_mode_for_mode (machine_mode); extern machine_mode bitwise_mode_for_mode (machine_mode); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:29.219658521 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:30.086577310 +0100 @@ -364,16 +364,16 @@ smallest_mode_for_size (unsigned int siz return mode; } -/* Find an integer mode of the exact same size, or BLKmode on failure. */ +/* Return an integer mode of exactly the same size as MODE, if one exists. */ -machine_mode +opt_scalar_int_mode int_mode_for_mode (machine_mode mode) { switch (GET_MODE_CLASS (mode)) { case MODE_INT: case MODE_PARTIAL_INT: - break; + return as_a (mode); case MODE_COMPLEX_INT: case MODE_COMPLEX_FLOAT: @@ -390,12 +390,11 @@ int_mode_for_mode (machine_mode mode) case MODE_VECTOR_UFRACT: case MODE_VECTOR_UACCUM: case MODE_POINTER_BOUNDS: - mode = mode_for_size (GET_MODE_BITSIZE (mode), MODE_INT, 0); - break; + return int_mode_for_size (GET_MODE_BITSIZE (mode), 0); case MODE_RANDOM: if (mode == BLKmode) - break; + return opt_scalar_int_mode (); /* fall through */ @@ -403,8 +402,6 @@ int_mode_for_mode (machine_mode mode) default: gcc_unreachable (); } - - return mode; } /* Find a mode that can be used for efficient bitwise operations on MODE. Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2017-07-13 09:18:29.209659459 +0100 +++ gcc/builtins.c 2017-07-13 09:18:30.027582784 +0100 @@ -5413,8 +5413,7 @@ expand_builtin_signbit (tree exp, rtx ta if (GET_MODE_SIZE (fmode) <= UNITS_PER_WORD) { - imode = int_mode_for_mode (fmode); - gcc_assert (imode != BLKmode); + imode = *int_mode_for_mode (fmode); temp = gen_lowpart (imode, temp); } else Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-08 11:37:46.573465901 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:30.028582691 +0100 @@ -4836,10 +4836,11 @@ expand_debug_expr (tree exp) } else { - machine_mode ifmode = int_mode_for_mode (mode); - machine_mode ihmode = int_mode_for_mode (imode); + scalar_int_mode ifmode; + scalar_int_mode ihmode; rtx halfsize; - if (ifmode == BLKmode || ihmode == BLKmode) + if (!int_mode_for_mode (mode).exists (&ifmode) + || !int_mode_for_mode (imode).exists (&ihmode)) return NULL; halfsize = GEN_INT (GET_MODE_BITSIZE (ihmode)); re = op0; Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:29.211659271 +0100 +++ gcc/combine.c 2017-07-13 09:18:30.031582413 +0100 @@ -8444,8 +8444,8 @@ gen_lowpart_or_truncate (machine_mode mo { /* Bit-cast X into an integer mode. */ if (!SCALAR_INT_MODE_P (GET_MODE (x))) - x = gen_lowpart (int_mode_for_mode (GET_MODE (x)), x); - x = simplify_gen_unary (TRUNCATE, int_mode_for_mode (mode), + x = gen_lowpart (*int_mode_for_mode (GET_MODE (x)), x); + x = simplify_gen_unary (TRUNCATE, *int_mode_for_mode (mode), x, GET_MODE (x)); } @@ -11519,7 +11519,7 @@ gen_lowpart_for_combine (machine_mode om if (imode == VOIDmode) { - imode = int_mode_for_mode (omode); + imode = *int_mode_for_mode (omode); x = gen_lowpart_common (imode, x); if (x == NULL) goto fail; Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:27.465825060 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:30.033582228 +0100 @@ -8148,7 +8148,7 @@ aarch64_emit_approx_sqrt (rtx dst, rtx s } machine_mode mmsk - = mode_for_vector (int_mode_for_mode (GET_MODE_INNER (mode)), + = mode_for_vector (*int_mode_for_mode (GET_MODE_INNER (mode)), GET_MODE_NUNITS (mode)); if (!recp) { Index: gcc/config/avr/avr.c =================================================================== --- gcc/config/avr/avr.c 2017-07-13 09:18:19.036703514 +0100 +++ gcc/config/avr/avr.c 2017-07-13 09:18:30.035582042 +0100 @@ -283,7 +283,7 @@ avr_to_int_mode (rtx x) return VOIDmode == mode ? x - : simplify_gen_subreg (int_mode_for_mode (mode), x, mode, 0); + : simplify_gen_subreg (*int_mode_for_mode (mode), x, mode, 0); } namespace { @@ -7737,7 +7737,7 @@ avr_out_plus_1 (rtx *xop, int *plen, enu machine_mode mode = GET_MODE (xop[0]); /* INT_MODE of the same size. */ - machine_mode imode = int_mode_for_mode (mode); + scalar_int_mode imode = *int_mode_for_mode (mode); /* Number of bytes to operate on. */ int n_bytes = GET_MODE_SIZE (mode); @@ -8240,7 +8240,7 @@ avr_out_plus (rtx insn, rtx *xop, int *p rtx xpattern = INSN_P (insn) ? single_set (as_a (insn)) : insn; rtx xdest = SET_DEST (xpattern); machine_mode mode = GET_MODE (xdest); - machine_mode imode = int_mode_for_mode (mode); + scalar_int_mode imode = *int_mode_for_mode (mode); int n_bytes = GET_MODE_SIZE (mode); enum rtx_code code_sat = GET_CODE (SET_SRC (xpattern)); enum rtx_code code @@ -9175,7 +9175,7 @@ #define MAY_CLOBBER(RR) avr_out_round (rtx_insn *insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) { machine_mode mode = GET_MODE (xop[0]); - machine_mode imode = int_mode_for_mode (mode); + scalar_int_mode imode = *int_mode_for_mode (mode); // The smallest fractional bit not cleared by the rounding is 2^(-RP). int fbit = (int) GET_MODE_FBIT (mode); double_int i_add = double_int_zero.set_bit (fbit-1 - INTVAL (xop[2])); Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-07-13 09:18:22.921279344 +0100 +++ gcc/config/i386/i386.c 2017-07-13 09:18:30.054580279 +0100 @@ -26215,7 +26215,7 @@ ix86_split_to_parts (rtx operand, rtx *p if (GET_CODE (operand) == CONST_VECTOR) { - machine_mode imode = int_mode_for_mode (mode); + scalar_int_mode imode = *int_mode_for_mode (mode); /* Caution: if we looked through a constant pool memory above, the operand may actually have a different mode now. That's ok, since we want to pun this all the way back to an integer. */ Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:28.017772208 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:30.062579537 +0100 @@ -38666,10 +38666,8 @@ rs6000_do_expand_vec_perm (rtx target, r imode = vmode; if (GET_MODE_CLASS (vmode) != MODE_VECTOR_INT) - { - imode = mode_for_size (GET_MODE_UNIT_BITSIZE (vmode), MODE_INT, 0); - imode = mode_for_vector (imode, nelt); - } + imode = mode_for_vector (*int_mode_for_mode (GET_MODE_INNER (vmode)), + nelt); x = gen_rtx_CONST_VECTOR (imode, gen_rtvec_v (nelt, perm)); x = expand_vec_perm (vmode, op0, op1, x, target); Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:28.021771829 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:30.071578702 +0100 @@ -35748,10 +35748,8 @@ rs6000_do_expand_vec_perm (rtx target, r imode = vmode; if (GET_MODE_CLASS (vmode) != MODE_VECTOR_INT) - { - imode = mode_for_size (GET_MODE_UNIT_BITSIZE (vmode), MODE_INT, 0); - imode = mode_for_vector (imode, nelt); - } + imode = mode_for_vector (*int_mode_for_mode (GET_MODE_INNER (vmode)), + nelt); x = gen_rtx_CONST_VECTOR (imode, gen_rtvec_v (nelt, perm)); x = expand_vec_perm (vmode, op0, op1, x, target); Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:28.023771640 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:30.075578330 +0100 @@ -6464,7 +6464,7 @@ s390_expand_vec_compare_cc (rtx target, default: gcc_unreachable (); } scratch_mode = mode_for_vector ( - int_mode_for_mode (GET_MODE_INNER (GET_MODE (cmp1))), + *int_mode_for_mode (GET_MODE_INNER (GET_MODE (cmp1))), GET_MODE_NUNITS (GET_MODE (cmp1))); gcc_assert (scratch_mode != BLKmode); @@ -6572,8 +6572,9 @@ s390_expand_vcond (rtx target, rtx then, /* We always use an integral type vector to hold the comparison result. */ - result_mode = mode_for_vector (int_mode_for_mode (GET_MODE_INNER (cmp_mode)), - GET_MODE_NUNITS (cmp_mode)); + result_mode + = mode_for_vector (*int_mode_for_mode (GET_MODE_INNER (cmp_mode)), + GET_MODE_NUNITS (cmp_mode)); result_target = gen_reg_rtx (result_mode); /* We allow vector immediates as comparison operands that Index: gcc/config/spu/spu.c =================================================================== --- gcc/config/spu/spu.c 2017-07-13 09:18:19.136692428 +0100 +++ gcc/config/spu/spu.c 2017-07-13 09:18:30.077578145 +0100 @@ -1492,10 +1492,9 @@ spu_split_immediate (rtx * ops) unsigned char arrlo[16]; rtx to, temp, hi, lo; int i; - machine_mode imode = mode; /* We need to do reals as ints because the constant used in the IOR might not be a legitimate real constant. */ - imode = int_mode_for_mode (mode); + scalar_int_mode imode = *int_mode_for_mode (mode); constant_to_array (mode, ops[1], arrhi); if (imode != mode) to = simplify_gen_subreg (imode, ops[0], mode, 0); @@ -1521,10 +1520,9 @@ spu_split_immediate (rtx * ops) unsigned char arr_andbi[16]; rtx to, reg_fsmbi, reg_and; int i; - machine_mode imode = mode; /* We need to do reals as ints because the constant used in the * AND might not be a legitimate real constant. */ - imode = int_mode_for_mode (mode); + scalar_int_mode imode = *int_mode_for_mode (mode); constant_to_array (mode, ops[1], arr_fsmbi); if (imode != mode) to = simplify_gen_subreg(imode, ops[0], GET_MODE (ops[0]), 0); @@ -4429,7 +4427,7 @@ spu_expand_mov (rtx * ops, machine_mode if (GET_CODE (ops[1]) == SUBREG && !valid_subreg (ops[1])) { rtx from = SUBREG_REG (ops[1]); - machine_mode imode = int_mode_for_mode (GET_MODE (from)); + scalar_int_mode imode = *int_mode_for_mode (GET_MODE (from)); gcc_assert (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_CLASS (imode) == MODE_INT Index: gcc/dse.c =================================================================== --- gcc/dse.c 2017-07-13 09:18:21.530429366 +0100 +++ gcc/dse.c 2017-07-13 09:18:30.078578052 +0100 @@ -1734,12 +1734,12 @@ get_stored_val (store_info *store_info, { /* The store is a memset (addr, const_val, const_size). */ gcc_assert (CONST_INT_P (store_info->rhs)); - store_mode = int_mode_for_mode (read_mode); - if (store_mode == BLKmode) + scalar_int_mode int_store_mode; + if (!int_mode_for_mode (read_mode).exists (&int_store_mode)) read_reg = NULL_RTX; else if (store_info->rhs == const0_rtx) - read_reg = extract_low_bits (read_mode, store_mode, const0_rtx); - else if (GET_MODE_BITSIZE (store_mode) > HOST_BITS_PER_WIDE_INT + read_reg = extract_low_bits (read_mode, int_store_mode, const0_rtx); + else if (GET_MODE_BITSIZE (int_store_mode) > HOST_BITS_PER_WIDE_INT || BITS_PER_UNIT >= HOST_BITS_PER_WIDE_INT) read_reg = NULL_RTX; else @@ -1753,8 +1753,8 @@ get_stored_val (store_info *store_info, c |= (c << shift); shift <<= 1; } - read_reg = gen_int_mode (c, store_mode); - read_reg = extract_low_bits (read_mode, store_mode, read_reg); + read_reg = gen_int_mode (c, int_store_mode); + read_reg = extract_low_bits (read_mode, int_store_mode, read_reg); } } else if (store_info->const_rhs Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:29.215658896 +0100 +++ gcc/expmed.c 2017-07-13 09:18:30.080577867 +0100 @@ -828,19 +828,15 @@ store_bit_field_1 (rtx str_rtx, unsigned if we aren't. This must come after the entire register case above, since that case is valid for any mode. The following cases are only valid for integral modes. */ - { - machine_mode imode = int_mode_for_mode (GET_MODE (op0)); - if (imode != GET_MODE (op0)) - { - if (MEM_P (op0)) - op0 = adjust_bitfield_address_size (op0, imode, 0, MEM_SIZE (op0)); - else - { - gcc_assert (imode != BLKmode); - op0 = gen_lowpart (imode, op0); - } - } - } + opt_scalar_int_mode imode = int_mode_for_mode (GET_MODE (op0)); + if (!imode.exists () || *imode != GET_MODE (op0)) + { + if (MEM_P (op0)) + op0 = adjust_bitfield_address_size (op0, imode.else_blk (), + 0, MEM_SIZE (op0)); + else + op0 = gen_lowpart (*imode, op0); + } /* Storing an lsb-aligned field in a register can be done with a movstrict instruction. */ @@ -955,7 +951,7 @@ store_bit_field_1 (rtx str_rtx, unsigned && GET_MODE_CLASS (GET_MODE (value)) != MODE_INT && GET_MODE_CLASS (GET_MODE (value)) != MODE_PARTIAL_INT) { - value = gen_reg_rtx (int_mode_for_mode (GET_MODE (value))); + value = gen_reg_rtx (*int_mode_for_mode (GET_MODE (value))); emit_move_insn (gen_lowpart (GET_MODE (orig_value), value), orig_value); } @@ -1425,8 +1421,7 @@ convert_extracted_bit_field (rtx x, mach value via a SUBREG. */ if (!SCALAR_INT_MODE_P (tmode)) { - scalar_int_mode int_mode - = *int_mode_for_size (GET_MODE_BITSIZE (tmode), 0); + scalar_int_mode int_mode = *int_mode_for_mode (tmode); x = convert_to_mode (int_mode, x, unsignedp); x = force_reg (int_mode, x); return gen_lowpart (tmode, x); @@ -1531,7 +1526,6 @@ extract_bit_field_1 (rtx str_rtx, unsign bool reverse, bool fallback_p, rtx *alt_rtl) { rtx op0 = str_rtx; - machine_mode int_mode; machine_mode mode1; if (tmode == VOIDmode) @@ -1620,30 +1614,29 @@ extract_bit_field_1 (rtx str_rtx, unsign /* Make sure we are playing with integral modes. Pun with subregs if we aren't. */ - { - machine_mode imode = int_mode_for_mode (GET_MODE (op0)); - if (imode != GET_MODE (op0)) - { - if (MEM_P (op0)) - op0 = adjust_bitfield_address_size (op0, imode, 0, MEM_SIZE (op0)); - else if (imode != BLKmode) - { - op0 = gen_lowpart (imode, op0); - - /* If we got a SUBREG, force it into a register since we - aren't going to be able to do another SUBREG on it. */ - if (GET_CODE (op0) == SUBREG) - op0 = force_reg (imode, op0); - } - else - { - HOST_WIDE_INT size = GET_MODE_SIZE (GET_MODE (op0)); - rtx mem = assign_stack_temp (GET_MODE (op0), size); - emit_move_insn (mem, op0); - op0 = adjust_bitfield_address_size (mem, BLKmode, 0, size); - } - } - } + opt_scalar_int_mode imode = int_mode_for_mode (GET_MODE (op0)); + if (!imode.exists () || *imode != GET_MODE (op0)) + { + if (MEM_P (op0)) + op0 = adjust_bitfield_address_size (op0, imode.else_blk (), + 0, MEM_SIZE (op0)); + else if (imode.exists ()) + { + op0 = gen_lowpart (*imode, op0); + + /* If we got a SUBREG, force it into a register since we + aren't going to be able to do another SUBREG on it. */ + if (GET_CODE (op0) == SUBREG) + op0 = force_reg (*imode, op0); + } + else + { + HOST_WIDE_INT size = GET_MODE_SIZE (GET_MODE (op0)); + rtx mem = assign_stack_temp (GET_MODE (op0), size); + emit_move_insn (mem, op0); + op0 = adjust_bitfield_address_size (mem, BLKmode, 0, size); + } + } /* ??? We currently assume TARGET is at least as big as BITSIZE. If that's wrong, the solution is to test for it and set TARGET to 0 @@ -1847,11 +1840,11 @@ extract_bit_field_1 (rtx str_rtx, unsign /* Find a correspondingly-sized integer field, so we can apply shifts and masks to it. */ - int_mode = int_mode_for_mode (tmode); - if (int_mode == BLKmode) - int_mode = int_mode_for_mode (mode); - /* Should probably push op0 out to memory and then do a load. */ - gcc_assert (int_mode != BLKmode); + scalar_int_mode int_mode; + if (!int_mode_for_mode (tmode).exists (&int_mode)) + /* If this fails, we should probably push op0 out to memory and then + do a load. */ + int_mode = *int_mode_for_mode (mode); target = extract_fixed_bit_field (int_mode, op0, bitsize, bitnum, target, unsignedp, reverse); @@ -2206,9 +2199,8 @@ extract_low_bits (machine_mode mode, mac return x; } - src_int_mode = int_mode_for_mode (src_mode); - int_mode = int_mode_for_mode (mode); - if (src_int_mode == BLKmode || int_mode == BLKmode) + if (!int_mode_for_mode (src_mode).exists (&src_int_mode) + || !int_mode_for_mode (mode).exists (&int_mode)) return NULL_RTX; if (!MODES_TIEABLE_P (src_int_mode, src_mode)) Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:29.216658803 +0100 +++ gcc/expr.c 2017-07-13 09:18:30.083577588 +0100 @@ -2094,17 +2094,17 @@ emit_group_load_1 (rtx *tmps, rtx dst, r && !MEM_P (orig_src) && GET_CODE (orig_src) != CONCAT) { - machine_mode imode = int_mode_for_mode (GET_MODE (orig_src)); - if (imode == BLKmode) - src = assign_stack_temp (GET_MODE (orig_src), ssize); + scalar_int_mode imode; + if (int_mode_for_mode (GET_MODE (orig_src)).exists (&imode)) + { + src = gen_reg_rtx (imode); + emit_move_insn (gen_lowpart (GET_MODE (orig_src), src), orig_src); + } else - src = gen_reg_rtx (imode); - if (imode != BLKmode) - src = gen_lowpart (GET_MODE (orig_src), src); - emit_move_insn (src, orig_src); - /* ...and back again. */ - if (imode != BLKmode) - src = gen_lowpart (imode, src); + { + src = assign_stack_temp (GET_MODE (orig_src), ssize); + emit_move_insn (src, orig_src); + } emit_group_load_1 (tmps, dst, src, type, ssize); return; } @@ -2368,14 +2368,18 @@ emit_group_store (rtx orig_dst, rtx src, if (!SCALAR_INT_MODE_P (m) && !MEM_P (orig_dst) && GET_CODE (orig_dst) != CONCAT) { - machine_mode imode = int_mode_for_mode (GET_MODE (orig_dst)); - if (imode == BLKmode) - dst = assign_stack_temp (GET_MODE (orig_dst), ssize); + scalar_int_mode imode; + if (int_mode_for_mode (GET_MODE (orig_dst)).exists (&imode)) + { + dst = gen_reg_rtx (imode); + emit_group_store (dst, src, type, ssize); + dst = gen_lowpart (GET_MODE (orig_dst), dst); + } else - dst = gen_reg_rtx (imode); - emit_group_store (dst, src, type, ssize); - if (imode != BLKmode) - dst = gen_lowpart (GET_MODE (orig_dst), dst); + { + dst = assign_stack_temp (GET_MODE (orig_dst), ssize); + emit_group_store (dst, src, type, ssize); + } emit_move_insn (orig_dst, dst); return; } @@ -3283,12 +3287,11 @@ emit_move_change_mode (machine_mode new_ static rtx_insn * emit_move_via_integer (machine_mode mode, rtx x, rtx y, bool force) { - machine_mode imode; + scalar_int_mode imode; enum insn_code code; /* There must exist a mode of the exact size we require. */ - imode = int_mode_for_mode (mode); - if (imode == BLKmode) + if (!int_mode_for_mode (mode).exists (&imode)) return NULL; /* The target must support moves in this mode. */ Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:23.799185854 +0100 +++ gcc/optabs.c 2017-07-13 09:18:30.085577402 +0100 @@ -2575,8 +2575,7 @@ expand_absneg_bit (enum rtx_code code, s if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD) { - imode = int_mode_for_mode (mode); - if (imode == BLKmode) + if (!int_mode_for_mode (mode).exists (&imode)) return NULL_RTX; word = 0; nwords = 1; @@ -3269,8 +3268,7 @@ expand_copysign_absneg (scalar_float_mod { if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD) { - imode = int_mode_for_mode (mode); - if (imode == BLKmode) + if (!int_mode_for_mode (mode).exists (&imode)) return NULL_RTX; op1 = gen_lowpart (imode, op1); } @@ -3332,15 +3330,14 @@ expand_copysign_absneg (scalar_float_mod expand_copysign_bit (scalar_float_mode mode, rtx op0, rtx op1, rtx target, int bitpos, bool op0_is_abs) { - machine_mode imode; + scalar_int_mode imode; int word, nwords, i; rtx temp; rtx_insn *insns; if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD) { - imode = int_mode_for_mode (mode); - if (imode == BLKmode) + if (!int_mode_for_mode (mode).exists (&imode)) return NULL_RTX; word = 0; nwords = 1; Index: gcc/tree-if-conv.c =================================================================== --- gcc/tree-if-conv.c 2017-07-03 14:36:28.872861805 +0100 +++ gcc/tree-if-conv.c 2017-07-13 09:18:30.087577217 +0100 @@ -933,8 +933,7 @@ ifcvt_can_use_mask_load_store (gimple *s /* Mask should be integer mode of the same size as the load/store mode. */ mode = TYPE_MODE (TREE_TYPE (lhs)); - if (int_mode_for_mode (mode) == BLKmode - || VECTOR_MODE_P (mode)) + if (!int_mode_for_mode (mode).exists () || VECTOR_MODE_P (mode)) return false; if (can_vec_mask_load_store_p (mode, VOIDmode, is_load)) Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2017-07-13 09:17:19.693324483 +0100 +++ gcc/tree-vect-slp.c 2017-07-13 09:18:30.088577124 +0100 @@ -3430,7 +3430,7 @@ vect_transform_slp_perm_load (slp_tree n /* The generic VEC_PERM_EXPR code always uses an integral type of the same size as the vector element being permuted. */ mask_element_type = lang_hooks.types.type_for_mode - (int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))), 1); + (*int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))), 1); mask_type = get_vectype_for_scalar_type (mask_element_type); nunits = TYPE_VECTOR_SUBPARTS (vectype); mask = XALLOCAVEC (unsigned char, nunits); Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-13 09:18:29.221658334 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:30.090576938 +0100 @@ -6432,7 +6432,7 @@ vect_gen_perm_mask_any (tree vectype, co nunits = TYPE_VECTOR_SUBPARTS (vectype); mask_elt_type = lang_hooks.types.type_for_mode - (int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))), 1); + (*int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))), 1); mask_type = get_vectype_for_scalar_type (mask_elt_type); mask_elts = XALLOCAVEC (tree, nunits); Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-07-13 09:18:22.945276764 +0100 +++ gcc/var-tracking.c 2017-07-13 09:18:30.093576660 +0100 @@ -6348,8 +6348,9 @@ prepare_call_arguments (basic_block bb, { /* For non-integer stack argument see also if they weren't initialized by integers. */ - machine_mode imode = int_mode_for_mode (GET_MODE (mem)); - if (imode != GET_MODE (mem) && imode != BLKmode) + scalar_int_mode imode; + if (int_mode_for_mode (GET_MODE (mem)).exists (&imode) + && imode != GET_MODE (mem)) { val = cselib_lookup (adjust_address_nv (mem, imode, 0), imode, 0, VOIDmode); From patchwork Thu Jul 13 08:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107605 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1929529qge; Thu, 13 Jul 2017 01:46:28 -0700 (PDT) X-Received: by 10.84.217.134 with SMTP id p6mr8942516pli.196.1499935588547; Thu, 13 Jul 2017 01:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935588; cv=none; d=google.com; s=arc-20160816; b=bx78tOjY9Z3LEMyfln7morsS1Y3ZG1jnxFhIjoLojQI+i3WgKl9YkxDJuRkDHfvC0I HgqzZsgbtaC2a9oAoXb00HrxD80aQu8tLDbtg6GSiYoFaYn7pEwF8M1TbhIJUE7013RS BG4CZDHeAazoJiPrX8pVIMMWsLy1xrZhQ5Xl8j42R3oACQzQ9g1w9muIYNPy42uA5TlN jAefUnQtcUs51mKVzyS/DvUy2qC3EVwZnGE2xDENNJbAlqxApuj5Lf3UYng6KPK7tFbY FXLVUQxNwwvFURCTDe+6G3lVn6P0KPA9enw7Vjq5x5HyNZZvudzfB5Jd0TfyofevPthJ e3Vg== 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=hEaAYZDkfYmMz/HxxhL3ZaaHHQ5A2GC40J/DTO4EfFY=; b=j7JzKzD17mbOjU3z62slCZi1CjoHrhcl013OEKxTolJeax11cjs+uJ7WKQXU8qfx1z 5VrPC0kMLsOqbkOfBfgCHSEJMabLF8/ZEJphd//PuwlPwDiWsdocLoKWlzaa2e0yDT9a AZPoMXQM4q9sMg9TtN/lFieC/gxs6zTkTCtMWXpN7JKqT0gSeXvBNS7DPjG1FhwkoINd 0GOqDErsUCqepJKRlZb1HeRPsYw91CF5VZBSVgZWYavjavlzhqUTpcryzAsQVWEWaDRI 0i6IpmSXY/ZrTgXmaNBjSiEPFUpne6He6PW4Mw/2VK8fjLNbOWZWnc959MsWV4l3Jyl9 eOnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=tz2ng0nd; spf=pass (google.com: domain of gcc-patches-return-458009-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458009-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 n6si3865654pgf.284.2017.07.13.01.46.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:46:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458009-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=tz2ng0nd; spf=pass (google.com: domain of gcc-patches-return-458009-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458009-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=QMxM4D/pDk7OgDH7NEHj+RxdEbFP/ vsxouoSnc+i8fF7D62asXAeRd+XodZ0vttvFkXHPWvILRvaXNIumQnrIFosqrEDu GLHcO6IcxdDRSDmVsvQv3zWNUIvlqCszxK9VWsN80i/Cc690FkoDWJola0lYiSe6 UgH23wZx52uvEw= 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=ZIuykm5rvGnQK4P1baYYhMx/M+Y=; b=tz2 ng0ndJ8AWlFJF31I1Ow0uUjOUVjSxCBPezceec2r2WEHlAhYOEoYqMsUAl5nDZlG vU6V20heyyMiujkcK11tSCeNsldHZaCFvqbjotBcpfFgeBjXIMEZmB3aptO33pyK bpjcYCshlkPsNhf9UhM92anyETHA2xXwhOdFGxVY= Received: (qmail 24471 invoked by alias); 13 Jul 2017 08:45:51 -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 10342 invoked by uid 89); 13 Jul 2017 08:45:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=nominal X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:45:40 +0000 Received: by mail-wr0-f170.google.com with SMTP id 77so49586041wrb.1 for ; Thu, 13 Jul 2017 01:45:39 -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=hEaAYZDkfYmMz/HxxhL3ZaaHHQ5A2GC40J/DTO4EfFY=; b=YTkMi6e0f/9/OMWIfdPa9VIOTytU2yROeeIV6ptmTM6C+UmFj1l/IPbvMZj96bwBlO gR/36+5eUfZSwWhY2M5C+jzh1+7Z/9a8+Ja7n5IQe2i1Z/rFCwh9C35u8946Dd0iechk fSBnfvFHds1FXkDo/zwHfSII8nRPba+ms4WiZdX8Lda7wPSMK/S0YbjBAh63HMtkuDEh 9bodCuhiJ58OXR5Uycmn0EqkryyHMh7VWQ9b4qjgkYh/81De+wUYYEGNrjFCsX11VvS7 ewE90+60/3CHKjGkOERBzPhdW1eQPtk7t5s6xep4BOjfBaOUOv4Usk05Ibkio84J41U6 GS0g== X-Gm-Message-State: AIVw1114M4UpL+vthoy4FhzlKN8RsCAVHmRtYHiAS87xnQ18jI6DBdsO CtEbIc1+FZbsRCCdDETR6g== X-Received: by 10.223.173.140 with SMTP id w12mr943773wrc.4.1499935536908; Thu, 13 Jul 2017 01:45:36 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id z195sm6035320wmz.28.2017.07.13.01.45.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:45:35 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [19/77] Add a smallest_int_mode_for_size helper function References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:45:34 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87vamwk9n5.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a wrapper around smallest_mode_for_size for cases in which the mode class is MODE_INT. Unlike (int_)mode_for_size, smallest_mode_for_size always returns a mode of the specified class, asserting if no such mode exists. smallest_int_mode_for_size therefore returns a scalar_int_mode rather than an opt_scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (smallest_mode_for_size): Fix formatting. (smallest_int_mode_for_size): New function. * cfgexpand.c (expand_debug_expr): Use smallest_int_mode_for_size instead of smallest_mode_for_size. * combine.c (make_extraction): Likewise. * config/arc/arc.c (arc_expand_movmem): Likewise. * config/arm/arm.c (arm_expand_divmod_libfunc): Likewise. * config/i386/i386.c (ix86_get_mask_mode): Likewise. * config/s390/s390.c (s390_expand_insv): Likewise. * config/sparc/sparc.c (assign_int_registers): Likewise. * config/spu/spu.c (spu_function_value): Likewise. (spu_function_arg): Likewise. * coverage.c (get_gcov_type): Likewise. (get_gcov_unsigned_t): Likewise. * dse.c (find_shift_sequence): Likewise. * expmed.c (store_bit_field_1): Likewise. * expr.c (convert_move): Likewise. (store_field): Likewise. * internal-fn.c (expand_arith_overflow): Likewise. * optabs-query.c (get_best_extraction_insn): Likewise. * optabs.c (expand_twoval_binop_libfunc): Likewise. * stor-layout.c (layout_type): Likewise. (initialize_sizetypes): Likewise. * targhooks.c (default_get_mask_mode): Likewise. * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Likewise. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:30.083577588 +0100 +++ gcc/machmode.h 2017-07-13 09:18:30.902501597 +0100 @@ -589,9 +589,16 @@ float_mode_for_size (unsigned int size) /* Similar to mode_for_size, but find the smallest mode for a given width. */ -extern machine_mode smallest_mode_for_size (unsigned int, - enum mode_class); +extern machine_mode smallest_mode_for_size (unsigned int, enum mode_class); +/* Find the narrowest integer mode that contains at least SIZE bits. + Such a mode must exist. */ + +inline scalar_int_mode +smallest_int_mode_for_size (unsigned int size) +{ + return as_a (smallest_mode_for_size (size, MODE_INT)); +} /* Return an integer mode of exactly the same size as the input mode. */ Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:30.028582691 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:30.888502896 +0100 @@ -4495,7 +4495,7 @@ expand_debug_expr (tree exp) { if (mode1 == VOIDmode) /* Bitfield. */ - mode1 = smallest_mode_for_size (bitsize, MODE_INT); + mode1 = smallest_int_mode_for_size (bitsize); if (bitpos >= BITS_PER_UNIT) { op0 = adjust_address_nv (op0, mode1, bitpos / BITS_PER_UNIT); Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:30.031582413 +0100 +++ gcc/combine.c 2017-07-13 09:18:30.889502803 +0100 @@ -7611,7 +7611,7 @@ make_extraction (machine_mode mode, rtx { /* Be careful not to go beyond the extracted object and maintain the natural alignment of the memory. */ - wanted_inner_mode = smallest_mode_for_size (len, MODE_INT); + wanted_inner_mode = smallest_int_mode_for_size (len); while (pos % GET_MODE_BITSIZE (wanted_inner_mode) + len > GET_MODE_BITSIZE (wanted_inner_mode)) wanted_inner_mode = *GET_MODE_WIDER_MODE (wanted_inner_mode); Index: gcc/config/arc/arc.c =================================================================== --- gcc/config/arc/arc.c 2017-07-13 09:18:19.018705510 +0100 +++ gcc/config/arc/arc.c 2017-07-13 09:18:30.890502711 +0100 @@ -7974,7 +7974,7 @@ arc_expand_movmem (rtx *operands) while (piece > size) piece >>= 1; - mode = smallest_mode_for_size (piece * BITS_PER_UNIT, MODE_INT); + mode = smallest_int_mode_for_size (piece * BITS_PER_UNIT); /* If we don't re-use temporaries, the scheduler gets carried away, and the register pressure gets unnecessarily high. */ if (0 && tmpx[i] && GET_MODE (tmpx[i]) == mode) Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-13 09:18:26.899879373 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:30.892502525 +0100 @@ -31096,8 +31096,8 @@ arm_expand_divmod_libfunc (rtx libfunc, if (mode == SImode) gcc_assert (!TARGET_IDIV); - machine_mode libval_mode = smallest_mode_for_size (2 * GET_MODE_BITSIZE (mode), - MODE_INT); + scalar_int_mode libval_mode + = smallest_int_mode_for_size (2 * GET_MODE_BITSIZE (mode)); rtx libval = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, libval_mode, 2, Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-07-13 09:18:30.054580279 +0100 +++ gcc/config/i386/i386.c 2017-07-13 09:18:30.896502154 +0100 @@ -51320,11 +51320,11 @@ ix86_get_mask_mode (unsigned nunits, uns || (TARGET_AVX512VL && (vector_size == 32 || vector_size == 16))) { if (elem_size == 4 || elem_size == 8 || TARGET_AVX512BW) - return smallest_mode_for_size (nunits, MODE_INT); + return smallest_int_mode_for_size (nunits); } - machine_mode elem_mode - = smallest_mode_for_size (elem_size * BITS_PER_UNIT, MODE_INT); + scalar_int_mode elem_mode + = smallest_int_mode_for_size (elem_size * BITS_PER_UNIT); gcc_assert (elem_size * nunits == vector_size); Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:30.075578330 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:30.898501968 +0100 @@ -6182,7 +6182,7 @@ s390_expand_insv (rtx dest, rtx op1, rtx return true; } - smode = smallest_mode_for_size (bitsize, MODE_INT); + smode = smallest_int_mode_for_size (bitsize); smode_bsize = GET_MODE_BITSIZE (smode); mode_bsize = GET_MODE_BITSIZE (mode); Index: gcc/config/sparc/sparc.c =================================================================== --- gcc/config/sparc/sparc.c 2017-07-13 09:18:19.134692649 +0100 +++ gcc/config/sparc/sparc.c 2017-07-13 09:18:30.899501876 +0100 @@ -6761,8 +6761,8 @@ assign_int_registers (HOST_WIDE_INT bitp the latter case we may pick up unwanted bits. It's not a problem at the moment but may wish to revisit. */ if (intoffset % BITS_PER_WORD != 0) - mode = smallest_mode_for_size (BITS_PER_WORD - intoffset % BITS_PER_WORD, - MODE_INT); + mode = smallest_int_mode_for_size (BITS_PER_WORD + - intoffset % BITS_PER_WORD); else mode = word_mode; Index: gcc/config/spu/spu.c =================================================================== --- gcc/config/spu/spu.c 2017-07-13 09:18:30.077578145 +0100 +++ gcc/config/spu/spu.c 2017-07-13 09:18:30.899501876 +0100 @@ -3808,8 +3808,7 @@ spu_function_value (const_tree type, con { if (byte_size < 4) byte_size = 4; - smode = - smallest_mode_for_size (byte_size * BITS_PER_UNIT, MODE_INT); + smode = smallest_int_mode_for_size (byte_size * BITS_PER_UNIT); RTVEC_ELT (v, n) = gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_REG (smode, FIRST_RETURN_REGNUM + n), @@ -3847,7 +3846,7 @@ spu_function_arg (cumulative_args_t cum_ rtx gr_reg; if (byte_size < 4) byte_size = 4; - smode = smallest_mode_for_size (byte_size * BITS_PER_UNIT, MODE_INT); + smode = smallest_int_mode_for_size (byte_size * BITS_PER_UNIT); gr_reg = gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_REG (smode, FIRST_ARG_REGNUM + *cum), const0_rtx); Index: gcc/coverage.c =================================================================== --- gcc/coverage.c 2017-06-07 07:42:16.503137200 +0100 +++ gcc/coverage.c 2017-07-13 09:18:30.899501876 +0100 @@ -143,8 +143,8 @@ static void coverage_obj_finish (vec 32 ? 64 : 32, MODE_INT); + scalar_int_mode mode + = smallest_int_mode_for_size (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32); return lang_hooks.types.type_for_mode (mode, false); } @@ -153,7 +153,7 @@ get_gcov_type (void) static tree get_gcov_unsigned_t (void) { - machine_mode mode = smallest_mode_for_size (32, MODE_INT); + scalar_int_mode mode = smallest_int_mode_for_size (32); return lang_hooks.types.type_for_mode (mode, true); } Index: gcc/dse.c =================================================================== --- gcc/dse.c 2017-07-13 09:18:30.078578052 +0100 +++ gcc/dse.c 2017-07-13 09:18:30.900501783 +0100 @@ -1573,7 +1573,7 @@ find_shift_sequence (int access_size, int shift, bool speed, bool require_cst) { machine_mode store_mode = GET_MODE (store_info->mem); - machine_mode new_mode; + scalar_int_mode new_mode; rtx read_reg = NULL; /* Some machines like the x86 have shift insns for each size of @@ -1583,14 +1583,15 @@ find_shift_sequence (int access_size, justify the value we want to read but is available in one insn on the machine. */ - FOR_EACH_MODE_FROM (new_mode, - smallest_mode_for_size (access_size * BITS_PER_UNIT, - MODE_INT)) + opt_scalar_int_mode new_mode_iter; + FOR_EACH_MODE_FROM (new_mode_iter, + smallest_int_mode_for_size (access_size * BITS_PER_UNIT)) { rtx target, new_reg, new_lhs; rtx_insn *shift_seq, *insn; int cost; + new_mode = *new_mode_iter; if (GET_MODE_BITSIZE (new_mode) > BITS_PER_WORD) break; Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:30.080577867 +0100 +++ gcc/expmed.c 2017-07-13 09:18:30.900501783 +0100 @@ -898,7 +898,7 @@ store_bit_field_1 (rtx str_rtx, unsigned is not allowed. */ fieldmode = GET_MODE (value); if (fieldmode == VOIDmode) - fieldmode = smallest_mode_for_size (nwords * BITS_PER_WORD, MODE_INT); + fieldmode = smallest_int_mode_for_size (nwords * BITS_PER_WORD); last = get_last_insn (); for (i = 0; i < nwords; i++) Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:30.083577588 +0100 +++ gcc/expr.c 2017-07-13 09:18:30.901501690 +0100 @@ -346,8 +346,8 @@ convert_move (rtx to, rtx from, int unsi xImode for all MODE_PARTIAL_INT modes they use, but no others. */ if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT) { - machine_mode full_mode - = smallest_mode_for_size (GET_MODE_BITSIZE (to_mode), MODE_INT); + scalar_int_mode full_mode + = smallest_int_mode_for_size (GET_MODE_BITSIZE (to_mode)); gcc_assert (convert_optab_handler (trunc_optab, to_mode, full_mode) != CODE_FOR_nothing); @@ -361,8 +361,8 @@ convert_move (rtx to, rtx from, int unsi if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT) { rtx new_from; - machine_mode full_mode - = smallest_mode_for_size (GET_MODE_BITSIZE (from_mode), MODE_INT); + scalar_int_mode full_mode + = smallest_int_mode_for_size (GET_MODE_BITSIZE (from_mode)); convert_optab ctab = unsignedp ? zext_optab : sext_optab; enum insn_code icode; @@ -6841,8 +6841,8 @@ store_field (rtx target, HOST_WIDE_INT b if (GET_CODE (temp) == PARALLEL) { HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); - machine_mode temp_mode - = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); + scalar_int_mode temp_mode + = smallest_int_mode_for_size (size * BITS_PER_UNIT); rtx temp_target = gen_reg_rtx (temp_mode); emit_group_store (temp_target, temp, TREE_TYPE (exp), size); temp = temp_target; @@ -6913,7 +6913,7 @@ store_field (rtx target, HOST_WIDE_INT b word size, we need to load the value (see again store_bit_field). */ if (GET_MODE (temp) == BLKmode && bitsize <= BITS_PER_WORD) { - machine_mode temp_mode = smallest_mode_for_size (bitsize, MODE_INT); + scalar_int_mode temp_mode = smallest_int_mode_for_size (bitsize); temp = extract_bit_field (temp, bitsize, 0, 1, NULL_RTX, temp_mode, temp_mode, false, NULL); } Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2017-07-13 09:18:29.217658709 +0100 +++ gcc/internal-fn.c 2017-07-13 09:18:30.902501597 +0100 @@ -2159,7 +2159,7 @@ expand_arith_overflow (enum tree_code co if (orig_precres == precres && precop <= BITS_PER_WORD) { int p = MAX (min_precision, precop); - machine_mode m = smallest_mode_for_size (p, MODE_INT); + scalar_int_mode m = smallest_int_mode_for_size (p); tree optype = build_nonstandard_integer_type (GET_MODE_PRECISION (m), uns0_p && uns1_p && unsr_p); @@ -2201,7 +2201,7 @@ expand_arith_overflow (enum tree_code co if (orig_precres == precres) { int p = MAX (prec0, prec1); - machine_mode m = smallest_mode_for_size (p, MODE_INT); + scalar_int_mode m = smallest_int_mode_for_size (p); tree optype = build_nonstandard_integer_type (GET_MODE_PRECISION (m), uns0_p && uns1_p && unsr_p); Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-07-13 09:18:22.934277946 +0100 +++ gcc/optabs-query.c 2017-07-13 09:18:30.902501597 +0100 @@ -193,13 +193,15 @@ get_best_extraction_insn (extraction_ins unsigned HOST_WIDE_INT struct_bits, machine_mode field_mode) { - machine_mode mode = smallest_mode_for_size (struct_bits, MODE_INT); - FOR_EACH_MODE_FROM (mode, mode) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_FROM (mode_iter, smallest_int_mode_for_size (struct_bits)) { + scalar_int_mode mode = *mode_iter; if (get_extraction_insn (insn, pattern, type, mode)) { - FOR_EACH_MODE_FROM (mode, mode) + FOR_EACH_MODE_FROM (mode_iter, mode) { + mode = *mode_iter; if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (field_mode) || TRULY_NOOP_TRUNCATION_MODES_P (insn->field_mode, field_mode)) Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:30.085577402 +0100 +++ gcc/optabs.c 2017-07-13 09:18:30.903501504 +0100 @@ -2083,8 +2083,7 @@ expand_twoval_binop_libfunc (optab binop /* The value returned by the library function will have twice as many bits as the nominal MODE. */ - libval_mode = smallest_mode_for_size (2 * GET_MODE_BITSIZE (mode), - MODE_INT); + libval_mode = smallest_int_mode_for_size (2 * GET_MODE_BITSIZE (mode)); start_sequence (); libval = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST, libval_mode, 2, Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:30.086577310 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:30.905501319 +0100 @@ -2131,12 +2131,15 @@ layout_type (tree type) case BOOLEAN_TYPE: case INTEGER_TYPE: case ENUMERAL_TYPE: - SET_TYPE_MODE (type, - smallest_mode_for_size (TYPE_PRECISION (type), MODE_INT)); - TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); - /* Don't set TYPE_PRECISION here, as it may be set by a bitfield. */ - TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); - break; + { + scalar_int_mode mode + = smallest_int_mode_for_size (TYPE_PRECISION (type)); + SET_TYPE_MODE (type, mode); + TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); + /* Don't set TYPE_PRECISION here, as it may be set by a bitfield. */ + TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); + break; + } case REAL_TYPE: { @@ -2581,8 +2584,7 @@ initialize_sizetypes (void) bprecision = MIN (precision + LOG2_BITS_PER_UNIT + 1, MAX_FIXED_MODE_SIZE); - bprecision - = GET_MODE_PRECISION (smallest_mode_for_size (bprecision, MODE_INT)); + bprecision = GET_MODE_PRECISION (smallest_int_mode_for_size (bprecision)); if (bprecision > HOST_BITS_PER_DOUBLE_INT) bprecision = HOST_BITS_PER_DOUBLE_INT; @@ -2597,17 +2599,18 @@ initialize_sizetypes (void) TYPE_UNSIGNED (bitsizetype) = 1; /* Now layout both types manually. */ - SET_TYPE_MODE (sizetype, smallest_mode_for_size (precision, MODE_INT)); + scalar_int_mode mode = smallest_int_mode_for_size (precision); + SET_TYPE_MODE (sizetype, mode); SET_TYPE_ALIGN (sizetype, GET_MODE_ALIGNMENT (TYPE_MODE (sizetype))); TYPE_SIZE (sizetype) = bitsize_int (precision); - TYPE_SIZE_UNIT (sizetype) = size_int (GET_MODE_SIZE (TYPE_MODE (sizetype))); + TYPE_SIZE_UNIT (sizetype) = size_int (GET_MODE_SIZE (mode)); set_min_and_max_values_for_integral_type (sizetype, precision, UNSIGNED); - SET_TYPE_MODE (bitsizetype, smallest_mode_for_size (bprecision, MODE_INT)); + mode = smallest_int_mode_for_size (bprecision); + SET_TYPE_MODE (bitsizetype, mode); SET_TYPE_ALIGN (bitsizetype, GET_MODE_ALIGNMENT (TYPE_MODE (bitsizetype))); TYPE_SIZE (bitsizetype) = bitsize_int (bprecision); - TYPE_SIZE_UNIT (bitsizetype) - = size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype))); + TYPE_SIZE_UNIT (bitsizetype) = size_int (GET_MODE_SIZE (mode)); set_min_and_max_values_for_integral_type (bitsizetype, bprecision, UNSIGNED); /* Create the signed variants of *sizetype. */ Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:27.468824773 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:30.905501319 +0100 @@ -1177,8 +1177,8 @@ default_autovectorize_vector_sizes (void default_get_mask_mode (unsigned nunits, unsigned vector_size) { unsigned elem_size = vector_size / nunits; - machine_mode elem_mode - = smallest_mode_for_size (elem_size * BITS_PER_UNIT, MODE_INT); + scalar_int_mode elem_mode + = smallest_int_mode_for_size (elem_size * BITS_PER_UNIT); machine_mode vector_mode; gcc_assert (elem_size * nunits == vector_size); Index: gcc/tree-ssa-loop-manip.c =================================================================== --- gcc/tree-ssa-loop-manip.c 2017-07-02 09:32:32.142745257 +0100 +++ gcc/tree-ssa-loop-manip.c 2017-07-13 09:18:30.905501319 +0100 @@ -1513,7 +1513,6 @@ canonicalize_loop_ivs (struct loop *loop gcond *stmt; edge exit = single_dom_exit (loop); gimple_seq stmts; - machine_mode mode; bool unsigned_p = false; for (psi = gsi_start_phis (loop->header); @@ -1540,7 +1539,7 @@ canonicalize_loop_ivs (struct loop *loop precision = TYPE_PRECISION (type); } - mode = smallest_mode_for_size (precision, MODE_INT); + scalar_int_mode mode = smallest_int_mode_for_size (precision); precision = GET_MODE_PRECISION (mode); type = build_nonstandard_integer_type (precision, unsigned_p); From patchwork Thu Jul 13 08:45:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107606 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1929946qge; Thu, 13 Jul 2017 01:47:01 -0700 (PDT) X-Received: by 10.98.64.129 with SMTP id f1mr37456111pfd.225.1499935620955; Thu, 13 Jul 2017 01:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935620; cv=none; d=google.com; s=arc-20160816; b=jqZOQMsdhfWDsfkZL56KxpGFingllr4yh8WlCTFwcLdWJ8wF4ZXnIFhmO8i0hPlmOW g8KNsTmBPlzX+QceBHwZ5VEUFSVSeT/LLrHHolPEp9eKKqEE6JTo1ppIvyq/lsTuyTTu njLXyJdKnbQzOgcQR74v/7BBjnw7/idiRoCRaM6EAs0TkTkS6VpNCZjkbUjzxOyOsnBI vvbfTHDUdR8g5f5/FGIGNMb0Q1+TQ/Em1AjVl6binUu0kFH+jWvN6u/7csYNsquom/qP IwOx7sMs1lcU7npATNqeVRcvkvAAQl7N9JSEv7lDmLTpIeKIGJIc/IEHXYIqJjISnoAz XJrA== 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=RunHNG+ioN7jE8jDQumH5IsGLysnNSLzYoZaTo3ngzY=; b=iNwav3EBpee2tQ5+M6MTxOiEWR1BiQ80iqqk4GKPyKCFQCxXWOtoxTdlk3yokphhM9 y7xSurf/r0OQzhzJpHQHosm1z0F0QFZcM5q2AbcQ8FywiKhE83szb9UXuQfeRRG6HZ+X vTWBCx11QZofvRllx0OM8yBFIjNNl5Cxb4zKUEk1lsVpj00IvAJ0B4n1FTK6P7tvjU5e R1hDuESIA0NvtdkEofuihud/p18nbahGOzst56T69c+AodN9tHBzibq+BvtjN7oynATX wNAPNvnfebHXa3V4bYJ9ggmPLDZgcNGixWPN7Wwou2fJ+YBJMD7s61Aais612AxnydbD jfbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=jh+JlMsp; spf=pass (google.com: domain of gcc-patches-return-458010-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458010-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 y19si3927816pgj.465.2017.07.13.01.47.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:47:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458010-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=jh+JlMsp; spf=pass (google.com: domain of gcc-patches-return-458010-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458010-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=IuYZvgJVc8TgturKvadH/zNij8Dw/ kphP7j6jV90gDjTeQNrRxs4P9EV0qnFV0InF1bjVgrWpypVOR2njw9O4+2KJWXJ2 wEgu3AiieEMyjEN2/7G8yLBq3zPZ2OpNJWfUeigNDlkkNiUYushnfzwvy2Bn2eNv 3HtrIMWy+fcPWk= 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=LSWa2YmJDCxLDZdMLfzc1ms4GAw=; b=jh+ JlMsp8V1Ud4f6jo2fwi1z1zlBlNm5RoGedjL74IaQdVB2x7NI1Tg7x0uX+k5SwR2 u0kfek2Ralec6/q4SKjVsSBoFIvoHKHruCeODXSWit5ubUKdUFtBlYOUlgvzthlB WHt9nHUtR+RAQ+WOwRcsZsOBxUyQCvwJ/SdsMdi4= Received: (qmail 40064 invoked by alias); 13 Jul 2017 08:46:18 -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 39634 invoked by uid 89); 13 Jul 2017 08:46:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=BAR X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:46:05 +0000 Received: by mail-wr0-f172.google.com with SMTP id r103so49477711wrb.0 for ; Thu, 13 Jul 2017 01:46:04 -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=RunHNG+ioN7jE8jDQumH5IsGLysnNSLzYoZaTo3ngzY=; b=hhS3GGkiTtaG7RYyWjlQqjuGgxxlEKYcxV5M5FMt97xt+fR8Rh81xEmpd2/vUNFcjS V7SPUpJBVxPw7+YDqJIPk0lFdJ68mm0NXbcUvgUE1QvXuZmdspZbkdIqv85Z2gI6HInW CyrpTzevZifCIjxOxwg9uAbiusVhpMCnfE1C5APqfxDKGTadQLEXfZYWLmtlQoDOYyl2 qfnJSsCUj6DGXZyMNRoO/S+xQVS6KfzoXRRgoiJhcuOZaUgRQWCMcHOxTOx/o+LJX58m 8Xro7+82IFAJMl4RQAUItlfY/fmiErgJLxETQvfK32uWhy2dxvFVe0rMmUp39UAtZ92b XZxw== X-Gm-Message-State: AIVw112xR01RaM4cAnqle86717//roCZH9nKTbYbhbUaayq3xe2+Rppx 62Ka0v3f4ivc4/Ge/PIjVQ== X-Received: by 10.223.160.111 with SMTP id l44mr1044714wrl.31.1499935561268; Thu, 13 Jul 2017 01:46:01 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 90sm4625084wrk.38.2017.07.13.01.45.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:45:59 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [20/77] Replace MODE_INT checks with is_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:45:57 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87r2xkk9mi.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Replace checks of "GET_MODE_CLASS (...) == MODE_INT" with "is_int_mode (..., &var)", in cases where it becomes useful to refer to the mode as a scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (is_int_mode): New fuction. * combine.c (find_split_point): Use it. (combine_simplify_rtx): Likewise. (simplify_if_then_else): Likewise. (simplify_set): Likewise. (simplify_shift_const_1): Likewise. (simplify_comparison): Likewise. * config/aarch64/aarch64.c (aarch64_rtx_costs): Likewise. * cse.c (notreg_cost): Likewise. (cse_insn): Likewise. * cselib.c (cselib_lookup_1): Likewise. * dojump.c (do_jump_1): Likewise. (do_compare_rtx_and_jump): Likewise. * dse.c (get_call_args): Likewise. * dwarf2out.c (rtl_for_decl_init): Likewise. (native_encode_initializer): Likewise. * expmed.c (emit_store_flag_1): Likewise. (emit_store_flag): Likewise. * expr.c (convert_modes): Likewise. (store_field): Likewise. (expand_expr_real_1): Likewise. * fold-const.c (fold_read_from_constant_string): Likewise. * gimple-ssa-sprintf.c (get_format_string): Likewise. * optabs-libfuncs.c (gen_int_libfunc): Likewise. * optabs.c (expand_binop): Likewise. (expand_unop): Likewise. (expand_abs_nojump): Likewise. (expand_one_cmpl_abs_nojump): Likewise. * simplify-rtx.c (mode_signbit_p): Likewise. (val_signbit_p): Likewise. (val_signbit_known_set_p): Likewise. (val_signbit_known_clear_p): Likewise. (simplify_relational_operation_1): Likewise. * stor-layout.c (vector_type_mode): Likewise. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_int_mode. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:30.902501597 +0100 +++ gcc/machmode.h 2017-07-13 09:18:31.699428322 +0100 @@ -696,6 +696,21 @@ struct int_n_data_t { extern bool int_n_enabled_p[NUM_INT_N_ENTS]; extern const int_n_data_t int_n_data[NUM_INT_N_ENTS]; +/* Return true if MODE has class MODE_INT, storing it as a scalar_int_mode + in *INT_MODE if so. */ + +template +inline bool +is_int_mode (machine_mode mode, T *int_mode) +{ + if (GET_MODE_CLASS (mode) == MODE_INT) + { + *int_mode = scalar_int_mode (scalar_int_mode::from_int (mode)); + return true; + } + return false; +} + /* Return true if MODE has class MODE_FLOAT, storing it as a scalar_float_mode in *FLOAT_MODE if so. */ Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:30.889502803 +0100 +++ gcc/combine.c 2017-07-13 09:18:31.690429148 +0100 @@ -4791,6 +4791,7 @@ find_split_point (rtx *loc, rtx_insn *in HOST_WIDE_INT pos = 0; int unsignedp = 0; rtx inner = NULL_RTX; + scalar_int_mode inner_mode; /* First special-case some codes. */ switch (code) @@ -5032,12 +5033,12 @@ find_split_point (rtx *loc, rtx_insn *in /* We can't optimize if either mode is a partial integer mode as we don't know how many bits are significant in those modes. */ - if (GET_MODE_CLASS (GET_MODE (inner)) == MODE_PARTIAL_INT + if (!is_int_mode (GET_MODE (inner), &inner_mode) || GET_MODE_CLASS (GET_MODE (SET_SRC (x))) == MODE_PARTIAL_INT) break; pos = 0; - len = GET_MODE_PRECISION (GET_MODE (inner)); + len = GET_MODE_PRECISION (inner_mode); unsignedp = 0; break; @@ -5560,6 +5561,7 @@ combine_simplify_rtx (rtx x, machine_mod { enum rtx_code code = GET_CODE (x); machine_mode mode = GET_MODE (x); + scalar_int_mode int_mode; rtx temp; int i; @@ -6070,47 +6072,51 @@ combine_simplify_rtx (rtx x, machine_mod ; else if (STORE_FLAG_VALUE == 1 - && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT - && op1 == const0_rtx - && mode == GET_MODE (op0) - && nonzero_bits (op0, mode) == 1) - return gen_lowpart (mode, + && new_code == NE + && is_int_mode (mode, &int_mode) + && op1 == const0_rtx + && int_mode == GET_MODE (op0) + && nonzero_bits (op0, int_mode) == 1) + return gen_lowpart (int_mode, expand_compound_operation (op0)); else if (STORE_FLAG_VALUE == 1 - && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT + && new_code == NE + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && (num_sign_bit_copies (op0, mode) - == GET_MODE_PRECISION (mode))) + && int_mode == GET_MODE (op0) + && (num_sign_bit_copies (op0, int_mode) + == GET_MODE_PRECISION (int_mode))) { op0 = expand_compound_operation (op0); - return simplify_gen_unary (NEG, mode, - gen_lowpart (mode, op0), - mode); + return simplify_gen_unary (NEG, int_mode, + gen_lowpart (int_mode, op0), + int_mode); } else if (STORE_FLAG_VALUE == 1 - && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT + && new_code == EQ + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && nonzero_bits (op0, mode) == 1) + && int_mode == GET_MODE (op0) + && nonzero_bits (op0, int_mode) == 1) { op0 = expand_compound_operation (op0); - return simplify_gen_binary (XOR, mode, - gen_lowpart (mode, op0), + return simplify_gen_binary (XOR, int_mode, + gen_lowpart (int_mode, op0), const1_rtx); } else if (STORE_FLAG_VALUE == 1 - && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT + && new_code == EQ + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && (num_sign_bit_copies (op0, mode) - == GET_MODE_PRECISION (mode))) + && int_mode == GET_MODE (op0) + && (num_sign_bit_copies (op0, int_mode) + == GET_MODE_PRECISION (int_mode))) { op0 = expand_compound_operation (op0); - return plus_constant (mode, gen_lowpart (mode, op0), 1); + return plus_constant (int_mode, gen_lowpart (int_mode, op0), 1); } /* If STORE_FLAG_VALUE is -1, we have cases similar to @@ -6119,48 +6125,51 @@ combine_simplify_rtx (rtx x, machine_mod ; else if (STORE_FLAG_VALUE == -1 - && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT + && new_code == NE + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && (num_sign_bit_copies (op0, mode) - == GET_MODE_PRECISION (mode))) - return gen_lowpart (mode, - expand_compound_operation (op0)); + && int_mode == GET_MODE (op0) + && (num_sign_bit_copies (op0, int_mode) + == GET_MODE_PRECISION (int_mode))) + return gen_lowpart (int_mode, expand_compound_operation (op0)); else if (STORE_FLAG_VALUE == -1 - && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT + && new_code == NE + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && nonzero_bits (op0, mode) == 1) + && int_mode == GET_MODE (op0) + && nonzero_bits (op0, int_mode) == 1) { op0 = expand_compound_operation (op0); - return simplify_gen_unary (NEG, mode, - gen_lowpart (mode, op0), - mode); + return simplify_gen_unary (NEG, int_mode, + gen_lowpart (int_mode, op0), + int_mode); } else if (STORE_FLAG_VALUE == -1 - && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT + && new_code == EQ + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && (num_sign_bit_copies (op0, mode) - == GET_MODE_PRECISION (mode))) + && int_mode == GET_MODE (op0) + && (num_sign_bit_copies (op0, int_mode) + == GET_MODE_PRECISION (int_mode))) { op0 = expand_compound_operation (op0); - return simplify_gen_unary (NOT, mode, - gen_lowpart (mode, op0), - mode); + return simplify_gen_unary (NOT, int_mode, + gen_lowpart (int_mode, op0), + int_mode); } /* If X is 0/1, (eq X 0) is X-1. */ else if (STORE_FLAG_VALUE == -1 - && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT + && new_code == EQ + && is_int_mode (mode, &int_mode) && op1 == const0_rtx - && mode == GET_MODE (op0) - && nonzero_bits (op0, mode) == 1) + && int_mode == GET_MODE (op0) + && nonzero_bits (op0, int_mode) == 1) { op0 = expand_compound_operation (op0); - return plus_constant (mode, gen_lowpart (mode, op0), -1); + return plus_constant (int_mode, gen_lowpart (int_mode, op0), -1); } /* If STORE_FLAG_VALUE says to just test the sign bit and X has just @@ -6168,16 +6177,17 @@ combine_simplify_rtx (rtx x, machine_mod (ashift x c) where C puts the bit in the sign bit. Remove any AND with STORE_FLAG_VALUE when we are done, since we are only going to test the sign bit. */ - if (new_code == NE && GET_MODE_CLASS (mode) == MODE_INT - && HWI_COMPUTABLE_MODE_P (mode) - && val_signbit_p (mode, STORE_FLAG_VALUE) + if (new_code == NE + && is_int_mode (mode, &int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode) + && val_signbit_p (int_mode, STORE_FLAG_VALUE) && op1 == const0_rtx - && mode == GET_MODE (op0) - && (i = exact_log2 (nonzero_bits (op0, mode))) >= 0) + && int_mode == GET_MODE (op0) + && (i = exact_log2 (nonzero_bits (op0, int_mode))) >= 0) { - x = simplify_shift_const (NULL_RTX, ASHIFT, mode, + x = simplify_shift_const (NULL_RTX, ASHIFT, int_mode, expand_compound_operation (op0), - GET_MODE_PRECISION (mode) - 1 - i); + GET_MODE_PRECISION (int_mode) - 1 - i); if (GET_CODE (x) == AND && XEXP (x, 1) == const_true_rtx) return XEXP (x, 0); else @@ -6263,6 +6273,7 @@ simplify_if_then_else (rtx x) int i; enum rtx_code false_code; rtx reversed; + scalar_int_mode int_mode; /* Simplify storing of the truth value. */ if (comparison_p && true_rtx == const_true_rtx && false_rtx == const0_rtx) @@ -6443,7 +6454,7 @@ simplify_if_then_else (rtx x) if ((STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1) && comparison_p - && GET_MODE_CLASS (mode) == MODE_INT + && is_int_mode (mode, &int_mode) && ! side_effects_p (x)) { rtx t = make_compound_operation (true_rtx, SET); @@ -6451,7 +6462,7 @@ simplify_if_then_else (rtx x) rtx cond_op0 = XEXP (cond, 0); rtx cond_op1 = XEXP (cond, 1); enum rtx_code op = UNKNOWN, extend_op = UNKNOWN; - machine_mode m = mode; + machine_mode m = int_mode; rtx z = 0, c1 = NULL_RTX; if ((GET_CODE (t) == PLUS || GET_CODE (t) == MINUS @@ -6480,7 +6491,7 @@ simplify_if_then_else (rtx x) && rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 0)), f) && (num_sign_bit_copies (f, GET_MODE (f)) > (unsigned int) - (GET_MODE_PRECISION (mode) + (GET_MODE_PRECISION (int_mode) - GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (t, 0), 0)))))) { c1 = XEXP (XEXP (t, 0), 1); z = f; op = GET_CODE (XEXP (t, 0)); @@ -6496,7 +6507,7 @@ simplify_if_then_else (rtx x) && rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 1)), f) && (num_sign_bit_copies (f, GET_MODE (f)) > (unsigned int) - (GET_MODE_PRECISION (mode) + (GET_MODE_PRECISION (int_mode) - GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (t, 0), 1)))))) { c1 = XEXP (XEXP (t, 0), 0); z = f; op = GET_CODE (XEXP (t, 0)); @@ -6512,7 +6523,7 @@ simplify_if_then_else (rtx x) || GET_CODE (XEXP (t, 0)) == LSHIFTRT || GET_CODE (XEXP (t, 0)) == ASHIFTRT) && GET_CODE (XEXP (XEXP (t, 0), 0)) == SUBREG - && HWI_COMPUTABLE_MODE_P (mode) + && HWI_COMPUTABLE_MODE_P (int_mode) && subreg_lowpart_p (XEXP (XEXP (t, 0), 0)) && rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 0)), f) && ((nonzero_bits (f, GET_MODE (f)) @@ -6528,7 +6539,7 @@ simplify_if_then_else (rtx x) || GET_CODE (XEXP (t, 0)) == IOR || GET_CODE (XEXP (t, 0)) == XOR) && GET_CODE (XEXP (XEXP (t, 0), 1)) == SUBREG - && HWI_COMPUTABLE_MODE_P (mode) + && HWI_COMPUTABLE_MODE_P (int_mode) && subreg_lowpart_p (XEXP (XEXP (t, 0), 1)) && rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 1)), f) && ((nonzero_bits (f, GET_MODE (f)) @@ -6552,7 +6563,7 @@ simplify_if_then_else (rtx x) temp = simplify_gen_binary (op, m, gen_lowpart (m, z), temp); if (extend_op != UNKNOWN) - temp = simplify_gen_unary (extend_op, mode, temp, m); + temp = simplify_gen_unary (extend_op, int_mode, temp, m); return temp; } @@ -6605,6 +6616,7 @@ simplify_set (rtx x) = GET_MODE (src) != VOIDmode ? GET_MODE (src) : GET_MODE (dest); rtx_insn *other_insn; rtx *cc_use; + scalar_int_mode int_mode; /* (set (pc) (return)) gets written as (return). */ if (GET_CODE (dest) == PC && ANY_RETURN_P (src)) @@ -6873,15 +6885,14 @@ simplify_set (rtx x) if (GET_CODE (dest) != PC && GET_CODE (src) == IF_THEN_ELSE - && GET_MODE_CLASS (GET_MODE (src)) == MODE_INT + && is_int_mode (GET_MODE (src), &int_mode) && (GET_CODE (XEXP (src, 0)) == EQ || GET_CODE (XEXP (src, 0)) == NE) && XEXP (XEXP (src, 0), 1) == const0_rtx - && GET_MODE (src) == GET_MODE (XEXP (XEXP (src, 0), 0)) + && int_mode == GET_MODE (XEXP (XEXP (src, 0), 0)) && (!HAVE_conditional_move - || ! can_conditionally_move_p (GET_MODE (src))) - && (num_sign_bit_copies (XEXP (XEXP (src, 0), 0), - GET_MODE (XEXP (XEXP (src, 0), 0))) - == GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (src, 0), 0)))) + || ! can_conditionally_move_p (int_mode)) + && (num_sign_bit_copies (XEXP (XEXP (src, 0), 0), int_mode) + == GET_MODE_PRECISION (int_mode)) && ! side_effects_p (src)) { rtx true_rtx = (GET_CODE (XEXP (src, 0)) == NE @@ -6903,17 +6914,17 @@ simplify_set (rtx x) && rtx_equal_p (XEXP (false_rtx, 1), true_rtx)) term1 = true_rtx, false_rtx = XEXP (false_rtx, 0), true_rtx = const0_rtx; - term2 = simplify_gen_binary (AND, GET_MODE (src), + term2 = simplify_gen_binary (AND, int_mode, XEXP (XEXP (src, 0), 0), true_rtx); - term3 = simplify_gen_binary (AND, GET_MODE (src), - simplify_gen_unary (NOT, GET_MODE (src), + term3 = simplify_gen_binary (AND, int_mode, + simplify_gen_unary (NOT, int_mode, XEXP (XEXP (src, 0), 0), - GET_MODE (src)), + int_mode), false_rtx); SUBST (SET_SRC (x), - simplify_gen_binary (IOR, GET_MODE (src), - simplify_gen_binary (IOR, GET_MODE (src), + simplify_gen_binary (IOR, int_mode, + simplify_gen_binary (IOR, int_mode, term1, term2), term3)); @@ -10318,7 +10329,8 @@ simplify_shift_const_1 (enum rtx_code co rtx orig_varop = varop; int count; machine_mode mode = result_mode; - machine_mode shift_mode, tmode; + machine_mode shift_mode; + scalar_int_mode tmode, inner_mode; unsigned int mode_words = (GET_MODE_SIZE (mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD; /* We form (outer_op (code varop count) (outer_const)). */ @@ -10486,17 +10498,16 @@ simplify_shift_const_1 (enum rtx_code co the same number of words as what we've seen so far. Then store the widest mode in MODE. */ if (subreg_lowpart_p (varop) - && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (varop))) - > GET_MODE_SIZE (GET_MODE (varop))) - && (unsigned int) ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (varop))) + && is_int_mode (GET_MODE (SUBREG_REG (varop)), &inner_mode) + && GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (GET_MODE (varop)) + && (unsigned int) ((GET_MODE_SIZE (inner_mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD) == mode_words - && GET_MODE_CLASS (GET_MODE (varop)) == MODE_INT - && GET_MODE_CLASS (GET_MODE (SUBREG_REG (varop))) == MODE_INT) + && GET_MODE_CLASS (GET_MODE (varop)) == MODE_INT) { varop = SUBREG_REG (varop); - if (GET_MODE_SIZE (GET_MODE (varop)) > GET_MODE_SIZE (mode)) - mode = GET_MODE (varop); + if (GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (mode)) + mode = inner_mode; continue; } break; @@ -11739,7 +11750,8 @@ simplify_comparison (enum rtx_code code, rtx op1 = *pop1; rtx tem, tem1; int i; - machine_mode mode, tmode; + scalar_int_mode mode, inner_mode; + machine_mode tmode; /* Try a few ways of applying the same transformation to both operands. */ while (1) @@ -12151,19 +12163,17 @@ simplify_comparison (enum rtx_code code, ; else if (subreg_lowpart_p (op0) && GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT - && GET_MODE_CLASS (GET_MODE (SUBREG_REG (op0))) == MODE_INT + && is_int_mode (GET_MODE (SUBREG_REG (op0)), &inner_mode) && (code == NE || code == EQ) - && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op0))) - <= HOST_BITS_PER_WIDE_INT) + && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT && !paradoxical_subreg_p (op0) - && (nonzero_bits (SUBREG_REG (op0), - GET_MODE (SUBREG_REG (op0))) + && (nonzero_bits (SUBREG_REG (op0), inner_mode) & ~GET_MODE_MASK (GET_MODE (op0))) == 0) { /* Remove outer subregs that don't do anything. */ - tem = gen_lowpart (GET_MODE (SUBREG_REG (op0)), op1); + tem = gen_lowpart (inner_mode, op1); - if ((nonzero_bits (tem, GET_MODE (SUBREG_REG (op0))) + if ((nonzero_bits (tem, inner_mode) & ~GET_MODE_MASK (GET_MODE (op0))) == 0) { op0 = SUBREG_REG (op0); @@ -12681,8 +12691,8 @@ simplify_comparison (enum rtx_code code, op1 = make_compound_operation (op1, SET); if (GET_CODE (op0) == SUBREG && subreg_lowpart_p (op0) - && GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT - && GET_MODE_CLASS (GET_MODE (SUBREG_REG (op0))) == MODE_INT + && is_int_mode (GET_MODE (op0), &mode) + && is_int_mode (GET_MODE (SUBREG_REG (op0)), &inner_mode) && (code == NE || code == EQ)) { if (paradoxical_subreg_p (op0)) @@ -12692,19 +12702,16 @@ simplify_comparison (enum rtx_code code, if (REG_P (SUBREG_REG (op0))) { op0 = SUBREG_REG (op0); - op1 = gen_lowpart (GET_MODE (op0), op1); + op1 = gen_lowpart (inner_mode, op1); } } - else if ((GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op0))) - <= HOST_BITS_PER_WIDE_INT) - && (nonzero_bits (SUBREG_REG (op0), - GET_MODE (SUBREG_REG (op0))) - & ~GET_MODE_MASK (GET_MODE (op0))) == 0) + else if (GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT + && (nonzero_bits (SUBREG_REG (op0), inner_mode) + & ~GET_MODE_MASK (mode)) == 0) { - tem = gen_lowpart (GET_MODE (SUBREG_REG (op0)), op1); + tem = gen_lowpart (inner_mode, op1); - if ((nonzero_bits (tem, GET_MODE (SUBREG_REG (op0))) - & ~GET_MODE_MASK (GET_MODE (op0))) == 0) + if ((nonzero_bits (tem, inner_mode) & ~GET_MODE_MASK (mode)) == 0) op0 = SUBREG_REG (op0), op1 = tem; } } @@ -12715,8 +12722,7 @@ simplify_comparison (enum rtx_code code, mode for which we can do the compare. There are a number of cases in which we can use the wider mode. */ - mode = GET_MODE (op0); - if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT + if (is_int_mode (GET_MODE (op0), &mode) && GET_MODE_SIZE (mode) < UNITS_PER_WORD && ! have_insn_for (COMPARE, mode)) FOR_EACH_WIDER_MODE (tmode, mode) Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:30.033582228 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:31.691429056 +0100 @@ -6744,6 +6744,7 @@ aarch64_rtx_costs (rtx x, machine_mode m const struct cpu_cost_table *extra_cost = aarch64_tune_params.insn_extra_cost; int code = GET_CODE (x); + scalar_int_mode int_mode; /* By default, assume that everything has equivalent cost to the cheapest instruction. Any additional costs are applied as a delta @@ -7306,28 +7307,29 @@ aarch64_rtx_costs (rtx x, machine_mode m return true; } - if (GET_MODE_CLASS (mode) == MODE_INT) + if (is_int_mode (mode, &int_mode)) { if (CONST_INT_P (op1)) { /* We have a mask + shift version of a UBFIZ i.e. the *andim_ashift_bfiz pattern. */ if (GET_CODE (op0) == ASHIFT - && aarch64_mask_and_shift_for_ubfiz_p (mode, op1, - XEXP (op0, 1))) + && aarch64_mask_and_shift_for_ubfiz_p (int_mode, op1, + XEXP (op0, 1))) { - *cost += rtx_cost (XEXP (op0, 0), mode, + *cost += rtx_cost (XEXP (op0, 0), int_mode, (enum rtx_code) code, 0, speed); if (speed) *cost += extra_cost->alu.bfx; return true; } - else if (aarch64_bitmask_imm (INTVAL (op1), mode)) + else if (aarch64_bitmask_imm (INTVAL (op1), int_mode)) { /* We possibly get the immediate for free, this is not modelled. */ - *cost += rtx_cost (op0, mode, (enum rtx_code) code, 0, speed); + *cost += rtx_cost (op0, int_mode, + (enum rtx_code) code, 0, speed); if (speed) *cost += extra_cost->alu.logical; @@ -7362,8 +7364,10 @@ aarch64_rtx_costs (rtx x, machine_mode m } /* In both cases we want to cost both operands. */ - *cost += rtx_cost (new_op0, mode, (enum rtx_code) code, 0, speed); - *cost += rtx_cost (op1, mode, (enum rtx_code) code, 1, speed); + *cost += rtx_cost (new_op0, int_mode, (enum rtx_code) code, + 0, speed); + *cost += rtx_cost (op1, int_mode, (enum rtx_code) code, + 1, speed); return true; } Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-07-13 09:18:21.529429475 +0100 +++ gcc/cse.c 2017-07-13 09:18:31.692428965 +0100 @@ -720,13 +720,14 @@ preferable (int cost_a, int regcost_a, i static int notreg_cost (rtx x, machine_mode mode, enum rtx_code outer, int opno) { + scalar_int_mode int_mode, inner_mode; return ((GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x)) - && GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_INT - && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) + && is_int_mode (mode, &int_mode) + && is_int_mode (GET_MODE (SUBREG_REG (x)), &inner_mode) + && GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (inner_mode) && subreg_lowpart_p (x) - && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (SUBREG_REG (x)))) + && TRULY_NOOP_TRUNCATION_MODES_P (int_mode, inner_mode)) ? 0 : rtx_cost (x, mode, outer, opno, optimize_this_for_speed_p) * 2); } @@ -4603,6 +4604,7 @@ cse_insn (rtx_insn *insn) /* Set nonzero if we need to call force_const_mem on with the contents of src_folded before using it. */ int src_folded_force_flag = 0; + scalar_int_mode int_mode; dest = SET_DEST (sets[i].rtl); src = SET_SRC (sets[i].rtl); @@ -4840,13 +4842,13 @@ cse_insn (rtx_insn *insn) wider mode. */ if (src_const && src_related == 0 && CONST_INT_P (src_const) - && GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_PRECISION (mode) < BITS_PER_WORD) + && is_int_mode (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) < BITS_PER_WORD) { - machine_mode wider_mode; - - FOR_EACH_WIDER_MODE (wider_mode, mode) + opt_scalar_int_mode wider_mode_iter; + FOR_EACH_WIDER_MODE (wider_mode_iter, int_mode) { + scalar_int_mode wider_mode = *wider_mode_iter; if (GET_MODE_PRECISION (wider_mode) > BITS_PER_WORD) break; @@ -4860,7 +4862,7 @@ cse_insn (rtx_insn *insn) const_elt; const_elt = const_elt->next_same_value) if (REG_P (const_elt->exp)) { - src_related = gen_lowpart (mode, const_elt->exp); + src_related = gen_lowpart (int_mode, const_elt->exp); break; } Index: gcc/cselib.c =================================================================== --- gcc/cselib.c 2017-04-18 19:52:35.063180496 +0100 +++ gcc/cselib.c 2017-07-13 09:18:31.692428965 +0100 @@ -2009,6 +2009,8 @@ cselib_lookup_1 (rtx x, machine_mode mod e = new_cselib_val (next_uid, GET_MODE (x), x); new_elt_loc_list (e, x); + + scalar_int_mode int_mode; if (REG_VALUES (i) == 0) { /* Maintain the invariant that the first entry of @@ -2018,27 +2020,27 @@ cselib_lookup_1 (rtx x, machine_mode mod REG_VALUES (i) = new_elt_list (REG_VALUES (i), NULL); } else if (cselib_preserve_constants - && GET_MODE_CLASS (mode) == MODE_INT) + && is_int_mode (mode, &int_mode)) { /* During var-tracking, try harder to find equivalences for SUBREGs. If a setter sets say a DImode register and user uses that register only in SImode, add a lowpart subreg location. */ struct elt_list *lwider = NULL; + scalar_int_mode lmode; l = REG_VALUES (i); if (l && l->elt == NULL) l = l->next; for (; l; l = l->next) - if (GET_MODE_CLASS (GET_MODE (l->elt->val_rtx)) == MODE_INT - && GET_MODE_SIZE (GET_MODE (l->elt->val_rtx)) - > GET_MODE_SIZE (mode) + if (is_int_mode (GET_MODE (l->elt->val_rtx), &lmode) + && GET_MODE_SIZE (lmode) > GET_MODE_SIZE (int_mode) && (lwider == NULL - || GET_MODE_SIZE (GET_MODE (l->elt->val_rtx)) + || GET_MODE_SIZE (lmode) < GET_MODE_SIZE (GET_MODE (lwider->elt->val_rtx)))) { struct elt_loc_list *el; if (i < FIRST_PSEUDO_REGISTER - && hard_regno_nregs[i][GET_MODE (l->elt->val_rtx)] != 1) + && hard_regno_nregs[i][lmode] != 1) continue; for (el = l->elt->locs; el; el = el->next) if (!REG_P (el->loc)) @@ -2048,7 +2050,7 @@ cselib_lookup_1 (rtx x, machine_mode mod } if (lwider) { - rtx sub = lowpart_subreg (mode, lwider->elt->val_rtx, + rtx sub = lowpart_subreg (int_mode, lwider->elt->val_rtx, GET_MODE (lwider->elt->val_rtx)); if (sub) new_elt_loc_list (e, sub); Index: gcc/dojump.c =================================================================== --- gcc/dojump.c 2017-07-13 09:18:29.212659178 +0100 +++ gcc/dojump.c 2017-07-13 09:18:31.693428873 +0100 @@ -203,6 +203,7 @@ do_jump_1 (enum tree_code code, tree op0 { machine_mode mode; rtx_code_label *drop_through_label = 0; + scalar_int_mode int_mode; switch (code) { @@ -218,8 +219,8 @@ do_jump_1 (enum tree_code code, tree op0 if (integer_zerop (op1)) do_jump (op0, if_true_label, if_false_label, prob.invert ()); - else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT - && !can_compare_p (EQ, TYPE_MODE (inner_type), ccp_jump)) + else if (is_int_mode (TYPE_MODE (inner_type), &int_mode) + && !can_compare_p (EQ, int_mode, ccp_jump)) do_jump_by_parts_equality (op0, op1, if_false_label, if_true_label, prob); else @@ -239,8 +240,8 @@ do_jump_1 (enum tree_code code, tree op0 if (integer_zerop (op1)) do_jump (op0, if_false_label, if_true_label, prob); - else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT - && !can_compare_p (NE, TYPE_MODE (inner_type), ccp_jump)) + else if (is_int_mode (TYPE_MODE (inner_type), &int_mode) + && !can_compare_p (NE, int_mode, ccp_jump)) do_jump_by_parts_equality (op0, op1, if_true_label, if_false_label, prob.invert ()); else @@ -251,10 +252,10 @@ do_jump_1 (enum tree_code code, tree op0 case LT_EXPR: mode = TYPE_MODE (TREE_TYPE (op0)); - if (GET_MODE_CLASS (mode) == MODE_INT - && ! can_compare_p (LT, mode, ccp_jump)) - do_jump_by_parts_greater (op0, op1, 1, if_false_label, if_true_label, - prob); + if (is_int_mode (mode, &int_mode) + && ! can_compare_p (LT, int_mode, ccp_jump)) + do_jump_by_parts_greater (op0, op1, 1, if_false_label, + if_true_label, prob); else do_compare_and_jump (op0, op1, LT, LTU, if_false_label, if_true_label, prob); @@ -262,8 +263,8 @@ do_jump_1 (enum tree_code code, tree op0 case LE_EXPR: mode = TYPE_MODE (TREE_TYPE (op0)); - if (GET_MODE_CLASS (mode) == MODE_INT - && ! can_compare_p (LE, mode, ccp_jump)) + if (is_int_mode (mode, &int_mode) + && ! can_compare_p (LE, int_mode, ccp_jump)) do_jump_by_parts_greater (op0, op1, 0, if_true_label, if_false_label, prob.invert ()); else @@ -273,10 +274,10 @@ do_jump_1 (enum tree_code code, tree op0 case GT_EXPR: mode = TYPE_MODE (TREE_TYPE (op0)); - if (GET_MODE_CLASS (mode) == MODE_INT - && ! can_compare_p (GT, mode, ccp_jump)) - do_jump_by_parts_greater (op0, op1, 0, if_false_label, if_true_label, - prob); + if (is_int_mode (mode, &int_mode) + && ! can_compare_p (GT, int_mode, ccp_jump)) + do_jump_by_parts_greater (op0, op1, 0, if_false_label, + if_true_label, prob); else do_compare_and_jump (op0, op1, GT, GTU, if_false_label, if_true_label, prob); @@ -284,8 +285,8 @@ do_jump_1 (enum tree_code code, tree op0 case GE_EXPR: mode = TYPE_MODE (TREE_TYPE (op0)); - if (GET_MODE_CLASS (mode) == MODE_INT - && ! can_compare_p (GE, mode, ccp_jump)) + if (is_int_mode (mode, &int_mode) + && ! can_compare_p (GE, int_mode, ccp_jump)) do_jump_by_parts_greater (op0, op1, 1, if_true_label, if_false_label, prob.invert ()); else @@ -1024,62 +1025,63 @@ do_compare_rtx_and_jump (rtx op0, rtx op if (! if_true_label) dummy_label = if_true_label = gen_label_rtx (); - if (GET_MODE_CLASS (mode) == MODE_INT - && ! can_compare_p (code, mode, ccp_jump)) + scalar_int_mode int_mode; + if (is_int_mode (mode, &int_mode) + && ! can_compare_p (code, int_mode, ccp_jump)) { switch (code) { case LTU: - do_jump_by_parts_greater_rtx (mode, 1, op1, op0, + do_jump_by_parts_greater_rtx (int_mode, 1, op1, op0, if_false_label, if_true_label, prob); break; case LEU: - do_jump_by_parts_greater_rtx (mode, 1, op0, op1, + do_jump_by_parts_greater_rtx (int_mode, 1, op0, op1, if_true_label, if_false_label, prob.invert ()); break; case GTU: - do_jump_by_parts_greater_rtx (mode, 1, op0, op1, + do_jump_by_parts_greater_rtx (int_mode, 1, op0, op1, if_false_label, if_true_label, prob); break; case GEU: - do_jump_by_parts_greater_rtx (mode, 1, op1, op0, + do_jump_by_parts_greater_rtx (int_mode, 1, op1, op0, if_true_label, if_false_label, prob.invert ()); break; case LT: - do_jump_by_parts_greater_rtx (mode, 0, op1, op0, + do_jump_by_parts_greater_rtx (int_mode, 0, op1, op0, if_false_label, if_true_label, prob); break; case LE: - do_jump_by_parts_greater_rtx (mode, 0, op0, op1, + do_jump_by_parts_greater_rtx (int_mode, 0, op0, op1, if_true_label, if_false_label, prob.invert ()); break; case GT: - do_jump_by_parts_greater_rtx (mode, 0, op0, op1, + do_jump_by_parts_greater_rtx (int_mode, 0, op0, op1, if_false_label, if_true_label, prob); break; case GE: - do_jump_by_parts_greater_rtx (mode, 0, op1, op0, + do_jump_by_parts_greater_rtx (int_mode, 0, op1, op0, if_true_label, if_false_label, prob.invert ()); break; case EQ: - do_jump_by_parts_equality_rtx (mode, op0, op1, if_false_label, + do_jump_by_parts_equality_rtx (int_mode, op0, op1, if_false_label, if_true_label, prob); break; case NE: - do_jump_by_parts_equality_rtx (mode, op0, op1, if_true_label, + do_jump_by_parts_equality_rtx (int_mode, op0, op1, if_true_label, if_false_label, prob.invert ()); break; Index: gcc/dse.c =================================================================== --- gcc/dse.c 2017-07-13 09:18:30.900501783 +0100 +++ gcc/dse.c 2017-07-13 09:18:31.693428873 +0100 @@ -2185,11 +2185,14 @@ get_call_args (rtx call_insn, tree fn, r arg != void_list_node && idx < nargs; arg = TREE_CHAIN (arg), idx++) { - machine_mode mode = TYPE_MODE (TREE_VALUE (arg)); + scalar_int_mode mode; rtx reg, link, tmp; + + if (!is_int_mode (TYPE_MODE (TREE_VALUE (arg)), &mode)) + return false; + reg = targetm.calls.function_arg (args_so_far, mode, NULL_TREE, true); - if (!reg || !REG_P (reg) || GET_MODE (reg) != mode - || GET_MODE_CLASS (mode) != MODE_INT) + if (!reg || !REG_P (reg) || GET_MODE (reg) != mode) return false; for (link = CALL_INSN_FUNCTION_USAGE (call_insn); @@ -2197,15 +2200,14 @@ get_call_args (rtx call_insn, tree fn, r link = XEXP (link, 1)) if (GET_CODE (XEXP (link, 0)) == USE) { + scalar_int_mode arg_mode; args[idx] = XEXP (XEXP (link, 0), 0); if (REG_P (args[idx]) && REGNO (args[idx]) == REGNO (reg) && (GET_MODE (args[idx]) == mode - || (GET_MODE_CLASS (GET_MODE (args[idx])) == MODE_INT - && (GET_MODE_SIZE (GET_MODE (args[idx])) - <= UNITS_PER_WORD) - && (GET_MODE_SIZE (GET_MODE (args[idx])) - > GET_MODE_SIZE (mode))))) + || (is_int_mode (GET_MODE (args[idx]), &arg_mode) + && (GET_MODE_SIZE (arg_mode) <= UNITS_PER_WORD) + && (GET_MODE_SIZE (arg_mode) > GET_MODE_SIZE (mode))))) break; } if (!link) Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:29.214658990 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:31.696428597 +0100 @@ -18758,9 +18758,10 @@ rtl_for_decl_init (tree init, tree type) { tree enttype = TREE_TYPE (type); tree domain = TYPE_DOMAIN (type); - machine_mode mode = TYPE_MODE (enttype); + scalar_int_mode mode; - if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1 + if (is_int_mode (TYPE_MODE (enttype), &mode) + && GET_MODE_SIZE (mode) == 1 && domain && integer_zerop (TYPE_MIN_VALUE (domain)) && compare_tree_int (TYPE_MAX_VALUE (domain), @@ -19241,9 +19242,10 @@ native_encode_initializer (tree init, un if (TREE_CODE (type) == ARRAY_TYPE) { tree enttype = TREE_TYPE (type); - machine_mode mode = TYPE_MODE (enttype); + scalar_int_mode mode; - if (GET_MODE_CLASS (mode) != MODE_INT || GET_MODE_SIZE (mode) != 1) + if (!is_int_mode (TYPE_MODE (enttype), &mode) + || GET_MODE_SIZE (mode) != 1) return false; if (int_size_in_bytes (type) != size) return false; Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:30.900501783 +0100 +++ gcc/expmed.c 2017-07-13 09:18:31.696428597 +0100 @@ -5391,8 +5391,9 @@ emit_store_flag_1 (rtx target, enum rtx_ /* If we are comparing a double-word integer with zero or -1, we can convert the comparison into one involving a single word. */ - if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD * 2 - && GET_MODE_CLASS (mode) == MODE_INT + scalar_int_mode int_mode; + if (is_int_mode (mode, &int_mode) + && GET_MODE_BITSIZE (int_mode) == BITS_PER_WORD * 2 && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0))) { rtx tem; @@ -5403,8 +5404,8 @@ emit_store_flag_1 (rtx target, enum rtx_ /* Do a logical OR or AND of the two words and compare the result. */ - op00 = simplify_gen_subreg (word_mode, op0, mode, 0); - op01 = simplify_gen_subreg (word_mode, op0, mode, UNITS_PER_WORD); + op00 = simplify_gen_subreg (word_mode, op0, int_mode, 0); + op01 = simplify_gen_subreg (word_mode, op0, int_mode, UNITS_PER_WORD); tem = expand_binop (word_mode, op1 == const0_rtx ? ior_optab : and_optab, op00, op01, NULL_RTX, unsignedp, @@ -5419,9 +5420,9 @@ emit_store_flag_1 (rtx target, enum rtx_ rtx op0h; /* If testing the sign bit, can just test on high word. */ - op0h = simplify_gen_subreg (word_mode, op0, mode, + op0h = simplify_gen_subreg (word_mode, op0, int_mode, subreg_highpart_offset (word_mode, - mode)); + int_mode)); tem = emit_store_flag (NULL_RTX, code, op0h, op1, word_mode, unsignedp, normalizep); } @@ -5446,21 +5447,21 @@ emit_store_flag_1 (rtx target, enum rtx_ /* If this is A < 0 or A >= 0, we can do this by taking the ones complement of A (for GE) and shifting the sign bit to the low bit. */ if (op1 == const0_rtx && (code == LT || code == GE) - && GET_MODE_CLASS (mode) == MODE_INT + && is_int_mode (mode, &int_mode) && (normalizep || STORE_FLAG_VALUE == 1 - || val_signbit_p (mode, STORE_FLAG_VALUE))) + || val_signbit_p (int_mode, STORE_FLAG_VALUE))) { subtarget = target; if (!target) - target_mode = mode; + target_mode = int_mode; /* If the result is to be wider than OP0, it is best to convert it first. If it is to be narrower, it is *incorrect* to convert it first. */ - else if (GET_MODE_SIZE (target_mode) > GET_MODE_SIZE (mode)) + else if (GET_MODE_SIZE (target_mode) > GET_MODE_SIZE (int_mode)) { - op0 = convert_modes (target_mode, mode, op0, 0); + op0 = convert_modes (target_mode, int_mode, op0, 0); mode = target_mode; } @@ -5870,8 +5871,9 @@ emit_store_flag (rtx target, enum rtx_co /* The remaining tricks only apply to integer comparisons. */ - if (GET_MODE_CLASS (mode) == MODE_INT) - return emit_store_flag_int (target, subtarget, code, op0, op1, mode, + scalar_int_mode int_mode; + if (is_int_mode (mode, &int_mode)) + return emit_store_flag_int (target, subtarget, code, op0, op1, int_mode, unsignedp, normalizep, trueval); return 0; Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:30.901501690 +0100 +++ gcc/expr.c 2017-07-13 09:18:31.697428505 +0100 @@ -630,6 +630,7 @@ convert_to_mode (machine_mode mode, rtx convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp) { rtx temp; + scalar_int_mode int_mode; /* If FROM is a SUBREG that indicates that we have already done at least the required extension, strip it. */ @@ -645,7 +646,8 @@ convert_modes (machine_mode mode, machin if (mode == oldmode) return x; - if (CONST_SCALAR_INT_P (x) && GET_MODE_CLASS (mode) == MODE_INT) + if (CONST_SCALAR_INT_P (x) + && is_int_mode (mode, &int_mode)) { /* If the caller did not tell us the old mode, then there is not much to do with respect to canonicalization. We have to @@ -653,24 +655,24 @@ convert_modes (machine_mode mode, machin if (GET_MODE_CLASS (oldmode) != MODE_INT) oldmode = MAX_MODE_INT; wide_int w = wide_int::from (rtx_mode_t (x, oldmode), - GET_MODE_PRECISION (mode), + GET_MODE_PRECISION (int_mode), unsignedp ? UNSIGNED : SIGNED); - return immed_wide_int_const (w, mode); + return immed_wide_int_const (w, int_mode); } /* We can do this with a gen_lowpart if both desired and current modes are integer, and this is either a constant integer, a register, or a non-volatile MEM. */ - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_CLASS (oldmode) == MODE_INT - && GET_MODE_PRECISION (mode) <= GET_MODE_PRECISION (oldmode) - && ((MEM_P (x) && !MEM_VOLATILE_P (x) && direct_load[(int) mode]) + scalar_int_mode int_oldmode; + if (is_int_mode (mode, &int_mode) + && is_int_mode (oldmode, &int_oldmode) + && GET_MODE_PRECISION (int_mode) <= GET_MODE_PRECISION (int_oldmode) + && ((MEM_P (x) && !MEM_VOLATILE_P (x) && direct_load[(int) int_mode]) || (REG_P (x) && (!HARD_REGISTER_P (x) - || HARD_REGNO_MODE_OK (REGNO (x), mode)) - && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (x))))) - - return gen_lowpart (mode, x); + || HARD_REGNO_MODE_OK (REGNO (x), int_mode)) + && TRULY_NOOP_TRUNCATION_MODES_P (int_mode, GET_MODE (x))))) + return gen_lowpart (int_mode, x); /* Converting from integer constant into mode is always equivalent to an subreg operation. */ @@ -6865,20 +6867,21 @@ store_field (rtx target, HOST_WIDE_INT b case, if it has reverse storage order, it needs to be accessed as a scalar field with reverse storage order and we must first put the value into target order. */ + scalar_int_mode temp_mode; if (AGGREGATE_TYPE_P (TREE_TYPE (exp)) - && GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT) + && is_int_mode (GET_MODE (temp), &temp_mode)) { - HOST_WIDE_INT size = GET_MODE_BITSIZE (GET_MODE (temp)); + HOST_WIDE_INT size = GET_MODE_BITSIZE (temp_mode); reverse = TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (exp)); if (reverse) - temp = flip_storage_order (GET_MODE (temp), temp); + temp = flip_storage_order (temp_mode, temp); if (bitsize < size && reverse ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN && !(mode == BLKmode && bitsize > BITS_PER_WORD)) - temp = expand_shift (RSHIFT_EXPR, GET_MODE (temp), temp, + temp = expand_shift (RSHIFT_EXPR, temp_mode, temp, size - bitsize, NULL_RTX, 1); } @@ -9953,13 +9956,15 @@ expand_expr_real_1 (tree exp, rtx target || GET_MODE_CLASS (mode) == MODE_VECTOR_ACCUM || GET_MODE_CLASS (mode) == MODE_VECTOR_UACCUM) return const_vector_from_tree (exp); - if (GET_MODE_CLASS (mode) == MODE_INT) + scalar_int_mode int_mode; + if (is_int_mode (mode, &int_mode)) { if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))) return const_scalar_mask_from_tree (exp); else { - tree type_for_mode = lang_hooks.types.type_for_mode (mode, 1); + tree type_for_mode + = lang_hooks.types.type_for_mode (int_mode, 1); if (type_for_mode) tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR, type_for_mode, exp); @@ -10354,9 +10359,9 @@ expand_expr_real_1 (tree exp, rtx target && compare_tree_int (index1, TREE_STRING_LENGTH (init)) < 0) { tree type = TREE_TYPE (TREE_TYPE (init)); - machine_mode mode = TYPE_MODE (type); + scalar_int_mode mode; - if (GET_MODE_CLASS (mode) == MODE_INT + if (is_int_mode (TYPE_MODE (type), &mode) && GET_MODE_SIZE (mode) == 1) return gen_int_mode (TREE_STRING_POINTER (init) [TREE_INT_CST_LOW (index1)], @@ -10374,6 +10379,7 @@ expand_expr_real_1 (tree exp, rtx target { unsigned HOST_WIDE_INT idx; tree field, value; + scalar_int_mode field_mode; FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (treeop0), idx, field, value) @@ -10386,8 +10392,8 @@ expand_expr_real_1 (tree exp, rtx target the bitfield does not meet either of those conditions, we can't do this optimization. */ && (! DECL_BIT_FIELD (field) - || ((GET_MODE_CLASS (DECL_MODE (field)) == MODE_INT) - && (GET_MODE_PRECISION (DECL_MODE (field)) + || (is_int_mode (DECL_MODE (field), &field_mode) + && (GET_MODE_PRECISION (field_mode) <= HOST_BITS_PER_WIDE_INT)))) { if (DECL_BIT_FIELD (field) @@ -10721,18 +10727,19 @@ expand_expr_real_1 (tree exp, rtx target and this is for big-endian data, we must put the field into the high-order bits. And we must also put it back into memory order if it has been previously reversed. */ + scalar_int_mode op0_mode; if (TREE_CODE (type) == RECORD_TYPE - && GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT) + && is_int_mode (GET_MODE (op0), &op0_mode)) { - HOST_WIDE_INT size = GET_MODE_BITSIZE (GET_MODE (op0)); + HOST_WIDE_INT size = GET_MODE_BITSIZE (op0_mode); if (bitsize < size && reversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN) - op0 = expand_shift (LSHIFT_EXPR, GET_MODE (op0), op0, + op0 = expand_shift (LSHIFT_EXPR, op0_mode, op0, size - bitsize, op0, 1); if (reversep) - op0 = flip_storage_order (GET_MODE (op0), op0); + op0 = flip_storage_order (op0_mode, op0); } /* If the result type is BLKmode, store the data into a temporary Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-07-13 09:18:24.774086700 +0100 +++ gcc/fold-const.c 2017-07-13 09:18:31.699428322 +0100 @@ -13722,14 +13722,15 @@ fold_read_from_constant_string (tree exp string = exp1; } + scalar_int_mode char_mode; if (string && TYPE_MODE (TREE_TYPE (exp)) == TYPE_MODE (TREE_TYPE (TREE_TYPE (string))) && TREE_CODE (string) == STRING_CST && TREE_CODE (index) == INTEGER_CST && compare_tree_int (index, TREE_STRING_LENGTH (string)) < 0 - && (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_TYPE (string)))) - == MODE_INT) - && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (string)))) == 1)) + && is_int_mode (TYPE_MODE (TREE_TYPE (TREE_TYPE (string))), + &char_mode) + && GET_MODE_SIZE (char_mode) == 1) return build_int_cst_type (TREE_TYPE (exp), (TREE_STRING_POINTER (string) [TREE_INT_CST_LOW (index)])); Index: gcc/gimple-ssa-sprintf.c =================================================================== --- gcc/gimple-ssa-sprintf.c 2017-07-12 14:49:07.685894332 +0100 +++ gcc/gimple-ssa-sprintf.c 2017-07-13 09:18:31.699428322 +0100 @@ -528,8 +528,9 @@ get_format_string (tree format, location tree type = TREE_TYPE (format); - if (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (type))) != MODE_INT - || GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (type))) != 1) + scalar_int_mode char_mode; + if (!is_int_mode (TYPE_MODE (TREE_TYPE (type)), &char_mode) + || GET_MODE_SIZE (char_mode) != 1) { /* Wide format string. */ return NULL; Index: gcc/optabs-libfuncs.c =================================================================== --- gcc/optabs-libfuncs.c 2017-07-13 09:18:29.218658615 +0100 +++ gcc/optabs-libfuncs.c 2017-07-13 09:18:31.700428230 +0100 @@ -189,8 +189,9 @@ gen_int_libfunc (optab optable, const ch { int maxsize = 2 * BITS_PER_WORD; int minsize = BITS_PER_WORD; + scalar_int_mode int_mode; - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!is_int_mode (mode, &int_mode)) return; if (maxsize < LONG_LONG_TYPE_SIZE) maxsize = LONG_LONG_TYPE_SIZE; @@ -198,10 +199,10 @@ gen_int_libfunc (optab optable, const ch && (trapv_binoptab_p (optable) || trapv_unoptab_p (optable))) minsize = INT_TYPE_SIZE; - if (GET_MODE_BITSIZE (mode) < minsize - || GET_MODE_BITSIZE (mode) > maxsize) + if (GET_MODE_BITSIZE (int_mode) < minsize + || GET_MODE_BITSIZE (int_mode) > maxsize) return; - gen_libfunc (optable, opname, suffix, mode); + gen_libfunc (optable, opname, suffix, int_mode); } /* Like gen_libfunc, but verify that FP and set decimal prefix if needed. */ Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:30.903501504 +0100 +++ gcc/optabs.c 2017-07-13 09:18:31.700428230 +0100 @@ -1112,6 +1112,7 @@ expand_binop (machine_mode mode, optab b ? OPTAB_WIDEN : methods); enum mode_class mclass; machine_mode wider_mode; + scalar_int_mode int_mode; rtx libfunc; rtx temp; rtx_insn *entry_last = get_last_insn (); @@ -1160,22 +1161,22 @@ expand_binop (machine_mode mode, optab b && optab_handler (rotr_optab, mode) != CODE_FOR_nothing) || (binoptab == rotr_optab && optab_handler (rotl_optab, mode) != CODE_FOR_nothing)) - && mclass == MODE_INT) + && is_int_mode (mode, &int_mode)) { optab otheroptab = (binoptab == rotl_optab ? rotr_optab : rotl_optab); rtx newop1; - unsigned int bits = GET_MODE_PRECISION (mode); + unsigned int bits = GET_MODE_PRECISION (int_mode); if (CONST_INT_P (op1)) newop1 = GEN_INT (bits - INTVAL (op1)); - else if (targetm.shift_truncation_mask (mode) == bits - 1) + else if (targetm.shift_truncation_mask (int_mode) == bits - 1) newop1 = negate_rtx (GET_MODE (op1), op1); else newop1 = expand_binop (GET_MODE (op1), sub_optab, gen_int_mode (bits, GET_MODE (op1)), op1, NULL_RTX, unsignedp, OPTAB_DIRECT); - temp = expand_binop_directly (mode, otheroptab, op0, newop1, + temp = expand_binop_directly (int_mode, otheroptab, op0, newop1, target, unsignedp, methods, last); if (temp) return temp; @@ -1319,8 +1320,8 @@ expand_binop (machine_mode mode, optab b /* These can be done a word at a time. */ if ((binoptab == and_optab || binoptab == ior_optab || binoptab == xor_optab) - && mclass == MODE_INT - && GET_MODE_SIZE (mode) > UNITS_PER_WORD + && is_int_mode (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > UNITS_PER_WORD && optab_handler (binoptab, word_mode) != CODE_FOR_nothing) { int i; @@ -1332,17 +1333,17 @@ expand_binop (machine_mode mode, optab b || target == op0 || target == op1 || !valid_multiword_target_p (target)) - target = gen_reg_rtx (mode); + target = gen_reg_rtx (int_mode); start_sequence (); /* Do the actual arithmetic. */ - for (i = 0; i < GET_MODE_BITSIZE (mode) / BITS_PER_WORD; i++) + for (i = 0; i < GET_MODE_BITSIZE (int_mode) / BITS_PER_WORD; i++) { - rtx target_piece = operand_subword (target, i, 1, mode); + rtx target_piece = operand_subword (target, i, 1, int_mode); rtx x = expand_binop (word_mode, binoptab, - operand_subword_force (op0, i, mode), - operand_subword_force (op1, i, mode), + operand_subword_force (op0, i, int_mode), + operand_subword_force (op1, i, int_mode), target_piece, unsignedp, next_methods); if (x == 0) @@ -1355,7 +1356,7 @@ expand_binop (machine_mode mode, optab b insns = get_insns (); end_sequence (); - if (i == GET_MODE_BITSIZE (mode) / BITS_PER_WORD) + if (i == GET_MODE_BITSIZE (int_mode) / BITS_PER_WORD) { emit_insn (insns); return target; @@ -1365,10 +1366,10 @@ expand_binop (machine_mode mode, optab b /* Synthesize double word shifts from single word shifts. */ if ((binoptab == lshr_optab || binoptab == ashl_optab || binoptab == ashr_optab) - && mclass == MODE_INT + && is_int_mode (mode, &int_mode) && (CONST_INT_P (op1) || optimize_insn_for_speed_p ()) - && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD - && GET_MODE_PRECISION (mode) == GET_MODE_BITSIZE (mode) + && GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD + && GET_MODE_PRECISION (int_mode) == GET_MODE_BITSIZE (int_mode) && optab_handler (binoptab, word_mode) != CODE_FOR_nothing && optab_handler (ashl_optab, word_mode) != CODE_FOR_nothing && optab_handler (lshr_optab, word_mode) != CODE_FOR_nothing) @@ -1376,7 +1377,7 @@ expand_binop (machine_mode mode, optab b unsigned HOST_WIDE_INT shift_mask, double_shift_mask; machine_mode op1_mode; - double_shift_mask = targetm.shift_truncation_mask (mode); + double_shift_mask = targetm.shift_truncation_mask (int_mode); shift_mask = targetm.shift_truncation_mask (word_mode); op1_mode = GET_MODE (op1) != VOIDmode ? GET_MODE (op1) : word_mode; @@ -1404,7 +1405,7 @@ expand_binop (machine_mode mode, optab b || target == op0 || target == op1 || !valid_multiword_target_p (target)) - target = gen_reg_rtx (mode); + target = gen_reg_rtx (int_mode); start_sequence (); @@ -1416,11 +1417,11 @@ expand_binop (machine_mode mode, optab b left_shift = binoptab == ashl_optab; outof_word = left_shift ^ ! WORDS_BIG_ENDIAN; - outof_target = operand_subword (target, outof_word, 1, mode); - into_target = operand_subword (target, 1 - outof_word, 1, mode); + outof_target = operand_subword (target, outof_word, 1, int_mode); + into_target = operand_subword (target, 1 - outof_word, 1, int_mode); - outof_input = operand_subword_force (op0, outof_word, mode); - into_input = operand_subword_force (op0, 1 - outof_word, mode); + outof_input = operand_subword_force (op0, outof_word, int_mode); + into_input = operand_subword_force (op0, 1 - outof_word, int_mode); if (expand_doubleword_shift (op1_mode, binoptab, outof_input, into_input, op1, @@ -1439,9 +1440,9 @@ expand_binop (machine_mode mode, optab b /* Synthesize double word rotates from single word shifts. */ if ((binoptab == rotl_optab || binoptab == rotr_optab) - && mclass == MODE_INT + && is_int_mode (mode, &int_mode) && CONST_INT_P (op1) - && GET_MODE_PRECISION (mode) == 2 * BITS_PER_WORD + && GET_MODE_PRECISION (int_mode) == 2 * BITS_PER_WORD && optab_handler (ashl_optab, word_mode) != CODE_FOR_nothing && optab_handler (lshr_optab, word_mode) != CODE_FOR_nothing) { @@ -1462,7 +1463,7 @@ expand_binop (machine_mode mode, optab b || target == op1 || !REG_P (target) || !valid_multiword_target_p (target)) - target = gen_reg_rtx (mode); + target = gen_reg_rtx (int_mode); start_sequence (); @@ -1476,11 +1477,11 @@ expand_binop (machine_mode mode, optab b left_shift = (binoptab == rotl_optab); outof_word = left_shift ^ ! WORDS_BIG_ENDIAN; - outof_target = operand_subword (target, outof_word, 1, mode); - into_target = operand_subword (target, 1 - outof_word, 1, mode); + outof_target = operand_subword (target, outof_word, 1, int_mode); + into_target = operand_subword (target, 1 - outof_word, 1, int_mode); - outof_input = operand_subword_force (op0, outof_word, mode); - into_input = operand_subword_force (op0, 1 - outof_word, mode); + outof_input = operand_subword_force (op0, outof_word, int_mode); + into_input = operand_subword_force (op0, 1 - outof_word, int_mode); if (shift_count == BITS_PER_WORD) { @@ -1556,13 +1557,13 @@ expand_binop (machine_mode mode, optab b /* These can be done a word at a time by propagating carries. */ if ((binoptab == add_optab || binoptab == sub_optab) - && mclass == MODE_INT - && GET_MODE_SIZE (mode) >= 2 * UNITS_PER_WORD + && is_int_mode (mode, &int_mode) + && GET_MODE_SIZE (int_mode) >= 2 * UNITS_PER_WORD && optab_handler (binoptab, word_mode) != CODE_FOR_nothing) { unsigned int i; optab otheroptab = binoptab == add_optab ? sub_optab : add_optab; - const unsigned int nwords = GET_MODE_BITSIZE (mode) / BITS_PER_WORD; + const unsigned int nwords = GET_MODE_BITSIZE (int_mode) / BITS_PER_WORD; rtx carry_in = NULL_RTX, carry_out = NULL_RTX; rtx xop0, xop1, xtarget; @@ -1576,10 +1577,10 @@ expand_binop (machine_mode mode, optab b #endif /* Prepare the operands. */ - xop0 = force_reg (mode, op0); - xop1 = force_reg (mode, op1); + xop0 = force_reg (int_mode, op0); + xop1 = force_reg (int_mode, op1); - xtarget = gen_reg_rtx (mode); + xtarget = gen_reg_rtx (int_mode); if (target == 0 || !REG_P (target) || !valid_multiword_target_p (target)) target = xtarget; @@ -1592,9 +1593,9 @@ expand_binop (machine_mode mode, optab b for (i = 0; i < nwords; i++) { int index = (WORDS_BIG_ENDIAN ? nwords - i - 1 : i); - rtx target_piece = operand_subword (xtarget, index, 1, mode); - rtx op0_piece = operand_subword_force (xop0, index, mode); - rtx op1_piece = operand_subword_force (xop1, index, mode); + rtx target_piece = operand_subword (xtarget, index, 1, int_mode); + rtx op0_piece = operand_subword_force (xop0, index, int_mode); + rtx op1_piece = operand_subword_force (xop1, index, int_mode); rtx x; /* Main add/subtract of the input operands. */ @@ -1653,16 +1654,16 @@ expand_binop (machine_mode mode, optab b carry_in = carry_out; } - if (i == GET_MODE_BITSIZE (mode) / (unsigned) BITS_PER_WORD) + if (i == GET_MODE_BITSIZE (int_mode) / (unsigned) BITS_PER_WORD) { - if (optab_handler (mov_optab, mode) != CODE_FOR_nothing + if (optab_handler (mov_optab, int_mode) != CODE_FOR_nothing || ! rtx_equal_p (target, xtarget)) { rtx_insn *temp = emit_move_insn (target, xtarget); set_dst_reg_note (temp, REG_EQUAL, gen_rtx_fmt_ee (optab_to_code (binoptab), - mode, copy_rtx (xop0), + int_mode, copy_rtx (xop0), copy_rtx (xop1)), target); } @@ -1682,26 +1683,26 @@ expand_binop (machine_mode mode, optab b try using a signed widening multiply. */ if (binoptab == smul_optab - && mclass == MODE_INT - && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD + && is_int_mode (mode, &int_mode) + && GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD && optab_handler (smul_optab, word_mode) != CODE_FOR_nothing && optab_handler (add_optab, word_mode) != CODE_FOR_nothing) { rtx product = NULL_RTX; - if (widening_optab_handler (umul_widen_optab, mode, word_mode) - != CODE_FOR_nothing) + if (widening_optab_handler (umul_widen_optab, int_mode, word_mode) + != CODE_FOR_nothing) { - product = expand_doubleword_mult (mode, op0, op1, target, + product = expand_doubleword_mult (int_mode, op0, op1, target, true, methods); if (!product) delete_insns_since (last); } if (product == NULL_RTX - && widening_optab_handler (smul_widen_optab, mode, word_mode) - != CODE_FOR_nothing) + && (widening_optab_handler (smul_widen_optab, int_mode, word_mode) + != CODE_FOR_nothing)) { - product = expand_doubleword_mult (mode, op0, op1, target, + product = expand_doubleword_mult (int_mode, op0, op1, target, false, methods); if (!product) delete_insns_since (last); @@ -1709,13 +1710,13 @@ expand_binop (machine_mode mode, optab b if (product != NULL_RTX) { - if (optab_handler (mov_optab, mode) != CODE_FOR_nothing) + if (optab_handler (mov_optab, int_mode) != CODE_FOR_nothing) { rtx_insn *move = emit_move_insn (target ? target : product, product); set_dst_reg_note (move, REG_EQUAL, - gen_rtx_fmt_ee (MULT, mode, + gen_rtx_fmt_ee (MULT, int_mode, copy_rtx (op0), copy_rtx (op1)), target ? target : product); @@ -2695,6 +2696,7 @@ expand_unop (machine_mode mode, optab un { enum mode_class mclass = GET_MODE_CLASS (mode); machine_mode wider_mode; + scalar_int_mode int_mode; scalar_float_mode float_mode; rtx temp; rtx libfunc; @@ -2852,24 +2854,24 @@ expand_unop (machine_mode mode, optab un /* These can be done a word at a time. */ if (unoptab == one_cmpl_optab - && mclass == MODE_INT - && GET_MODE_SIZE (mode) > UNITS_PER_WORD + && is_int_mode (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > UNITS_PER_WORD && optab_handler (unoptab, word_mode) != CODE_FOR_nothing) { int i; rtx_insn *insns; if (target == 0 || target == op0 || !valid_multiword_target_p (target)) - target = gen_reg_rtx (mode); + target = gen_reg_rtx (int_mode); start_sequence (); /* Do the actual arithmetic. */ - for (i = 0; i < GET_MODE_BITSIZE (mode) / BITS_PER_WORD; i++) + for (i = 0; i < GET_MODE_BITSIZE (int_mode) / BITS_PER_WORD; i++) { - rtx target_piece = operand_subword (target, i, 1, mode); + rtx target_piece = operand_subword (target, i, 1, int_mode); rtx x = expand_unop (word_mode, unoptab, - operand_subword_force (op0, i, mode), + operand_subword_force (op0, i, int_mode), target_piece, unsignedp); if (target_piece != x) @@ -3115,18 +3117,20 @@ expand_abs_nojump (machine_mode mode, rt value of X as (((signed) x >> (W-1)) ^ x) - ((signed) x >> (W-1)), where W is the width of MODE. */ - if (GET_MODE_CLASS (mode) == MODE_INT + scalar_int_mode int_mode; + if (is_int_mode (mode, &int_mode) && BRANCH_COST (optimize_insn_for_speed_p (), false) >= 2) { - rtx extended = expand_shift (RSHIFT_EXPR, mode, op0, - GET_MODE_PRECISION (mode) - 1, + rtx extended = expand_shift (RSHIFT_EXPR, int_mode, op0, + GET_MODE_PRECISION (int_mode) - 1, NULL_RTX, 0); - temp = expand_binop (mode, xor_optab, extended, op0, target, 0, + temp = expand_binop (int_mode, xor_optab, extended, op0, target, 0, OPTAB_LIB_WIDEN); if (temp != 0) - temp = expand_binop (mode, result_unsignedp ? sub_optab : subv_optab, + temp = expand_binop (int_mode, + result_unsignedp ? sub_optab : subv_optab, temp, extended, target, 0, OPTAB_LIB_WIDEN); if (temp != 0) @@ -3219,15 +3223,16 @@ expand_one_cmpl_abs_nojump (machine_mode /* If this machine has expensive jumps, we can do one's complement absolute value of X as (((signed) x >> (W-1)) ^ x). */ - if (GET_MODE_CLASS (mode) == MODE_INT + scalar_int_mode int_mode; + if (is_int_mode (mode, &int_mode) && BRANCH_COST (optimize_insn_for_speed_p (), false) >= 2) { - rtx extended = expand_shift (RSHIFT_EXPR, mode, op0, - GET_MODE_PRECISION (mode) - 1, + rtx extended = expand_shift (RSHIFT_EXPR, int_mode, op0, + GET_MODE_PRECISION (int_mode) - 1, NULL_RTX, 0); - temp = expand_binop (mode, xor_optab, extended, op0, target, 0, + temp = expand_binop (int_mode, xor_optab, extended, op0, target, 0, OPTAB_LIB_WIDEN); if (temp != 0) Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:29.218658615 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:31.701428138 +0100 @@ -77,11 +77,12 @@ mode_signbit_p (machine_mode mode, const { unsigned HOST_WIDE_INT val; unsigned int width; + scalar_int_mode int_mode; - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!is_int_mode (mode, &int_mode)) return false; - width = GET_MODE_PRECISION (mode); + width = GET_MODE_PRECISION (int_mode); if (width == 0) return false; @@ -129,15 +130,16 @@ mode_signbit_p (machine_mode mode, const val_signbit_p (machine_mode mode, unsigned HOST_WIDE_INT val) { unsigned int width; + scalar_int_mode int_mode; - if (GET_MODE_CLASS (mode) != MODE_INT) + if (!is_int_mode (mode, &int_mode)) return false; - width = GET_MODE_PRECISION (mode); + width = GET_MODE_PRECISION (int_mode); if (width == 0 || width > HOST_BITS_PER_WIDE_INT) return false; - val &= GET_MODE_MASK (mode); + val &= GET_MODE_MASK (int_mode); return val == (HOST_WIDE_INT_1U << (width - 1)); } @@ -148,10 +150,11 @@ val_signbit_known_set_p (machine_mode mo { unsigned int width; - if (GET_MODE_CLASS (mode) != MODE_INT) + scalar_int_mode int_mode; + if (!is_int_mode (mode, &int_mode)) return false; - width = GET_MODE_PRECISION (mode); + width = GET_MODE_PRECISION (int_mode); if (width == 0 || width > HOST_BITS_PER_WIDE_INT) return false; @@ -166,10 +169,11 @@ val_signbit_known_clear_p (machine_mode { unsigned int width; - if (GET_MODE_CLASS (mode) != MODE_INT) + scalar_int_mode int_mode; + if (!is_int_mode (mode, &int_mode)) return false; - width = GET_MODE_PRECISION (mode); + width = GET_MODE_PRECISION (int_mode); if (width == 0 || width > HOST_BITS_PER_WIDE_INT) return false; @@ -4819,18 +4823,19 @@ simplify_relational_operation_1 (enum rt /* (ne:SI (zero_extract:SI FOO (const_int 1) BAR) (const_int 0))) is the same as (zero_extract:SI FOO (const_int 1) BAR). */ + scalar_int_mode int_mode; if (code == NE && op1 == const0_rtx - && GET_MODE_CLASS (mode) == MODE_INT + && is_int_mode (mode, &int_mode) && cmp_mode != VOIDmode /* ??? Work-around BImode bugs in the ia64 backend. */ - && mode != BImode + && int_mode != BImode && cmp_mode != BImode && nonzero_bits (op0, cmp_mode) == 1 && STORE_FLAG_VALUE == 1) - return GET_MODE_SIZE (mode) > GET_MODE_SIZE (cmp_mode) - ? simplify_gen_unary (ZERO_EXTEND, mode, op0, cmp_mode) - : lowpart_subreg (mode, op0, cmp_mode); + return GET_MODE_SIZE (int_mode) > GET_MODE_SIZE (cmp_mode) + ? simplify_gen_unary (ZERO_EXTEND, int_mode, op0, cmp_mode) + : lowpart_subreg (int_mode, op0, cmp_mode); /* (eq/ne (xor x y) 0) simplifies to (eq/ne x y). */ if ((code == EQ || code == NE) Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:30.905501319 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:31.701428138 +0100 @@ -2449,10 +2449,10 @@ vector_type_mode (const_tree t) && (!targetm.vector_mode_supported_p (mode) || !have_regs_of_mode[mode])) { - machine_mode innermode = TREE_TYPE (t)->type_common.mode; + scalar_int_mode innermode; /* For integers, try mapping it to a same-sized scalar mode. */ - if (GET_MODE_CLASS (innermode) == MODE_INT) + if (is_int_mode (TREE_TYPE (t)->type_common.mode, &innermode)) { unsigned int size = (TYPE_VECTOR_SUBPARTS (t) * GET_MODE_BITSIZE (innermode)); Index: gcc/go/go-lang.c =================================================================== --- gcc/go/go-lang.c 2017-07-13 09:18:23.798185961 +0100 +++ gcc/go/go-lang.c 2017-07-13 09:18:31.699428322 +0100 @@ -382,10 +382,11 @@ go_langhook_type_for_mode (machine_mode return NULL_TREE; } + scalar_int_mode imode; scalar_float_mode fmode; enum mode_class mc = GET_MODE_CLASS (mode); - if (mc == MODE_INT) - return go_langhook_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); + if (is_int_mode (mode, &imode)) + return go_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp); else if (is_float_mode (mode, &fmode)) { switch (GET_MODE_BITSIZE (fmode)) From patchwork Thu Jul 13 08:46:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107607 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1930614qge; Thu, 13 Jul 2017 01:47:48 -0700 (PDT) X-Received: by 10.98.19.136 with SMTP id 8mr59849981pft.105.1499935668053; Thu, 13 Jul 2017 01:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935668; cv=none; d=google.com; s=arc-20160816; b=guqeaTxb5lY6xNKi8lBvcgCSZlDjeyXgrdPik+G6MoieUPGsoiLudtO5wJ1uzRr2XN +84EccabIcyPwoK5CX/m6yiJkhK4ou8rVGy2gXiI9eFUsQTQD+I3V5cPV55ZskYO+ezX Ai8rVYybPqPRTl9N6mEKIR64Ruo6LxIF1JpfpGgvlKuN+h8Q+iqiFhEUL/CITMNnJR14 ctmUvVZVEQXeQlKwgo+eWUh3LSpK1YsBsnEOInGom36FNPeLiYyyls1K6e+xSj5JF4Ec nXO3XfIYD5OJjMgpyopKfyjt2auS8e05D6OeOZElsyZelP12kLVq7U/Oc//FChjeTo+5 LMGw== 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=selNIucqYhI+i9jDoReTI7xt96X3c46jUXXxoyGRhIs=; b=oz0ULxji4zV4miqSB2sq0BCVu10/Y6LrrlELhUwVxJdaYCLkK3xq+SiaEXT2Sa594+ M0vvBo2USV5yqfVwNJPq+WyHyxCoJeWMad+9CNsc7N023p3cp/PZ0ndYlCVyR45HwPN8 A+SbNwFf2AWKQPmH5u6tDsAsWRW+/F8n1byWxFR3v7E4pg8CDFgyTNkzO36y6akk3kj9 XCc8fW6MVwAhddVKFZSd3L9CbCln3uUPNnFmHSMtCqtxi2DQ/pu4i5Oi4ATwY4ePOKfw TMq5cZNJCO9/Co5uBRAyHL781uXtnabkp9uZNs8pkA1ndKdVFdK0zqSQG8WjRTvJPDfx zVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=QQHSdACz; spf=pass (google.com: domain of gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458012-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 x66si3692794pfb.38.2017.07.13.01.47.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458012-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=QQHSdACz; spf=pass (google.com: domain of gcc-patches-return-458012-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458012-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=rvnkVTNAVt6AvvdtGd68GmvYmyxdA ydxA5SMh6+nlXzA3zLIBQNCoG1j8rYOlhe2wotGeadL6l7jD4UozlhcGDhv42m+a k9c+mbeAY8Rfm7CH3OuxCnaHMtDF+cCTpqkHYfY583GYrna7vw2vxG++9D4Abj1N 9Xs45GpUr8MTJg= 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=3an6EODbvLEBL/s444+uEqTBHh0=; b=QQH SdACzojNs+ODvFDJ/ZOfAZQ5MkaOI3d2vJNCJ6rXNEifIXSeNcBlyeRJxR2rJXPY 0y+JbUasunMN0PF/e37yxSCQ+uW48WyM7drlB4BtgmuGAfX6sYmKLxZjmHCUXHL7 PSGRAdeWR3/AvykV05n6c+pGzIiQszrsI87fp0Ao= Received: (qmail 49392 invoked by alias); 13 Jul 2017 08:46:37 -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 49061 invoked by uid 89); 13 Jul 2017 08:46:36 -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=Quick X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:46:26 +0000 Received: by mail-wm0-f52.google.com with SMTP id 62so16541897wmw.1 for ; Thu, 13 Jul 2017 01:46:25 -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=selNIucqYhI+i9jDoReTI7xt96X3c46jUXXxoyGRhIs=; b=HDa6G9p0/oGUGkNCZww20Q+tsLguU3f49o119es+X9k/I/hfizqgKoI0TTDHeKPifB Qr+r3mYFVPl0//2a25gMr/3ZSXGz9BsaMIiC498+fMt7njL7kDGbVa91d0lGf4DIyAwp x6WpV3G4mBbMNwXVGKCslwUBk2GAFg7aar8kgU4uokbh54Vz8KzI6LONeDwL+Prb1SFm 6Gec8APoQBBDvcOUqn1Xwjiowk+TszIDg0s2tLf+KgThnulPilDMUaFw+6w4L2gVeaR7 wj6nXA1L3DAnnovAWEPcuKl4CYAQdjJyU6k9xF0oxa74Q2ONht3IlfNprCCCEMzWov9o sVhA== X-Gm-Message-State: AIVw110EQydiSjSUpnN3bDrY35qXnsQ6oR6Fo1pzo4EcPpBSb5j23D7y HF7+XcKZ6amWg/2iJec4yQ== X-Received: by 10.28.1.8 with SMTP id 8mr1188321wmb.88.1499935581979; Thu, 13 Jul 2017 01:46:21 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 185sm5609633wmn.33.2017.07.13.01.46.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:46:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [21/77] Replace SCALAR_INT_MODE_P checks with is_a References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:46:19 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87mv88k9lw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces checks of "SCALAR_INT_MODE_P (...)" with "is_a (..., &var)" in cases where it becomes useful to refer to the mode as a scalar_int_mode. It also replaces some checks for the two constituent classes (MODE_INT and MODE_PARTIAL_INT). The patch also introduces is_a checks for some uses of HWI_COMPUTABLE_MODE_P, which is a subcondition of SCALAR_INT_MODE_P. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * wide-int.h (int_traits) New class. (int_traits) Likewise. * cfgexpand.c (expand_debug_expr): Use is_a . Use GET_MODE_UNIT_PRECISION and remove redundant test for SCALAR_INT_MODE_P. * combine.c (set_nonzero_bits_and_sign_copies): Use is_a . (find_split_point): Likewise. (combine_simplify_rtx): Likewise. (simplify_logical): Likewise. (expand_compound_operation): Likewise. (expand_field_assignment): Likewise. (make_compound_operation): Likewise. (extended_count): Likewise. (change_zero_ext): Likewise. (simplify_comparison): Likewise. * dwarf2out.c (scompare_loc_descriptor): Likewise. (ucompare_loc_descriptor): Likewise. (minmax_loc_descriptor): Likewise. (mem_loc_descriptor): Likewise. (loc_descriptor): Likewise. * expmed.c (init_expmed_one_mode): Likewise. * lra-constraints.c (lra_constraint_offset): Likewise. * optabs.c (prepare_libcall_arg): Likewise. * postreload.c (move2add_note_store): Likewise. * reload.c (operands_match_p): Likewise. * rtl.h (load_extend_op): Likewise. * rtlhooks.c (gen_lowpart_general): Likewise. * simplify-rtx.c (simplify_truncation): Likewise. (simplify_unary_operation_1): Likewise. (simplify_binary_operation_1): Likewise. (simplify_const_binary_operation): Likewise. (simplify_const_relational_operation): Likewise. (simplify_subreg): Likewise. * stor-layout.c (bitwise_mode_for_mode): Likewise. * var-tracking.c (adjust_mems): Likewise. (prepare_call_arguments): Likewise. gcc/ada/ * gcc-interface/decl.c (check_ok_for_atomic_type): Use is_a . * gcc-interface/trans.c (Pragma_to_gnu): Likewise. * gcc-interface/utils.c (gnat_type_for_mode): Likewise. gcc/fortran/ * trans-types.c (gfc_type_for_mode): Use is_a . Index: gcc/wide-int.h =================================================================== --- gcc/wide-int.h 2017-03-28 16:19:28.000000000 +0100 +++ gcc/wide-int.h 2017-07-13 09:18:32.530352523 +0100 @@ -1468,6 +1468,14 @@ wi::primitive_int_traits :: namespace wi { template <> + struct int_traits + : public primitive_int_traits {}; + + template <> + struct int_traits + : public primitive_int_traits {}; + + template <> struct int_traits : public primitive_int_traits {}; Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:30.888502896 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:32.520353432 +0100 @@ -4137,6 +4137,7 @@ expand_debug_expr (tree exp) machine_mode inner_mode = VOIDmode; int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp)); addr_space_t as; + scalar_int_mode op1_mode; switch (TREE_CODE_CLASS (TREE_CODE (exp))) { @@ -4186,16 +4187,10 @@ expand_debug_expr (tree exp) case WIDEN_LSHIFT_EXPR: /* Ensure second operand isn't wider than the first one. */ inner_mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))); - if (SCALAR_INT_MODE_P (inner_mode)) - { - machine_mode opmode = mode; - if (VECTOR_MODE_P (mode)) - opmode = GET_MODE_INNER (mode); - if (SCALAR_INT_MODE_P (opmode) - && (GET_MODE_PRECISION (opmode) - < GET_MODE_PRECISION (inner_mode))) - op1 = lowpart_subreg (opmode, op1, inner_mode); - } + if (is_a (inner_mode, &op1_mode) + && (GET_MODE_UNIT_PRECISION (mode) + < GET_MODE_PRECISION (op1_mode))) + op1 = lowpart_subreg (GET_MODE_INNER (mode), op1, op1_mode); break; default: break; Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:31.690429148 +0100 +++ gcc/combine.c 2017-07-13 09:18:32.521353341 +0100 @@ -1706,6 +1706,7 @@ update_rsp_from_reg_equal (reg_stat_type set_nonzero_bits_and_sign_copies (rtx x, const_rtx set, void *data) { rtx_insn *insn = (rtx_insn *) data; + scalar_int_mode mode; if (REG_P (x) && REGNO (x) >= FIRST_PSEUDO_REGISTER @@ -1713,13 +1714,14 @@ set_nonzero_bits_and_sign_copies (rtx x, say what its contents were. */ && ! REGNO_REG_SET_P (DF_LR_IN (ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb), REGNO (x)) - && HWI_COMPUTABLE_MODE_P (GET_MODE (x))) + && is_a (GET_MODE (x), &mode) + && HWI_COMPUTABLE_MODE_P (mode)) { reg_stat_type *rsp = ®_stat[REGNO (x)]; if (set == 0 || GET_CODE (set) == CLOBBER) { - rsp->nonzero_bits = GET_MODE_MASK (GET_MODE (x)); + rsp->nonzero_bits = GET_MODE_MASK (mode); rsp->sign_bit_copies = 1; return; } @@ -1749,7 +1751,7 @@ set_nonzero_bits_and_sign_copies (rtx x, break; if (!link) { - rsp->nonzero_bits = GET_MODE_MASK (GET_MODE (x)); + rsp->nonzero_bits = GET_MODE_MASK (mode); rsp->sign_bit_copies = 1; return; } @@ -1768,7 +1770,7 @@ set_nonzero_bits_and_sign_copies (rtx x, update_rsp_from_reg_equal (rsp, insn, set, x); else { - rsp->nonzero_bits = GET_MODE_MASK (GET_MODE (x)); + rsp->nonzero_bits = GET_MODE_MASK (mode); rsp->sign_bit_copies = 1; } } @@ -4926,37 +4928,38 @@ find_split_point (rtx *loc, rtx_insn *in /* See if this is a bitfield assignment with everything constant. If so, this is an IOR of an AND, so split it into that. */ if (GET_CODE (SET_DEST (x)) == ZERO_EXTRACT - && HWI_COMPUTABLE_MODE_P (GET_MODE (XEXP (SET_DEST (x), 0))) + && is_a (GET_MODE (XEXP (SET_DEST (x), 0)), + &inner_mode) + && HWI_COMPUTABLE_MODE_P (inner_mode) && CONST_INT_P (XEXP (SET_DEST (x), 1)) && CONST_INT_P (XEXP (SET_DEST (x), 2)) && CONST_INT_P (SET_SRC (x)) && ((INTVAL (XEXP (SET_DEST (x), 1)) + INTVAL (XEXP (SET_DEST (x), 2))) - <= GET_MODE_PRECISION (GET_MODE (XEXP (SET_DEST (x), 0)))) + <= GET_MODE_PRECISION (inner_mode)) && ! side_effects_p (XEXP (SET_DEST (x), 0))) { HOST_WIDE_INT pos = INTVAL (XEXP (SET_DEST (x), 2)); unsigned HOST_WIDE_INT len = INTVAL (XEXP (SET_DEST (x), 1)); unsigned HOST_WIDE_INT src = INTVAL (SET_SRC (x)); rtx dest = XEXP (SET_DEST (x), 0); - machine_mode mode = GET_MODE (dest); unsigned HOST_WIDE_INT mask = (HOST_WIDE_INT_1U << len) - 1; rtx or_mask; if (BITS_BIG_ENDIAN) - pos = GET_MODE_PRECISION (mode) - len - pos; + pos = GET_MODE_PRECISION (inner_mode) - len - pos; - or_mask = gen_int_mode (src << pos, mode); + or_mask = gen_int_mode (src << pos, inner_mode); if (src == mask) SUBST (SET_SRC (x), - simplify_gen_binary (IOR, mode, dest, or_mask)); + simplify_gen_binary (IOR, inner_mode, dest, or_mask)); else { - rtx negmask = gen_int_mode (~(mask << pos), mode); + rtx negmask = gen_int_mode (~(mask << pos), inner_mode); SUBST (SET_SRC (x), - simplify_gen_binary (IOR, mode, - simplify_gen_binary (AND, mode, + simplify_gen_binary (IOR, inner_mode, + simplify_gen_binary (AND, inner_mode, dest, negmask), or_mask)); } @@ -5796,15 +5799,18 @@ combine_simplify_rtx (rtx x, machine_mod return temp; /* If op is known to have all lower bits zero, the result is zero. */ + scalar_int_mode int_mode, int_op0_mode; if (!in_dest - && SCALAR_INT_MODE_P (mode) - && SCALAR_INT_MODE_P (op0_mode) - && GET_MODE_PRECISION (mode) < GET_MODE_PRECISION (op0_mode) - && subreg_lowpart_offset (mode, op0_mode) == SUBREG_BYTE (x) - && HWI_COMPUTABLE_MODE_P (op0_mode) - && (nonzero_bits (SUBREG_REG (x), op0_mode) - & GET_MODE_MASK (mode)) == 0) - return CONST0_RTX (mode); + && is_a (mode, &int_mode) + && is_a (op0_mode, &int_op0_mode) + && (GET_MODE_PRECISION (int_mode) + < GET_MODE_PRECISION (int_op0_mode)) + && (subreg_lowpart_offset (int_mode, int_op0_mode) + == SUBREG_BYTE (x)) + && HWI_COMPUTABLE_MODE_P (int_op0_mode) + && (nonzero_bits (SUBREG_REG (x), int_op0_mode) + & GET_MODE_MASK (int_mode)) == 0) + return CONST0_RTX (int_mode); } /* Don't change the mode of the MEM if that would change the meaning @@ -5912,12 +5918,13 @@ combine_simplify_rtx (rtx x, machine_mod sign_extract. The `and' may be a zero_extend and the two , - constants may be reversed. */ if (GET_CODE (XEXP (x, 0)) == XOR + && is_a (mode, &int_mode) && CONST_INT_P (XEXP (x, 1)) && CONST_INT_P (XEXP (XEXP (x, 0), 1)) && INTVAL (XEXP (x, 1)) == -INTVAL (XEXP (XEXP (x, 0), 1)) && ((i = exact_log2 (UINTVAL (XEXP (XEXP (x, 0), 1)))) >= 0 || (i = exact_log2 (UINTVAL (XEXP (x, 1)))) >= 0) - && HWI_COMPUTABLE_MODE_P (mode) + && HWI_COMPUTABLE_MODE_P (int_mode) && ((GET_CODE (XEXP (XEXP (x, 0), 0)) == AND && CONST_INT_P (XEXP (XEXP (XEXP (x, 0), 0), 1)) && (UINTVAL (XEXP (XEXP (XEXP (x, 0), 0), 1)) @@ -5926,11 +5933,11 @@ combine_simplify_rtx (rtx x, machine_mod && (GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (XEXP (x, 0), 0), 0))) == (unsigned int) i + 1)))) return simplify_shift_const - (NULL_RTX, ASHIFTRT, mode, - simplify_shift_const (NULL_RTX, ASHIFT, mode, + (NULL_RTX, ASHIFTRT, int_mode, + simplify_shift_const (NULL_RTX, ASHIFT, int_mode, XEXP (XEXP (XEXP (x, 0), 0), 0), - GET_MODE_PRECISION (mode) - (i + 1)), - GET_MODE_PRECISION (mode) - (i + 1)); + GET_MODE_PRECISION (int_mode) - (i + 1)), + GET_MODE_PRECISION (int_mode) - (i + 1)); /* If only the low-order bit of X is possibly nonzero, (plus x -1) can become (ashiftrt (ashift (xor x 1) C) C) where C is @@ -6948,9 +6955,9 @@ simplify_set (rtx x) static rtx simplify_logical (rtx x) { - machine_mode mode = GET_MODE (x); rtx op0 = XEXP (x, 0); rtx op1 = XEXP (x, 1); + scalar_int_mode mode; switch (GET_CODE (x)) { @@ -6958,7 +6965,8 @@ simplify_logical (rtx x) /* We can call simplify_and_const_int only if we don't lose any (sign) bits when converting INTVAL (op1) to "unsigned HOST_WIDE_INT". */ - if (CONST_INT_P (op1) + if (is_a (GET_MODE (x), &mode) + && CONST_INT_P (op1) && (HWI_COMPUTABLE_MODE_P (mode) || INTVAL (op1) > 0)) { @@ -7033,6 +7041,7 @@ expand_compound_operation (rtx x) int unsignedp = 0; unsigned int modewidth; rtx tem; + scalar_int_mode inner_mode; switch (GET_CODE (x)) { @@ -7051,25 +7060,24 @@ expand_compound_operation (rtx x) if (CONST_INT_P (XEXP (x, 0))) return x; + /* Reject modes that aren't scalar integers because turning vector + or complex modes into shifts causes problems. */ + if (!is_a (GET_MODE (XEXP (x, 0)), &inner_mode)) + return x; + /* Return if (subreg:MODE FROM 0) is not a safe replacement for (zero_extend:MODE FROM) or (sign_extend:MODE FROM). It is for any MEM because (SUBREG (MEM...)) is guaranteed to cause the MEM to be reloaded. If not for that, MEM's would very rarely be safe. - Reject MODEs bigger than a word, because we might not be able + Reject modes bigger than a word, because we might not be able to reference a two-register group starting with an arbitrary register (and currently gen_lowpart might crash for a SUBREG). */ - if (GET_MODE_SIZE (GET_MODE (XEXP (x, 0))) > UNITS_PER_WORD) + if (GET_MODE_SIZE (inner_mode) > UNITS_PER_WORD) return x; - /* Reject MODEs that aren't scalar integers because turning vector - or complex modes into shifts causes problems. */ - - if (! SCALAR_INT_MODE_P (GET_MODE (XEXP (x, 0)))) - return x; - - len = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))); + len = GET_MODE_PRECISION (inner_mode); /* If the inner object has VOIDmode (the only way this can happen is if it is an ASM_OPERANDS), we can't do anything since we don't know how much masking to do. */ @@ -7089,25 +7097,23 @@ expand_compound_operation (rtx x) return XEXP (x, 0); if (!CONST_INT_P (XEXP (x, 1)) - || !CONST_INT_P (XEXP (x, 2)) - || GET_MODE (XEXP (x, 0)) == VOIDmode) + || !CONST_INT_P (XEXP (x, 2))) return x; - /* Reject MODEs that aren't scalar integers because turning vector + /* Reject modes that aren't scalar integers because turning vector or complex modes into shifts causes problems. */ - - if (! SCALAR_INT_MODE_P (GET_MODE (XEXP (x, 0)))) + if (!is_a (GET_MODE (XEXP (x, 0)), &inner_mode)) return x; len = INTVAL (XEXP (x, 1)); pos = INTVAL (XEXP (x, 2)); /* This should stay within the object being extracted, fail otherwise. */ - if (len + pos > GET_MODE_PRECISION (GET_MODE (XEXP (x, 0)))) + if (len + pos > GET_MODE_PRECISION (inner_mode)) return x; if (BITS_BIG_ENDIAN) - pos = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - len - pos; + pos = GET_MODE_PRECISION (inner_mode) - len - pos; break; @@ -7118,12 +7124,10 @@ expand_compound_operation (rtx x) bit is not set, as this is easier to optimize. It will be converted back to cheaper alternative in make_extraction. */ if (GET_CODE (x) == SIGN_EXTEND - && (HWI_COMPUTABLE_MODE_P (GET_MODE (x)) - && ((nonzero_bits (XEXP (x, 0), GET_MODE (XEXP (x, 0))) - & ~(((unsigned HOST_WIDE_INT) - GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) - >> 1)) - == 0))) + && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) + && ((nonzero_bits (XEXP (x, 0), inner_mode) + & ~(((unsigned HOST_WIDE_INT) GET_MODE_MASK (inner_mode)) >> 1)) + == 0)) { machine_mode mode = GET_MODE (x); rtx temp = gen_rtx_ZERO_EXTEND (mode, XEXP (x, 0)); @@ -7150,7 +7154,7 @@ expand_compound_operation (rtx x) && GET_MODE (XEXP (XEXP (x, 0), 0)) == GET_MODE (x) && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) && (nonzero_bits (XEXP (XEXP (x, 0), 0), GET_MODE (x)) - & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + & ~GET_MODE_MASK (inner_mode)) == 0) return XEXP (XEXP (x, 0), 0); /* Likewise for (zero_extend:DI (subreg:SI foo:DI 0)). */ @@ -7159,7 +7163,7 @@ expand_compound_operation (rtx x) && subreg_lowpart_p (XEXP (x, 0)) && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) && (nonzero_bits (SUBREG_REG (XEXP (x, 0)), GET_MODE (x)) - & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + & ~GET_MODE_MASK (inner_mode)) == 0) return SUBREG_REG (XEXP (x, 0)); /* (zero_extend:DI (truncate:SI foo:DI)) is just foo:DI when foo @@ -7169,9 +7173,8 @@ expand_compound_operation (rtx x) if (GET_CODE (XEXP (x, 0)) == TRUNCATE && GET_MODE (XEXP (XEXP (x, 0), 0)) == GET_MODE (x) && COMPARISON_P (XEXP (XEXP (x, 0), 0)) - && (GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - <= HOST_BITS_PER_WIDE_INT) - && (STORE_FLAG_VALUE & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT + && (STORE_FLAG_VALUE & ~GET_MODE_MASK (inner_mode)) == 0) return XEXP (XEXP (x, 0), 0); /* Likewise for (zero_extend:DI (subreg:SI foo:DI 0)). */ @@ -7179,9 +7182,8 @@ expand_compound_operation (rtx x) && GET_MODE (SUBREG_REG (XEXP (x, 0))) == GET_MODE (x) && subreg_lowpart_p (XEXP (x, 0)) && COMPARISON_P (SUBREG_REG (XEXP (x, 0))) - && (GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - <= HOST_BITS_PER_WIDE_INT) - && (STORE_FLAG_VALUE & ~GET_MODE_MASK (GET_MODE (XEXP (x, 0)))) == 0) + && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT + && (STORE_FLAG_VALUE & ~GET_MODE_MASK (inner_mode)) == 0) return SUBREG_REG (XEXP (x, 0)); } @@ -7246,7 +7248,7 @@ expand_field_assignment (const_rtx x) rtx pos; /* Always counts from low bit. */ int len; rtx mask, cleared, masked; - machine_mode compute_mode; + scalar_int_mode compute_mode; /* Loop until we find something we can't simplify. */ while (1) @@ -7314,17 +7316,15 @@ expand_field_assignment (const_rtx x) while (GET_CODE (inner) == SUBREG && subreg_lowpart_p (inner)) inner = SUBREG_REG (inner); - compute_mode = GET_MODE (inner); - /* Don't attempt bitwise arithmetic on non scalar integer modes. */ - if (! SCALAR_INT_MODE_P (compute_mode)) + if (!is_a (GET_MODE (inner), &compute_mode)) { /* Don't do anything for vector or complex integral types. */ - if (! FLOAT_MODE_P (compute_mode)) + if (! FLOAT_MODE_P (GET_MODE (inner))) break; /* Try to find an integral mode to pun with. */ - if (!int_mode_for_size (GET_MODE_BITSIZE (compute_mode), 0) + if (!int_mode_for_size (GET_MODE_BITSIZE (GET_MODE (inner)), 0) .exists (&compute_mode)) break; @@ -8274,10 +8274,11 @@ make_compound_operation (rtx x, enum rtx && XEXP (x, 1) == const0_rtx) ? COMPARE : in_code == COMPARE || in_code == EQ ? SET : in_code); - if (SCALAR_INT_MODE_P (GET_MODE (x))) + scalar_int_mode mode; + if (is_a (GET_MODE (x), &mode)) { - rtx new_rtx = make_compound_operation_int (GET_MODE (x), &x, - in_code, &next_code); + rtx new_rtx = make_compound_operation_int (mode, &x, in_code, + &next_code); if (new_rtx) return new_rtx; code = GET_CODE (x); @@ -10117,10 +10118,12 @@ extended_count (const_rtx x, machine_mod if (nonzero_sign_valid == 0) return 0; + scalar_int_mode int_mode; return (unsignedp - ? (HWI_COMPUTABLE_MODE_P (mode) - ? (unsigned int) (GET_MODE_PRECISION (mode) - 1 - - floor_log2 (nonzero_bits (x, mode))) + ? (is_a (mode, &int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode) + ? (unsigned int) (GET_MODE_PRECISION (int_mode) - 1 + - floor_log2 (nonzero_bits (x, int_mode))) : 0) : num_sign_bit_copies (x, mode) - 1); } @@ -11290,7 +11293,9 @@ change_zero_ext (rtx pat) FOR_EACH_SUBRTX_PTR (iter, array, src, NONCONST) { rtx x = **iter; - machine_mode mode = GET_MODE (x); + scalar_int_mode mode; + if (!is_a (GET_MODE (x), &mode)) + continue; int size; if (GET_CODE (x) == ZERO_EXTRACT @@ -11316,7 +11321,6 @@ change_zero_ext (rtx pat) x = gen_lowpart_SUBREG (mode, x); } else if (GET_CODE (x) == ZERO_EXTEND - && SCALAR_INT_MODE_P (mode) && GET_CODE (XEXP (x, 0)) == SUBREG && SCALAR_INT_MODE_P (GET_MODE (SUBREG_REG (XEXP (x, 0)))) && !paradoxical_subreg_p (XEXP (x, 0)) @@ -11328,7 +11332,6 @@ change_zero_ext (rtx pat) x = gen_lowpart_SUBREG (mode, x); } else if (GET_CODE (x) == ZERO_EXTEND - && SCALAR_INT_MODE_P (mode) && REG_P (XEXP (x, 0)) && HARD_REGISTER_P (XEXP (x, 0)) && can_change_dest_mode (XEXP (x, 0), 0, mode)) @@ -12414,11 +12417,11 @@ simplify_comparison (enum rtx_code code, if (GET_CODE (XEXP (op0, 0)) == SUBREG && CONST_INT_P (XEXP (op0, 1))) { - tmode = GET_MODE (SUBREG_REG (XEXP (op0, 0))); unsigned HOST_WIDE_INT c1 = INTVAL (XEXP (op0, 1)); /* Require an integral mode, to avoid creating something like (AND:SF ...). */ - if (SCALAR_INT_MODE_P (tmode) + if ((is_a + (GET_MODE (SUBREG_REG (XEXP (op0, 0))), &tmode)) /* It is unsafe to commute the AND into the SUBREG if the SUBREG is paradoxical and WORD_REGISTER_OPERATIONS is not defined. As originally written the upper bits Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:31.696428597 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:32.524353068 +0100 @@ -13944,7 +13944,7 @@ scompare_loc_descriptor_narrow (enum dwa return compare_loc_descriptor (op, op0, op1); } -/* Return location descriptor for signed comparison OP RTL. */ +/* Return location descriptor for unsigned comparison OP RTL. */ static dw_loc_descr_ref scompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, @@ -13958,10 +13958,11 @@ scompare_loc_descriptor (enum dwarf_loca if (op_mode == VOIDmode) return NULL; + scalar_int_mode int_op_mode; if (dwarf_strict && dwarf_version < 5 - && (!SCALAR_INT_MODE_P (op_mode) - || GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE)) + && (!is_a (op_mode, &int_op_mode) + || GET_MODE_SIZE (int_op_mode) > DWARF2_ADDR_SIZE)) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), op_mode, mem_mode, @@ -13972,13 +13973,13 @@ scompare_loc_descriptor (enum dwarf_loca if (op0 == NULL || op1 == NULL) return NULL; - if (SCALAR_INT_MODE_P (op_mode)) + if (is_a (op_mode, &int_op_mode)) { - if (GET_MODE_SIZE (op_mode) < DWARF2_ADDR_SIZE) - return scompare_loc_descriptor_narrow (op, rtl, op_mode, op0, op1); + if (GET_MODE_SIZE (int_op_mode) < DWARF2_ADDR_SIZE) + return scompare_loc_descriptor_narrow (op, rtl, int_op_mode, op0, op1); - if (GET_MODE_SIZE (op_mode) > DWARF2_ADDR_SIZE) - return scompare_loc_descriptor_wide (op, op_mode, op0, op1); + if (GET_MODE_SIZE (int_op_mode) > DWARF2_ADDR_SIZE) + return scompare_loc_descriptor_wide (op, int_op_mode, op0, op1); } return compare_loc_descriptor (op, op0, op1); } @@ -13989,14 +13990,14 @@ scompare_loc_descriptor (enum dwarf_loca ucompare_loc_descriptor (enum dwarf_location_atom op, rtx rtl, machine_mode mem_mode) { - machine_mode op_mode = GET_MODE (XEXP (rtl, 0)); dw_loc_descr_ref op0, op1; - if (op_mode == VOIDmode) - op_mode = GET_MODE (XEXP (rtl, 1)); - if (op_mode == VOIDmode) - return NULL; - if (!SCALAR_INT_MODE_P (op_mode)) + machine_mode test_op_mode = GET_MODE (XEXP (rtl, 0)); + if (test_op_mode == VOIDmode) + test_op_mode = GET_MODE (XEXP (rtl, 1)); + + scalar_int_mode op_mode; + if (!is_a (test_op_mode, &op_mode)) return NULL; if (dwarf_strict @@ -14064,10 +14065,11 @@ minmax_loc_descriptor (rtx rtl, machine_ dw_loc_descr_ref op0, op1, ret; dw_loc_descr_ref bra_node, drop_node; + scalar_int_mode int_mode; if (dwarf_strict && dwarf_version < 5 - && (!SCALAR_INT_MODE_P (mode) - || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE)) + && (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE)) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, @@ -14099,19 +14101,19 @@ minmax_loc_descriptor (rtx rtl, machine_ add_loc_descr (&op1, new_loc_descr (DW_OP_plus_uconst, bias, 0)); } } - else if (!SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE) + else if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE) { - int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (mode)) * BITS_PER_UNIT; + int shift = (DWARF2_ADDR_SIZE - GET_MODE_SIZE (int_mode)) * BITS_PER_UNIT; add_loc_descr (&op0, int_loc_descriptor (shift)); add_loc_descr (&op0, new_loc_descr (DW_OP_shl, 0, 0)); add_loc_descr (&op1, int_loc_descriptor (shift)); add_loc_descr (&op1, new_loc_descr (DW_OP_shl, 0, 0)); } - else if (SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + else if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { - dw_die_ref type_die = base_type_for_mode (mode, 0); + dw_die_ref type_die = base_type_for_mode (int_mode, 0); dw_loc_descr_ref cvt; if (type_die == NULL) return NULL; @@ -14142,9 +14144,9 @@ minmax_loc_descriptor (rtx rtl, machine_ bra_node->dw_loc_oprnd1.val_class = dw_val_class_loc; bra_node->dw_loc_oprnd1.v.val_loc = drop_node; if ((GET_CODE (rtl) == SMIN || GET_CODE (rtl) == SMAX) - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) - ret = convert_descriptor_to_mode (mode, ret); + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) + ret = convert_descriptor_to_mode (int_mode, ret); return ret; } @@ -14605,6 +14607,7 @@ mem_loc_descriptor (rtx rtl, machine_mod if (mode != GET_MODE (rtl) && GET_MODE (rtl) != VOIDmode) return NULL; + scalar_int_mode int_mode, inner_mode; switch (GET_CODE (rtl)) { case POST_INC: @@ -14625,29 +14628,26 @@ mem_loc_descriptor (rtx rtl, machine_mod case TRUNCATE: if (inner == NULL_RTX) inner = XEXP (rtl, 0); - if (SCALAR_INT_MODE_P (mode) - && SCALAR_INT_MODE_P (GET_MODE (inner)) - && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + if (is_a (mode, &int_mode) + && is_a (GET_MODE (inner), &inner_mode) + && (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED - || (mode == Pmode && mem_mode != VOIDmode) + || (int_mode == Pmode && mem_mode != VOIDmode) #endif ) - && GET_MODE_SIZE (GET_MODE (inner)) <= DWARF2_ADDR_SIZE) + && GET_MODE_SIZE (inner_mode) <= DWARF2_ADDR_SIZE) { mem_loc_result = mem_loc_descriptor (inner, - GET_MODE (inner), + inner_mode, mem_mode, initialized); break; } if (dwarf_strict && dwarf_version < 5) break; - if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (inner))) - break; - if (GET_MODE_SIZE (mode) != GET_MODE_SIZE (GET_MODE (inner)) - && (!SCALAR_INT_MODE_P (mode) - || !SCALAR_INT_MODE_P (GET_MODE (inner)))) - break; - else + if (is_a (mode, &int_mode) + && is_a (GET_MODE (inner), &inner_mode) + ? GET_MODE_SIZE (int_mode) <= GET_MODE_SIZE (inner_mode) + : GET_MODE_SIZE (mode) == GET_MODE_SIZE (GET_MODE (inner))) { dw_die_ref type_die; dw_loc_descr_ref cvt; @@ -14672,8 +14672,8 @@ mem_loc_descriptor (rtx rtl, machine_mod cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, cvt); - if (SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) + if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE) { /* Convert it to untyped afterwards. */ cvt = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0); @@ -14683,12 +14683,12 @@ mem_loc_descriptor (rtx rtl, machine_mod break; case REG: - if (! SCALAR_INT_MODE_P (mode) - || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE + if (!is_a (mode, &int_mode) + || (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE && rtl != arg_pointer_rtx && rtl != frame_pointer_rtx #ifdef POINTERS_EXTEND_UNSIGNED - && (mode != Pmode || mem_mode == VOIDmode) + && (int_mode != Pmode || mem_mode == VOIDmode) #endif )) { @@ -14742,14 +14742,14 @@ mem_loc_descriptor (rtx rtl, machine_mod case SIGN_EXTEND: case ZERO_EXTEND: - if (!SCALAR_INT_MODE_P (mode)) + if (!is_a (mode, &int_mode)) break; op0 = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (XEXP (rtl, 0)), mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == 0) break; else if (GET_CODE (rtl) == ZERO_EXTEND - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE && GET_MODE_BITSIZE (GET_MODE (XEXP (rtl, 0))) < HOST_BITS_PER_WIDE_INT /* If DW_OP_const{1,2,4}u won't be used, it is shorter @@ -14763,7 +14763,7 @@ mem_loc_descriptor (rtx rtl, machine_mod int_loc_descriptor (GET_MODE_MASK (imode))); add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_and, 0, 0)); } - else if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) + else if (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE) { int shift = DWARF2_ADDR_SIZE - GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))); @@ -14787,7 +14787,7 @@ mem_loc_descriptor (rtx rtl, machine_mod GET_CODE (rtl) == ZERO_EXTEND); if (type_die1 == NULL) break; - type_die2 = base_type_for_mode (mode, 1); + type_die2 = base_type_for_mode (int_mode, 1); if (type_die2 == NULL) break; mem_loc_result = op0; @@ -14822,8 +14822,8 @@ mem_loc_descriptor (rtx rtl, machine_mod mem_loc_result = tls_mem_loc_descriptor (rtl); if (mem_loc_result != NULL) { - if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE - || !SCALAR_INT_MODE_P(mode)) + if (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { dw_die_ref type_die; dw_loc_descr_ref deref; @@ -14841,12 +14841,12 @@ mem_loc_descriptor (rtx rtl, machine_mod deref->dw_loc_oprnd2.v.val_die_ref.external = 0; add_loc_descr (&mem_loc_result, deref); } - else if (GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE) + else if (GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE) add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0)); else add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref_size, - GET_MODE_SIZE (mode), 0)); + GET_MODE_SIZE (int_mode), 0)); } break; @@ -14859,10 +14859,10 @@ mem_loc_descriptor (rtx rtl, machine_mod pool. */ case CONST: case SYMBOL_REF: - if (!SCALAR_INT_MODE_P (mode) - || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE + if (!is_a (mode, &int_mode) + || (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED - && (mode != Pmode || mem_mode == VOIDmode) + && (int_mode != Pmode || mem_mode == VOIDmode) #endif )) break; @@ -14891,8 +14891,8 @@ mem_loc_descriptor (rtx rtl, machine_mod if (!const_ok_for_output (rtl)) { if (GET_CODE (rtl) == CONST) - mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, - initialized); + mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0), int_mode, + mem_mode, initialized); break; } @@ -14914,8 +14914,8 @@ mem_loc_descriptor (rtx rtl, machine_mod return NULL; if (REG_P (ENTRY_VALUE_EXP (rtl))) { - if (!SCALAR_INT_MODE_P (mode) - || GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + if (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) op0 = mem_loc_descriptor (ENTRY_VALUE_EXP (rtl), mode, VOIDmode, VAR_INIT_STATUS_INITIALIZED); else @@ -14969,10 +14969,10 @@ mem_loc_descriptor (rtx rtl, machine_mod case PLUS: plus: if (is_based_loc (rtl) - && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + && is_a (mode, &int_mode) + && (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE || XEXP (rtl, 0) == arg_pointer_rtx - || XEXP (rtl, 0) == frame_pointer_rtx) - && SCALAR_INT_MODE_P (mode)) + || XEXP (rtl, 0) == frame_pointer_rtx)) mem_loc_result = based_loc_descr (XEXP (rtl, 0), INTVAL (XEXP (rtl, 1)), VAR_INIT_STATUS_INITIALIZED); @@ -15011,12 +15011,12 @@ mem_loc_descriptor (rtx rtl, machine_mod case DIV: if ((!dwarf_strict || dwarf_version >= 5) - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { mem_loc_result = typed_binop (DW_OP_div, rtl, base_type_for_mode (mode, 0), - mode, mem_mode); + int_mode, mem_mode); break; } op = DW_OP_div; @@ -15039,17 +15039,17 @@ mem_loc_descriptor (rtx rtl, machine_mod goto do_shift; do_shift: - if (!SCALAR_INT_MODE_P (mode)) + if (!is_a (mode, &int_mode)) break; - op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, + op0 = mem_loc_descriptor (XEXP (rtl, 0), int_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); { rtx rtlop1 = XEXP (rtl, 1); if (GET_MODE (rtlop1) != VOIDmode && GET_MODE_BITSIZE (GET_MODE (rtlop1)) - < GET_MODE_BITSIZE (mode)) - rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); - op1 = mem_loc_descriptor (rtlop1, mode, mem_mode, + < GET_MODE_BITSIZE (int_mode)) + rtlop1 = gen_rtx_ZERO_EXTEND (int_mode, rtlop1); + op1 = mem_loc_descriptor (rtlop1, int_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); } @@ -15116,16 +15116,16 @@ mem_loc_descriptor (rtx rtl, machine_mod case UDIV: if ((!dwarf_strict || dwarf_version >= 5) - && SCALAR_INT_MODE_P (mode)) + && is_a (mode, &int_mode)) { - if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE) + if (GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { op = DW_OP_div; goto do_binop; } mem_loc_result = typed_binop (DW_OP_div, rtl, - base_type_for_mode (mode, 1), - mode, mem_mode); + base_type_for_mode (int_mode, 1), + int_mode, mem_mode); } break; @@ -15153,9 +15153,10 @@ mem_loc_descriptor (rtx rtl, machine_mod break; case CONST_INT: - if (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + if (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE #ifdef POINTERS_EXTEND_UNSIGNED - || (mode == Pmode + || (int_mode == Pmode && mem_mode != VOIDmode && trunc_int_for_mode (INTVAL (rtl), ptr_mode) == INTVAL (rtl)) #endif @@ -15165,10 +15166,10 @@ mem_loc_descriptor (rtx rtl, machine_mod break; } if ((!dwarf_strict || dwarf_version >= 5) - && (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT - || GET_MODE_BITSIZE (mode) == HOST_BITS_PER_DOUBLE_INT)) + && (GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_WIDE_INT + || GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_DOUBLE_INT)) { - dw_die_ref type_die = base_type_for_mode (mode, 1); + dw_die_ref type_die = base_type_for_mode (int_mode, 1); scalar_int_mode amode; if (type_die == NULL) return NULL; @@ -15179,7 +15180,7 @@ mem_loc_descriptor (rtx rtl, machine_mod /* const DW_OP_convert vs. DW_OP_const_type . */ && size_of_int_loc_descriptor (INTVAL (rtl)) + 1 + 1 - < (unsigned long) 1 + 1 + 1 + GET_MODE_SIZE (mode)) + < (unsigned long) 1 + 1 + 1 + GET_MODE_SIZE (int_mode)) { mem_loc_result = int_loc_descriptor (INTVAL (rtl)); op0 = new_loc_descr (dwarf_OP (DW_OP_convert), 0, 0); @@ -15194,7 +15195,7 @@ mem_loc_descriptor (rtx rtl, machine_mod mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_die_ref; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.die = type_die; mem_loc_result->dw_loc_oprnd1.v.val_die_ref.external = 0; - if (GET_MODE_BITSIZE (mode) == HOST_BITS_PER_WIDE_INT) + if (GET_MODE_BITSIZE (int_mode) == HOST_BITS_PER_WIDE_INT) mem_loc_result->dw_loc_oprnd2.val_class = dw_val_class_const; else { @@ -15327,11 +15328,11 @@ mem_loc_descriptor (rtx rtl, machine_mod case SIGN_EXTRACT: if (CONST_INT_P (XEXP (rtl, 1)) && CONST_INT_P (XEXP (rtl, 2)) + && is_a (mode, &int_mode) && ((unsigned) INTVAL (XEXP (rtl, 1)) + (unsigned) INTVAL (XEXP (rtl, 2)) - <= GET_MODE_BITSIZE (mode)) - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE + <= GET_MODE_BITSIZE (int_mode)) + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE && GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) <= DWARF2_ADDR_SIZE) { int shift, size; @@ -15407,12 +15408,11 @@ mem_loc_descriptor (rtx rtl, machine_mod mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == NULL) break; - if (SCALAR_INT_MODE_P (GET_MODE (XEXP (rtl, 0))) + if (is_a (GET_MODE (XEXP (rtl, 0)), &int_mode) && (GET_CODE (rtl) == FLOAT - || GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) - <= DWARF2_ADDR_SIZE)) + || GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE)) { - type_die = base_type_for_mode (GET_MODE (XEXP (rtl, 0)), + type_die = base_type_for_mode (int_mode, GET_CODE (rtl) == UNSIGNED_FLOAT); if (type_die == NULL) break; @@ -15430,11 +15430,11 @@ mem_loc_descriptor (rtx rtl, machine_mod cvt->dw_loc_oprnd1.v.val_die_ref.die = type_die; cvt->dw_loc_oprnd1.v.val_die_ref.external = 0; add_loc_descr (&op0, cvt); - if (SCALAR_INT_MODE_P (mode) + if (is_a (mode, &int_mode) && (GET_CODE (rtl) == FIX - || GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE)) + || GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE)) { - op0 = convert_descriptor_to_mode (mode, op0); + op0 = convert_descriptor_to_mode (int_mode, op0); if (op0 == NULL) break; } @@ -15675,6 +15675,7 @@ loc_descriptor (rtx rtl, machine_mode mo enum var_init_status initialized) { dw_loc_descr_ref loc_result = NULL; + scalar_int_mode int_mode; switch (GET_CODE (rtl)) { @@ -15901,9 +15902,9 @@ loc_descriptor (rtx rtl, machine_mode mo /* FALLTHRU */ do_default: default: - if ((SCALAR_INT_MODE_P (mode) - && GET_MODE (rtl) == mode - && GET_MODE_SIZE (GET_MODE (rtl)) <= DWARF2_ADDR_SIZE + if ((is_a (mode, &int_mode) + && GET_MODE (rtl) == int_mode + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE && dwarf_version >= 4) || (!dwarf_strict && mode != VOIDmode && mode != BLKmode)) { Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:31.696428597 +0100 +++ gcc/expmed.c 2017-07-13 09:18:32.525352977 +0100 @@ -202,14 +202,15 @@ init_expmed_one_mode (struct init_expmed speed)); } - if (SCALAR_INT_MODE_P (mode)) + scalar_int_mode int_mode_to; + if (is_a (mode, &int_mode_to)) { FOR_EACH_MODE_IN_CLASS (mode_from, MODE_INT) - init_expmed_one_conv (all, mode, mode_from, speed); + init_expmed_one_conv (all, int_mode_to, mode_from, speed); - machine_mode wider_mode; - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_WIDER_MODE (mode).exists (&wider_mode)) + scalar_int_mode wider_mode; + if (GET_MODE_CLASS (int_mode_to) == MODE_INT + && GET_MODE_WIDER_MODE (int_mode_to).exists (&wider_mode)) { PUT_MODE (all->zext, wider_mode); PUT_MODE (all->wide_mult, wider_mode); @@ -218,8 +219,9 @@ init_expmed_one_mode (struct init_expmed set_mul_widen_cost (speed, wider_mode, set_src_cost (all->wide_mult, wider_mode, speed)); - set_mul_highpart_cost (speed, mode, - set_src_cost (all->wide_trunc, mode, speed)); + set_mul_highpart_cost (speed, int_mode_to, + set_src_cost (all->wide_trunc, + int_mode_to, speed)); } } } Index: gcc/lra-constraints.c =================================================================== --- gcc/lra-constraints.c 2017-07-05 16:29:19.599861904 +0100 +++ gcc/lra-constraints.c 2017-07-13 09:18:32.526352886 +0100 @@ -671,8 +671,11 @@ ok_for_base_p_nonstrict (rtx reg, machin lra_constraint_offset (int regno, machine_mode mode) { lra_assert (regno < FIRST_PSEUDO_REGISTER); - if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (mode) > UNITS_PER_WORD - && SCALAR_INT_MODE_P (mode)) + + scalar_int_mode int_mode; + if (WORDS_BIG_ENDIAN + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > UNITS_PER_WORD) return hard_regno_nregs[regno][mode] - 1; return 0; } Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:31.700428230 +0100 +++ gcc/optabs.c 2017-07-13 09:18:32.526352886 +0100 @@ -4996,9 +4996,9 @@ expand_fix (rtx to, rtx from, int unsign static rtx prepare_libcall_arg (rtx arg, int uintp) { - machine_mode mode = GET_MODE (arg); + scalar_int_mode mode; machine_mode arg_mode; - if (SCALAR_INT_MODE_P (mode)) + if (is_a (GET_MODE (arg), &mode)) { /* If we need to promote the integer function argument we need to do it here instead of inside emit_library_call_value because in Index: gcc/postreload.c =================================================================== --- gcc/postreload.c 2017-07-13 09:18:21.535428823 +0100 +++ gcc/postreload.c 2017-07-13 09:18:32.527352795 +0100 @@ -2154,7 +2154,7 @@ move2add_note_store (rtx dst, const_rtx { rtx_insn *insn = (rtx_insn *) data; unsigned int regno = 0; - machine_mode mode = GET_MODE (dst); + scalar_int_mode mode; /* Some targets do argument pushes without adding REG_INC notes. */ @@ -2174,8 +2174,10 @@ move2add_note_store (rtx dst, const_rtx else return; - if (SCALAR_INT_MODE_P (mode) - && GET_CODE (set) == SET) + if (!is_a (GET_MODE (dst), &mode)) + goto invalidate; + + if (GET_CODE (set) == SET) { rtx note, sym = NULL_RTX; rtx off; @@ -2202,8 +2204,7 @@ move2add_note_store (rtx dst, const_rtx } } - if (SCALAR_INT_MODE_P (mode) - && GET_CODE (set) == SET + if (GET_CODE (set) == SET && GET_CODE (SET_DEST (set)) != ZERO_EXTRACT && GET_CODE (SET_DEST (set)) != STRICT_LOW_PART) { Index: gcc/reload.c =================================================================== --- gcc/reload.c 2017-03-28 16:19:20.000000000 +0100 +++ gcc/reload.c 2017-07-13 09:18:32.527352795 +0100 @@ -2264,14 +2264,18 @@ operands_match_p (rtx x, rtx y) multiple hard register group of scalar integer registers, so that for example (reg:DI 0) and (reg:SI 1) will be considered the same register. */ - if (REG_WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD - && SCALAR_INT_MODE_P (GET_MODE (x)) + scalar_int_mode xmode; + if (REG_WORDS_BIG_ENDIAN + && is_a (GET_MODE (x), &xmode) + && GET_MODE_SIZE (xmode) > UNITS_PER_WORD && i < FIRST_PSEUDO_REGISTER) - i += hard_regno_nregs[i][GET_MODE (x)] - 1; - if (REG_WORDS_BIG_ENDIAN && GET_MODE_SIZE (GET_MODE (y)) > UNITS_PER_WORD - && SCALAR_INT_MODE_P (GET_MODE (y)) + i += hard_regno_nregs[i][xmode] - 1; + scalar_int_mode ymode; + if (REG_WORDS_BIG_ENDIAN + && is_a (GET_MODE (y), &ymode) + && GET_MODE_SIZE (ymode) > UNITS_PER_WORD && j < FIRST_PSEUDO_REGISTER) - j += hard_regno_nregs[j][GET_MODE (y)] - 1; + j += hard_regno_nregs[j][ymode] - 1; return i == j; } Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-02 10:05:20.997439436 +0100 +++ gcc/rtl.h 2017-07-13 09:18:32.528352705 +0100 @@ -3822,9 +3822,10 @@ struct GTY(()) cgraph_rtl_info { inline rtx_code load_extend_op (machine_mode mode) { - if (SCALAR_INT_MODE_P (mode) - && GET_MODE_PRECISION (mode) < BITS_PER_WORD) - return LOAD_EXTEND_OP (mode); + scalar_int_mode int_mode; + if (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) < BITS_PER_WORD) + return LOAD_EXTEND_OP (int_mode); return UNKNOWN; } Index: gcc/rtlhooks.c =================================================================== --- gcc/rtlhooks.c 2017-02-23 19:54:03.000000000 +0000 +++ gcc/rtlhooks.c 2017-07-13 09:18:32.528352705 +0100 @@ -64,11 +64,12 @@ gen_lowpart_general (machine_mode mode, gcc_assert (MEM_P (x)); /* The following exposes the use of "x" to CSE. */ - if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD - && SCALAR_INT_MODE_P (GET_MODE (x)) - && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (x)) + scalar_int_mode xmode; + if (is_a (GET_MODE (x), &xmode) + && GET_MODE_SIZE (xmode) <= UNITS_PER_WORD + && TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode) && !reload_completed) - return gen_lowpart_general (mode, force_reg (GET_MODE (x), x)); + return gen_lowpart_general (mode, force_reg (xmode, x)); if (WORDS_BIG_ENDIAN) offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD) Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:31.701428138 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:32.529352614 +0100 @@ -641,6 +641,8 @@ simplify_truncation (machine_mode mode, { unsigned int precision = GET_MODE_UNIT_PRECISION (mode); unsigned int op_precision = GET_MODE_UNIT_PRECISION (op_mode); + scalar_int_mode int_mode, int_op_mode, subreg_mode; + gcc_assert (precision <= op_precision); /* Optimize truncations of zero and sign extended values. */ @@ -806,19 +808,19 @@ simplify_truncation (machine_mode mode, if the MEM has a mode-dependent address. */ if ((GET_CODE (op) == LSHIFTRT || GET_CODE (op) == ASHIFTRT) - && SCALAR_INT_MODE_P (op_mode) + && is_a (op_mode, &int_op_mode) && MEM_P (XEXP (op, 0)) && CONST_INT_P (XEXP (op, 1)) && (INTVAL (XEXP (op, 1)) % GET_MODE_BITSIZE (mode)) == 0 && INTVAL (XEXP (op, 1)) > 0 - && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (op_mode) + && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (int_op_mode) && ! mode_dependent_address_p (XEXP (XEXP (op, 0), 0), MEM_ADDR_SPACE (XEXP (op, 0))) && ! MEM_VOLATILE_P (XEXP (op, 0)) && (GET_MODE_SIZE (mode) >= UNITS_PER_WORD || WORDS_BIG_ENDIAN == BYTES_BIG_ENDIAN)) { - int byte = subreg_lowpart_offset (mode, op_mode); + int byte = subreg_lowpart_offset (mode, int_op_mode); int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT; return adjust_address_nv (XEXP (op, 0), mode, (WORDS_BIG_ENDIAN @@ -839,21 +841,20 @@ simplify_truncation (machine_mode mode, /* (truncate:A (subreg:B (truncate:C X) 0)) is (truncate:A X). */ if (GET_CODE (op) == SUBREG - && SCALAR_INT_MODE_P (mode) + && is_a (mode, &int_mode) && SCALAR_INT_MODE_P (op_mode) - && SCALAR_INT_MODE_P (GET_MODE (SUBREG_REG (op))) + && is_a (GET_MODE (SUBREG_REG (op)), &subreg_mode) && GET_CODE (SUBREG_REG (op)) == TRUNCATE && subreg_lowpart_p (op)) { rtx inner = XEXP (SUBREG_REG (op), 0); - if (GET_MODE_PRECISION (mode) - <= GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op)))) - return simplify_gen_unary (TRUNCATE, mode, inner, GET_MODE (inner)); + if (GET_MODE_PRECISION (int_mode) <= GET_MODE_PRECISION (subreg_mode)) + return simplify_gen_unary (TRUNCATE, int_mode, inner, + GET_MODE (inner)); else /* If subreg above is paradoxical and C is narrower than A, return (subreg:A (truncate:C X) 0). */ - return simplify_gen_subreg (mode, SUBREG_REG (op), - GET_MODE (SUBREG_REG (op)), 0); + return simplify_gen_subreg (int_mode, SUBREG_REG (op), subreg_mode, 0); } /* (truncate:A (truncate:B X)) is (truncate:A X). */ @@ -915,6 +916,7 @@ simplify_unary_operation_1 (enum rtx_cod { enum rtx_code reversed; rtx temp; + scalar_int_mode inner; switch (code) { @@ -1147,9 +1149,8 @@ simplify_unary_operation_1 (enum rtx_cod /* (neg (lt x 0)) is (lshiftrt X C) if STORE_FLAG_VALUE is -1. */ if (GET_CODE (op) == LT && XEXP (op, 1) == const0_rtx - && SCALAR_INT_MODE_P (GET_MODE (XEXP (op, 0)))) + && is_a (GET_MODE (XEXP (op, 0)), &inner)) { - machine_mode inner = GET_MODE (XEXP (op, 0)); int isize = GET_MODE_PRECISION (inner); if (STORE_FLAG_VALUE == 1) { @@ -2128,6 +2129,7 @@ simplify_binary_operation_1 (enum rtx_co rtx tem, reversed, opleft, opright; HOST_WIDE_INT val; unsigned int width = GET_MODE_PRECISION (mode); + scalar_int_mode int_mode; /* Even if we can't compute a constant result, there are some cases worth simplifying. */ @@ -2178,66 +2180,66 @@ simplify_binary_operation_1 (enum rtx_co have X (if C is 2 in the example above). But don't make something more expensive than we had before. */ - if (SCALAR_INT_MODE_P (mode)) + if (is_a (mode, &int_mode)) { rtx lhs = op0, rhs = op1; - wide_int coeff0 = wi::one (GET_MODE_PRECISION (mode)); - wide_int coeff1 = wi::one (GET_MODE_PRECISION (mode)); + wide_int coeff0 = wi::one (GET_MODE_PRECISION (int_mode)); + wide_int coeff1 = wi::one (GET_MODE_PRECISION (int_mode)); if (GET_CODE (lhs) == NEG) { - coeff0 = wi::minus_one (GET_MODE_PRECISION (mode)); + coeff0 = wi::minus_one (GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == MULT && CONST_SCALAR_INT_P (XEXP (lhs, 1))) { - coeff0 = rtx_mode_t (XEXP (lhs, 1), mode); + coeff0 = rtx_mode_t (XEXP (lhs, 1), int_mode); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == ASHIFT && CONST_INT_P (XEXP (lhs, 1)) && INTVAL (XEXP (lhs, 1)) >= 0 - && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (int_mode)) { coeff0 = wi::set_bit_in_zero (INTVAL (XEXP (lhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } if (GET_CODE (rhs) == NEG) { - coeff1 = wi::minus_one (GET_MODE_PRECISION (mode)); + coeff1 = wi::minus_one (GET_MODE_PRECISION (int_mode)); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == MULT && CONST_INT_P (XEXP (rhs, 1))) { - coeff1 = rtx_mode_t (XEXP (rhs, 1), mode); + coeff1 = rtx_mode_t (XEXP (rhs, 1), int_mode); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == ASHIFT && CONST_INT_P (XEXP (rhs, 1)) && INTVAL (XEXP (rhs, 1)) >= 0 - && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (int_mode)) { coeff1 = wi::set_bit_in_zero (INTVAL (XEXP (rhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); rhs = XEXP (rhs, 0); } if (rtx_equal_p (lhs, rhs)) { - rtx orig = gen_rtx_PLUS (mode, op0, op1); + rtx orig = gen_rtx_PLUS (int_mode, op0, op1); rtx coeff; bool speed = optimize_function_for_speed_p (cfun); - coeff = immed_wide_int_const (coeff0 + coeff1, mode); + coeff = immed_wide_int_const (coeff0 + coeff1, int_mode); - tem = simplify_gen_binary (MULT, mode, lhs, coeff); - return (set_src_cost (tem, mode, speed) - <= set_src_cost (orig, mode, speed) ? tem : 0); + tem = simplify_gen_binary (MULT, int_mode, lhs, coeff); + return (set_src_cost (tem, int_mode, speed) + <= set_src_cost (orig, int_mode, speed) ? tem : 0); } } @@ -2355,67 +2357,67 @@ simplify_binary_operation_1 (enum rtx_co have X (if C is 2 in the example above). But don't make something more expensive than we had before. */ - if (SCALAR_INT_MODE_P (mode)) + if (is_a (mode, &int_mode)) { rtx lhs = op0, rhs = op1; - wide_int coeff0 = wi::one (GET_MODE_PRECISION (mode)); - wide_int negcoeff1 = wi::minus_one (GET_MODE_PRECISION (mode)); + wide_int coeff0 = wi::one (GET_MODE_PRECISION (int_mode)); + wide_int negcoeff1 = wi::minus_one (GET_MODE_PRECISION (int_mode)); if (GET_CODE (lhs) == NEG) { - coeff0 = wi::minus_one (GET_MODE_PRECISION (mode)); + coeff0 = wi::minus_one (GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == MULT && CONST_SCALAR_INT_P (XEXP (lhs, 1))) { - coeff0 = rtx_mode_t (XEXP (lhs, 1), mode); + coeff0 = rtx_mode_t (XEXP (lhs, 1), int_mode); lhs = XEXP (lhs, 0); } else if (GET_CODE (lhs) == ASHIFT && CONST_INT_P (XEXP (lhs, 1)) && INTVAL (XEXP (lhs, 1)) >= 0 - && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (lhs, 1)) < GET_MODE_PRECISION (int_mode)) { coeff0 = wi::set_bit_in_zero (INTVAL (XEXP (lhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); lhs = XEXP (lhs, 0); } if (GET_CODE (rhs) == NEG) { - negcoeff1 = wi::one (GET_MODE_PRECISION (mode)); + negcoeff1 = wi::one (GET_MODE_PRECISION (int_mode)); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == MULT && CONST_INT_P (XEXP (rhs, 1))) { - negcoeff1 = wi::neg (rtx_mode_t (XEXP (rhs, 1), mode)); + negcoeff1 = wi::neg (rtx_mode_t (XEXP (rhs, 1), int_mode)); rhs = XEXP (rhs, 0); } else if (GET_CODE (rhs) == ASHIFT && CONST_INT_P (XEXP (rhs, 1)) && INTVAL (XEXP (rhs, 1)) >= 0 - && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (mode)) + && INTVAL (XEXP (rhs, 1)) < GET_MODE_PRECISION (int_mode)) { negcoeff1 = wi::set_bit_in_zero (INTVAL (XEXP (rhs, 1)), - GET_MODE_PRECISION (mode)); + GET_MODE_PRECISION (int_mode)); negcoeff1 = -negcoeff1; rhs = XEXP (rhs, 0); } if (rtx_equal_p (lhs, rhs)) { - rtx orig = gen_rtx_MINUS (mode, op0, op1); + rtx orig = gen_rtx_MINUS (int_mode, op0, op1); rtx coeff; bool speed = optimize_function_for_speed_p (cfun); - coeff = immed_wide_int_const (coeff0 + negcoeff1, mode); + coeff = immed_wide_int_const (coeff0 + negcoeff1, int_mode); - tem = simplify_gen_binary (MULT, mode, lhs, coeff); - return (set_src_cost (tem, mode, speed) - <= set_src_cost (orig, mode, speed) ? tem : 0); + tem = simplify_gen_binary (MULT, int_mode, lhs, coeff); + return (set_src_cost (tem, int_mode, speed) + <= set_src_cost (orig, int_mode, speed) ? tem : 0); } } @@ -3890,8 +3892,6 @@ simplify_binary_operation_1 (enum rtx_co simplify_const_binary_operation (enum rtx_code code, machine_mode mode, rtx op0, rtx op1) { - unsigned int width = GET_MODE_PRECISION (mode); - if (VECTOR_MODE_P (mode) && code != VEC_CONCAT && GET_CODE (op0) == CONST_VECTOR @@ -4085,15 +4085,15 @@ simplify_const_binary_operation (enum rt } /* We can fold some multi-word operations. */ - if ((GET_MODE_CLASS (mode) == MODE_INT - || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT) + scalar_int_mode int_mode; + if (is_a (mode, &int_mode) && CONST_SCALAR_INT_P (op0) && CONST_SCALAR_INT_P (op1)) { wide_int result; bool overflow; - rtx_mode_t pop0 = rtx_mode_t (op0, mode); - rtx_mode_t pop1 = rtx_mode_t (op1, mode); + rtx_mode_t pop0 = rtx_mode_t (op0, int_mode); + rtx_mode_t pop1 = rtx_mode_t (op1, int_mode); #if TARGET_SUPPORTS_WIDE_INT == 0 /* This assert keeps the simplification from producing a result @@ -4102,7 +4102,7 @@ simplify_const_binary_operation (enum rt simplify something and so you if you added this to the test above the code would die later anyway. If this assert happens, you just need to make the port support wide int. */ - gcc_assert (width <= HOST_BITS_PER_DOUBLE_INT); + gcc_assert (GET_MODE_PRECISION (int_mode) <= HOST_BITS_PER_DOUBLE_INT); #endif switch (code) { @@ -4176,8 +4176,8 @@ simplify_const_binary_operation (enum rt { wide_int wop1 = pop1; if (SHIFT_COUNT_TRUNCATED) - wop1 = wi::umod_trunc (wop1, width); - else if (wi::geu_p (wop1, width)) + wop1 = wi::umod_trunc (wop1, GET_MODE_PRECISION (int_mode)); + else if (wi::geu_p (wop1, GET_MODE_PRECISION (int_mode))) return NULL_RTX; switch (code) @@ -4223,7 +4223,7 @@ simplify_const_binary_operation (enum rt default: return NULL_RTX; } - return immed_wide_int_const (result, mode); + return immed_wide_int_const (result, int_mode); } return NULL_RTX; @@ -5145,12 +5145,14 @@ simplify_const_relational_operation (enu } /* Optimize comparisons with upper and lower bounds. */ - if (HWI_COMPUTABLE_MODE_P (mode) - && CONST_INT_P (trueop1) + scalar_int_mode int_mode; + if (CONST_INT_P (trueop1) + && is_a (mode, &int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode) && !side_effects_p (trueop0)) { int sign; - unsigned HOST_WIDE_INT nonzero = nonzero_bits (trueop0, mode); + unsigned HOST_WIDE_INT nonzero = nonzero_bits (trueop0, int_mode); HOST_WIDE_INT val = INTVAL (trueop1); HOST_WIDE_INT mmin, mmax; @@ -5163,7 +5165,7 @@ simplify_const_relational_operation (enu sign = 1; /* Get a reduced range if the sign bit is zero. */ - if (nonzero <= (GET_MODE_MASK (mode) >> 1)) + if (nonzero <= (GET_MODE_MASK (int_mode) >> 1)) { mmin = 0; mmax = nonzero; @@ -5171,13 +5173,14 @@ simplify_const_relational_operation (enu else { rtx mmin_rtx, mmax_rtx; - get_mode_bounds (mode, sign, mode, &mmin_rtx, &mmax_rtx); + get_mode_bounds (int_mode, sign, int_mode, &mmin_rtx, &mmax_rtx); mmin = INTVAL (mmin_rtx); mmax = INTVAL (mmax_rtx); if (sign) { - unsigned int sign_copies = num_sign_bit_copies (trueop0, mode); + unsigned int sign_copies + = num_sign_bit_copies (trueop0, int_mode); mmin >>= (sign_copies - 1); mmax >>= (sign_copies - 1); @@ -6229,12 +6232,14 @@ simplify_subreg (machine_mode outermode, return CONST0_RTX (outermode); } - if (SCALAR_INT_MODE_P (outermode) - && SCALAR_INT_MODE_P (innermode) - && GET_MODE_PRECISION (outermode) < GET_MODE_PRECISION (innermode) - && byte == subreg_lowpart_offset (outermode, innermode)) + scalar_int_mode int_outermode, int_innermode; + if (is_a (outermode, &int_outermode) + && is_a (innermode, &int_innermode) + && (GET_MODE_PRECISION (int_outermode) + < GET_MODE_PRECISION (int_innermode)) + && byte == subreg_lowpart_offset (int_outermode, int_innermode)) { - rtx tem = simplify_truncation (outermode, op, innermode); + rtx tem = simplify_truncation (int_outermode, op, int_innermode); if (tem) return tem; } Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:31.701428138 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:32.529352614 +0100 @@ -412,8 +412,10 @@ bitwise_mode_for_mode (machine_mode mode { /* Quick exit if we already have a suitable mode. */ unsigned int bitsize = GET_MODE_BITSIZE (mode); - if (SCALAR_INT_MODE_P (mode) && bitsize <= MAX_FIXED_MODE_SIZE) - return mode; + scalar_int_mode int_mode; + if (is_a (mode, &int_mode) + && GET_MODE_BITSIZE (int_mode) <= MAX_FIXED_MODE_SIZE) + return int_mode; /* Reuse the sanity checks from int_mode_for_mode. */ gcc_checking_assert ((int_mode_for_mode (mode), true)); Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-07-13 09:18:30.093576660 +0100 +++ gcc/var-tracking.c 2017-07-13 09:18:32.530352523 +0100 @@ -1008,6 +1008,7 @@ adjust_mems (rtx loc, const_rtx old_rtx, rtx mem, addr = loc, tem; machine_mode mem_mode_save; bool store_save; + scalar_int_mode tem_mode, tem_subreg_mode; switch (GET_CODE (loc)) { case REG: @@ -1122,16 +1123,14 @@ adjust_mems (rtx loc, const_rtx old_rtx, || GET_CODE (SUBREG_REG (tem)) == MINUS || GET_CODE (SUBREG_REG (tem)) == MULT || GET_CODE (SUBREG_REG (tem)) == ASHIFT) - && (GET_MODE_CLASS (GET_MODE (tem)) == MODE_INT - || GET_MODE_CLASS (GET_MODE (tem)) == MODE_PARTIAL_INT) - && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_INT - || GET_MODE_CLASS (GET_MODE (SUBREG_REG (tem))) == MODE_PARTIAL_INT) - && GET_MODE_PRECISION (GET_MODE (tem)) - < GET_MODE_PRECISION (GET_MODE (SUBREG_REG (tem))) + && is_a (GET_MODE (tem), &tem_mode) + && is_a (GET_MODE (SUBREG_REG (tem)), + &tem_subreg_mode) + && (GET_MODE_PRECISION (tem_mode) + < GET_MODE_PRECISION (tem_subreg_mode)) && subreg_lowpart_p (tem) && use_narrower_mode_test (SUBREG_REG (tem), tem)) - return use_narrower_mode (SUBREG_REG (tem), GET_MODE (tem), - GET_MODE (SUBREG_REG (tem))); + return use_narrower_mode (SUBREG_REG (tem), tem_mode, tem_subreg_mode); return tem; case ASM_OPERANDS: /* Don't do any replacements in second and following @@ -6301,15 +6300,15 @@ prepare_call_arguments (basic_block bb, else if (REG_P (x)) { cselib_val *val = cselib_lookup (x, GET_MODE (x), 0, VOIDmode); + scalar_int_mode mode; if (val && cselib_preserved_value_p (val)) item = val->val_rtx; - else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT - || GET_MODE_CLASS (GET_MODE (x)) == MODE_PARTIAL_INT) + else if (is_a (GET_MODE (x), &mode)) { - machine_mode mode; - - FOR_EACH_WIDER_MODE (mode, GET_MODE (x)) + opt_scalar_int_mode mode_iter; + FOR_EACH_WIDER_MODE (mode_iter, mode) { + mode = *mode_iter; if (GET_MODE_BITSIZE (mode) > BITS_PER_WORD) break; Index: gcc/ada/gcc-interface/decl.c =================================================================== --- gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:29.208659553 +0100 +++ gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:32.518353613 +0100 @@ -8801,9 +8801,10 @@ check_ok_for_atomic_type (tree type, Ent /* Consider all aligned floating-point types atomic and any aligned types that are represented by integers no wider than a machine word. */ + scalar_int_mode int_mode; if ((mclass == MODE_FLOAT - || ((mclass == MODE_INT || mclass == MODE_PARTIAL_INT) - && GET_MODE_BITSIZE (mode) <= BITS_PER_WORD)) + || (is_a (mode, &int_mode) + && GET_MODE_BITSIZE (int_mode) <= BITS_PER_WORD)) && align >= GET_MODE_ALIGNMENT (mode)) return; Index: gcc/ada/gcc-interface/trans.c =================================================================== --- gcc/ada/gcc-interface/trans.c 2017-06-30 12:50:38.300660048 +0100 +++ gcc/ada/gcc-interface/trans.c 2017-07-13 09:18:32.519353522 +0100 @@ -1275,6 +1275,7 @@ Pragma_to_gnu (Node_Id gnat_node) tree gnu_expr = gnat_to_gnu (gnat_expr); int use_address; machine_mode mode; + scalar_int_mode int_mode; tree asm_constraint = NULL_TREE; #ifdef ASM_COMMENT_START char *comment; @@ -1286,9 +1287,8 @@ Pragma_to_gnu (Node_Id gnat_node) /* Use the value only if it fits into a normal register, otherwise use the address. */ mode = TYPE_MODE (TREE_TYPE (gnu_expr)); - use_address = ((GET_MODE_CLASS (mode) != MODE_INT - && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT) - || GET_MODE_SIZE (mode) > UNITS_PER_WORD); + use_address = (!is_a (mode, &int_mode) + || GET_MODE_SIZE (int_mode) > UNITS_PER_WORD); if (use_address) gnu_expr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr); Index: gcc/ada/gcc-interface/utils.c =================================================================== --- gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:29.208659553 +0100 +++ gcc/ada/gcc-interface/utils.c 2017-07-13 09:18:32.519353522 +0100 @@ -3470,8 +3470,9 @@ gnat_type_for_mode (machine_mode mode, i return float_type_for_precision (GET_MODE_PRECISION (float_mode), float_mode); - if (SCALAR_INT_MODE_P (mode)) - return gnat_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); + scalar_int_mode int_mode; + if (is_a (mode, &int_mode)) + return gnat_type_for_size (GET_MODE_BITSIZE (int_mode), unsignedp); if (VECTOR_MODE_P (mode)) { Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c 2017-07-13 09:18:26.363931259 +0100 +++ gcc/fortran/trans-types.c 2017-07-13 09:18:32.525352977 +0100 @@ -3109,14 +3109,15 @@ gfc_type_for_mode (machine_mode mode, in { int i; tree *base; + scalar_int_mode int_mode; if (GET_MODE_CLASS (mode) == MODE_FLOAT) base = gfc_real_types; else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) base = gfc_complex_types; - else if (SCALAR_INT_MODE_P (mode)) + else if (is_a (mode, &int_mode)) { - tree type = gfc_type_for_size (GET_MODE_PRECISION (mode), unsignedp); + tree type = gfc_type_for_size (GET_MODE_PRECISION (int_mode), unsignedp); return type != NULL_TREE && mode == TYPE_MODE (type) ? type : NULL_TREE; } else if (VECTOR_MODE_P (mode)) From patchwork Thu Jul 13 08:46:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107608 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1930835qge; Thu, 13 Jul 2017 01:48:07 -0700 (PDT) X-Received: by 10.98.166.91 with SMTP id t88mr60600121pfe.153.1499935687705; Thu, 13 Jul 2017 01:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935687; cv=none; d=google.com; s=arc-20160816; b=LC6mO9uPWKOGImb4/4oUzcRt/Xvm9SGbdKUyw3Gc/zKHMKm6Prd4gLBAdIlWfjEGo9 pxuAThtSjRrSML12OMBR+0pRzgQj79NcPzC+B2QStsyeYly1B/72kOVrdlC7iHzAn9ur RinWE9yLVbhbazdCGmULA5oYMCrdmzXAxh7k5DL/eCS/SiAo9qMSoZjWJDx3JP6cth02 QFqxuBx0GSekSf4f1VS/nefTBZy0QMttxulCwIcYwcAWlUXuLoOIssy/wp3MWXeC1aGg /RxYmGvq/S+7Nw5T/muqyvAmRkEkyA6SXCdjq9JR9QbvKz4uR4SiLnfYX/1AtvJ1liCy tUJw== 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=KRDZJO7CAxil5zuegm4qHY23s6ecnIUCf9t2q4i4yG4=; b=M5/hbJn7V7Vd+V9TC788FnMQ1PtqaR4BE3w0qWH8E/lMWa/RE6NIV9RAuB27bWQEok YtpYJXlp1HrB08wByYN+8mRlpNrTp7JjtSVihvBy710EbpOPtAEvjbSQ9SI4TGR+AZoW xqSEkLs+7TmQ6wZL/Mzn3utLiLpEavj6wKRc1D2sl/vdX6YLUYsBsU4XxMnjt64pggkJ dGjtdh/tQ+ju3ggOHkyHZsXpX+MuiufLWiKqvtqe+0f59tBcXazO5VyLmR/xRYKlzu1P rYstr2UuxxZKAY8DWJM1S//fD6jOXRsIehuSt5FOt84S+m++XUDSrT6fIYPXkZd8Nhs9 TLvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=e+WLnE5X; spf=pass (google.com: domain of gcc-patches-return-458013-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458013-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 t19si4005349plj.412.2017.07.13.01.48.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458013-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=e+WLnE5X; spf=pass (google.com: domain of gcc-patches-return-458013-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458013-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=MzTxVZmOA6ZfcAnAa7OkDXJpSAn8N iX5z4e4IjIyDLRKGJ902fHKstQukcGnUeKkDKi1JApzmJPgLSkBXy5rVlTH+c8Zw RT5NNP+lsxFi44ePh4RwPMS51UX75zlQXtNYRL+tmsuYGQaer92HDPp6Z5CmSXop RrKATO4Uieqcl0= 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=MT5c7BRDMA+LUcEsZwUmfFEH/hE=; b=e+W LnE5XMVV3PffzEioxTu8z3bW/0FeBdg7B2DAbyCfYSbRFZQTtqcyfzACGkTorE3m FRTrNdZAAvUiwV7OK8biyVmyFbWYVsgEYSCCrGtGGwyfhiGlHRus4Zq/qcJkQ+gO KOOJmenCu8ARFjYrsp1tb1/8NZxXLekJU6/SOTyI= Received: (qmail 57457 invoked by alias); 13 Jul 2017 08:46:54 -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 57145 invoked by uid 89); 13 Jul 2017 08:46:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2314 X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:46:50 +0000 Received: by mail-wr0-f174.google.com with SMTP id 77so49600654wrb.1 for ; Thu, 13 Jul 2017 01:46:49 -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=KRDZJO7CAxil5zuegm4qHY23s6ecnIUCf9t2q4i4yG4=; b=navZjCAawYtw2QOrkorJqxjSbT9ZqwYqkxaSyuya2oc/8xTdFIiFo5dpeTNgQlMXnF rSlbtJvAHKd0eOg+RftmyMJviBy4dhX/ugSoP/QjULhp7Ks9iQKP+NehkKUQFvXRXF/6 Ml8wm1lIYztd0sq4LPfyOxZqbrISoAlMD05ezDMI0luZFWVCE3hNzJuOXKkrvFLtRDV/ e4i90RdwMloJYmNiBqnC0/RrFabnjuQn2veNJP44dkA0qYYOtuyTW7hp1RCd13VxdrSr NVFZREFIthD1YJoyTbZkC79l/nmZpXcgvp8EPcsw9hf4EXiNE3vC+ZoYhOIfL7BuW8Me oE1w== X-Gm-Message-State: AIVw113g0iypebxInkeGfulT4JVRdJA16VRIFcyaMKXGZqgo3OokKpcX ouFZL22LqwPqDo70a+p8ZQ== X-Received: by 10.223.155.197 with SMTP id e5mr760512wrc.55.1499935607772; Thu, 13 Jul 2017 01:46:47 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id h130sm5115952wmd.34.2017.07.13.01.46.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:46:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [22/77] Replace !VECTOR_MODE_P with is_a References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:46:45 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87iniwk9l6.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces some checks of !VECTOR_MODE_P with checks of is_a , in cases where the scalar integer modes were the only useful alternatives left. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * simplify-rtx.c (simplify_binary_operation_1): Use is_a instead of !VECTOR_MODE_P. Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:32.529352614 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:33.217290298 +0100 @@ -2129,7 +2129,7 @@ simplify_binary_operation_1 (enum rtx_co rtx tem, reversed, opleft, opright; HOST_WIDE_INT val; unsigned int width = GET_MODE_PRECISION (mode); - scalar_int_mode int_mode; + scalar_int_mode int_mode, inner_mode; /* Even if we can't compute a constant result, there are some cases worth simplifying. */ @@ -3365,27 +3365,24 @@ simplify_binary_operation_1 (enum rtx_co (subreg:M1 ([a|l]shiftrt:M2 (reg:M2) (const_int )) ). */ if ((code == ASHIFTRT || code == LSHIFTRT) - && !VECTOR_MODE_P (mode) + && is_a (mode, &int_mode) && SUBREG_P (op0) && CONST_INT_P (op1) && GET_CODE (SUBREG_REG (op0)) == LSHIFTRT - && !VECTOR_MODE_P (GET_MODE (SUBREG_REG (op0))) + && is_a (GET_MODE (SUBREG_REG (op0)), + &inner_mode) && CONST_INT_P (XEXP (SUBREG_REG (op0), 1)) - && (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0))) - > GET_MODE_BITSIZE (mode)) + && GET_MODE_BITSIZE (inner_mode) > GET_MODE_BITSIZE (int_mode) && (INTVAL (XEXP (SUBREG_REG (op0), 1)) - == (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0))) - - GET_MODE_BITSIZE (mode))) + == GET_MODE_BITSIZE (inner_mode) - GET_MODE_BITSIZE (int_mode)) && subreg_lowpart_p (op0)) { rtx tmp = GEN_INT (INTVAL (XEXP (SUBREG_REG (op0), 1)) + INTVAL (op1)); - machine_mode inner_mode = GET_MODE (SUBREG_REG (op0)); - tmp = simplify_gen_binary (code, - GET_MODE (SUBREG_REG (op0)), + tmp = simplify_gen_binary (code, inner_mode, XEXP (SUBREG_REG (op0), 0), tmp); - return lowpart_subreg (mode, tmp, inner_mode); + return lowpart_subreg (int_mode, tmp, inner_mode); } if (SHIFT_COUNT_TRUNCATED && CONST_INT_P (op1)) From patchwork Thu Jul 13 08:47:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107609 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1931086qge; Thu, 13 Jul 2017 01:48:31 -0700 (PDT) X-Received: by 10.98.82.87 with SMTP id g84mr59671498pfb.232.1499935710940; Thu, 13 Jul 2017 01:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935710; cv=none; d=google.com; s=arc-20160816; b=0Oe0BuYSfI6vK/qytwn6iDChWJlI/MURYM1BTiqc2rz5wHMkPx/9uOnJKP/8cu6JNA 1HhrBZ1QSijENjsSR4kneAJLk2/hMXa7+UmJwxVn284pwLaw0rkvcHreMHdo1lcwGzeA 5jMjyVWQ2jpLWEgH/gQc0MNLmZKxxP9LgBqX+ke+Qfyh1eArgjf81o+HP8JU/9zpC+9S Vz6dxZ+wrI1AEAPhacMMJhgBdbqi2T0N/UwK1AZJV+IKI+NT6O2AG+4lXTqMU4aU7cjV vMYBkRr44grgmywLRG/4+zl+dDgEaVvdSW4ah0SwsJm6W6ph5IT94I1cbUmcbnPL73zf kpKQ== 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=n9t9/lxKBsZug+TPRkx/f0LN91/v7DvC6apuQ4eimRE=; b=gvq3M9qMb/18s3TYIrS+xQJti/1DfX+unucZ0nUEcZ9gRnu5s564HgQv4S8V24KPNi 9iFQoUkL8W8UwaXIFmh9ZQaNF3+icxHOK8Qbx6qonGWqsXe/bTOxkcCmxE4HDqzKNXlf aL0rk1WxRBprtRcIsF+7jsXbN+6OxTOMWLduWGmczdQnJnVLR2lcS73TZD0Oyg4/YjeO vceKhLX2vqNQs+k7qWlyAhuQYlP/+a1QXd3mKVniCHnJFdU+0FVHqaL7LckuagZgQTou A8zQ2iYlZG7Ai+GHXBMvU70iDpen9HNfvFRPUzziJllni/FtkeIeocemd40pkJ5wX5Mf r7oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=gncD3CYJ; spf=pass (google.com: domain of gcc-patches-return-458014-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458014-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 q1si3788749pgs.23.2017.07.13.01.48.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:48:30 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458014-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=gncD3CYJ; spf=pass (google.com: domain of gcc-patches-return-458014-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458014-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=EaIpsa5xh+KlcQ9yc0s0vCNNhaGk+ EfDsEu3q97G1FGDNidi1DMEjPepQSZKITyz0xLsZ1gZfQcn8aCTSexZThu5hV5ND 44jLEfk1VkFec+zVbc77NOz+gsckUQ+vFduV9lR5igHNXInp+CNneoLlwh9Z+X+t wuIgxuHxPD0xz8= 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=uJUvwaOQ5nRpQEHOW3Gn61+hiOY=; b=gnc D3CYJMB9PKTyi7yxQ7n0ucoKxCTsE6/gNPHBqVtzDCVmMMYcql+uEkWkb8vGkKoD 8X0r/IRMCSaejosBO8ae8gjZxN2J8Wm6b8Ze3PNCbGyYcfmYHyZMxQ9QgPUw27V9 FOCaf+npSeT7IBTXptVrL9ZJRBRIbqvu/urshSE0= Received: (qmail 68771 invoked by alias); 13 Jul 2017 08:47:16 -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 68178 invoked by uid 89); 13 Jul 2017 08:47:15 -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-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:47:11 +0000 Received: by mail-wm0-f44.google.com with SMTP id f67so18161333wmh.1 for ; Thu, 13 Jul 2017 01:47:11 -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=n9t9/lxKBsZug+TPRkx/f0LN91/v7DvC6apuQ4eimRE=; b=Xjyoz8lEMQp8hKGMD3jfpcNpjNBkQWWcfbw8Kg13TEAliM+0Z34LHJM5yqemMhZwwJ dp0sfzTUh7u4Lq9idHRx3jHsjnYnWto1iTO23W3phvtOfidWn6Pl7jzLCRqaOTJ1H+7W 056Bl7vhF6GDZ82Pr8RMSRcIhuuJ6WcQGIF2CUOqbOxWMtCPuioNfFaQZsgKzYTah6s7 yhgiCG2oMquPFFjAisyqU3yhv830DqBJoEadmETz+BSP3+PW75HrKQ03iyurcKygEjTP L0xx6iB+ZcZYdbxKmWgZxS1fvpKv9WAbuPx2ynYLPMP8SYcHpItlN2mzQ1yfhUSFwx8J Yolw== X-Gm-Message-State: AIVw110KUoRYTl0pY1nrZINuF4iORXhj6JiWdpmglGue0DWl2lL8Hiy2 x6QvdbNXg0O3pHcntpuP8g== X-Received: by 10.28.46.3 with SMTP id u3mr1150839wmu.68.1499935629340; Thu, 13 Jul 2017 01:47:09 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id j190sm6139482wmd.22.2017.07.13.01.47.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:47:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [23/77] Replace != VOIDmode checks with is_a References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:47:06 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87eftkk9kl.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces some checks against VOIDmode with checks of is_a , in cases where scalar integer modes were the only useful alternatives left. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * cfgexpand.c (expand_debug_expr): Use is_a instead of != VOIDmode. * combine.c (if_then_else_cond): Likewise. (change_zero_ext): Likewise. * dwarf2out.c (mem_loc_descriptor): Likewise. (loc_descriptor): Likewise. * rtlanal.c (canonicalize_condition): Likewise. * simplify-rtx.c (simplify_relational_operation_1): Likewise. Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:32.520353432 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:33.650251357 +0100 @@ -4137,7 +4137,7 @@ expand_debug_expr (tree exp) machine_mode inner_mode = VOIDmode; int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp)); addr_space_t as; - scalar_int_mode op1_mode; + scalar_int_mode op0_mode, op1_mode; switch (TREE_CODE_CLASS (TREE_CODE (exp))) { @@ -4579,23 +4579,23 @@ expand_debug_expr (tree exp) size_t, we need to check for mis-matched modes and correct the addend. */ if (op0 && op1 - && GET_MODE (op0) != VOIDmode && GET_MODE (op1) != VOIDmode - && GET_MODE (op0) != GET_MODE (op1)) + && is_a (GET_MODE (op0), &op0_mode) + && is_a (GET_MODE (op1), &op1_mode) + && op0_mode != op1_mode) { - if (GET_MODE_BITSIZE (GET_MODE (op0)) < GET_MODE_BITSIZE (GET_MODE (op1)) - /* If OP0 is a partial mode, then we must truncate, even if it has - the same bitsize as OP1 as GCC's representation of partial modes - is opaque. */ - || (GET_MODE_CLASS (GET_MODE (op0)) == MODE_PARTIAL_INT - && GET_MODE_BITSIZE (GET_MODE (op0)) == GET_MODE_BITSIZE (GET_MODE (op1)))) - op1 = simplify_gen_unary (TRUNCATE, GET_MODE (op0), op1, - GET_MODE (op1)); + if (GET_MODE_BITSIZE (op0_mode) < GET_MODE_BITSIZE (op1_mode) + /* If OP0 is a partial mode, then we must truncate, even + if it has the same bitsize as OP1 as GCC's + representation of partial modes is opaque. */ + || (GET_MODE_CLASS (op0_mode) == MODE_PARTIAL_INT + && (GET_MODE_BITSIZE (op0_mode) + == GET_MODE_BITSIZE (op1_mode)))) + op1 = simplify_gen_unary (TRUNCATE, op0_mode, op1, op1_mode); else /* We always sign-extend, regardless of the signedness of the operand, because the operand is always unsigned here even if the original C expression is signed. */ - op1 = simplify_gen_unary (SIGN_EXTEND, GET_MODE (op0), op1, - GET_MODE (op1)); + op1 = simplify_gen_unary (SIGN_EXTEND, op0_mode, op1, op1_mode); } /* Fall through. */ case PLUS_EXPR: Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:32.521353341 +0100 +++ gcc/combine.c 2017-07-13 09:18:33.652251177 +0100 @@ -9041,6 +9041,7 @@ if_then_else_cond (rtx x, rtx *ptrue, rt enum rtx_code code = GET_CODE (x); rtx cond0, cond1, true0, true1, false0, false1; unsigned HOST_WIDE_INT nz; + scalar_int_mode int_mode; /* If we are comparing a value against zero, we are done. */ if ((code == NE || code == EQ) @@ -9237,8 +9238,9 @@ if_then_else_cond (rtx x, rtx *ptrue, rt /* If X is known to be either 0 or -1, those are the true and false values when testing X. */ else if (x == constm1_rtx || x == const0_rtx - || (mode != VOIDmode && mode != BLKmode - && num_sign_bit_copies (x, mode) == GET_MODE_PRECISION (mode))) + || (is_a (mode, &int_mode) + && (num_sign_bit_copies (x, int_mode) + == GET_MODE_PRECISION (int_mode)))) { *ptrue = constm1_rtx, *pfalse = const0_rtx; return x; @@ -11293,7 +11295,7 @@ change_zero_ext (rtx pat) FOR_EACH_SUBRTX_PTR (iter, array, src, NONCONST) { rtx x = **iter; - scalar_int_mode mode; + scalar_int_mode mode, inner_mode; if (!is_a (GET_MODE (x), &mode)) continue; int size; @@ -11301,12 +11303,9 @@ change_zero_ext (rtx pat) if (GET_CODE (x) == ZERO_EXTRACT && CONST_INT_P (XEXP (x, 1)) && CONST_INT_P (XEXP (x, 2)) - && GET_MODE (XEXP (x, 0)) != VOIDmode - && GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - <= GET_MODE_PRECISION (mode)) + && is_a (GET_MODE (XEXP (x, 0)), &inner_mode) + && GET_MODE_PRECISION (inner_mode) <= GET_MODE_PRECISION (mode)) { - machine_mode inner_mode = GET_MODE (XEXP (x, 0)); - size = INTVAL (XEXP (x, 1)); int start = INTVAL (XEXP (x, 2)); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:32.524353068 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:33.654250997 +0100 @@ -14607,7 +14607,7 @@ mem_loc_descriptor (rtx rtl, machine_mod if (mode != GET_MODE (rtl) && GET_MODE (rtl) != VOIDmode) return NULL; - scalar_int_mode int_mode, inner_mode; + scalar_int_mode int_mode, inner_mode, op1_mode; switch (GET_CODE (rtl)) { case POST_INC: @@ -15045,9 +15045,8 @@ mem_loc_descriptor (rtx rtl, machine_mod VAR_INIT_STATUS_INITIALIZED); { rtx rtlop1 = XEXP (rtl, 1); - if (GET_MODE (rtlop1) != VOIDmode - && GET_MODE_BITSIZE (GET_MODE (rtlop1)) - < GET_MODE_BITSIZE (int_mode)) + if (is_a (GET_MODE (rtlop1), &op1_mode) + && GET_MODE_BITSIZE (op1_mode) < GET_MODE_BITSIZE (int_mode)) rtlop1 = gen_rtx_ZERO_EXTEND (int_mode, rtlop1); op1 = mem_loc_descriptor (rtlop1, int_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); @@ -15878,7 +15877,8 @@ loc_descriptor (rtx rtl, machine_mode mo break; /* FALLTHROUGH */ case LABEL_REF: - if (mode != VOIDmode && GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE + if (is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE && (dwarf_version >= 4 || !dwarf_strict)) { loc_result = new_addr_loc_descr (rtl, dtprel_false); Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:22.937277624 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:33.655250907 +0100 @@ -5559,40 +5559,39 @@ canonicalize_condition (rtx_insn *insn, if we can do computations in the relevant mode and we do not overflow. */ - if (GET_MODE_CLASS (GET_MODE (op0)) != MODE_CC - && CONST_INT_P (op1) - && GET_MODE (op0) != VOIDmode - && GET_MODE_PRECISION (GET_MODE (op0)) <= HOST_BITS_PER_WIDE_INT) + scalar_int_mode op0_mode; + if (CONST_INT_P (op1) + && is_a (GET_MODE (op0), &op0_mode) + && GET_MODE_PRECISION (op0_mode) <= HOST_BITS_PER_WIDE_INT) { HOST_WIDE_INT const_val = INTVAL (op1); unsigned HOST_WIDE_INT uconst_val = const_val; unsigned HOST_WIDE_INT max_val - = (unsigned HOST_WIDE_INT) GET_MODE_MASK (GET_MODE (op0)); + = (unsigned HOST_WIDE_INT) GET_MODE_MASK (op0_mode); switch (code) { case LE: if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1) - code = LT, op1 = gen_int_mode (const_val + 1, GET_MODE (op0)); + code = LT, op1 = gen_int_mode (const_val + 1, op0_mode); break; /* When cross-compiling, const_val might be sign-extended from BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */ case GE: if ((const_val & max_val) - != (HOST_WIDE_INT_1U - << (GET_MODE_PRECISION (GET_MODE (op0)) - 1))) - code = GT, op1 = gen_int_mode (const_val - 1, GET_MODE (op0)); + != (HOST_WIDE_INT_1U << (GET_MODE_PRECISION (op0_mode) - 1))) + code = GT, op1 = gen_int_mode (const_val - 1, op0_mode); break; case LEU: if (uconst_val < max_val) - code = LTU, op1 = gen_int_mode (uconst_val + 1, GET_MODE (op0)); + code = LTU, op1 = gen_int_mode (uconst_val + 1, op0_mode); break; case GEU: if (uconst_val != 0) - code = GTU, op1 = gen_int_mode (uconst_val - 1, GET_MODE (op0)); + code = GTU, op1 = gen_int_mode (uconst_val - 1, op0_mode); break; default: Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:33.217290298 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:33.655250907 +0100 @@ -4820,19 +4820,19 @@ simplify_relational_operation_1 (enum rt /* (ne:SI (zero_extract:SI FOO (const_int 1) BAR) (const_int 0))) is the same as (zero_extract:SI FOO (const_int 1) BAR). */ - scalar_int_mode int_mode; + scalar_int_mode int_mode, int_cmp_mode; if (code == NE && op1 == const0_rtx && is_int_mode (mode, &int_mode) - && cmp_mode != VOIDmode + && is_a (cmp_mode, &int_cmp_mode) /* ??? Work-around BImode bugs in the ia64 backend. */ && int_mode != BImode - && cmp_mode != BImode - && nonzero_bits (op0, cmp_mode) == 1 + && int_cmp_mode != BImode + && nonzero_bits (op0, int_cmp_mode) == 1 && STORE_FLAG_VALUE == 1) - return GET_MODE_SIZE (int_mode) > GET_MODE_SIZE (cmp_mode) - ? simplify_gen_unary (ZERO_EXTEND, int_mode, op0, cmp_mode) - : lowpart_subreg (int_mode, op0, cmp_mode); + return GET_MODE_SIZE (int_mode) > GET_MODE_SIZE (int_cmp_mode) + ? simplify_gen_unary (ZERO_EXTEND, int_mode, op0, int_cmp_mode) + : lowpart_subreg (int_mode, op0, int_cmp_mode); /* (eq/ne (xor x y) 0) simplifies to (eq/ne x y). */ if ((code == EQ || code == NE) From patchwork Thu Jul 13 08:47:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107610 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1931430qge; Thu, 13 Jul 2017 01:48:55 -0700 (PDT) X-Received: by 10.98.68.156 with SMTP id m28mr58808094pfi.159.1499935735117; Thu, 13 Jul 2017 01:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935735; cv=none; d=google.com; s=arc-20160816; b=fJ+Ri5q36QztAwqnpzRyAKoh9pTVpuZh/P4D/3lm/GuYz9fYfYrLL8vp3HhM5bJ6zu KM+FGliWBcZ7rl/pmjyQmi7bMPuZf00cf/qrnkeGDnNNV2OT7BIRxbMi8V3AQIyLhJ72 KGe7IoF6cba1CdAR4HKYowuAwBujeen8iT6G3FoKowmfcJMEtMEVwdZChaPvsimaLuNg pbZtODbNEkC5oi8YLa78M3ldtcbjhgHRSzN7745Gz9FyXDL9zkgl+19dYh0+WOEJFxN+ gM5lXQltI++BYu4V8fseNP1oqtNwFFxZc1aYrCZ8sbjQjyHZWhvg/FMqlOoJQD1dPAJP OMNQ== 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=kvg5fogUrlyDZpyvethipKAkQwXupzsnaamHaYE9S74=; b=tohOv3g5Z8Xmotex/E7YZXVnmDMfs8gKiTpOXmTMykesQjzfilnnppx1eMGEdU78Zx jbMP+OZFLHxbJ48s62dRuUULj8RHpLD1fxUYdYz18qma69PeJzOm+vd5wKnoTXrsvCkb DBVVQtRhQofwJGXgWZLNtUP+HQvFh0gi6IXcsxNRjq34UjUeJvj5OBX9OKUB6RWOOUTA N4oDE4G3+hFsO1IzmR5JwrBYks2JRmHigSRIIX92oC60cd7UDpjmKq2BKthQ7Yp0JT/I iauVc4v/vx03Mwm2hfzdjKWf+xtHrt2nbAfyNbF5+IGilWpxou482fpdZFqY417CEeUH SCHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=V47jK320; spf=pass (google.com: domain of gcc-patches-return-458015-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458015-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 o24si4008983pli.552.2017.07.13.01.48.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458015-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=V47jK320; spf=pass (google.com: domain of gcc-patches-return-458015-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458015-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=L1PnRV9m/aqnGArWy7ZG4M0JNiBFw zOHhylCjHlyF+xCkoBki92PZhBQOUC0PE2fJeLHwzfallOAJcful8cgOdgV2zcUQ Kp7JyV4AseBPwpo1lvYQADvotYoQj//ddqhygVOchOu+dt/bM0IVBIdyUp2NW3GL U2en6g6WstXzhQ= 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=jJX2uXPO7s1Id0z3lwzERMeyOMs=; b=V47 jK320m9cT3se/d0DOEk8+lOsl2VK+N1gG9CMuK4Ieijvd9/PemtZLp88ka/qYXND EUkX/2BG5m9GN+5fz8kkES76RuDjOMLiShq+U6M5/q25i2oDJG3/eSCXiztUBrtq FFjLKed20UM4b2ORZ1qCnFAdQCkvmcHD7RBsS20M= Received: (qmail 79217 invoked by alias); 13 Jul 2017 08:47:37 -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 78855 invoked by uid 89); 13 Jul 2017 08:47:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:47:34 +0000 Received: by mail-wm0-f51.google.com with SMTP id w126so16528380wme.0 for ; Thu, 13 Jul 2017 01:47:33 -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=kvg5fogUrlyDZpyvethipKAkQwXupzsnaamHaYE9S74=; b=Ct1J6Ympljk/mTesbOlayYeflUUYrjV4bF/QuIIPMKVtFDvJmQAdPjPE+sBJ+egMcB HSGniet7bytQZyUjz4Ax8D9AFud3ClwroZ7kCCMC5WXaoMk4dqfWCkU0rCYRe01J02p0 gdzaRk3wauYZuKXDLOj7CEnkuOV2TF1ZjUBjCC6ren1zM7ipjmSk908v2gYo0YWpIOSi moC2+uLbAedXG3jvaePM+CNS2rx1rYpX2wZoC78+c9QbubWmZBZrC5u5MHLYkyEcoJhP g+pP6B6einsnj+zGyMXOwwUDCaJwjb7qJza3D5FCccb3qojhbNysfya3weWiDZRTjVf3 ia/Q== X-Gm-Message-State: AIVw112/Qm3zqq3P4kgFBGPRawA/A7zq+d5ffbLNHJjmVDPfcnMNU2zc w/MwjYM2anrG1j05r9VQ5A== X-Received: by 10.28.139.145 with SMTP id n139mr1111774wmd.53.1499935652015; Thu, 13 Jul 2017 01:47:32 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 13sm2813282wrl.57.2017.07.13.01.47.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:47:31 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [24/77] Replace a != BLKmode check with is_a References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:47:30 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87a848k9jx.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces a check against BLKmode with a check of is_a , in a case where scalar integer modes were the only useful alternatives left. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * gimple-fold.c (gimple_fold_builtin_memory_op): Use is_a instead of != BLKmode. Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c 2017-07-08 11:37:46.572463892 +0100 +++ gcc/gimple-fold.c 2017-07-13 09:18:34.110210088 +0100 @@ -715,31 +715,29 @@ gimple_fold_builtin_memory_op (gimple_st unsigned ilen = tree_to_uhwi (len); if (pow2p_hwi (ilen)) { + scalar_int_mode mode; tree type = lang_hooks.types.type_for_size (ilen * 8, 1); if (type - && TYPE_MODE (type) != BLKmode - && (GET_MODE_SIZE (TYPE_MODE (type)) * BITS_PER_UNIT - == ilen * 8) + && is_a (TYPE_MODE (type), &mode) + && GET_MODE_SIZE (mode) * BITS_PER_UNIT == ilen * 8 /* If the destination pointer is not aligned we must be able to emit an unaligned store. */ - && (dest_align >= GET_MODE_ALIGNMENT (TYPE_MODE (type)) - || !SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), dest_align) - || (optab_handler (movmisalign_optab, TYPE_MODE (type)) + && (dest_align >= GET_MODE_ALIGNMENT (mode) + || !SLOW_UNALIGNED_ACCESS (mode, dest_align) + || (optab_handler (movmisalign_optab, mode) != CODE_FOR_nothing))) { tree srctype = type; tree desttype = type; - if (src_align < GET_MODE_ALIGNMENT (TYPE_MODE (type))) + if (src_align < GET_MODE_ALIGNMENT (mode)) srctype = build_aligned_type (type, src_align); tree srcmem = fold_build2 (MEM_REF, srctype, src, off0); tree tem = fold_const_aggregate_ref (srcmem); if (tem) srcmem = tem; - else if (src_align < GET_MODE_ALIGNMENT (TYPE_MODE (type)) - && SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), - src_align) - && (optab_handler (movmisalign_optab, - TYPE_MODE (type)) + else if (src_align < GET_MODE_ALIGNMENT (mode) + && SLOW_UNALIGNED_ACCESS (mode, src_align) + && (optab_handler (movmisalign_optab, mode) == CODE_FOR_nothing)) srcmem = NULL_TREE; if (srcmem) @@ -755,7 +753,7 @@ gimple_fold_builtin_memory_op (gimple_st gimple_set_vuse (new_stmt, gimple_vuse (stmt)); gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); } - if (dest_align < GET_MODE_ALIGNMENT (TYPE_MODE (type))) + if (dest_align < GET_MODE_ALIGNMENT (mode)) desttype = build_aligned_type (type, dest_align); new_stmt = gimple_build_assign (fold_build2 (MEM_REF, desttype, From patchwork Thu Jul 13 08:47:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107611 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1931648qge; Thu, 13 Jul 2017 01:49:10 -0700 (PDT) X-Received: by 10.99.47.66 with SMTP id v63mr8215763pgv.4.1499935750902; Thu, 13 Jul 2017 01:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935750; cv=none; d=google.com; s=arc-20160816; b=SKp0xh+8dHO/zt1wTiS1+vaJwJQz1Lj5fiBt1R+znlDFR8P2Hd0sGVvPIWwn3R80C8 XUPxsxzObpULVxwXQ/GH/1j8vffygKD0UV+hf2sLL6RSEZjkz9p2NvuJIktWmxf98FVU KyEbAJxmqezfhhAQybqbM79vZT1fKhlxOasaHT5zK2igPznp6Po07Do9TlywaTC/DDlv xCgr6eYrpFlNxAfWmh3blmSOIGOGOPteT2Zgct1fvJjsjLX8U4Y2eCvmwY+Ns/jPsaAk OovmSKz7IlKBFxz31/E0kZR6cxxDqxU//kSgx2Qa31JfwhLc8W4XTWk4lPp/jH9xwEJN p8Bg== 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=0iUeesH2B9YbapzsY1LTWCXB6dcptKqRH1EJ6wzYXYM=; b=NntZ8FRmzSCi2oUCFGolwEHa9tH5MArhMqDNKpshqOF7Kn/Z/zn/5ytRqbu1249956 Uqj8jAG2GF8ZqoUu+5znRIHFuJ92C4ohDjpUERZPE18wUKgViDv8MYU/l9nvpUpRdQq3 /6+hdAdcfmw3oTt9gLdX3k+/3QEjjqn9OIU/8h0H63o4z3PvHNji2OHaW4mZXN1HYl5c BR0Q6+zvK3nrauBV5QNpnr9On7z6ltgipd8D2Rxa1XqOIP7qRhyjY/BwSY0IqQWDm3Hy G3KvXIVZla+2pf13wBj80W49VtwzXgQjXE30rKpZUdAVKwKoSyhfKqmRyZRyxH+qehYx rQkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=v4XlFDrP; spf=pass (google.com: domain of gcc-patches-return-458016-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458016-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 j191si3696040pgd.195.2017.07.13.01.49.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:49:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458016-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=v4XlFDrP; spf=pass (google.com: domain of gcc-patches-return-458016-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458016-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=W4muyCOgRnDIEsFvVBIlH+tLGElPv Q6mgLpFktvQFVH36TY1NF0owTsemD8eW01hI+7SR2E/OvXx/4YaEEw2zZPtEAecx IfWj8PIFJCbFMgBGqMNGX6z2VDK2ir30oKBb/1s1f1H0TnV09yNaavKafihRppXV 8b3/AME1yupBTw= 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=IVHAYFHKTFZFjGQCngoccgHUk/w=; b=v4X lFDrPTFOqmH5LYgfrJi9ZpPgvsY4p5K5yd7t1Jf47gbIc/UG8AHmnoP5sDWB3OMP XYhMK4L7HZj6Dq2y1Ep0usZkPLfhVB3e366Nus6TSeSjsnm0euqIwadaYc13gJ7F 64Emvlmqej4P9fLXjuCYKR+l5gC5uW5meTakW0GM= Received: (qmail 90860 invoked by alias); 13 Jul 2017 08:48:00 -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 90599 invoked by uid 89); 13 Jul 2017 08:47:59 -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=OTHER, POS X-HELO: mail-wr0-f181.google.com Received: from mail-wr0-f181.google.com (HELO mail-wr0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:47:54 +0000 Received: by mail-wr0-f181.google.com with SMTP id c11so49382828wrc.3 for ; Thu, 13 Jul 2017 01:47:54 -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=0iUeesH2B9YbapzsY1LTWCXB6dcptKqRH1EJ6wzYXYM=; b=cvywRx1dd5lmkBxjdEL6WeA8s/oI3XDGT1W2fM2TaK5myRtsQ5PdHekhClBM33y4RA YcfPvlR57NTcb1g7X+UqBZNFU2KKlXLoBQq8Gygib3vZJSHBivI46fchQE4gb6bkjPVW gLx/Sr0Vp2rif6eLD9nmOTJGA3ubfCns9KlQ7Np3tG9AXHTtr8p/dbVmQAB90P/VQczH kPhTM7ieFdCJQ4rPG0Od9+mNTlK/LXPCCoo72MwvH8RsNCPdx/omizqXwSqg7RdOfkAs YfdKdd9D67nkGq9kDWehhjlUrfjZVLf+j0EALSV2MDEmTBXm1U15DurOqQT7iFUWlW0B LIqQ== X-Gm-Message-State: AIVw11329I56r8EaAOvAXVhEOT1pnNwdOtmcxczfpOIA4HO+g8J7MbmS BYNNOK3zf65AOjtON3VtsA== X-Received: by 10.223.170.219 with SMTP id i27mr898531wrc.49.1499935671865; Thu, 13 Jul 2017 01:47:51 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id o197sm6449232wmd.9.2017.07.13.01.47.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:47:51 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [25/77] Use is_a for bitmask optimisations References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:47:49 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8760ewk9je.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Explicitly check for scalar_int_mode in code that maps arithmetic to full-mode bit operations. These operations wouldn't work correctly for vector modes, for example. In many cases this is enforced also by checking whether an operand is CONST_INT_P, but there were other cases where the condition is more indirect. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (combine_simplify_rtx): Add checks for is_a . (simplify_if_then_else): Likewise. (make_field_assignment): Likewise. (simplify_comparison): Likewise. * ifcvt.c (noce_try_bitop): Likewise. * loop-invariant.c (canonicalize_address_mult): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:33.652251177 +0100 +++ gcc/combine.c 2017-07-13 09:18:34.533172436 +0100 @@ -5850,13 +5850,14 @@ combine_simplify_rtx (rtx x, machine_mod if (!REG_P (temp) && ! (GET_CODE (temp) == SUBREG && REG_P (SUBREG_REG (temp))) - && (i = exact_log2 (nonzero_bits (temp, mode))) >= 0) + && is_a (mode, &int_mode) + && (i = exact_log2 (nonzero_bits (temp, int_mode))) >= 0) { rtx temp1 = simplify_shift_const - (NULL_RTX, ASHIFTRT, mode, - simplify_shift_const (NULL_RTX, ASHIFT, mode, temp, - GET_MODE_PRECISION (mode) - 1 - i), - GET_MODE_PRECISION (mode) - 1 - i); + (NULL_RTX, ASHIFTRT, int_mode, + simplify_shift_const (NULL_RTX, ASHIFT, int_mode, temp, + GET_MODE_PRECISION (int_mode) - 1 - i), + GET_MODE_PRECISION (int_mode) - 1 - i); /* If all we did was surround TEMP with the two shifts, we haven't improved anything, so don't use it. Otherwise, @@ -5947,12 +5948,15 @@ combine_simplify_rtx (rtx x, machine_mod && !REG_P (XEXP (x, 0)) && ! (GET_CODE (XEXP (x, 0)) == SUBREG && REG_P (SUBREG_REG (XEXP (x, 0)))) - && nonzero_bits (XEXP (x, 0), mode) == 1) - return simplify_shift_const (NULL_RTX, ASHIFTRT, mode, - simplify_shift_const (NULL_RTX, ASHIFT, mode, - gen_rtx_XOR (mode, XEXP (x, 0), const1_rtx), - GET_MODE_PRECISION (mode) - 1), - GET_MODE_PRECISION (mode) - 1); + && is_a (mode, &int_mode) + && nonzero_bits (XEXP (x, 0), int_mode) == 1) + return simplify_shift_const + (NULL_RTX, ASHIFTRT, int_mode, + simplify_shift_const (NULL_RTX, ASHIFT, int_mode, + gen_rtx_XOR (int_mode, XEXP (x, 0), + const1_rtx), + GET_MODE_PRECISION (int_mode) - 1), + GET_MODE_PRECISION (int_mode) - 1); /* If we are adding two things that have no bits in common, convert the addition into an IOR. This will often be further simplified, @@ -5990,11 +5994,12 @@ combine_simplify_rtx (rtx x, machine_mod case MINUS: /* (minus (and (const_int -pow2))) becomes (and (const_int pow2-1)) */ - if (GET_CODE (XEXP (x, 1)) == AND + if (is_a (mode, &int_mode) + && GET_CODE (XEXP (x, 1)) == AND && CONST_INT_P (XEXP (XEXP (x, 1), 1)) && pow2p_hwi (-UINTVAL (XEXP (XEXP (x, 1), 1))) && rtx_equal_p (XEXP (XEXP (x, 1), 0), XEXP (x, 0))) - return simplify_and_const_int (NULL_RTX, mode, XEXP (x, 0), + return simplify_and_const_int (NULL_RTX, int_mode, XEXP (x, 0), -INTVAL (XEXP (XEXP (x, 1), 1)) - 1); break; @@ -6025,14 +6030,16 @@ combine_simplify_rtx (rtx x, machine_mod case UDIV: /* If this is a divide by a power of two, treat it as a shift if its first operand is a shift. */ - if (CONST_INT_P (XEXP (x, 1)) + if (is_a (mode, &int_mode) + && CONST_INT_P (XEXP (x, 1)) && (i = exact_log2 (UINTVAL (XEXP (x, 1)))) >= 0 && (GET_CODE (XEXP (x, 0)) == ASHIFT || GET_CODE (XEXP (x, 0)) == LSHIFTRT || GET_CODE (XEXP (x, 0)) == ASHIFTRT || GET_CODE (XEXP (x, 0)) == ROTATE || GET_CODE (XEXP (x, 0)) == ROTATERT)) - return simplify_shift_const (NULL_RTX, LSHIFTRT, mode, XEXP (x, 0), i); + return simplify_shift_const (NULL_RTX, LSHIFTRT, int_mode, + XEXP (x, 0), i); break; case EQ: case NE: @@ -6316,22 +6323,28 @@ simplify_if_then_else (rtx x) std::swap (true_rtx, false_rtx); } - /* If we are comparing against zero and the expression being tested has - only a single bit that might be nonzero, that is its value when it is - not equal to zero. Similarly if it is known to be -1 or 0. */ - - if (true_code == EQ && true_val == const0_rtx - && pow2p_hwi (nzb = nonzero_bits (from, GET_MODE (from)))) - { - false_code = EQ; - false_val = gen_int_mode (nzb, GET_MODE (from)); - } - else if (true_code == EQ && true_val == const0_rtx - && (num_sign_bit_copies (from, GET_MODE (from)) - == GET_MODE_PRECISION (GET_MODE (from)))) + scalar_int_mode from_mode; + if (is_a (GET_MODE (from), &from_mode)) { - false_code = EQ; - false_val = constm1_rtx; + /* If we are comparing against zero and the expression being + tested has only a single bit that might be nonzero, that is + its value when it is not equal to zero. Similarly if it is + known to be -1 or 0. */ + if (true_code == EQ + && true_val == const0_rtx + && pow2p_hwi (nzb = nonzero_bits (from, from_mode))) + { + false_code = EQ; + false_val = gen_int_mode (nzb, from_mode); + } + else if (true_code == EQ + && true_val == const0_rtx + && (num_sign_bit_copies (from, from_mode) + == GET_MODE_PRECISION (from_mode))) + { + false_code = EQ; + false_val = constm1_rtx; + } } /* Now simplify an arm if we know the value of the register in the @@ -6581,16 +6594,19 @@ simplify_if_then_else (rtx x) negation of a single bit, we can convert this operation to a shift. We can actually do this more generally, but it doesn't seem worth it. */ - if (true_code == NE && XEXP (cond, 1) == const0_rtx - && false_rtx == const0_rtx && CONST_INT_P (true_rtx) - && ((1 == nonzero_bits (XEXP (cond, 0), mode) + if (true_code == NE + && is_a (mode, &int_mode) + && XEXP (cond, 1) == const0_rtx + && false_rtx == const0_rtx + && CONST_INT_P (true_rtx) + && ((1 == nonzero_bits (XEXP (cond, 0), int_mode) && (i = exact_log2 (UINTVAL (true_rtx))) >= 0) - || ((num_sign_bit_copies (XEXP (cond, 0), mode) - == GET_MODE_PRECISION (mode)) + || ((num_sign_bit_copies (XEXP (cond, 0), int_mode) + == GET_MODE_PRECISION (int_mode)) && (i = exact_log2 (-UINTVAL (true_rtx))) >= 0))) return - simplify_shift_const (NULL_RTX, ASHIFT, mode, - gen_lowpart (mode, XEXP (cond, 0)), i); + simplify_shift_const (NULL_RTX, ASHIFT, int_mode, + gen_lowpart (int_mode, XEXP (cond, 0)), i); /* (IF_THEN_ELSE (NE A 0) C1 0) is A or a zero-extend of A if the only non-zero bit in A is C1. */ @@ -9483,7 +9499,11 @@ make_field_assignment (rtx x) HOST_WIDE_INT pos; unsigned HOST_WIDE_INT len; rtx other; - machine_mode mode; + + /* All the rules in this function are specific to scalar integers. */ + scalar_int_mode mode; + if (!is_a (GET_MODE (dest), &mode)) + return x; /* If SRC was (and (not (ashift (const_int 1) POS)) DEST), this is a clear of a one-bit field. We will have changed it to @@ -9556,7 +9576,6 @@ make_field_assignment (rtx x) /* Partial overlap. We can reduce the source AND. */ if ((and_mask & ze_mask) != and_mask) { - mode = GET_MODE (src); src = gen_rtx_AND (mode, XEXP (src, 0), gen_int_mode (and_mask & ze_mask, mode)); return gen_rtx_SET (dest, src); @@ -9575,7 +9594,10 @@ make_field_assignment (rtx x) assignment. The first one we are likely to encounter is an outer narrowing SUBREG, which we can just strip for the purposes of identifying the constant-field assignment. */ - if (GET_CODE (src) == SUBREG && subreg_lowpart_p (src)) + scalar_int_mode src_mode = mode; + if (GET_CODE (src) == SUBREG + && subreg_lowpart_p (src) + && is_a (GET_MODE (SUBREG_REG (src)), &src_mode)) src = SUBREG_REG (src); if (GET_CODE (src) != IOR && GET_CODE (src) != XOR) @@ -9621,10 +9643,11 @@ make_field_assignment (rtx x) else return x; - pos = get_pos_from_mask ((~c1) & GET_MODE_MASK (GET_MODE (dest)), &len); - if (pos < 0 || pos + len > GET_MODE_PRECISION (GET_MODE (dest)) - || GET_MODE_PRECISION (GET_MODE (dest)) > HOST_BITS_PER_WIDE_INT - || (c1 & nonzero_bits (other, GET_MODE (dest))) != 0) + pos = get_pos_from_mask ((~c1) & GET_MODE_MASK (mode), &len); + if (pos < 0 + || pos + len > GET_MODE_PRECISION (mode) + || GET_MODE_PRECISION (mode) > HOST_BITS_PER_WIDE_INT + || (c1 & nonzero_bits (other, mode)) != 0) return x; assign = make_extraction (VOIDmode, dest, pos, NULL_RTX, len, 1, 1, 0); @@ -9633,17 +9656,16 @@ make_field_assignment (rtx x) /* The mode to use for the source is the mode of the assignment, or of what is inside a possible STRICT_LOW_PART. */ - mode = (GET_CODE (assign) == STRICT_LOW_PART - ? GET_MODE (XEXP (assign, 0)) : GET_MODE (assign)); + machine_mode new_mode = (GET_CODE (assign) == STRICT_LOW_PART + ? GET_MODE (XEXP (assign, 0)) : GET_MODE (assign)); /* Shift OTHER right POS places and make it the source, restricting it to the proper length and mode. */ src = canon_reg_for_combine (simplify_shift_const (NULL_RTX, LSHIFTRT, - GET_MODE (src), - other, pos), + src_mode, other, pos), dest); - src = force_to_mode (src, mode, + src = force_to_mode (src, new_mode, len >= HOST_BITS_PER_WIDE_INT ? HOST_WIDE_INT_M1U : (HOST_WIDE_INT_1U << len) - 1, @@ -11767,16 +11789,17 @@ simplify_comparison (enum rtx_code code, && GET_CODE (XEXP (op1, 0)) == ASHIFT && GET_CODE (XEXP (XEXP (op0, 0), 0)) == SUBREG && GET_CODE (XEXP (XEXP (op1, 0), 0)) == SUBREG - && (GET_MODE (SUBREG_REG (XEXP (XEXP (op0, 0), 0))) - == GET_MODE (SUBREG_REG (XEXP (XEXP (op1, 0), 0)))) + && is_a (GET_MODE (op0), &mode) + && (is_a + (GET_MODE (SUBREG_REG (XEXP (XEXP (op0, 0), 0))), &inner_mode)) + && inner_mode == GET_MODE (SUBREG_REG (XEXP (XEXP (op1, 0), 0))) && CONST_INT_P (XEXP (op0, 1)) && XEXP (op0, 1) == XEXP (op1, 1) && XEXP (op0, 1) == XEXP (XEXP (op0, 0), 1) && XEXP (op0, 1) == XEXP (XEXP (op1, 0), 1) && (INTVAL (XEXP (op0, 1)) - == (GET_MODE_PRECISION (GET_MODE (op0)) - - (GET_MODE_PRECISION - (GET_MODE (SUBREG_REG (XEXP (XEXP (op0, 0), 0)))))))) + == (GET_MODE_PRECISION (mode) + - GET_MODE_PRECISION (inner_mode)))) { op0 = SUBREG_REG (XEXP (XEXP (op0, 0), 0)); op1 = SUBREG_REG (XEXP (XEXP (op1, 0), 0)); Index: gcc/ifcvt.c =================================================================== --- gcc/ifcvt.c 2017-06-30 12:50:38.245662583 +0100 +++ gcc/ifcvt.c 2017-07-13 09:18:34.533172436 +0100 @@ -2808,7 +2808,7 @@ noce_try_bitop (struct noce_if_info *if_ { rtx cond, x, a, result; rtx_insn *seq; - machine_mode mode; + scalar_int_mode mode; enum rtx_code code; int bitnum; @@ -2816,6 +2816,10 @@ noce_try_bitop (struct noce_if_info *if_ cond = if_info->cond; code = GET_CODE (cond); + /* Check for an integer operation. */ + if (!is_a (GET_MODE (x), &mode)) + return FALSE; + if (!noce_simple_bbs (if_info)) return FALSE; @@ -2838,7 +2842,6 @@ noce_try_bitop (struct noce_if_info *if_ || ! rtx_equal_p (x, XEXP (cond, 0))) return FALSE; bitnum = INTVAL (XEXP (cond, 2)); - mode = GET_MODE (x); if (BITS_BIG_ENDIAN) bitnum = GET_MODE_BITSIZE (mode) - 1 - bitnum; if (bitnum < 0 || bitnum >= HOST_BITS_PER_WIDE_INT) Index: gcc/loop-invariant.c =================================================================== --- gcc/loop-invariant.c 2017-05-18 07:51:11.897799636 +0100 +++ gcc/loop-invariant.c 2017-07-13 09:18:34.534172347 +0100 @@ -774,16 +774,16 @@ canonicalize_address_mult (rtx x) FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST) { rtx sub = *iter; - - if (GET_CODE (sub) == ASHIFT + scalar_int_mode sub_mode; + if (is_a (GET_MODE (sub), &sub_mode) + && GET_CODE (sub) == ASHIFT && CONST_INT_P (XEXP (sub, 1)) - && INTVAL (XEXP (sub, 1)) < GET_MODE_BITSIZE (GET_MODE (sub)) + && INTVAL (XEXP (sub, 1)) < GET_MODE_BITSIZE (sub_mode) && INTVAL (XEXP (sub, 1)) >= 0) { HOST_WIDE_INT shift = INTVAL (XEXP (sub, 1)); PUT_CODE (sub, MULT); - XEXP (sub, 1) = gen_int_mode (HOST_WIDE_INT_1 << shift, - GET_MODE (sub)); + XEXP (sub, 1) = gen_int_mode (HOST_WIDE_INT_1 << shift, sub_mode); iter.skip_subrtxes (); } } Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:33.655250907 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:34.534172347 +0100 @@ -916,7 +916,7 @@ simplify_unary_operation_1 (enum rtx_cod { enum rtx_code reversed; rtx temp; - scalar_int_mode inner; + scalar_int_mode inner, int_mode; switch (code) { @@ -977,10 +977,11 @@ simplify_unary_operation_1 (enum rtx_cod minus 1 is (ge foo (const_int 0)) if STORE_FLAG_VALUE is -1, so we can perform the above simplification. */ if (STORE_FLAG_VALUE == -1 + && is_a (mode, &int_mode) && GET_CODE (op) == ASHIFTRT && CONST_INT_P (XEXP (op, 1)) - && INTVAL (XEXP (op, 1)) == GET_MODE_PRECISION (mode) - 1) - return simplify_gen_relational (GE, mode, VOIDmode, + && INTVAL (XEXP (op, 1)) == GET_MODE_PRECISION (int_mode) - 1) + return simplify_gen_relational (GE, int_mode, VOIDmode, XEXP (op, 0), const0_rtx); @@ -1330,8 +1331,10 @@ simplify_unary_operation_1 (enum rtx_cod return op; /* If operand is known to be only -1 or 0, convert ABS to NEG. */ - if (num_sign_bit_copies (op, mode) == GET_MODE_PRECISION (mode)) - return gen_rtx_NEG (mode, op); + if (is_a (mode, &int_mode) + && (num_sign_bit_copies (op, int_mode) + == GET_MODE_PRECISION (int_mode))) + return gen_rtx_NEG (int_mode, op); break; @@ -1485,12 +1488,13 @@ simplify_unary_operation_1 (enum rtx_cod is similarly (zero_extend:M (subreg:O )). */ if ((GET_CODE (op) == ASHIFTRT || GET_CODE (op) == LSHIFTRT) && GET_CODE (XEXP (op, 0)) == ASHIFT + && is_a (mode, &int_mode) && CONST_INT_P (XEXP (op, 1)) && XEXP (XEXP (op, 0), 1) == XEXP (op, 1) && GET_MODE_BITSIZE (GET_MODE (op)) > INTVAL (XEXP (op, 1))) { scalar_int_mode tmode; - gcc_assert (GET_MODE_BITSIZE (mode) + gcc_assert (GET_MODE_BITSIZE (int_mode) > GET_MODE_BITSIZE (GET_MODE (op))); if (int_mode_for_size (GET_MODE_BITSIZE (GET_MODE (op)) - INTVAL (XEXP (op, 1)), 1).exists (&tmode)) @@ -1500,7 +1504,7 @@ simplify_unary_operation_1 (enum rtx_cod if (inner) return simplify_gen_unary (GET_CODE (op) == ASHIFTRT ? SIGN_EXTEND : ZERO_EXTEND, - mode, inner, tmode); + int_mode, inner, tmode); } } @@ -1601,6 +1605,7 @@ simplify_unary_operation_1 (enum rtx_cod GET_MODE_PRECISION (N) - I bits. */ if (GET_CODE (op) == LSHIFTRT && GET_CODE (XEXP (op, 0)) == ASHIFT + && is_a (mode, &int_mode) && CONST_INT_P (XEXP (op, 1)) && XEXP (XEXP (op, 0), 1) == XEXP (op, 1) && GET_MODE_PRECISION (GET_MODE (op)) > INTVAL (XEXP (op, 1))) @@ -1612,7 +1617,8 @@ simplify_unary_operation_1 (enum rtx_cod rtx inner = rtl_hooks.gen_lowpart_no_emit (tmode, XEXP (XEXP (op, 0), 0)); if (inner) - return simplify_gen_unary (ZERO_EXTEND, mode, inner, tmode); + return simplify_gen_unary (ZERO_EXTEND, int_mode, + inner, tmode); } } From patchwork Thu Jul 13 08:48:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107612 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1931862qge; Thu, 13 Jul 2017 01:49:28 -0700 (PDT) X-Received: by 10.99.143.21 with SMTP id n21mr8053274pgd.145.1499935767964; Thu, 13 Jul 2017 01:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935767; cv=none; d=google.com; s=arc-20160816; b=NHhtMy+kGhlKyLSdkfrhJY9jkgBLqXo4xC+Oq0vZpw/JuS2OJm1MPrRp23X8oE2jqi JSf/sbYv2O6mm7QwVZQVfUD2N/BHwJbJZsmo4sl/HFZAFTDiOdvTyfMu+DO6vTmP4DI3 h9wu1MTyLo8zg4scrgvZoexY/YZHekMdU9W2rDJ442LQ5Yrg+AUojzuWLmqPLlSDZjmU YDZddX8yhgnm6QDdmZa1DDqdwI+JMMtW8d25KmKo3GDcieHJlvR42uOIIEJWOiIoLsdB u+Bbx0NSrk5ROXl5JuKkOV+gvYtpp7uz1m2aOhxcPUJAEV4keKFvbTIVN1RBqedn3oyw kSQA== 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=voj4Tf78NBS0Ln+PqFEtx9h94/VNto0FHzLZAL/VGEg=; b=v9Oaly8lfYxHG1c/Kt/a2EaoCboescZYbK3BhE8Gw5UKYC21iZBcmR0knE6ca2xZtf b8uvDGpXzgVQF7nFC9OK/N0QXVF5yq26HwTi/59PZv+6e2+6vHjCdyUe74llKDqb7jFR hJ09W8CvW1HExu4opcjBH+YANvNddKsdRjQT8fq1sxbaPuOJB/0DkChNeLm603qt/+xi Wsm4NCVnaW11t213Us4XMz8A7CQPJ/q87yPjLaOZa/kl7CnF2QB3pWCjs+VSt+IO/xut 3MzT8d/Te+K1tKe5I2zKnMonkK3pfyN1H3FV2NPvbJoueTdnGW/Spx4YZeEgg66chyDg rq0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=tTy9ERyv; spf=pass (google.com: domain of gcc-patches-return-458017-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458017-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 n5si3837202pgk.175.2017.07.13.01.49.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:49:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458017-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=tTy9ERyv; spf=pass (google.com: domain of gcc-patches-return-458017-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458017-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=FmRGrcySvl7sZWdN/YyHryTonSOTw aAGWcLWAy96u8kRjDGBhr8d/TdImeNIBqIqqJtswvXM5RTUNuOSqN7K4TnGVP/iT 8BCiSAAqamz4IOW66O0VKOpd/zRTHYi0CYDydUFKkd0VXgiHH3yKUid1AgqeBjC+ 0/8P8i6uK5DFh0= 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=/81jGIyD1ylHza4dzPvb/w+S6zw=; b=tTy 9ERyvRvjXbpIauWuP/6PlFOVmAayNPNosV9VTqL3mtRpt3hwRIS5cbrLmp2CSP5+ a0Rzax6EwMLffJNYeOj7AegqbnQaDJpZZX4DFKAOUgWwcfVyKZ+QV8HEY8ovCwjO hqgOl9/9pfaH1VLBusV3rMidq6FkB74efRvqqL4A= Received: (qmail 5378 invoked by alias); 13 Jul 2017 08:48:47 -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 115848 invoked by uid 89); 13 Jul 2017 08:48:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:48:22 +0000 Received: by mail-wr0-f171.google.com with SMTP id k67so49336625wrc.2 for ; Thu, 13 Jul 2017 01:48:14 -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=voj4Tf78NBS0Ln+PqFEtx9h94/VNto0FHzLZAL/VGEg=; b=BIRF+PdyY7TKTwy2vR+B239dbDLP1to8Fm34dr0EaO7455xTb38DZLxxUx3Y1Y0CP+ Bw78YCeCJMRLbxCLAUe3h8cL4XCBqQhRxBwpQMullEKK5kWoSPeoZ5Z6Jk7yLKpC+e0u BawTPQHeFecQtzMovfdhdVu5rL/uIc5w3TztRkMSViu8sYvdS2ahUuXdkDC6nlugTakG Of7xZo63lh82yQzyoIPUqKfyCFMKCMDYUrllhOX23uub2xCcpfg6qcxQfs3V2dt1Mqf5 uNP6EVtda9WRjPED5kO9Q8617l4BBewJJtl0BBXMaJq+GhJmb2IW5LxQJkRde+97UfHI neVQ== X-Gm-Message-State: AIVw11046Xkw3EP6fYxqZky7lXbN3AMgzHlxHSlpecR7dtH8mhNnHqve DKaNXJJ+lFJGO0BW7Pvemg== X-Received: by 10.223.134.169 with SMTP id 38mr846192wrx.92.1499935692633; Thu, 13 Jul 2017 01:48:12 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id o6sm4835010wrc.48.2017.07.13.01.48.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:48:11 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [26/77] Use is_a in subreg/extract simplifications References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:48:10 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <871spkk9it.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds is_a checks to various places that were optimising subregs or extractions in ways that only made sense for scalar integers. Often the subreg transformations were looking for extends, truncates or shifts and trying to remove the subreg, which wouldn't be correct if the SUBREG_REG was a vector rather than a scalar. The simplify_binary_operation_1 part also removes a redundant: GET_MODE (opleft) == GET_MODE (XEXP (opright, 0)) since this must be true for: (ior A (lshifrt B ...)) A == opleft, B == XEXP (opright, 0) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (find_split_point): Add is_a checks. (make_compound_operation_int): Likewise. (change_zero_ext): Likewise. * expr.c (convert_move): Likewise. (convert_modes): Likewise. * fwprop.c (forward_propagate_subreg): Likewise. * loop-iv.c (get_biv_step_1): Likewise. * optabs.c (widen_operand): Likewise. * postreload.c (move2add_valid_value_p): Likewise. * recog.c (simplify_while_replacing): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. (simplify_binary_operation_1): Likewise. Remove redundant mode equality check. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:34.533172436 +0100 +++ gcc/combine.c 2017-07-13 09:18:35.047126725 +0100 @@ -4793,7 +4793,7 @@ find_split_point (rtx *loc, rtx_insn *in HOST_WIDE_INT pos = 0; int unsignedp = 0; rtx inner = NULL_RTX; - scalar_int_mode inner_mode; + scalar_int_mode mode, inner_mode; /* First special-case some codes. */ switch (code) @@ -5047,7 +5047,9 @@ find_split_point (rtx *loc, rtx_insn *in case SIGN_EXTRACT: case ZERO_EXTRACT: - if (CONST_INT_P (XEXP (SET_SRC (x), 1)) + if (is_a (GET_MODE (XEXP (SET_SRC (x), 0)), + &inner_mode) + && CONST_INT_P (XEXP (SET_SRC (x), 1)) && CONST_INT_P (XEXP (SET_SRC (x), 2))) { inner = XEXP (SET_SRC (x), 0); @@ -5055,7 +5057,7 @@ find_split_point (rtx *loc, rtx_insn *in pos = INTVAL (XEXP (SET_SRC (x), 2)); if (BITS_BIG_ENDIAN) - pos = GET_MODE_PRECISION (GET_MODE (inner)) - len - pos; + pos = GET_MODE_PRECISION (inner_mode) - len - pos; unsignedp = (code == ZERO_EXTRACT); } break; @@ -5065,10 +5067,9 @@ find_split_point (rtx *loc, rtx_insn *in } if (len && pos >= 0 - && pos + len <= GET_MODE_PRECISION (GET_MODE (inner))) + && pos + len <= GET_MODE_PRECISION (GET_MODE (inner)) + && is_a (GET_MODE (SET_SRC (x)), &mode)) { - machine_mode mode = GET_MODE (SET_SRC (x)); - /* For unsigned, we have a choice of a shift followed by an AND or two shifts. Use two shifts for field sizes where the constant might be too large. We assume here that we can @@ -7859,6 +7860,7 @@ make_compound_operation_int (machine_mod rtx new_rtx = 0; int i; rtx tem; + scalar_int_mode inner_mode; bool equality_comparison = false; if (in_code == EQ) @@ -7967,11 +7969,12 @@ make_compound_operation_int (machine_mod /* Same as previous, but for (subreg (lshiftrt ...)) in first op. */ else if (GET_CODE (XEXP (x, 0)) == SUBREG && subreg_lowpart_p (XEXP (x, 0)) + && is_a (GET_MODE (SUBREG_REG (XEXP (x, 0))), + &inner_mode) && GET_CODE (SUBREG_REG (XEXP (x, 0))) == LSHIFTRT && (i = exact_log2 (UINTVAL (XEXP (x, 1)) + 1)) >= 0) { rtx inner_x0 = SUBREG_REG (XEXP (x, 0)); - machine_mode inner_mode = GET_MODE (inner_x0); new_rtx = make_compound_operation (XEXP (inner_x0, 0), next_code); new_rtx = make_extraction (inner_mode, new_rtx, 0, XEXP (inner_x0, 1), @@ -8170,14 +8173,14 @@ make_compound_operation_int (machine_mod /* If the SUBREG is masking of a logical right shift, make an extraction. */ if (GET_CODE (inner) == LSHIFTRT + && is_a (GET_MODE (inner), &inner_mode) + && GET_MODE_SIZE (mode) < GET_MODE_SIZE (inner_mode) && CONST_INT_P (XEXP (inner, 1)) - && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (inner)) - && (UINTVAL (XEXP (inner, 1)) - < GET_MODE_PRECISION (GET_MODE (inner))) + && UINTVAL (XEXP (inner, 1)) < GET_MODE_PRECISION (inner_mode) && subreg_lowpart_p (x)) { new_rtx = make_compound_operation (XEXP (inner, 0), next_code); - int width = GET_MODE_PRECISION (GET_MODE (inner)) + int width = GET_MODE_PRECISION (inner_mode) - INTVAL (XEXP (inner, 1)); if (width > mode_width) width = mode_width; @@ -11380,15 +11383,16 @@ change_zero_ext (rtx pat) maybe_swap_commutative_operands (**iter); rtx *dst = &SET_DEST (pat); + scalar_int_mode mode; if (GET_CODE (*dst) == ZERO_EXTRACT && REG_P (XEXP (*dst, 0)) + && is_a (GET_MODE (XEXP (*dst, 0)), &mode) && CONST_INT_P (XEXP (*dst, 1)) && CONST_INT_P (XEXP (*dst, 2))) { rtx reg = XEXP (*dst, 0); int width = INTVAL (XEXP (*dst, 1)); int offset = INTVAL (XEXP (*dst, 2)); - machine_mode mode = GET_MODE (reg); int reg_width = GET_MODE_PRECISION (mode); if (BITS_BIG_ENDIAN) offset = reg_width - width - offset; Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:31.697428505 +0100 +++ gcc/expr.c 2017-07-13 09:18:35.048126637 +0100 @@ -239,11 +239,14 @@ convert_move (rtx to, rtx from, int unsi the required extension, strip it. We don't handle such SUBREGs as TO here. */ - if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) + scalar_int_mode to_int_mode; + if (GET_CODE (from) == SUBREG + && SUBREG_PROMOTED_VAR_P (from) + && is_a (to_mode, &to_int_mode) && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) - >= GET_MODE_PRECISION (to_mode)) + >= GET_MODE_PRECISION (to_int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) - from = gen_lowpart (to_mode, from), from_mode = to_mode; + from = gen_lowpart (to_int_mode, from), from_mode = to_int_mode; gcc_assert (GET_CODE (to) != SUBREG || !SUBREG_PROMOTED_VAR_P (to)); @@ -635,10 +638,12 @@ convert_modes (machine_mode mode, machin /* If FROM is a SUBREG that indicates that we have already done at least the required extension, strip it. */ - if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x) - && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode) + if (GET_CODE (x) == SUBREG + && SUBREG_PROMOTED_VAR_P (x) + && is_a (mode, &int_mode) + && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (int_mode) && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp)) - x = gen_lowpart (mode, SUBREG_REG (x)); + x = gen_lowpart (int_mode, SUBREG_REG (x)); if (GET_MODE (x) != VOIDmode) oldmode = GET_MODE (x); Index: gcc/fwprop.c =================================================================== --- gcc/fwprop.c 2017-04-18 19:52:33.713921172 +0100 +++ gcc/fwprop.c 2017-07-13 09:18:35.048126637 +0100 @@ -1096,6 +1096,7 @@ forward_propagate_subreg (df_ref use, rt rtx use_reg = DF_REF_REG (use); rtx_insn *use_insn; rtx src; + scalar_int_mode int_use_mode, src_mode; /* Only consider subregs... */ machine_mode use_mode = GET_MODE (use_reg); @@ -1139,17 +1140,19 @@ forward_propagate_subreg (df_ref use, rt definition of Y or, failing that, allow A to be deleted after reload through register tying. Introducing more uses of Y prevents both optimisations. */ - else if (subreg_lowpart_p (use_reg)) + else if (is_a (use_mode, &int_use_mode) + && subreg_lowpart_p (use_reg)) { use_insn = DF_REF_INSN (use); src = SET_SRC (def_set); if ((GET_CODE (src) == ZERO_EXTEND || GET_CODE (src) == SIGN_EXTEND) + && is_a (GET_MODE (src), &src_mode) && REG_P (XEXP (src, 0)) && REGNO (XEXP (src, 0)) >= FIRST_PSEUDO_REGISTER && GET_MODE (XEXP (src, 0)) == use_mode && !free_load_extend (src, def_insn) - && (targetm.mode_rep_extended (use_mode, GET_MODE (src)) + && (targetm.mode_rep_extended (int_use_mode, src_mode) != (int) GET_CODE (src)) && all_uses_available_at (def_insn, use_insn)) return try_fwprop_subst (use, DF_REF_LOC (use), XEXP (src, 0), Index: gcc/loop-iv.c =================================================================== --- gcc/loop-iv.c 2017-02-23 19:54:20.000000000 +0000 +++ gcc/loop-iv.c 2017-07-13 09:18:35.049126549 +0100 @@ -739,9 +739,9 @@ get_biv_step_1 (df_ref def, rtx reg, if (GET_CODE (next) == SUBREG) { - machine_mode amode = GET_MODE (next); - - if (GET_MODE_SIZE (amode) > GET_MODE_SIZE (*inner_mode)) + scalar_int_mode amode; + if (!is_a (GET_MODE (next), &amode) + || GET_MODE_SIZE (amode) > GET_MODE_SIZE (*inner_mode)) return false; *inner_mode = amode; Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:32.526352886 +0100 +++ gcc/optabs.c 2017-07-13 09:18:35.049126549 +0100 @@ -195,6 +195,7 @@ widen_operand (rtx op, machine_mode mode int unsignedp, int no_extend) { rtx result; + scalar_int_mode int_mode; /* If we don't have to extend and this is a constant, return it. */ if (no_extend && GET_MODE (op) == VOIDmode) @@ -204,19 +205,20 @@ widen_operand (rtx op, machine_mode mode extend since it will be more efficient to do so unless the signedness of a promoted object differs from our extension. */ if (! no_extend + || !is_a (mode, &int_mode) || (GET_CODE (op) == SUBREG && SUBREG_PROMOTED_VAR_P (op) && SUBREG_CHECK_PROMOTED_SIGN (op, unsignedp))) return convert_modes (mode, oldmode, op, unsignedp); /* If MODE is no wider than a single word, we return a lowpart or paradoxical SUBREG. */ - if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD) - return gen_lowpart (mode, force_reg (GET_MODE (op), op)); + if (GET_MODE_SIZE (int_mode) <= UNITS_PER_WORD) + return gen_lowpart (int_mode, force_reg (GET_MODE (op), op)); /* Otherwise, get an object of MODE, clobber it, and set the low-order part to OP. */ - result = gen_reg_rtx (mode); + result = gen_reg_rtx (int_mode); emit_clobber (result); emit_move_insn (gen_lowpart (GET_MODE (op), result), op); return result; Index: gcc/postreload.c =================================================================== --- gcc/postreload.c 2017-07-13 09:18:32.527352795 +0100 +++ gcc/postreload.c 2017-07-13 09:18:35.050126461 +0100 @@ -1699,14 +1699,16 @@ move2add_valid_value_p (int regno, machi if (mode != reg_mode[regno]) { - if (!MODES_OK_FOR_MOVE2ADD (mode, reg_mode[regno])) + scalar_int_mode old_mode; + if (!is_a (reg_mode[regno], &old_mode) + || !MODES_OK_FOR_MOVE2ADD (mode, old_mode)) return false; /* The value loaded into regno in reg_mode[regno] is also valid in mode after truncation only if (REG:mode regno) is the lowpart of (REG:reg_mode[regno] regno). Now, for big endian, the starting regno of the lowpart might be different. */ - int s_off = subreg_lowpart_offset (mode, reg_mode[regno]); - s_off = subreg_regno_offset (regno, reg_mode[regno], s_off, mode); + int s_off = subreg_lowpart_offset (mode, old_mode); + s_off = subreg_regno_offset (regno, old_mode, s_off, mode); if (s_off != 0) /* We could in principle adjust regno, check reg_mode[regno] to be BLKmode, and return s_off to the caller (vs. -1 for failure), Index: gcc/recog.c =================================================================== --- gcc/recog.c 2017-06-30 12:50:38.299660094 +0100 +++ gcc/recog.c 2017-07-13 09:18:35.050126461 +0100 @@ -560,6 +560,7 @@ simplify_while_replacing (rtx *loc, rtx rtx x = *loc; enum rtx_code code = GET_CODE (x); rtx new_rtx = NULL_RTX; + scalar_int_mode is_mode; if (SWAPPABLE_OPERANDS_P (x) && swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1))) @@ -655,6 +656,7 @@ simplify_while_replacing (rtx *loc, rtx happen, we might just fail in some cases). */ if (MEM_P (XEXP (x, 0)) + && is_a (GET_MODE (XEXP (x, 0)), &is_mode) && CONST_INT_P (XEXP (x, 1)) && CONST_INT_P (XEXP (x, 2)) && !mode_dependent_address_p (XEXP (XEXP (x, 0), 0), @@ -662,7 +664,6 @@ simplify_while_replacing (rtx *loc, rtx && !MEM_VOLATILE_P (XEXP (x, 0))) { machine_mode wanted_mode = VOIDmode; - machine_mode is_mode = GET_MODE (XEXP (x, 0)); int pos = INTVAL (XEXP (x, 2)); if (GET_CODE (x) == ZERO_EXTRACT && targetm.have_extzv ()) Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:34.534172347 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:35.051126373 +0100 @@ -916,7 +916,7 @@ simplify_unary_operation_1 (enum rtx_cod { enum rtx_code reversed; rtx temp; - scalar_int_mode inner, int_mode; + scalar_int_mode inner, int_mode, op0_mode; switch (code) { @@ -1628,21 +1628,19 @@ simplify_unary_operation_1 (enum rtx_cod (zero_extend:SI (subreg:QI (and:SI (reg:SI) (const_int 63)) 0)) is (and:SI (reg:SI) (const_int 63)). */ if (GET_CODE (op) == SUBREG - && GET_MODE_PRECISION (GET_MODE (op)) - < GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op))) - && GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op))) - <= HOST_BITS_PER_WIDE_INT - && GET_MODE_PRECISION (mode) - >= GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op))) + && is_a (mode, &int_mode) + && is_a (GET_MODE (SUBREG_REG (op)), &op0_mode) + && GET_MODE_PRECISION (GET_MODE (op)) < GET_MODE_PRECISION (op0_mode) + && GET_MODE_PRECISION (op0_mode) <= HOST_BITS_PER_WIDE_INT + && GET_MODE_PRECISION (int_mode) >= GET_MODE_PRECISION (op0_mode) && subreg_lowpart_p (op) - && (nonzero_bits (SUBREG_REG (op), GET_MODE (SUBREG_REG (op))) + && (nonzero_bits (SUBREG_REG (op), op0_mode) & ~GET_MODE_MASK (GET_MODE (op))) == 0) { - if (GET_MODE_PRECISION (mode) - == GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op)))) + if (GET_MODE_PRECISION (int_mode) == GET_MODE_PRECISION (op0_mode)) return SUBREG_REG (op); - return simplify_gen_unary (ZERO_EXTEND, mode, SUBREG_REG (op), - GET_MODE (SUBREG_REG (op))); + return simplify_gen_unary (ZERO_EXTEND, int_mode, SUBREG_REG (op), + op0_mode); } #if defined(POINTERS_EXTEND_UNSIGNED) @@ -2707,21 +2705,23 @@ simplify_binary_operation_1 (enum rtx_co by simplify_shift_const. */ if (GET_CODE (opleft) == SUBREG + && is_a (mode, &int_mode) + && is_a (GET_MODE (SUBREG_REG (opleft)), + &inner_mode) && GET_CODE (SUBREG_REG (opleft)) == ASHIFT && GET_CODE (opright) == LSHIFTRT && GET_CODE (XEXP (opright, 0)) == SUBREG - && GET_MODE (opleft) == GET_MODE (XEXP (opright, 0)) && SUBREG_BYTE (opleft) == SUBREG_BYTE (XEXP (opright, 0)) - && (GET_MODE_SIZE (GET_MODE (opleft)) - < GET_MODE_SIZE (GET_MODE (SUBREG_REG (opleft)))) + && GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (inner_mode) && rtx_equal_p (XEXP (SUBREG_REG (opleft), 0), SUBREG_REG (XEXP (opright, 0))) && CONST_INT_P (XEXP (SUBREG_REG (opleft), 1)) && CONST_INT_P (XEXP (opright, 1)) - && (INTVAL (XEXP (SUBREG_REG (opleft), 1)) + INTVAL (XEXP (opright, 1)) - == GET_MODE_PRECISION (mode))) - return gen_rtx_ROTATE (mode, XEXP (opright, 0), - XEXP (SUBREG_REG (opleft), 1)); + && (INTVAL (XEXP (SUBREG_REG (opleft), 1)) + + INTVAL (XEXP (opright, 1)) + == GET_MODE_PRECISION (int_mode))) + return gen_rtx_ROTATE (int_mode, XEXP (opright, 0), + XEXP (SUBREG_REG (opleft), 1)); /* If we have (ior (and (X C1) C2)), simplify this by making C1 as small as possible if C1 actually changes. */ From patchwork Thu Jul 13 08:48:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107613 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1932006qge; Thu, 13 Jul 2017 01:49:39 -0700 (PDT) X-Received: by 10.99.135.73 with SMTP id i70mr7937548pge.74.1499935779705; Thu, 13 Jul 2017 01:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935779; cv=none; d=google.com; s=arc-20160816; b=RC/nvWxNJVxRPGnqPqWUsOMkpC9yxDzUxaXcyZfXOtiUeXNVHklh56vLRqoMQD/nzV KN9mqG00BqsdqzxYPMPt+ngtOAaHz3yyn45NSYTANT0vkRNUvYO+B7CZHHC+yUEYwUJI B9LGq3HyTYxHH1pudrI5Y2HPlBfVVjfHB4CD4+plPJL0LSthC22hzcxHnlbLhLvmxNNc aBFatWJbkC8LmUKIF96lVKA4yJddb2fg8hx9bJdT2VvglfREKFK/Q9XH6SC4n/7aiS4G ym/lBl5OEvoH+p162wXF/wZBPPuKlb0d7jqswslpba5QbJp+8CMuJwfhZxwbR9mGDywV FOfg== 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=k0Nkabq1tuaO6Jx8Lz7wMXjER/I0vqLUsJh7phyHdzY=; b=D4fs1FUbwxo1EyoChzS1MlMIExq/QxYNBwL+XPoG415UPc0EWQ/E3AMqCaEzfgSrhy PQS2vnIN71EMuqfcK7kePjeDspjH5jypLWYrvr2155T5beFnnp5ZU46dT+nm+c3Y/JEm XPC4c9WKY8eNbQXZkpoXdc8Ub8zCtwcRNl60LVYJ70GgPH8KUbHKl5+bWuJZOh7OC+aI b5GW4ZrybQ9v6kKS0fHPHyr/f/3LwWKhMR2KgivSCS/NbKa85GXnkdlx+x+QJtsO0oSw 1IzDSaYZ7vXUEiPU3x7Gy0T7mhBWIENVVCAye+YEttfiJfmDgmY8HzG/6UJ5x7PjzFjP Q3Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=RRVmwlCg; spf=pass (google.com: domain of gcc-patches-return-458018-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458018-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 s71si3754033pfk.12.2017.07.13.01.49.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458018-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=RRVmwlCg; spf=pass (google.com: domain of gcc-patches-return-458018-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458018-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=yp9Eh2YGb0wn/34kCWqkch2f2Yq8c 1+zEqsgS4XIHYvh/jli3g3umcnmCK3bcpEvnyUzHK3YKX1DWKz19vl7IArghrRJ+ K+KJvKWMi/NLH78UWA1M5y3pj9djSFC83WBaK2YpStj11PwpzSL+4j47vt46Dh8N gkyrAgi7mAGYAk= 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=SggvoMm5sKMsNvHWUgr6JTD5+q0=; b=RRV mwlCgGgZSX8KiiEKaakhErP89z8WyuEhLyUqx9dJadlcNhCfbpapGH89SwIs8MaE upmgaASdQX662PrrKrKfTuQdeZkVBc5xtPzhAo3cak4tgXofARLi+sO/OBXlZDvw rt22j8b35hdDtgTB+8stiVKV1v/IWASMPFFg7L6Q= Received: (qmail 7454 invoked by alias); 13 Jul 2017 08:48: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 122246 invoked by uid 89); 13 Jul 2017 08:48:39 -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=Hx-languages-length:3806 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:48:36 +0000 Received: by mail-wr0-f180.google.com with SMTP id r103so49509618wrb.0 for ; Thu, 13 Jul 2017 01:48:34 -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=k0Nkabq1tuaO6Jx8Lz7wMXjER/I0vqLUsJh7phyHdzY=; b=scAgKwCStFoHMxiHpoAxRnJIIusLmQtNAlA2JnHx3O0HOTX+p3qCKDXPuNDbnNF7BB LU6Yp1/vAGVY/IF3CByr+xeuRtZDTtxPFvY/f1mrbr+8HMzlwa11WAPNbDqXfspB6kZq b16gfW2PCqxoVX+InjQWQZzHt74dec8VwGqpjoQz0Bde61bSkXPXnUrkrYydrUG8iprY HJ26GbBH4XTtU8SHqnn4HwRcH10Ie0X/X1ZmQCVkOyTT69h8mPtZeC/+ajZM3cC9Ncoe 3jKorcgfatg723DUaLgzmIfKGta2RtODaE92UHrc7pNIykTCKIg+dY3T5CBKASdGTF0X 3slQ== X-Gm-Message-State: AIVw113scUd4ggp4CY4fxL2Sn39cHopTAWe8H5i5S0S3QfoGKJIXcroK 8MTqE6C5JhJSXOpCwdZ4wQ== X-Received: by 10.223.139.24 with SMTP id n24mr936641wra.116.1499935711428; Thu, 13 Jul 2017 01:48:31 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id e125sm4956727wmd.25.2017.07.13.01.48.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:48:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [27/77] Use is_a before LOAD_EXTEND_OP References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:48:29 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87wp7ciuxu.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds is_a checks before load_extend_op/ LOAD_EXTEND_OP calls, if that becomes useful for later patches. (load_extend_op will return UNKNOWN for any other type of mode.) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * cse.c (cse_insn): Add is_a checks. * reload.c (push_reload): Likewise. (find_reloads): Likewise. Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-07-13 09:18:31.692428965 +0100 +++ gcc/cse.c 2017-07-13 09:18:35.510085933 +0100 @@ -4923,7 +4923,8 @@ cse_insn (rtx_insn *insn) rtx_code extend_op; if (flag_expensive_optimizations && src_related == 0 && MEM_P (src) && ! do_not_record - && (extend_op = load_extend_op (mode)) != UNKNOWN) + && is_a (mode, &int_mode) + && (extend_op = load_extend_op (int_mode)) != UNKNOWN) { struct rtx_def memory_extend_buf; rtx memory_extend_rtx = &memory_extend_buf; @@ -4935,7 +4936,7 @@ cse_insn (rtx_insn *insn) PUT_CODE (memory_extend_rtx, extend_op); XEXP (memory_extend_rtx, 0) = src; - FOR_EACH_WIDER_MODE (tmode, mode) + FOR_EACH_WIDER_MODE (tmode, int_mode) { struct table_elt *larger_elt; @@ -4952,7 +4953,7 @@ cse_insn (rtx_insn *insn) larger_elt; larger_elt = larger_elt->next_same_value) if (REG_P (larger_elt->exp)) { - src_related = gen_lowpart (mode, larger_elt->exp); + src_related = gen_lowpart (int_mode, larger_elt->exp); break; } Index: gcc/reload.c =================================================================== --- gcc/reload.c 2017-07-13 09:18:32.527352795 +0100 +++ gcc/reload.c 2017-07-13 09:18:35.511085845 +0100 @@ -1050,6 +1050,7 @@ push_reload (rtx in, rtx out, rtx *inloc register class. But if it is inside a STRICT_LOW_PART, we have no choice, so we hope we do get the right register class there. */ + scalar_int_mode inner_mode; if (in != 0 && GET_CODE (in) == SUBREG && (subreg_lowpart_p (in) || strict_low) #ifdef CANNOT_CHANGE_MODE_CLASS @@ -1065,12 +1066,12 @@ push_reload (rtx in, rtx out, rtx *inloc && ((GET_MODE_PRECISION (inmode) > GET_MODE_PRECISION (GET_MODE (SUBREG_REG (in)))) || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD - && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in))) - <= UNITS_PER_WORD) + && is_a (GET_MODE (SUBREG_REG (in)), + &inner_mode) + && GET_MODE_SIZE (inner_mode) <= UNITS_PER_WORD && (GET_MODE_PRECISION (inmode) - > GET_MODE_PRECISION (GET_MODE (SUBREG_REG (in)))) - && INTEGRAL_MODE_P (GET_MODE (SUBREG_REG (in))) - && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (in))) != UNKNOWN) + > GET_MODE_PRECISION (inner_mode)) + && LOAD_EXTEND_OP (inner_mode) != UNKNOWN) || (WORD_REGISTER_OPERATIONS && (GET_MODE_PRECISION (inmode) < GET_MODE_PRECISION (GET_MODE (SUBREG_REG (in)))) @@ -3109,6 +3110,7 @@ find_reloads (rtx_insn *insn, int replac operand = SUBREG_REG (operand); /* Force reload if this is a constant or PLUS or if there may be a problem accessing OPERAND in the outer mode. */ + scalar_int_mode inner_mode; if (CONSTANT_P (operand) || GET_CODE (operand) == PLUS /* We must force a reload of paradoxical SUBREGs @@ -3146,13 +3148,13 @@ find_reloads (rtx_insn *insn, int replac || BYTES_BIG_ENDIAN || ((GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD) - && (GET_MODE_SIZE (GET_MODE (operand)) + && (is_a + (GET_MODE (operand), &inner_mode)) + && (GET_MODE_SIZE (inner_mode) <= UNITS_PER_WORD) && (GET_MODE_SIZE (operand_mode[i]) - > GET_MODE_SIZE (GET_MODE (operand))) - && INTEGRAL_MODE_P (GET_MODE (operand)) - && LOAD_EXTEND_OP (GET_MODE (operand)) - != UNKNOWN))) + > GET_MODE_SIZE (inner_mode)) + && LOAD_EXTEND_OP (inner_mode) != UNKNOWN))) ) force_reload = 1; } From patchwork Thu Jul 13 08:48:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107614 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1932298qge; Thu, 13 Jul 2017 01:50:03 -0700 (PDT) X-Received: by 10.84.129.45 with SMTP id 42mr8873100plb.150.1499935803173; Thu, 13 Jul 2017 01:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935803; cv=none; d=google.com; s=arc-20160816; b=bXP3bRodhotLnIeXIItSlhwHjlcUBhK3fgk7NZFKllDEFTpflgiLzIFX/N/9nt9OKw ubz5OA+6JPhEXnmzg0uPmj1ovVbaZ0yW67uo9QNOofnjyYc+LIrUugxAhbxw5lrGYLrl z6WihGwiskYM/GJw68k5mbDuzwdVfaVBd7/ur9E68zj92HpiEElVk4JuqsSbOTrBefr1 syPe1Yjx4kVY1lc374i2mr58D6osuSlkRsgIGKJDuODMwhqLoXA2Ug4x5osKgA2+s/U8 Ijg2dWD0TPOWQv879HA7kOafU7NQByKyBBn6YCFfFG6n81aPq6KPKs9wo5FkHnuUfRtX PxrA== 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=HuXzBKLK651wc43MX5wxw7i+GXWifewYea7n5J3K+pw=; b=OS2Ar3wdWk4RJpO4qoBigh4CdgfqJnk6w3btlON7tfCGIW8Ohzp4s5XZYsfUa2dUH7 BA5yiWMRCasvJON0v3SJdbrqsIjPvPZl7nKWWIGY9tzhLprY6j9lIABXMYhXJdbFMVHA ECQthM2ZTfs3baIbXTwrsFxPsMS6n25Z4fpXRN0G4Y0lKwc3tewEXmcjSXCZ/5n5A40g i958W0S8Prhusrg1WWd+D9Ho7xr8/s2tHSl3kYmA1J0dJ5t37SH/LLhVybt4KOSq0sJa q8Uci/p5R6IswdDqjjDy/wwzGHT0cq4jA8jZQ2V1BsZpvIRbiR/fNDeNQrzsOAo17feg 8OtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=bU+h1vgt; spf=pass (google.com: domain of gcc-patches-return-458019-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458019-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 78si3799953pfv.354.2017.07.13.01.50.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458019-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=bU+h1vgt; spf=pass (google.com: domain of gcc-patches-return-458019-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458019-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=rBCZFu+65Wf5GQEv98pEciqlrf9Yx IpGtbexLkFJCDE8S6VuV/FmPUfhyETXYcQmCLnEtlmfgjxSZpP7+UCmbmDZI4B2d lCKDGIVkYz30fOjiAAlnaAxQcVe4OozbCdq2+kO6rTZH38LDj3u6ZpKl3P7JKs3K HAC/DBfyVByRW4= 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=Wjb6BmFW78hv0VIX+9jAlgF9mZ4=; b=bU+ h1vgth4Cqn1TqBsMYCnBWpzwphERZ2VsHnEMBf+Z2hVKMU6PyLOJgsFFDpLhIClm jtxVqwIYuYBWore5+E4knVIFABWJSKmg5c8Y02HdzqgzG0lP3JcG9hDeg4RkhGuH R0tHOgy9fjy6o4H3b2eXMU0MDbGYORpLJHkagvds= Received: (qmail 15559 invoked by alias); 13 Jul 2017 08:49:01 -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 15166 invoked by uid 89); 13 Jul 2017 08:49:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:48:54 +0000 Received: by mail-wr0-f172.google.com with SMTP id k67so49345496wrc.2 for ; Thu, 13 Jul 2017 01:48:53 -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=HuXzBKLK651wc43MX5wxw7i+GXWifewYea7n5J3K+pw=; b=C4IHfsGNmhdAMRRl3lOB0CKcdC9XThHhuFA/xgM6ZlzAu1lhHQyRDL/Kw/ikiDnunH IHfVO7o5vlbqRX+OtbyxViY7ddSNA58LhMUP4WfzCI26WrilN+LRqGOniGQ41L3toxWY x7A2vLw/NwAcpiAGvtN9a+SAx3gixfbY996StNF7+IlKt4/JzF2RZXbFV9QvbtWC67CW 9sEmCS7K8qG5X6Pm3bmbAUBKiRlrcUgQfDE1ygLUiYvNCFv9XYVYXU68Sr7JpTHUbFfI /TVuyIdanvxUSUQwrMkVdLzyKFVhGk2BYOqRRbZiOh+ItxRK3F3lUp3AjypyZn7li3Tp ht7g== X-Gm-Message-State: AIVw110cgLt/sRbZQTrOY3FWBTWSOV0dbGFWdvyiGL4CwiEQb94G/caf ZY8IrQqVHg8E4OCown1zTQ== X-Received: by 10.223.154.65 with SMTP id z59mr893284wrb.136.1499935731736; Thu, 13 Jul 2017 01:48:51 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id o4sm5400371wrb.27.2017.07.13.01.48.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:48:51 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [28/77] Use is_a for miscellaneous types of test References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:48:49 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87shi0iuxa.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds is_a checks to various places that were explicitly or implicitly restricted to integers already, in cases where adding an explicit is_a is useful for later patches. In simplify_if_then_else, the: GET_MODE (XEXP (XEXP (t, 0), N)) expressions were equivalent to: GET_MODE (XEXP (t, 0)) due to the type of operation. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (sign_extend_short_imm): Add is_a checks. (try_combine): Likewise. (simplify_if_then_else): Likewise. * cse.c (cse_insn): Likewise. * dwarf2out.c (mem_loc_descriptor): Likewise. * emit-rtl.c (gen_lowpart_common): Likewise. * simplify-rtx.c (simplify_truncation): Likewise. (simplify_binary_operation_1): Likewise. (simplify_const_relational_operation): Likewise. (simplify_ternary_operation): Likewise. * tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Likewise. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:35.047126725 +0100 +++ gcc/combine.c 2017-07-13 09:18:35.965045845 +0100 @@ -1636,11 +1636,13 @@ setup_incoming_promotions (rtx_insn *fir static rtx sign_extend_short_imm (rtx src, machine_mode mode, unsigned int prec) { - if (GET_MODE_PRECISION (mode) < prec - && CONST_INT_P (src) + scalar_int_mode int_mode; + if (CONST_INT_P (src) + && is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) < prec && INTVAL (src) > 0 - && val_signbit_known_set_p (mode, INTVAL (src))) - src = GEN_INT (INTVAL (src) | ~GET_MODE_MASK (mode)); + && val_signbit_known_set_p (int_mode, INTVAL (src))) + src = GEN_INT (INTVAL (src) | ~GET_MODE_MASK (int_mode)); return src; } @@ -3166,6 +3168,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx op0 = i2src, op1 = XEXP (SET_SRC (PATTERN (i3)), 1); machine_mode compare_mode, orig_compare_mode; enum rtx_code compare_code = UNKNOWN, orig_compare_code = UNKNOWN; + scalar_int_mode mode; newpat = PATTERN (i3); newpat_dest = SET_DEST (newpat); @@ -3176,8 +3179,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, &cc_use_insn))) { compare_code = orig_compare_code = GET_CODE (*cc_use_loc); - compare_code = simplify_compare_const (compare_code, - GET_MODE (i2dest), op0, &op1); + if (is_a (GET_MODE (i2dest), &mode)) + compare_code = simplify_compare_const (compare_code, mode, + op0, &op1); target_canonicalize_comparison (&compare_code, &op0, &op1, 1); } @@ -6288,7 +6292,7 @@ simplify_if_then_else (rtx x) int i; enum rtx_code false_code; rtx reversed; - scalar_int_mode int_mode; + scalar_int_mode int_mode, inner_mode; /* Simplify storing of the truth value. */ if (comparison_p && true_rtx == const_true_rtx && false_rtx == const0_rtx) @@ -6500,6 +6504,7 @@ simplify_if_then_else (rtx x) && rtx_equal_p (XEXP (t, 1), f)) c1 = XEXP (t, 0), op = GET_CODE (t), z = f; else if (GET_CODE (t) == SIGN_EXTEND + && is_a (GET_MODE (XEXP (t, 0)), &inner_mode) && (GET_CODE (XEXP (t, 0)) == PLUS || GET_CODE (XEXP (t, 0)) == MINUS || GET_CODE (XEXP (t, 0)) == IOR @@ -6513,13 +6518,14 @@ simplify_if_then_else (rtx x) && (num_sign_bit_copies (f, GET_MODE (f)) > (unsigned int) (GET_MODE_PRECISION (int_mode) - - GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (t, 0), 0)))))) + - GET_MODE_PRECISION (inner_mode)))) { c1 = XEXP (XEXP (t, 0), 1); z = f; op = GET_CODE (XEXP (t, 0)); extend_op = SIGN_EXTEND; - m = GET_MODE (XEXP (t, 0)); + m = inner_mode; } else if (GET_CODE (t) == SIGN_EXTEND + && is_a (GET_MODE (XEXP (t, 0)), &inner_mode) && (GET_CODE (XEXP (t, 0)) == PLUS || GET_CODE (XEXP (t, 0)) == IOR || GET_CODE (XEXP (t, 0)) == XOR) @@ -6529,13 +6535,14 @@ simplify_if_then_else (rtx x) && (num_sign_bit_copies (f, GET_MODE (f)) > (unsigned int) (GET_MODE_PRECISION (int_mode) - - GET_MODE_PRECISION (GET_MODE (XEXP (XEXP (t, 0), 1)))))) + - GET_MODE_PRECISION (inner_mode)))) { c1 = XEXP (XEXP (t, 0), 0); z = f; op = GET_CODE (XEXP (t, 0)); extend_op = SIGN_EXTEND; - m = GET_MODE (XEXP (t, 0)); + m = inner_mode; } else if (GET_CODE (t) == ZERO_EXTEND + && is_a (GET_MODE (XEXP (t, 0)), &inner_mode) && (GET_CODE (XEXP (t, 0)) == PLUS || GET_CODE (XEXP (t, 0)) == MINUS || GET_CODE (XEXP (t, 0)) == IOR @@ -6548,14 +6555,15 @@ simplify_if_then_else (rtx x) && subreg_lowpart_p (XEXP (XEXP (t, 0), 0)) && rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 0)), f) && ((nonzero_bits (f, GET_MODE (f)) - & ~GET_MODE_MASK (GET_MODE (XEXP (XEXP (t, 0), 0)))) + & ~GET_MODE_MASK (inner_mode)) == 0)) { c1 = XEXP (XEXP (t, 0), 1); z = f; op = GET_CODE (XEXP (t, 0)); extend_op = ZERO_EXTEND; - m = GET_MODE (XEXP (t, 0)); + m = inner_mode; } else if (GET_CODE (t) == ZERO_EXTEND + && is_a (GET_MODE (XEXP (t, 0)), &inner_mode) && (GET_CODE (XEXP (t, 0)) == PLUS || GET_CODE (XEXP (t, 0)) == IOR || GET_CODE (XEXP (t, 0)) == XOR) @@ -6564,12 +6572,12 @@ simplify_if_then_else (rtx x) && subreg_lowpart_p (XEXP (XEXP (t, 0), 1)) && rtx_equal_p (SUBREG_REG (XEXP (XEXP (t, 0), 1)), f) && ((nonzero_bits (f, GET_MODE (f)) - & ~GET_MODE_MASK (GET_MODE (XEXP (XEXP (t, 0), 1)))) + & ~GET_MODE_MASK (inner_mode)) == 0)) { c1 = XEXP (XEXP (t, 0), 0); z = f; op = GET_CODE (XEXP (t, 0)); extend_op = ZERO_EXTEND; - m = GET_MODE (XEXP (t, 0)); + m = inner_mode; } if (z) @@ -6613,17 +6621,17 @@ simplify_if_then_else (rtx x) non-zero bit in A is C1. */ if (true_code == NE && XEXP (cond, 1) == const0_rtx && false_rtx == const0_rtx && CONST_INT_P (true_rtx) - && INTEGRAL_MODE_P (GET_MODE (XEXP (cond, 0))) - && (UINTVAL (true_rtx) & GET_MODE_MASK (mode)) - == nonzero_bits (XEXP (cond, 0), GET_MODE (XEXP (cond, 0))) - && (i = exact_log2 (UINTVAL (true_rtx) & GET_MODE_MASK (mode))) >= 0) + && is_a (mode, &int_mode) + && is_a (GET_MODE (XEXP (cond, 0)), &inner_mode) + && (UINTVAL (true_rtx) & GET_MODE_MASK (int_mode)) + == nonzero_bits (XEXP (cond, 0), inner_mode) + && (i = exact_log2 (UINTVAL (true_rtx) & GET_MODE_MASK (int_mode))) >= 0) { rtx val = XEXP (cond, 0); - machine_mode val_mode = GET_MODE (val); - if (val_mode == mode) + if (inner_mode == int_mode) return val; - else if (GET_MODE_PRECISION (val_mode) < GET_MODE_PRECISION (mode)) - return simplify_gen_unary (ZERO_EXTEND, mode, val, val_mode); + else if (GET_MODE_PRECISION (inner_mode) < GET_MODE_PRECISION (int_mode)) + return simplify_gen_unary (ZERO_EXTEND, int_mode, val, inner_mode); } return x; Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-07-13 09:18:35.510085933 +0100 +++ gcc/cse.c 2017-07-13 09:18:35.966045757 +0100 @@ -4878,13 +4878,14 @@ cse_insn (rtx_insn *insn) value. */ if (flag_expensive_optimizations && ! src_related + && is_a (mode, &int_mode) && GET_CODE (src) == AND && CONST_INT_P (XEXP (src, 1)) - && GET_MODE_SIZE (mode) < UNITS_PER_WORD) + && GET_MODE_SIZE (int_mode) < UNITS_PER_WORD) { machine_mode tmode; rtx new_and = gen_rtx_AND (VOIDmode, NULL_RTX, XEXP (src, 1)); - FOR_EACH_WIDER_MODE (tmode, mode) + FOR_EACH_WIDER_MODE (tmode, int_mode) { if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) break; @@ -4905,7 +4906,7 @@ cse_insn (rtx_insn *insn) if (REG_P (larger_elt->exp)) { src_related - = gen_lowpart (mode, larger_elt->exp); + = gen_lowpart (int_mode, larger_elt->exp); break; } Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:33.654250997 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:35.968045581 +0100 @@ -14742,31 +14742,29 @@ mem_loc_descriptor (rtx rtl, machine_mod case SIGN_EXTEND: case ZERO_EXTEND: - if (!is_a (mode, &int_mode)) + if (!is_a (mode, &int_mode) + || !is_a (GET_MODE (XEXP (rtl, 0)), &inner_mode)) break; - op0 = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (XEXP (rtl, 0)), + op0 = mem_loc_descriptor (XEXP (rtl, 0), inner_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == 0) break; else if (GET_CODE (rtl) == ZERO_EXTEND && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE - && GET_MODE_BITSIZE (GET_MODE (XEXP (rtl, 0))) - < HOST_BITS_PER_WIDE_INT + && GET_MODE_BITSIZE (inner_mode) < HOST_BITS_PER_WIDE_INT /* If DW_OP_const{1,2,4}u won't be used, it is shorter to expand zero extend as two shifts instead of masking. */ - && GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) <= 4) + && GET_MODE_SIZE (inner_mode) <= 4) { - machine_mode imode = GET_MODE (XEXP (rtl, 0)); mem_loc_result = op0; add_loc_descr (&mem_loc_result, - int_loc_descriptor (GET_MODE_MASK (imode))); + int_loc_descriptor (GET_MODE_MASK (inner_mode))); add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_and, 0, 0)); } else if (GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE) { - int shift = DWARF2_ADDR_SIZE - - GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))); + int shift = DWARF2_ADDR_SIZE - GET_MODE_SIZE (inner_mode); shift *= BITS_PER_UNIT; if (GET_CODE (rtl) == SIGN_EXTEND) op = DW_OP_shra; @@ -14783,7 +14781,7 @@ mem_loc_descriptor (rtx rtl, machine_mod dw_die_ref type_die1, type_die2; dw_loc_descr_ref cvt; - type_die1 = base_type_for_mode (GET_MODE (XEXP (rtl, 0)), + type_die1 = base_type_for_mode (inner_mode, GET_CODE (rtl) == ZERO_EXTEND); if (type_die1 == NULL) break; @@ -15328,14 +15326,15 @@ mem_loc_descriptor (rtx rtl, machine_mod if (CONST_INT_P (XEXP (rtl, 1)) && CONST_INT_P (XEXP (rtl, 2)) && is_a (mode, &int_mode) + && is_a (GET_MODE (XEXP (rtl, 0)), &inner_mode) + && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE + && GET_MODE_SIZE (inner_mode) <= DWARF2_ADDR_SIZE && ((unsigned) INTVAL (XEXP (rtl, 1)) + (unsigned) INTVAL (XEXP (rtl, 2)) - <= GET_MODE_BITSIZE (int_mode)) - && GET_MODE_SIZE (int_mode) <= DWARF2_ADDR_SIZE - && GET_MODE_SIZE (GET_MODE (XEXP (rtl, 0))) <= DWARF2_ADDR_SIZE) + <= GET_MODE_BITSIZE (int_mode))) { int shift, size; - op0 = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (XEXP (rtl, 0)), + op0 = mem_loc_descriptor (XEXP (rtl, 0), inner_mode, mem_mode, VAR_INIT_STATUS_INITIALIZED); if (op0 == 0) break; @@ -15347,8 +15346,7 @@ mem_loc_descriptor (rtx rtl, machine_mod size = INTVAL (XEXP (rtl, 1)); shift = INTVAL (XEXP (rtl, 2)); if (BITS_BIG_ENDIAN) - shift = GET_MODE_BITSIZE (GET_MODE (XEXP (rtl, 0))) - - shift - size; + shift = GET_MODE_BITSIZE (inner_mode) - shift - size; if (shift + size != (int) DWARF2_ADDR_SIZE) { add_loc_descr (&mem_loc_result, Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:29.215658896 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:35.969045492 +0100 @@ -1430,9 +1430,11 @@ gen_lowpart_common (machine_mode mode, r if (SCALAR_FLOAT_MODE_P (mode) && msize > xsize) return 0; + scalar_int_mode int_mode, int_innermode, from_mode; if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND) - && (GET_MODE_CLASS (mode) == MODE_INT - || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)) + && is_a (mode, &int_mode) + && is_a (innermode, &int_innermode) + && is_a (GET_MODE (XEXP (x, 0)), &from_mode)) { /* If we are getting the low-order part of something that has been sign- or zero-extended, we can either just use the object being @@ -1442,12 +1444,12 @@ gen_lowpart_common (machine_mode mode, r This case is used mostly by combine and cse. */ - if (GET_MODE (XEXP (x, 0)) == mode) + if (from_mode == int_mode) return XEXP (x, 0); - else if (msize < GET_MODE_SIZE (GET_MODE (XEXP (x, 0)))) - return gen_lowpart_common (mode, XEXP (x, 0)); - else if (msize < xsize) - return gen_rtx_fmt_e (GET_CODE (x), mode, XEXP (x, 0)); + else if (GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (from_mode)) + return gen_lowpart_common (int_mode, XEXP (x, 0)); + else if (GET_MODE_SIZE (int_mode) < GET_MODE_SIZE (int_innermode)) + return gen_rtx_fmt_e (GET_CODE (x), int_mode, XEXP (x, 0)); } else if (GET_CODE (x) == SUBREG || REG_P (x) || GET_CODE (x) == CONCAT || GET_CODE (x) == CONST_VECTOR Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:35.051126373 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:35.969045492 +0100 @@ -808,21 +808,22 @@ simplify_truncation (machine_mode mode, if the MEM has a mode-dependent address. */ if ((GET_CODE (op) == LSHIFTRT || GET_CODE (op) == ASHIFTRT) + && is_a (mode, &int_mode) && is_a (op_mode, &int_op_mode) && MEM_P (XEXP (op, 0)) && CONST_INT_P (XEXP (op, 1)) - && (INTVAL (XEXP (op, 1)) % GET_MODE_BITSIZE (mode)) == 0 + && INTVAL (XEXP (op, 1)) % GET_MODE_BITSIZE (int_mode) == 0 && INTVAL (XEXP (op, 1)) > 0 && INTVAL (XEXP (op, 1)) < GET_MODE_BITSIZE (int_op_mode) && ! mode_dependent_address_p (XEXP (XEXP (op, 0), 0), MEM_ADDR_SPACE (XEXP (op, 0))) && ! MEM_VOLATILE_P (XEXP (op, 0)) - && (GET_MODE_SIZE (mode) >= UNITS_PER_WORD + && (GET_MODE_SIZE (int_mode) >= UNITS_PER_WORD || WORDS_BIG_ENDIAN == BYTES_BIG_ENDIAN)) { - int byte = subreg_lowpart_offset (mode, int_op_mode); + int byte = subreg_lowpart_offset (int_mode, int_op_mode); int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT; - return adjust_address_nv (XEXP (op, 0), mode, + return adjust_address_nv (XEXP (op, 0), int_mode, (WORDS_BIG_ENDIAN ? byte - shifted_bytes : byte + shifted_bytes)); @@ -2980,19 +2981,21 @@ simplify_binary_operation_1 (enum rtx_co is (lt foo (const_int 0)), so we can perform the above simplification if STORE_FLAG_VALUE is 1. */ - if (STORE_FLAG_VALUE == 1 + if (is_a (mode, &int_mode) + && STORE_FLAG_VALUE == 1 && trueop1 == const1_rtx && GET_CODE (op0) == LSHIFTRT && CONST_INT_P (XEXP (op0, 1)) - && INTVAL (XEXP (op0, 1)) == GET_MODE_PRECISION (mode) - 1) - return gen_rtx_GE (mode, XEXP (op0, 0), const0_rtx); + && INTVAL (XEXP (op0, 1)) == GET_MODE_PRECISION (int_mode) - 1) + return gen_rtx_GE (int_mode, XEXP (op0, 0), const0_rtx); /* (xor (comparison foo bar) (const_int sign-bit)) when STORE_FLAG_VALUE is the sign bit. */ - if (val_signbit_p (mode, STORE_FLAG_VALUE) + if (is_a (mode, &int_mode) + && val_signbit_p (int_mode, STORE_FLAG_VALUE) && trueop1 == const_true_rtx && COMPARISON_P (op0) - && (reversed = reversed_comparison (op0, mode))) + && (reversed = reversed_comparison (op0, int_mode))) return reversed; tem = simplify_byte_swapping_operation (code, mode, op0, op1); @@ -3415,17 +3418,17 @@ simplify_binary_operation_1 (enum rtx_co return op0; /* Optimize (lshiftrt (clz X) C) as (eq X 0). */ if (GET_CODE (op0) == CLZ + && is_a (GET_MODE (XEXP (op0, 0)), &inner_mode) && CONST_INT_P (trueop1) && STORE_FLAG_VALUE == 1 && INTVAL (trueop1) < (HOST_WIDE_INT)width) { - machine_mode imode = GET_MODE (XEXP (op0, 0)); unsigned HOST_WIDE_INT zero_val = 0; - if (CLZ_DEFINED_VALUE_AT_ZERO (imode, zero_val) - && zero_val == GET_MODE_PRECISION (imode) + if (CLZ_DEFINED_VALUE_AT_ZERO (inner_mode, zero_val) + && zero_val == GET_MODE_PRECISION (inner_mode) && INTVAL (trueop1) == exact_log2 (zero_val)) - return simplify_gen_relational (EQ, mode, imode, + return simplify_gen_relational (EQ, mode, inner_mode, XEXP (op0, 0), const0_rtx); } goto canonicalize_shift; @@ -5266,7 +5269,9 @@ simplify_const_relational_operation (enu } /* Optimize integer comparisons with zero. */ - if (trueop1 == const0_rtx && !side_effects_p (trueop0)) + if (is_a (mode, &int_mode) + && trueop1 == const0_rtx + && !side_effects_p (trueop0)) { /* Some addresses are known to be nonzero. We don't know their sign, but equality comparisons are known. */ @@ -5285,7 +5290,7 @@ simplify_const_relational_operation (enu rtx inner_const = avoid_constant_pool_reference (XEXP (op0, 1)); if (CONST_INT_P (inner_const) && inner_const != const0_rtx) { - int sign_bitnum = GET_MODE_PRECISION (mode) - 1; + int sign_bitnum = GET_MODE_PRECISION (int_mode) - 1; int has_sign = (HOST_BITS_PER_WIDE_INT >= sign_bitnum && (UINTVAL (inner_const) & (HOST_WIDE_INT_1U @@ -5401,13 +5406,9 @@ simplify_ternary_operation (enum rtx_cod machine_mode op0_mode, rtx op0, rtx op1, rtx op2) { - unsigned int width = GET_MODE_PRECISION (mode); bool any_change = false; rtx tem, trueop2; - - /* VOIDmode means "infinite" precision. */ - if (width == 0) - width = HOST_BITS_PER_WIDE_INT; + scalar_int_mode int_mode, int_op0_mode; switch (code) { @@ -5441,17 +5442,21 @@ simplify_ternary_operation (enum rtx_cod if (CONST_INT_P (op0) && CONST_INT_P (op1) && CONST_INT_P (op2) - && ((unsigned) INTVAL (op1) + (unsigned) INTVAL (op2) <= width) - && width <= (unsigned) HOST_BITS_PER_WIDE_INT) + && is_a (mode, &int_mode) + && INTVAL (op1) + INTVAL (op2) <= GET_MODE_PRECISION (int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode)) { /* Extracting a bit-field from a constant */ unsigned HOST_WIDE_INT val = UINTVAL (op0); HOST_WIDE_INT op1val = INTVAL (op1); HOST_WIDE_INT op2val = INTVAL (op2); - if (BITS_BIG_ENDIAN) - val >>= GET_MODE_PRECISION (op0_mode) - op2val - op1val; - else + if (!BITS_BIG_ENDIAN) val >>= op2val; + else if (is_a (op0_mode, &int_op0_mode)) + val >>= GET_MODE_PRECISION (int_op0_mode) - op2val - op1val; + else + /* Not enough information to calculate the bit position. */ + break; if (HOST_BITS_PER_WIDE_INT != op1val) { @@ -5464,7 +5469,7 @@ simplify_ternary_operation (enum rtx_cod val |= ~ ((HOST_WIDE_INT_1U << op1val) - 1); } - return gen_int_mode (val, mode); + return gen_int_mode (val, int_mode); } break; Index: gcc/tree-ssa-loop-ivopts.c =================================================================== --- gcc/tree-ssa-loop-ivopts.c 2017-06-08 08:51:43.228281186 +0100 +++ gcc/tree-ssa-loop-ivopts.c 2017-07-13 09:18:35.970045404 +0100 @@ -4011,6 +4011,7 @@ force_expr_to_var_cost (tree expr, bool tree op0, op1; comp_cost cost0, cost1, cost; machine_mode mode; + scalar_int_mode int_mode; if (!costs_initialized) { @@ -4133,8 +4134,9 @@ force_expr_to_var_cost (tree expr, bool mult = op0; if (mult != NULL_TREE + && is_a (mode, &int_mode) && cst_and_fits_in_hwi (TREE_OPERAND (mult, 1)) - && get_shiftadd_cost (expr, mode, cost0, cost1, mult, + && get_shiftadd_cost (expr, int_mode, cost0, cost1, mult, speed, &sa_cost)) return sa_cost; } From patchwork Thu Jul 13 08:49:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107615 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1932588qge; Thu, 13 Jul 2017 01:50:28 -0700 (PDT) X-Received: by 10.98.198.87 with SMTP id m84mr60664073pfg.122.1499935828088; Thu, 13 Jul 2017 01:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935828; cv=none; d=google.com; s=arc-20160816; b=McML/zbWbX4RqU3kFyCMshDqVX3N2iu08GiAYz6clmtaWZTa6uqrQ4Bi6APoEYE8jU 6/92bRXs1KUqULgAHIhUepq/Mor6k/xWbsNWU9d3DEJf8e1ilO7NzPdAxiHmwoVCeeMH R/CbG/LgfLOxkTSevU76ietdigdQwlGtSWILD5euqs5lEPelOsDv6iLnvM/shNarVaXk aOgngLcPmTK7dxcNJBC8P181r4uc3UTP7kpW0LU6B7oNeYHKIK8lFc+qMRy/BcUpiVLx r4h+dSI1VlbLLvt6rv/QOHX48wzmsoD7viWP50/lgd/u/vxjSFOFyQvwLNn//EJ5PAIW bXmg== 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=ariXgZEf6uN/UuLg0lBk4baJjzPAu8+lHTFov4MOJPI=; b=Hu74j/M1BlMOeGqmLUTKY3qdmYUoSp2tk3/kFfSDqcYbTWeYJrVvs033m+lJZRbPFH MIE/+saAJsMnMa1AqByrjGdWSRjYR6HBQ1H5VtIAKsqGHH9UBNt2HJAFLkCsXP9NFIpX rkqGysDTsdHeFB9V0/oOd1uXSDJWU/qwdP3KYzxdCLkHyhy68whmgmaUqa5iZ8ZrR+nM SuJtV+5pf4WaFZBDUmXOztEK7I/V60hTZtmbffzMu0Q6D3DAqy7fii6nIQ98nJQQVw5m gwB90lhPvLkYC2Zy037N1gKqS3vV1Bysz/yaqpsDYKIddyAQ6m/Nca7WrJ9eRapayXA3 K1Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=ZJgBwNZi; spf=pass (google.com: domain of gcc-patches-return-458020-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458020-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 m22si3757709pfk.233.2017.07.13.01.50.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:50:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458020-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=ZJgBwNZi; spf=pass (google.com: domain of gcc-patches-return-458020-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458020-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=S/cmTe6pMX73LIYorumyRHfQ0xIKW lIOtswnVNFIDDqgt8YF8GwPULNL1fk6kuwJFiB/+B3EFUdiLKWJ+cc/+3kracs/e 9uTXfMWMxsDUE9mKDXo55q+NyWK08u7NcU81PIJp3ZIkv++BztpMd1fSsTODf2F7 JMtQnttU/qMti0= 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=i2dHY1R6Wem93sUXZ2s2qDssNKo=; b=ZJg BwNZiIJromfZ1XBl6AIV8xdtFiXehdN9RWl9axwJzpqy+yxvtRCv5iLHQ1EsP4y9 J0aUsJHU0RcpvB5fokv+f5T3lrwv9zwzO4AkjvpvWrO/tyxIL/LNx+S5FPO0uNJ4 N5E8sR9IBCeAxQ+UMWzZvyLNsNUbUc1py06KBK3w= Received: (qmail 27780 invoked by alias); 13 Jul 2017 08:49:18 -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 26245 invoked by uid 89); 13 Jul 2017 08:49:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:49:13 +0000 Received: by mail-wm0-f50.google.com with SMTP id w126so16569097wme.0 for ; Thu, 13 Jul 2017 01:49:13 -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=ariXgZEf6uN/UuLg0lBk4baJjzPAu8+lHTFov4MOJPI=; b=HryQz51t+IwvnE6YOHZAP6gQ3TtJvTtXpLDOUh0VkY8jUyxm/H52GOW3ERsvYCta/F l9GYUhXO+04+wxPdnucDTGpT7zkEiYya0ICywtOmYyhkeWzK7h6ZpYPjKDt+sNlMZ+D2 ju8oz6/YnIYQFOCjtgU/TrNF8R+vshPGOO2SQfYafvFlJwSu+0tfNps8XxEQr9bioz8N LcGPkXBhDr67NApzFjeCcaQksgfDqPVgEXKjuU7dFPmlbPgdilYerw3/WVZw9Y20lKtR UZfc+vyB1Dvdy5Pgf3gpZH4fPpyWAsrq0HSL9xaMr4Z1gd6i97bMYDUKl5xM6schfHWL u4LQ== X-Gm-Message-State: AIVw113DKCRmmAxnV+GIzz5z+S1pRErK1RTLjK/5SOvDACv6Oc86U2Ng yj7TBB9ntzoXnrA8lMr5ow== X-Received: by 10.28.10.208 with SMTP id 199mr1141298wmk.127.1499935751470; Thu, 13 Jul 2017 01:49:11 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 2sm3289986wrn.24.2017.07.13.01.49.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:49:10 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [29/77] Make some *_loc_descriptor helpers take scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:49:09 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87o9soiuwq.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The *_loc_descriptor routines for clz, popcount, bswap and rotate all required SCALAR_INT_MODE_P. This patch moves the checks into the caller (mem_loc_descriptor) so that the types of the mode parameters can be scalar_int_mode instead of machine_mode. The MOD handling in mem_loc_descriptor is also specific to scalar integer modes. Adding an explicit check allows typed_binop to take a scalar_int_mode too. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * dwarf2out.c (typed_binop): Change mode parameter to scalar_int_mode. (clz_loc_descriptor): Likewise. Remove SCALAR_INT_MODE_P check. (popcount_loc_descriptor): Likewise. (bswap_loc_descriptor): Likewise. (rotate_loc_descriptor): Likewise. (mem_loc_descriptor): Add is_a checks before calling the functions above. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:35.968045581 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:36.422005956 +0100 @@ -14156,7 +14156,7 @@ minmax_loc_descriptor (rtx rtl, machine_ static dw_loc_descr_ref typed_binop (enum dwarf_location_atom op, rtx rtl, dw_die_ref type_die, - machine_mode mode, machine_mode mem_mode) + scalar_int_mode mode, machine_mode mem_mode) { dw_loc_descr_ref cvt, op0, op1; @@ -14212,7 +14212,7 @@ typed_binop (enum dwarf_location_atom op L4: DW_OP_nop */ static dw_loc_descr_ref -clz_loc_descriptor (rtx rtl, machine_mode mode, +clz_loc_descriptor (rtx rtl, scalar_int_mode mode, machine_mode mem_mode) { dw_loc_descr_ref op0, ret, tmp; @@ -14223,8 +14223,7 @@ clz_loc_descriptor (rtx rtl, machine_mod dw_loc_descr_ref l4jump, l4label; rtx msb; - if (!SCALAR_INT_MODE_P (mode) - || GET_MODE (XEXP (rtl, 0)) != mode) + if (GET_MODE (XEXP (rtl, 0)) != mode) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, @@ -14324,15 +14323,14 @@ clz_loc_descriptor (rtx rtl, machine_mod L2: DW_OP_drop */ static dw_loc_descr_ref -popcount_loc_descriptor (rtx rtl, machine_mode mode, +popcount_loc_descriptor (rtx rtl, scalar_int_mode mode, machine_mode mem_mode) { dw_loc_descr_ref op0, ret, tmp; dw_loc_descr_ref l1jump, l1label; dw_loc_descr_ref l2jump, l2label; - if (!SCALAR_INT_MODE_P (mode) - || GET_MODE (XEXP (rtl, 0)) != mode) + if (GET_MODE (XEXP (rtl, 0)) != mode) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, @@ -14385,17 +14383,16 @@ popcount_loc_descriptor (rtx rtl, machin L2: DW_OP_drop DW_OP_swap DW_OP_drop */ static dw_loc_descr_ref -bswap_loc_descriptor (rtx rtl, machine_mode mode, +bswap_loc_descriptor (rtx rtl, scalar_int_mode mode, machine_mode mem_mode) { dw_loc_descr_ref op0, ret, tmp; dw_loc_descr_ref l1jump, l1label; dw_loc_descr_ref l2jump, l2label; - if (!SCALAR_INT_MODE_P (mode) - || BITS_PER_UNIT != 8 + if (BITS_PER_UNIT != 8 || (GET_MODE_BITSIZE (mode) != 32 - && GET_MODE_BITSIZE (mode) != 64)) + && GET_MODE_BITSIZE (mode) != 64)) return NULL; op0 = mem_loc_descriptor (XEXP (rtl, 0), mode, mem_mode, @@ -14470,16 +14467,13 @@ bswap_loc_descriptor (rtx rtl, machine_m [ DW_OP_swap constMASK DW_OP_and DW_OP_swap ] DW_OP_shr DW_OP_or */ static dw_loc_descr_ref -rotate_loc_descriptor (rtx rtl, machine_mode mode, +rotate_loc_descriptor (rtx rtl, scalar_int_mode mode, machine_mode mem_mode) { rtx rtlop1 = XEXP (rtl, 1); dw_loc_descr_ref op0, op1, ret, mask[2] = { NULL, NULL }; int i; - if (!SCALAR_INT_MODE_P (mode)) - return NULL; - if (GET_MODE (rtlop1) != VOIDmode && GET_MODE_BITSIZE (GET_MODE (rtlop1)) < GET_MODE_BITSIZE (mode)) rtlop1 = gen_rtx_ZERO_EXTEND (mode, rtlop1); @@ -15085,12 +15079,13 @@ mem_loc_descriptor (rtx rtl, machine_mod break; case MOD: - if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE - && (!dwarf_strict || dwarf_version >= 5)) + if ((!dwarf_strict || dwarf_version >= 5) + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) > DWARF2_ADDR_SIZE) { mem_loc_result = typed_binop (DW_OP_mod, rtl, base_type_for_mode (mode, 0), - mode, mem_mode); + int_mode, mem_mode); break; } @@ -15442,21 +15437,25 @@ mem_loc_descriptor (rtx rtl, machine_mod case CLZ: case CTZ: case FFS: - mem_loc_result = clz_loc_descriptor (rtl, mode, mem_mode); + if (is_a (mode, &int_mode)) + mem_loc_result = clz_loc_descriptor (rtl, int_mode, mem_mode); break; case POPCOUNT: case PARITY: - mem_loc_result = popcount_loc_descriptor (rtl, mode, mem_mode); + if (is_a (mode, &int_mode)) + mem_loc_result = popcount_loc_descriptor (rtl, int_mode, mem_mode); break; case BSWAP: - mem_loc_result = bswap_loc_descriptor (rtl, mode, mem_mode); + if (is_a (mode, &int_mode)) + mem_loc_result = bswap_loc_descriptor (rtl, int_mode, mem_mode); break; case ROTATE: case ROTATERT: - mem_loc_result = rotate_loc_descriptor (rtl, mode, mem_mode); + if (is_a (mode, &int_mode)) + mem_loc_result = rotate_loc_descriptor (rtl, int_mode, mem_mode); break; case COMPARE: From patchwork Thu Jul 13 08:49:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107616 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1932813qge; Thu, 13 Jul 2017 01:50:40 -0700 (PDT) X-Received: by 10.98.86.193 with SMTP id h62mr59473014pfj.205.1499935839913; Thu, 13 Jul 2017 01:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935839; cv=none; d=google.com; s=arc-20160816; b=E9nxHmCglVM6uLBdV4bLPsS0wWlYP/mDzEIrvyLg21uwM9zHtf98QZjP5dyhFXIZoa 7MiGCJfhDHdsc2D9By3PpIgZJRnpL+adhDJh9Q5e8CQZHD4JH6FPQAoor1qova3YKP8K ZKpPJ2HU5JTZZRT4JfVPeeSvmRrt6497LwOAh0MbxILu1lLdg1OZ8PU6MHb6gEGJjcyl 2y3U4jpQlLjKi9ZrMONVzbotFWwsy6p+0XXWCqMtrI9e/4zp3ynTjjD63oTbC554RkfP 4x3cUjvi3yw9UlM9GxVfUJYFBS8HbrGjGZ8arX2BbxbJFGlHQPIHoDJVF3pZCjQR5FN0 GqeQ== 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=oXqnb5gyhGuTnagNE6pQsp6dMTd55t1JUsbGCB5XZds=; b=Vp/9vNp8E0g7peRNEtCP4NpGjNfNvsqskRfGHowo6RQAwDheQuYjFhsEaGTx7urSI8 P7VYy5+MwYxwDAL1y780+vRncLjwUtrs05xHjJLAgSpnCl7Jotp0KyYh9uGGy16GAwTt 0fLJ01gL5ffJ/wDet3HYiBomO7QU0iHY/sy1jlXbWvKoN49SYR1JqWvysEQAR/bUm3Pv pN2uBN9QllDUlhozmggzKDm1STuUOufohdBr+tCiPWCu0mfGayiiUvgWZw+3HWjEHpDS 75Sc/vOMDfCIKlWOlX3x7ZWtkqy+uK8GGl+dVsq3iHLLmR2GxLqk9XjQFjdHi+AV8eQZ rvFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=g7lIa46J; spf=pass (google.com: domain of gcc-patches-return-458021-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458021-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 y66si3761209pgb.540.2017.07.13.01.50.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:50:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458021-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=g7lIa46J; spf=pass (google.com: domain of gcc-patches-return-458021-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458021-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=hxKPNpbKuMDkRKZ2aYe8qtjwNG/sb aatMKRUFC2rYQM4oqXZnuc3Vyw6ndabmMnPMolZ4JqT0/1Iq04Py7TZRAKeWx2m5 x/NjeMgrmzyhjfzvQvkAMr8pHSHoweERWKPiTsDU62Gnu1symI+UQxRY2IveoaP/ ymxqx7RldChym0= 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=+eh59F1ui8nesX/q1T3qj1elfLo=; b=g7l Ia46JXMwyhW72USh8pzhHCWa67ODwco/xG2RZ/3qxvVes3KIcrkXlbbn1r1aCIe1 EYqPqHaC+t4GLVRh4taxDJpievm0+3UGc5qDOZiKZOyjtAQ2CtU3Pt8Ne72LoEkD 9oALaBrHk6mgbPNt7NrW5aoJAM6wxEArqqDAP1Ks= Received: (qmail 42116 invoked by alias); 13 Jul 2017 08:49:36 -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 41378 invoked by uid 89); 13 Jul 2017 08:49:35 -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-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:49:33 +0000 Received: by mail-wm0-f51.google.com with SMTP id 62so16618047wmw.1 for ; Thu, 13 Jul 2017 01:49:32 -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=oXqnb5gyhGuTnagNE6pQsp6dMTd55t1JUsbGCB5XZds=; b=K7PnPGSYXEz1Lrvui+M1KMvApiaex2gOKYXga45pyFil1FZfFTiKjuN4Df3wXOgBFf RriiMkhjS5exINFKO9lghC8pFYqq4TatmIbHXsO585vqR8G8d8Cs6B0z/t9OvoAbf2LH cLqtEU3DIMzDb1l4REyJ5wz6Jb9V9YaSnnoBJ4GU8MuSFFiPF/XT9mBQfM9irsof3Hd/ XEIV9cnFu6mXgiPTJTMS5C2amtqvSgPgAc242bLSN6+q2acsNv9gpBvfhfGjR0pirM7l nHzPLc5u/KX7YmmHKVCSrzXgg/XsIz/h+FRbakROgyHXwdZIq0iJ1VitEOtpxcJXdofk jG3A== X-Gm-Message-State: AIVw113Zf7HGio4sqmp1kTfjx7ZH7FYpvC9ovIngeCTLotI6e4jcI5Cn AaMgLb99hjr7Vomnn/ZC7Q== X-Received: by 10.28.51.212 with SMTP id z203mr1258354wmz.103.1499935770660; Thu, 13 Jul 2017 01:49:30 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id o197sm6454619wmd.9.2017.07.13.01.49.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:49:29 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [30/77] Use scalar_int_mode for doubleword splits References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:49:28 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87k23ciuw7.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses is_a in a couple of places that were splitting doubleword integer operations into word_mode operations. It also uses scalar_int_mode in the expand_expr_real_2 handling of doubleword shifts. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (expand_expr_real_2): Use scalar_int_mode for the double-word mode. * lower-subreg.c (resolve_shift_zext): Use is_a . * optabs.c (expand_unop): Likewise. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:35.048126637 +0100 +++ gcc/expr.c 2017-07-13 09:18:36.841969327 +0100 @@ -8201,6 +8201,7 @@ expand_expr_real_2 (sepops ops, rtx targ tree type; int unsignedp; machine_mode mode; + scalar_int_mode int_mode; enum tree_code code = ops->code; optab this_optab; rtx subtarget, original_target; @@ -9165,8 +9166,8 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b if (code == LSHIFT_EXPR && target && REG_P (target) - && mode == GET_MODE_WIDER_MODE (word_mode).else_void () - && GET_MODE_SIZE (mode) == 2 * GET_MODE_SIZE (word_mode) + && GET_MODE_2XWIDER_MODE (word_mode).exists (&int_mode) + && mode == int_mode && TREE_CONSTANT (treeop1) && TREE_CODE (treeop0) == SSA_NAME) { @@ -9177,20 +9178,20 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b machine_mode rmode = TYPE_MODE (TREE_TYPE (gimple_assign_rhs1 (def))); - if (GET_MODE_SIZE (rmode) < GET_MODE_SIZE (mode) + if (GET_MODE_SIZE (rmode) < GET_MODE_SIZE (int_mode) && TREE_INT_CST_LOW (treeop1) < GET_MODE_BITSIZE (word_mode) && ((TREE_INT_CST_LOW (treeop1) + GET_MODE_BITSIZE (rmode)) >= GET_MODE_BITSIZE (word_mode))) { rtx_insn *seq, *seq_old; unsigned int high_off = subreg_highpart_offset (word_mode, - mode); + int_mode); bool extend_unsigned = TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (def))); - rtx low = lowpart_subreg (word_mode, op0, mode); - rtx dest_low = lowpart_subreg (word_mode, target, mode); + rtx low = lowpart_subreg (word_mode, op0, int_mode); + rtx dest_low = lowpart_subreg (word_mode, target, int_mode); rtx dest_high = simplify_gen_subreg (word_mode, target, - mode, high_off); + int_mode, high_off); HOST_WIDE_INT ramount = (BITS_PER_WORD - TREE_INT_CST_LOW (treeop1)); tree rshift = build_int_cst (TREE_TYPE (treeop1), ramount); @@ -9213,12 +9214,13 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b end_sequence (); temp = target ; - if (have_insn_for (ASHIFT, mode)) + if (have_insn_for (ASHIFT, int_mode)) { bool speed_p = optimize_insn_for_speed_p (); start_sequence (); - rtx ret_old = expand_variable_shift (code, mode, op0, - treeop1, target, + rtx ret_old = expand_variable_shift (code, int_mode, + op0, treeop1, + target, unsignedp); seq_old = get_insns (); Index: gcc/lower-subreg.c =================================================================== --- gcc/lower-subreg.c 2017-07-13 09:18:29.217658709 +0100 +++ gcc/lower-subreg.c 2017-07-13 09:18:36.841969327 +0100 @@ -1219,6 +1219,7 @@ resolve_shift_zext (rtx_insn *insn) rtx_insn *insns; rtx src_reg, dest_reg, dest_upper, upper_src = NULL_RTX; int src_reg_num, dest_reg_num, offset1, offset2, src_offset; + scalar_int_mode inner_mode; set = single_set (insn); if (!set) @@ -1232,6 +1233,8 @@ resolve_shift_zext (rtx_insn *insn) return NULL; op_operand = XEXP (op, 0); + if (!is_a (GET_MODE (op_operand), &inner_mode)) + return NULL; /* We can tear this operation apart only if the regs were already torn apart. */ @@ -1244,8 +1247,7 @@ resolve_shift_zext (rtx_insn *insn) src_reg_num = (GET_CODE (op) == LSHIFTRT || GET_CODE (op) == ASHIFTRT) ? 1 : 0; - if (WORDS_BIG_ENDIAN - && GET_MODE_SIZE (GET_MODE (op_operand)) > UNITS_PER_WORD) + if (WORDS_BIG_ENDIAN && GET_MODE_SIZE (inner_mode) > UNITS_PER_WORD) src_reg_num = 1 - src_reg_num; if (GET_CODE (op) == ZERO_EXTEND) Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:35.049126549 +0100 +++ gcc/optabs.c 2017-07-13 09:18:36.842969240 +0100 @@ -2736,22 +2736,24 @@ expand_unop (machine_mode mode, optab un } if (unoptab == popcount_optab - && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD && optab_handler (unoptab, word_mode) != CODE_FOR_nothing && optimize_insn_for_speed_p ()) { - temp = expand_doubleword_popcount (mode, op0, target); + temp = expand_doubleword_popcount (int_mode, op0, target); if (temp) return temp; } if (unoptab == parity_optab - && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD + && is_a (mode, &int_mode) + && GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD && (optab_handler (unoptab, word_mode) != CODE_FOR_nothing || optab_handler (popcount_optab, word_mode) != CODE_FOR_nothing) && optimize_insn_for_speed_p ()) { - temp = expand_doubleword_parity (mode, op0, target); + temp = expand_doubleword_parity (int_mode, op0, target); if (temp) return temp; } From patchwork Thu Jul 13 08:49:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107617 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1933104qge; Thu, 13 Jul 2017 01:51:01 -0700 (PDT) X-Received: by 10.84.232.134 with SMTP id i6mr8926618plk.248.1499935861414; Thu, 13 Jul 2017 01:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935861; cv=none; d=google.com; s=arc-20160816; b=eojPaskgAwucf4C9SFOPz9uIvmky1y+KcY9W48K67BThosovQAKlQxN1+L0HjT/FFl qGqGml7dAizAYdFF00JDBXKPlls0N+UN7S/1WRKFD5GAcHODE11I4oQuWxPkbr51iWoj CjVzw0ccFeg6aYgBfs6b+3PpUERpT4rJY7ujXlhN+2EnDIqf8Ytv8rf1mjeTbdK5SiKI lsp5ZHsaaTV5wunBExm5sWDmu/iVwUt7TUTCN2HWoKXgfec38fMmI8SMKwuMYUUd38g5 aSyHx5e8CgzUyFC5jPSS+MytgJT1BiWJ5yJTMFByY+b8FJbr8R0beMfMghmTRmD9OBEP 7djg== 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=SSzitk/c6NjOpueX23hEf7wHcMl38bSO0ogoWq7+sJw=; b=BkHmvezZsdEaV20Bd3wAJoqmbuzOnIq8xz9QVS7X5z8b4OPibMR6eJZpCYXSOkTPUA FaD0l2oWtu3CD5k4+rvqtVT60HjlQ2yHaxNVvA5SsnK9U2lku7BRQj29sp9aRovT41jL KhdQBgbqZiSoHIy9KXGbNH7p/zFYz7sXO5548VoMP5e9b+tKwaBYw9c3SwAJb7yRQKqB RUr95ZiZhyWXKir9Y5F6uM0vDF4VlbWvEipvQDrLtJnN+vLvXu8pSqqR0aztFdmjyrdI D59T65s99qPeeKhXmwpKFPhiHRwO+AYHKm9FOwswq+Hnf8PXvinsDDQ9AnM5wJeiv3Jm f4Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=xozYjVRd; spf=pass (google.com: domain of gcc-patches-return-458022-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458022-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 e3si4105954plb.11.2017.07.13.01.51.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:51:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458022-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=xozYjVRd; spf=pass (google.com: domain of gcc-patches-return-458022-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458022-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=lTgKJInRSPNokm1XnsyRz9XC3UHeq nbgqaYcsLCRsD55Z4/7N7Eg9l3S6VF4AddoOLDW8vaI5NNBVtrprN1xOKfqe3ibo OBXeHPf2Xc3JxJiRiUuZO6G9xRCIIYDFrhM0TQZcDaitL7jl5aCH/mOLG8pSQ6pv TqobH9AXY2UFhM= 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=Op+Ixwjw3mrWVCaIctdrhDzcFdU=; b=xoz YjVRdNV+Byn7v5doARqIMnsMiWUTYE3H+fhfOqxA3jDaS+XnVYhadWXVxrC2+aUx dFgGgJ3x248H6tmFs6h5Q2m2Zo7CK1cnSRyBWgOz+fdHFt1ZALV+GY7yz0/4XrNC JGMeSJNXgf47r2DPMOCGjyQYiYgIoWrWO2VQ/2dk= Received: (qmail 63928 invoked by alias); 13 Jul 2017 08:50:00 -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 60529 invoked by uid 89); 13 Jul 2017 08:49:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=guarding X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:49:51 +0000 Received: by mail-wr0-f173.google.com with SMTP id 77so49638955wrb.1 for ; Thu, 13 Jul 2017 01:49:51 -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=SSzitk/c6NjOpueX23hEf7wHcMl38bSO0ogoWq7+sJw=; b=iaKp1T4cmNzNebX4hO/ZZ8aT+GS6bbKQBW/veME24VyDcgmwsppHP6WQxcvYpI182t uFUnxUxsYBIqaE0zf7YvBiFAzbAJ/TrJ1loVQtlP34SG8xhI0z3p/lhb69vGs3ZaQrWG UF+HP3kPeZ9479KLM6t4MnuHprB2mqYi4FKfa/F0oczq+33xnbjOr38+J6TAufbe0K9K PfMs5/wBXhn9G8zRlSblFCjgSh9dtX3wtQZ5/v0l8B8De4+EX/npyuhPCZH0PpfObmWT 62u3OmBUaL+m7Ry8U74L402AaC5EGNoZjikeeGEokxbpIYBe9MhOAjZf3S5ThHeIup/+ YXTA== X-Gm-Message-State: AIVw110kd9g8T/8JokBWVkPlSMEturkvKubdQHH4nxVPIZ4Gy//qUGM0 1zggG7Td6gEOUDrx8c/zTw== X-Received: by 10.223.163.12 with SMTP id c12mr883295wrb.85.1499935789459; Thu, 13 Jul 2017 01:49:49 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b83sm3033117wmh.30.2017.07.13.01.49.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:49:48 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [31/77] Use scalar_int_mode for move2add References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:49:46 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87fue0iuvp.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The postreload move2add optimisations are specific to scalar integers. This patch adds an explicit check to the main guarding "if" and propagates the information through subroutines. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * postreload.c (move2add_valid_value_p): Change the type of the mode parameter to scalar_int_mode. (move2add_use_add2_insn): Add a mode parameter and use it instead of GET_MODE (reg). (move2add_use_add3_insn): Likewise. (reload_cse_move2add): Update accordingly. Index: gcc/postreload.c =================================================================== --- gcc/postreload.c 2017-07-13 09:18:35.050126461 +0100 +++ gcc/postreload.c 2017-07-13 09:18:37.226935948 +0100 @@ -1692,7 +1692,7 @@ move2add_record_sym_value (rtx reg, rtx /* Check if REGNO contains a valid value in MODE. */ static bool -move2add_valid_value_p (int regno, machine_mode mode) +move2add_valid_value_p (int regno, scalar_int_mode mode) { if (reg_set_luid[regno] <= move2add_last_label_luid) return false; @@ -1723,21 +1723,21 @@ move2add_valid_value_p (int regno, machi return true; } -/* This function is called with INSN that sets REG to (SYM + OFF), - while REG is known to already have value (SYM + offset). +/* This function is called with INSN that sets REG (of mode MODE) + to (SYM + OFF), while REG is known to already have value (SYM + offset). This function tries to change INSN into an add instruction (set (REG) (plus (REG) (OFF - offset))) using the known value. It also updates the information about REG's known value. Return true if we made a change. */ static bool -move2add_use_add2_insn (rtx reg, rtx sym, rtx off, rtx_insn *insn) +move2add_use_add2_insn (scalar_int_mode mode, rtx reg, rtx sym, rtx off, + rtx_insn *insn) { rtx pat = PATTERN (insn); rtx src = SET_SRC (pat); int regno = REGNO (reg); - rtx new_src = gen_int_mode (UINTVAL (off) - reg_offset[regno], - GET_MODE (reg)); + rtx new_src = gen_int_mode (UINTVAL (off) - reg_offset[regno], mode); bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn)); bool changed = false; @@ -1759,7 +1759,7 @@ move2add_use_add2_insn (rtx reg, rtx sym else { struct full_rtx_costs oldcst, newcst; - rtx tem = gen_rtx_PLUS (GET_MODE (reg), reg, new_src); + rtx tem = gen_rtx_PLUS (mode, reg, new_src); get_full_set_rtx_cost (pat, &oldcst); SET_SRC (pat) = tem; @@ -1769,10 +1769,10 @@ move2add_use_add2_insn (rtx reg, rtx sym if (costs_lt_p (&newcst, &oldcst, speed) && have_add2_insn (reg, new_src)) changed = validate_change (insn, &SET_SRC (pat), tem, 0); - else if (sym == NULL_RTX && GET_MODE (reg) != BImode) + else if (sym == NULL_RTX && mode != BImode) { - machine_mode narrow_mode; - FOR_EACH_MODE_UNTIL (narrow_mode, GET_MODE (reg)) + scalar_int_mode narrow_mode; + FOR_EACH_MODE_UNTIL (narrow_mode, mode) { if (have_insn_for (STRICT_LOW_PART, narrow_mode) && ((reg_offset[regno] & ~GET_MODE_MASK (narrow_mode)) @@ -1802,9 +1802,9 @@ move2add_use_add2_insn (rtx reg, rtx sym } -/* This function is called with INSN that sets REG to (SYM + OFF), - but REG doesn't have known value (SYM + offset). This function - tries to find another register which is known to already have +/* This function is called with INSN that sets REG (of mode MODE) to + (SYM + OFF), but REG doesn't have known value (SYM + offset). This + function tries to find another register which is known to already have value (SYM + offset) and change INSN into an add instruction (set (REG) (plus (the found register) (OFF - offset))) if such a register is found. It also updates the information about @@ -1812,7 +1812,8 @@ move2add_use_add2_insn (rtx reg, rtx sym Return true iff we made a change. */ static bool -move2add_use_add3_insn (rtx reg, rtx sym, rtx off, rtx_insn *insn) +move2add_use_add3_insn (scalar_int_mode mode, rtx reg, rtx sym, rtx off, + rtx_insn *insn) { rtx pat = PATTERN (insn); rtx src = SET_SRC (pat); @@ -1831,7 +1832,7 @@ move2add_use_add3_insn (rtx reg, rtx sym SET_SRC (pat) = plus_expr; for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (move2add_valid_value_p (i, GET_MODE (reg)) + if (move2add_valid_value_p (i, mode) && reg_base_reg[i] < 0 && reg_symbol_ref[i] != NULL_RTX && rtx_equal_p (sym, reg_symbol_ref[i])) @@ -1921,8 +1922,10 @@ reload_cse_move2add (rtx_insn *first) pat = PATTERN (insn); /* For simplicity, we only perform this optimization on straightforward SETs. */ + scalar_int_mode mode; if (GET_CODE (pat) == SET - && REG_P (SET_DEST (pat))) + && REG_P (SET_DEST (pat)) + && is_a (GET_MODE (SET_DEST (pat)), &mode)) { rtx reg = SET_DEST (pat); int regno = REGNO (reg); @@ -1930,7 +1933,7 @@ reload_cse_move2add (rtx_insn *first) /* Check if we have valid information on the contents of this register in the mode of REG. */ - if (move2add_valid_value_p (regno, GET_MODE (reg)) + if (move2add_valid_value_p (regno, mode) && dbg_cnt (cse2_move2add)) { /* Try to transform (set (REGX) (CONST_INT A)) @@ -1950,7 +1953,8 @@ reload_cse_move2add (rtx_insn *first) && reg_base_reg[regno] < 0 && reg_symbol_ref[regno] == NULL_RTX) { - changed |= move2add_use_add2_insn (reg, NULL_RTX, src, insn); + changed |= move2add_use_add2_insn (mode, reg, NULL_RTX, + src, insn); continue; } @@ -1967,7 +1971,7 @@ reload_cse_move2add (rtx_insn *first) else if (REG_P (src) && reg_set_luid[regno] == reg_set_luid[REGNO (src)] && reg_base_reg[regno] == reg_base_reg[REGNO (src)] - && move2add_valid_value_p (REGNO (src), GET_MODE (reg))) + && move2add_valid_value_p (REGNO (src), mode)) { rtx_insn *next = next_nonnote_nondebug_insn (insn); rtx set = NULL_RTX; @@ -1987,7 +1991,7 @@ reload_cse_move2add (rtx_insn *first) gen_int_mode (added_offset + base_offset - regno_offset, - GET_MODE (reg)); + mode); bool success = false; bool speed = optimize_bb_for_speed_p (BLOCK_FOR_INSN (insn)); @@ -1999,11 +2003,11 @@ reload_cse_move2add (rtx_insn *first) { rtx old_src = SET_SRC (set); struct full_rtx_costs oldcst, newcst; - rtx tem = gen_rtx_PLUS (GET_MODE (reg), reg, new_src); + rtx tem = gen_rtx_PLUS (mode, reg, new_src); get_full_set_rtx_cost (set, &oldcst); SET_SRC (set) = tem; - get_full_set_src_cost (tem, GET_MODE (reg), &newcst); + get_full_set_src_cost (tem, mode, &newcst); SET_SRC (set) = old_src; costs_add_n_insns (&oldcst, 1); @@ -2023,7 +2027,7 @@ reload_cse_move2add (rtx_insn *first) move2add_record_mode (reg); reg_offset[regno] = trunc_int_for_mode (added_offset + base_offset, - GET_MODE (reg)); + mode); continue; } } @@ -2059,16 +2063,16 @@ reload_cse_move2add (rtx_insn *first) /* If the reg already contains the value which is sum of sym and some constant value, we can use an add2 insn. */ - if (move2add_valid_value_p (regno, GET_MODE (reg)) + if (move2add_valid_value_p (regno, mode) && reg_base_reg[regno] < 0 && reg_symbol_ref[regno] != NULL_RTX && rtx_equal_p (sym, reg_symbol_ref[regno])) - changed |= move2add_use_add2_insn (reg, sym, off, insn); + changed |= move2add_use_add2_insn (mode, reg, sym, off, insn); /* Otherwise, we have to find a register whose value is sum of sym and some constant value. */ else - changed |= move2add_use_add3_insn (reg, sym, off, insn); + changed |= move2add_use_add3_insn (mode, reg, sym, off, insn); continue; } From patchwork Thu Jul 13 08:50:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107618 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1933292qge; Thu, 13 Jul 2017 01:51:15 -0700 (PDT) X-Received: by 10.99.104.129 with SMTP id d123mr8017585pgc.236.1499935875597; Thu, 13 Jul 2017 01:51:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935875; cv=none; d=google.com; s=arc-20160816; b=rHKG45Ft70hyWW84yLAN+5azU6ZCvk7rg4eEC8varpZcLC9+UdtkBOKDERxWAi1XI2 f10yT1tSjr+VNYlltSc/zMz58Uka66RvTkrGfZ45pphbJAuEd3KNy9uP2q4ZQ+jY88oa QqxA8SuzGuz8nHD53NyZVrhhbfczj3jWs1RKAkt0vLt53nFVj+4JQ007flNeol1SDSkG bdEkcEo14Qw2XU5L8Siqd37O4YLpiHCSpfuC4tePyu7D5SCGadLCzmSX9XBFvR/CZdwG 1BasurrtP5Ovf7fgIdvcBvdnql0/SWHx+1h8iaxxsgbjWXHUhE8BF1Tl5Qs0JtxpGYgj sTQQ== 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=5DQhvP2EaLcjpbNV18pGPE4T/f+gVRH8ZG/xYiqyRcM=; b=lrYfKOPjS5Ovw/z6fRAMwQAkNNcKPvQ4FJGXjheY9Dq5MipwgQfFiSGJenP4Ck+x1A 1RisnQ5dLnpk1/dbgRWUsqxM/+zmZvmCfBa8HCkoNLkutF1kBipZ+hkxr8hUYH0mKHuY Ez3vQf8tn9UHwzXrpCYYDdwEm2mMr6AmI686gNw5SfPESjyLPE7DlnfxndwxUeO54LZG UuWd5BPZHXNpfAaptqVdudKZaQdvacGEhsBDWeCZPxUA4yCwTWwGI7ixaQcAI8BvDR0Z Z/GnKCiVHOJezXA8AYH1vTJJHhHbyQRIO6vyxXgQFyThqODTUEp6FFgb0kA+GvqcZ8Dr SuDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=DHq7itT+; spf=pass (google.com: domain of gcc-patches-return-458023-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458023-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 m24si3984937pli.323.2017.07.13.01.51.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:51:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458023-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=DHq7itT+; spf=pass (google.com: domain of gcc-patches-return-458023-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458023-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=DdJS49WUMx2hjHd/X/G78s9WzJyRJ CXozZ4VMWijNqsjIT9dblFwjgAsFiu7Fmd7ahLKPSJXsWoMF88KQg3EI9ECoPX9g YbskhZkbUO2HIHmiORTUByekGow3/k/lFCcob4JsSry6o6iBalN+DPaVv6jgzB9+ XCtHbK42GKkT/g= 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=DLrpz9MCYlfu7cYSMd9G/7sBG8w=; b=DHq 7itT+rXWmDgxF6hZWA5mcwJrbXsyyIz/RuGOEITFcPQ2tRjpRONgvr070+sfMIH7 s+G3TALoykqgCugLWLiDJiQOAGc9sihsl05t0uISfnWhWJN3xmuGSl+FhkyP8+PT /F2ImxWNdb/vUo1NLIEoNLs+X3vKEbWiCpR1f2dY= Received: (qmail 79076 invoked by alias); 13 Jul 2017 08:50:14 -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 78400 invoked by uid 89); 13 Jul 2017 08:50:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:50:11 +0000 Received: by mail-wm0-f53.google.com with SMTP id f67so18242857wmh.1 for ; Thu, 13 Jul 2017 01:50:10 -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=5DQhvP2EaLcjpbNV18pGPE4T/f+gVRH8ZG/xYiqyRcM=; b=JPip38Xnu3Y7n3ylplfY59T5TYMIginZed0Ju7KUHBpwcOaI52aiT18xBAKrXIpUHH WXELwZyuQK09vRicW9vBmyCfIuYPGE56JjiyMi3rNakEfLbULQkrciz1C/u4RP2WVVmY hLHKrsnz/LK3bxluOqj+PorxsyMoM79L9nyXt20hNcDaruOSGVMkKuvSw1jxrXdWT+gv 4fTXLHyFpB9wjmwmBU50PPGF/9jV5KPjt3zTp84sg2sWaH9UdErJUfkz4abvjWC72oX1 WNM4jSBUThnZc9THVlT+NOiJN5nQdSMb1qVrrXSyBYGTyu62wDOOzV0E2YmlzYQ25zTF lqpQ== X-Gm-Message-State: AIVw111o86ylbjRMdkqb9tPAH8AJ0p1sXPgRrXWcVE2IZxSoGI1xAPDX DXLI0toc2WqcHoI3qhluwQ== X-Received: by 10.28.71.133 with SMTP id m5mr1125615wmi.97.1499935808813; Thu, 13 Jul 2017 01:50:08 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b197sm4849950wmb.4.2017.07.13.01.50.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:50:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [32/77] Check is_a before calling valid_pointer_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:50:06 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87bmooiuv5.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 A future patch will make valid_pointer_mode take a scalar_int_mode instead of a machine_mode. is_a <...> rather than as_a <...> is needed here because we're checking a mode supplied by the user. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/c-family/ * c-attribs.c (handle_mode_attribute): Check for a scalar_int_mode before calling targetm.addr_space.valid_pointer_mode. Index: gcc/c-family/c-attribs.c =================================================================== --- gcc/c-family/c-attribs.c 2017-06-30 12:50:37.302706033 +0100 +++ gcc/c-family/c-attribs.c 2017-07-13 09:18:37.622901759 +0100 @@ -1438,10 +1438,12 @@ handle_mode_attribute (tree *node, tree if (POINTER_TYPE_P (type)) { + scalar_int_mode addr_mode; addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (type)); tree (*fn)(tree, machine_mode, bool); - if (!targetm.addr_space.valid_pointer_mode (mode, as)) + if (!is_a (mode, &addr_mode) + || !targetm.addr_space.valid_pointer_mode (addr_mode, as)) { error ("invalid pointer mode %qs", p); return NULL_TREE; @@ -1451,7 +1453,7 @@ handle_mode_attribute (tree *node, tree fn = build_pointer_type_for_mode; else fn = build_reference_type_for_mode; - typefm = fn (TREE_TYPE (type), mode, false); + typefm = fn (TREE_TYPE (type), addr_mode, false); } else { From patchwork Thu Jul 13 08:50:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107619 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1933513qge; Thu, 13 Jul 2017 01:51:33 -0700 (PDT) X-Received: by 10.84.137.1 with SMTP id 1mr8664593plm.75.1499935893517; Thu, 13 Jul 2017 01:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935893; cv=none; d=google.com; s=arc-20160816; b=Y0IPVxBkQaRrADMUBzE7cfB9uQ/FsDx97ArJJM0U79vPnnEojB/Df40m26MVHiVOCz A4B+YujuB6y1Uw5hGct41tlGvU+w7lv365Hx2lBgvDh0p4e4WSY74e3dKu65X4po3sc6 6lbTjakWgmcE1+hwXrxkTDH41kOaIeG3Jw68bHdC9I8boBkIvpkNUfo92X4vT74VNvfR HqwHt3fcJtyJeUDDkZuGx8pSDorMuWFWvssyVYP7+RDZT5MqLO+mZ+G8GaxEZXm0NX0k NdebFDMZdwCOhdkSKYbjsDKT5Gbf2GR1Yw2ImIYrlx5nCvDM4YLQCcUj3yXR/WMKHhj5 W+0A== 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=u0wevqStV7/32aAABbR7PZI/8yJ1wbh31pyHl6ajjDY=; b=YdrRrJ9J3YWETWA9fsjS9OU4nPZIbTIe//AmPcmSc2jDV9oGeyfIhqFzc61JZxliDc XyD8YaUCSQ5nGSNxl0yd4TXARl+XGnASqRI5P+r5frnyjzSeW1/swxRhIKEkFOZD4sOh w89EB8k5y+YUIyOieakS4XhxA0Gh9HtYoKXGaVrLY+guUoY4dzhJ3clIyyiyhkzZ3/In PCds+7PE7L9qYfrtNByiUHA5nDbwdyEKVIAfElhYEH0ziGG3CBZnO5M8UYNlJOH5ffQ0 CE5bvrGqHHW4UedpDEVzL06OXQ1C5l6P3L7oBNQuJVNQ043VP09Sl77TjI0GvfgLkQGn fsCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=ZpGBWdqb; spf=pass (google.com: domain of gcc-patches-return-458024-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458024-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 h64si3843123pfg.456.2017.07.13.01.51.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458024-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=ZpGBWdqb; spf=pass (google.com: domain of gcc-patches-return-458024-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458024-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=JpOkCzlYOYjszjRIK4wQ07J4hpVcY TADm6naJqgiY4/s8BpXToghwr8a0R4yiz+ZaIu+tWTXLn1s4eCTLGdi+Vf5d6Hx+ pvSsgl8A9SWqaLvMi+3fDhqltV6zq6Y4t4jEuJOLWs7Opvkf61uJW6ysP5wXZtgb 9pI2Z1+ilk3PuI= 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=fvRGaOkKp1VZTjHgcIfxOkOUB5w=; b=ZpG BWdqbuC7ge1qc6iNT9BdBUrcqrbqy7WvKsrN0RuHGBNISk83/3a2yWYqCWrR9tH7 wvItnrxl9dmcuPMpiqDbMDMPaAzpl+RYHwk6sb8ZHbH2Nrss/j2EU0bd3jahOQC+ sZAkMPTjFw5r4+t0fz3Ylyx2lwqoUUGMoYc2/4so= Received: (qmail 98464 invoked by alias); 13 Jul 2017 08:50:33 -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 97742 invoked by uid 89); 13 Jul 2017 08:50:33 -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-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:50:30 +0000 Received: by mail-wm0-f45.google.com with SMTP id f67so18251669wmh.1 for ; Thu, 13 Jul 2017 01:50:29 -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=u0wevqStV7/32aAABbR7PZI/8yJ1wbh31pyHl6ajjDY=; b=tLr1vIpy8qZFyRU0TWM0MmfSZMJbGbsqxkYVJjTv2ddVsww1TmYYZF3k47tw+4lert Tq1qY/+tZo2p1VJ/3Yv0jSt+F6pdOni19kjP/u0pggl5rPb2eS79MV74hLhCzUvzP5WO M3cZIoGhT7VfWdAE4U/EPFFs/8yNpQgsAl4GD9cqwc0v2oAsAEqqeqWrdCKaV2ipTvkC LJeYQu10fo4ThRj92Hpt+p3B+GXOmqlCDSPkJJUsOHogoMUrXNiTCRpcwOSeq4thqZ3r KVUdoR56ix0umU/lma3yyofJlVBwEu0quyKXiadwHnDMkp4E5s9P59l9WgV9ee2SGgoH xFEQ== X-Gm-Message-State: AIVw1128Xh0vr/PyDGx+i62HAtWS9Za3DXPaaiKAltXLD666pcJhGPXU XPXMx1xJEmWtjH6gUwZglg== X-Received: by 10.28.48.201 with SMTP id w192mr1123111wmw.28.1499935827819; Thu, 13 Jul 2017 01:50:27 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 33sm3556883wrr.58.2017.07.13.01.50.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:50:27 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [33/77] Add a NARROWEST_INT_MODE macro References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:50:25 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <877ezciuum.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch replaces uses of GET_CLASS_NARROWEST_MODE (MODE_INT) with a new NARROWEST_INT_MODE macro, which has type scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (NARROWEST_INT_MODE): New macro. * expr.c (alignment_for_piecewise_move): Use it instead of GET_CLASS_NARROWEST_MODE (MODE_INT). (push_block): Likewise. * stor-layout.c (bit_field_mode_iterator::bit_field_mode_iterator): Likewise. * tree-vrp.c (simplify_float_conversion_using_ranges): Likewise. gcc/ada/ * gcc-interface/decl.c (validate_size): Use NARROWEST_INT_MODE instead of GET_CLASS_NARROWEST_MODE (MODE_INT). Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:31.699428322 +0100 +++ gcc/machmode.h 2017-07-13 09:18:38.043865449 +0100 @@ -656,6 +656,12 @@ #define GET_MODE_ALIGNMENT(MODE) get_mod #define GET_CLASS_NARROWEST_MODE(CLASS) \ ((machine_mode) class_narrowest_mode[CLASS]) +/* The narrowest full integer mode available on the target. */ + +#define NARROWEST_INT_MODE \ + (scalar_int_mode \ + (scalar_int_mode::from_int (class_narrowest_mode[MODE_INT]))) + /* Return the narrowest mode in T's class. */ template Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:36.841969327 +0100 +++ gcc/expr.c 2017-07-13 09:18:38.043865449 +0100 @@ -707,7 +707,7 @@ alignment_for_piecewise_move (unsigned i { machine_mode tmode, xmode; - xmode = GET_CLASS_NARROWEST_MODE (MODE_INT); + xmode = NARROWEST_INT_MODE; FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) { if (GET_MODE_SIZE (tmode) > max_pieces @@ -3910,7 +3910,7 @@ push_block (rtx size, int extra, int bel negate_rtx (Pmode, size)); } - return memory_address (GET_CLASS_NARROWEST_MODE (MODE_INT), temp); + return memory_address (NARROWEST_INT_MODE, temp); } /* A utility routine that returns the base of an auto-inc memory, or NULL. */ Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:32.529352614 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:38.044865363 +0100 @@ -2697,7 +2697,7 @@ fixup_unsigned_type (tree type) HOST_WIDE_INT bitregion_start, HOST_WIDE_INT bitregion_end, unsigned int align, bool volatilep) -: m_mode (GET_CLASS_NARROWEST_MODE (MODE_INT)), m_bitsize (bitsize), +: m_mode (NARROWEST_INT_MODE), m_bitsize (bitsize), m_bitpos (bitpos), m_bitregion_start (bitregion_start), m_bitregion_end (bitregion_end), m_align (align), m_volatilep (volatilep), m_count (0) Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c 2017-07-13 09:18:24.776086502 +0100 +++ gcc/tree-vrp.c 2017-07-13 09:18:38.045865278 +0100 @@ -10115,7 +10115,7 @@ simplify_float_conversion_using_ranges ( integer mode available. */ else { - mode = GET_CLASS_NARROWEST_MODE (MODE_INT); + mode = NARROWEST_INT_MODE; for (;;) { /* If we cannot do a signed conversion to float from mode Index: gcc/ada/gcc-interface/decl.c =================================================================== --- gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:32.518353613 +0100 +++ gcc/ada/gcc-interface/decl.c 2017-07-13 09:18:38.042865534 +0100 @@ -8574,7 +8574,7 @@ validate_size (Uint uint_size, tree gnu_ by the smallest integral mode that's valid for pointers. */ if (TREE_CODE (gnu_type) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (gnu_type)) { - machine_mode p_mode = GET_CLASS_NARROWEST_MODE (MODE_INT); + scalar_int_mode p_mode = NARROWEST_INT_MODE; while (!targetm.valid_pointer_mode (p_mode)) p_mode = *GET_MODE_WIDER_MODE (p_mode); type_size = bitsize_int (GET_MODE_BITSIZE (p_mode)); From patchwork Thu Jul 13 08:50:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107620 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1933676qge; Thu, 13 Jul 2017 01:51:50 -0700 (PDT) X-Received: by 10.98.215.73 with SMTP id v9mr60369900pfl.103.1499935910144; Thu, 13 Jul 2017 01:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935910; cv=none; d=google.com; s=arc-20160816; b=NzhSYFKJawqS0doUWwe3Rb8xJwvJbgXEjP1BM44/F9/dgZyxhnVESMJcZHp7NrPQvS Qt0vmY/QKLGUwbfyQg0VLuiJpBBZfjw2xMAnuGfO+JrmaT/GQx+BNoNQfow5sPELJmmz RhzzO1X6AIEhKjbU4ustDA/B25fj0abKzKAz/5PqdZYc6ofIq52LX/uegRRDIjGOAfmH oUYECmbT4zxun5o1XghBkVlenTV3cj2AlH8Pyd3Q5xRACI91P+8MgdCO1fE37BsiJ/wC Q4l7oxYis2xKYF0BTELR/zX8fQcMINe/Cw5cm7hY1jkJq3BKXHpu/uieXYYGjfpHYhag Tjvg== 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=CUFCov01bZ/ZLxin59yqlLL8pE0wBMBFknaGyV6GzOg=; b=LKwv09CE/46f8tmY4ts3wxcUba112ELo521ZEibHBFfFzpONghQJYIm+uR8wr6VYpG 7khE/R/oeacFcLVDENC7acUF1uYqpKecqH0Tgq9aowVX+XUvBchXlT0ZQgXu2S4Fd9Ae /cofc8iWqeyx1GDraYKBn9Fp4S3Ke+SNN5epATZsw58J8nPa77F8msq7uAOQNqL6hmXP ZtjxKZ+RBlvyV/j+/ODJRUVqeB0zI8YJux2lfusTD+b2hFydJDL0d+EWXfmMSKhDPbqT XIx+DYGAkNjhjpW6dZhRbieJoullBcQLhiYBGXrTB+VE149TgHCxhf15EUK2HUYzHfuf Vg/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=EcWOFmaF; spf=pass (google.com: domain of gcc-patches-return-458025-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458025-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 r5si3954863pgj.289.2017.07.13.01.51.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458025-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=EcWOFmaF; spf=pass (google.com: domain of gcc-patches-return-458025-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458025-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=jD9X+2HRvX6X7SBDGrqFpm6J/nOey yNQZJI0KzixuU5o5WF6PVzaj0Wk0J8Y0tjkcjTyasKPYfN1k2mirQi/awNKdsWjw D0a03zkb2Ega9UKkMNqxaAZTNWijKmIR54cqh/4pfnZJCSuCA9Qr2mDUvZJlt5X+ wHwP1lThkPUMuc= 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=/psnYIT0CdjOZKzlXvFcQQ/eKH8=; b=EcW OFmaFfeeeicfJBIfosD3ubr0i7Wo29OPsTJWbd5oYODr5nTLblhsGzwNFoQyofCf 0hVyN/lNldzQwlLa0K/3sEDQS9cu+EJo5/3Y3xkud/n3BBf+bm0kKGdpGL6vK58e htXWtAkgPfBvQMjW+swvtmVz1KnLSHmEmAYdIgdE= Received: (qmail 120925 invoked by alias); 13 Jul 2017 08:51:00 -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 120282 invoked by uid 89); 13 Jul 2017 08:50:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=ri X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:50:51 +0000 Received: by mail-wm0-f42.google.com with SMTP id i127so18234383wma.0 for ; Thu, 13 Jul 2017 01:50:50 -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=CUFCov01bZ/ZLxin59yqlLL8pE0wBMBFknaGyV6GzOg=; b=ehuVTN3wQPTCZl1vML3Ou4ej855skn50kYVziOEsSPdAxzHzgJppaswMlx53uZ1zdP bmeGyePaKKAS5VfgEekN7M71pG0cbOKgueNwL7wl98bSWzlpSq6eht2sJlWrwmzUwJ10 wOKoc+XOzUXWmpbu2EajiZEc8KjBf5fhaf/jyzEnyiC/9S7WNWuYhtDtwb9dNqu5/XrW 5gYejxQozPNcIfxSP6FBNQgXbyhcA8L8C/I5cHnM/WoyA6fKpXo6esmFQFaVegRpccHg QilCQ5ols4GsGtqgIgQlbTmAJ0//eKmUgIV2B/dx3egqFJ3GxYmUJQU9UZzofg9PvWJL BOrQ== X-Gm-Message-State: AIVw113imRb/z0CGLotdeebInLjIOomBwykAGlz5roZolYt3MORvkyVj 9VNv7k/pJG1fSFc6VYdOxA== X-Received: by 10.28.137.199 with SMTP id l190mr1121522wmd.117.1499935848419; Thu, 13 Jul 2017 01:50:48 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id p27sm5857728wmf.23.2017.07.13.01.50.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:50:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [34/77] Add a SCALAR_INT_TYPE_MODE macro References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:50:45 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8737a0iuu2.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a SCALAR_INT_TYPE_MODE macro that asserts that the type has a scalar integer mode and returns it as a scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (SCALAR_INT_TYPE_MODE): New macro. * builtins.c (expand_builtin_signbit): Use it. * cfgexpand.c (expand_debug_expr): Likewise. * dojump.c (do_jump): Likewise. (do_compare_and_jump): Likewise. * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Likewise. * expmed.c (make_tree): Likewise. * expr.c (expand_expr_real_2): Likewise. (expand_expr_real_1): Likewise. (try_casesi): Likewise. * fold-const-call.c (fold_const_call_ss): Likewise. * fold-const.c (unextend): Likewise. (extract_muldiv_1): Likewise. (fold_single_bit_test): Likewise. (native_encode_int): Likewise. (native_encode_string): Likewise. (native_interpret_int): Likewise. * gimple-fold.c (gimple_fold_builtin_memset): Likewise. * internal-fn.c (expand_addsub_overflow): Likewise. (expand_neg_overflow): Likewise. (expand_mul_overflow): Likewise. (expand_arith_overflow): Likewise. * match.pd: Likewise. * stor-layout.c (layout_type): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-ssa-math-opts.c (convert_mult_to_widen): Likewise. * tree-ssanames.c (get_range_info): Likewise. * tree-switch-conversion.c (array_value_type) Likewise. * tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise. (vect_recog_divmod_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. * tree-vrp.c (extract_range_basic): Likewise. (simplify_float_conversion_using_ranges): Likewise. * tree.c (int_fits_type_p): Likewise. * ubsan.c (instrument_bool_enum_load): Likewise. * varasm.c (mergeable_string_section): Likewise. (narrowing_initializer_constant_valid_p): Likewise. (output_constant): Likewise. gcc/cp/ * cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE. gcc/fortran/ * target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE. (size_logical): Likewise. gcc/objc/ * objc-encoding.c (encode_type): Use SCALAR_INT_TYPE_MODE. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-07-13 09:18:24.776086502 +0100 +++ gcc/tree.h 2017-07-13 09:18:38.668812030 +0100 @@ -1852,6 +1852,8 @@ #define TYPE_MODE_RAW(NODE) (TYPE_CHECK #define TYPE_MODE(NODE) \ (VECTOR_TYPE_P (TYPE_CHECK (NODE)) \ ? vector_type_mode (NODE) : (NODE)->type_common.mode) +#define SCALAR_INT_TYPE_MODE(NODE) \ + (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_FLOAT_TYPE_MODE(NODE) \ (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SET_TYPE_MODE(NODE, MODE) \ Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2017-07-13 09:18:30.027582784 +0100 +++ gcc/builtins.c 2017-07-13 09:18:38.655813141 +0100 @@ -5378,7 +5378,7 @@ expand_builtin_signbit (tree exp, rtx ta arg = CALL_EXPR_ARG (exp, 0); fmode = SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (arg)); - rmode = TYPE_MODE (TREE_TYPE (exp)); + rmode = SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)); fmt = REAL_MODE_FORMAT (fmode); arg = builtin_save_expr (arg); Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:33.650251357 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:38.656813056 +0100 @@ -4137,7 +4137,7 @@ expand_debug_expr (tree exp) machine_mode inner_mode = VOIDmode; int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp)); addr_space_t as; - scalar_int_mode op0_mode, op1_mode; + scalar_int_mode op0_mode, op1_mode, addr_mode; switch (TREE_CODE_CLASS (TREE_CODE (exp))) { @@ -4912,7 +4912,8 @@ expand_debug_expr (tree exp) } as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp))); - op0 = convert_debug_memory_address (mode, XEXP (op0, 0), as); + addr_mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)); + op0 = convert_debug_memory_address (addr_mode, XEXP (op0, 0), as); return op0; Index: gcc/dojump.c =================================================================== --- gcc/dojump.c 2017-07-13 09:18:31.693428873 +0100 +++ gcc/dojump.c 2017-07-13 09:18:38.657812970 +0100 @@ -571,7 +571,7 @@ do_jump (tree exp, rtx_code_label *if_fa if (TREE_CODE (shift) == INTEGER_CST && compare_tree_int (shift, 0) >= 0 && compare_tree_int (shift, HOST_BITS_PER_WIDE_INT) < 0 - && prefer_and_bit_test (TYPE_MODE (argtype), + && prefer_and_bit_test (SCALAR_INT_TYPE_MODE (argtype), TREE_INT_CST_LOW (shift))) { unsigned HOST_WIDE_INT mask @@ -1190,17 +1190,14 @@ do_compare_and_jump (tree treeop0, tree return; type = TREE_TYPE (treeop0); - mode = TYPE_MODE (type); if (TREE_CODE (treeop0) == INTEGER_CST && (TREE_CODE (treeop1) != INTEGER_CST - || (GET_MODE_BITSIZE (mode) - > GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (treeop1)))))) - { - /* op0 might have been replaced by promoted constant, in which - case the type of second argument should be used. */ - type = TREE_TYPE (treeop1); - mode = TYPE_MODE (type); - } + || (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type)) + > GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (treeop1)))))) + /* op0 might have been replaced by promoted constant, in which + case the type of second argument should be used. */ + type = TREE_TYPE (treeop1); + mode = TYPE_MODE (type); unsignedp = TYPE_UNSIGNED (type); code = unsignedp ? unsigned_code : signed_code; Index: gcc/dwarf2cfi.c =================================================================== --- gcc/dwarf2cfi.c 2017-06-30 12:50:38.644644197 +0100 +++ gcc/dwarf2cfi.c 2017-07-13 09:18:38.657812970 +0100 @@ -302,7 +302,7 @@ void init_one_dwarf_reg_size (int regno, expand_builtin_init_dwarf_reg_sizes (tree address) { unsigned int i; - machine_mode mode = TYPE_MODE (char_type_node); + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (char_type_node); rtx addr = expand_normal (address); rtx mem = gen_rtx_MEM (BLKmode, addr); Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:32.525352977 +0100 +++ gcc/expmed.c 2017-07-13 09:18:38.658812885 +0100 @@ -5195,7 +5195,7 @@ make_tree (tree type, rtx x) address mode to pointer mode. */ if (POINTER_TYPE_P (type)) x = convert_memory_address_addr_space - (TYPE_MODE (type), x, TYPE_ADDR_SPACE (TREE_TYPE (type))); + (SCALAR_INT_TYPE_MODE (type), x, TYPE_ADDR_SPACE (TREE_TYPE (type))); /* Note that we do *not* use SET_DECL_RTL here, because we do not want set_decl_rtl to go adjusting REG_ATTRS for this temporary. */ Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:38.043865449 +0100 +++ gcc/expr.c 2017-07-13 09:18:38.659812799 +0100 @@ -9070,11 +9070,12 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b instead. */ if (reduce_bit_field && TYPE_UNSIGNED (type)) { + int_mode = SCALAR_INT_TYPE_MODE (type); wide_int mask = wi::mask (TYPE_PRECISION (type), - false, GET_MODE_PRECISION (mode)); + false, GET_MODE_PRECISION (int_mode)); - temp = expand_binop (mode, xor_optab, op0, - immed_wide_int_const (mask, mode), + temp = expand_binop (int_mode, xor_optab, op0, + immed_wide_int_const (mask, int_mode), target, 1, OPTAB_LIB_WIDEN); } else @@ -9175,7 +9176,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b if (is_gimple_assign (def) && gimple_assign_rhs_code (def) == NOP_EXPR) { - machine_mode rmode = TYPE_MODE + scalar_int_mode rmode = SCALAR_INT_TYPE_MODE (TREE_TYPE (gimple_assign_rhs1 (def))); if (GET_MODE_SIZE (rmode) < GET_MODE_SIZE (int_mode) @@ -9943,15 +9944,16 @@ expand_expr_real_1 (tree exp, rtx target return decl_rtl; case INTEGER_CST: - /* Given that TYPE_PRECISION (type) is not always equal to - GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from - the former to the latter according to the signedness of the - type. */ - temp = immed_wide_int_const (wi::to_wide - (exp, - GET_MODE_PRECISION (TYPE_MODE (type))), - TYPE_MODE (type)); - return temp; + { + /* Given that TYPE_PRECISION (type) is not always equal to + GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from + the former to the latter according to the signedness of the + type. */ + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type); + temp = immed_wide_int_const + (wi::to_wide (exp, GET_MODE_PRECISION (mode)), mode); + return temp; + } case VECTOR_CST: { @@ -10410,7 +10412,8 @@ expand_expr_real_1 (tree exp, rtx target if (DECL_BIT_FIELD (field)) { HOST_WIDE_INT bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)); - machine_mode imode = TYPE_MODE (TREE_TYPE (field)); + scalar_int_mode imode + = SCALAR_INT_TYPE_MODE (TREE_TYPE (field)); if (TYPE_UNSIGNED (TREE_TYPE (field))) { @@ -11540,10 +11543,10 @@ try_casesi (tree index_type, tree index_ if (! targetm.have_casesi ()) return 0; - /* Convert the index to SImode. */ - if (GET_MODE_BITSIZE (TYPE_MODE (index_type)) > GET_MODE_BITSIZE (index_mode)) + /* The index must be some form of integer. Convert it to SImode. */ + scalar_int_mode omode = SCALAR_INT_TYPE_MODE (index_type); + if (GET_MODE_BITSIZE (omode) > GET_MODE_BITSIZE (index_mode)) { - machine_mode omode = TYPE_MODE (index_type); rtx rangertx = expand_normal (range); /* We must handle the endpoints in the original mode. */ @@ -11560,7 +11563,7 @@ try_casesi (tree index_type, tree index_ } else { - if (TYPE_MODE (index_type) != index_mode) + if (omode != index_mode) { index_type = lang_hooks.types.type_for_mode (index_mode, 0); index_expr = fold_convert (index_type, index_expr); Index: gcc/fold-const-call.c =================================================================== --- gcc/fold-const-call.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/fold-const-call.c 2017-07-13 09:18:38.659812799 +0100 @@ -844,7 +844,8 @@ fold_const_call_ss (wide_int *result, co int tmp; if (wi::ne_p (arg, 0)) tmp = wi::clz (arg); - else if (! CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (arg_type), tmp)) + else if (!CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (arg_type), + tmp)) tmp = TYPE_PRECISION (arg_type); *result = wi::shwi (tmp, precision); return true; @@ -855,7 +856,8 @@ fold_const_call_ss (wide_int *result, co int tmp; if (wi::ne_p (arg, 0)) tmp = wi::ctz (arg); - else if (! CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (arg_type), tmp)) + else if (!CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (arg_type), + tmp)) tmp = TYPE_PRECISION (arg_type); *result = wi::shwi (tmp, precision); return true; Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-07-13 09:18:31.699428322 +0100 +++ gcc/fold-const.c 2017-07-13 09:18:38.661812628 +0100 @@ -5471,7 +5471,7 @@ fold_range_test (location_t loc, enum tr unextend (tree c, int p, int unsignedp, tree mask) { tree type = TREE_TYPE (c); - int modesize = GET_MODE_BITSIZE (TYPE_MODE (type)); + int modesize = GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type)); tree temp; if (p == modesize || unsignedp) @@ -6061,8 +6061,9 @@ extract_muldiv_1 (tree t, tree c, enum t { tree type = TREE_TYPE (t); enum tree_code tcode = TREE_CODE (t); - tree ctype = (wide_type != 0 && (GET_MODE_SIZE (TYPE_MODE (wide_type)) - > GET_MODE_SIZE (TYPE_MODE (type))) + tree ctype = (wide_type != 0 + && (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (wide_type)) + > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type))) ? wide_type : type); tree t1, t2; int same_p = tcode == code; @@ -6757,7 +6758,7 @@ fold_single_bit_test (location_t loc, en tree inner = TREE_OPERAND (arg0, 0); tree type = TREE_TYPE (arg0); int bitnum = tree_log2 (TREE_OPERAND (arg0, 1)); - machine_mode operand_mode = TYPE_MODE (type); + scalar_int_mode operand_mode = SCALAR_INT_TYPE_MODE (type); int ops_unsigned; tree signed_type, unsigned_type, intermediate_type; tree tem, one; @@ -7068,7 +7069,7 @@ fold_plusminus_mult_expr (location_t loc native_encode_int (const_tree expr, unsigned char *ptr, int len, int off) { tree type = TREE_TYPE (expr); - int total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); + int total_bytes = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)); int byte, offset, word, words; unsigned char value; @@ -7278,7 +7279,8 @@ native_encode_string (const_tree expr, u if (TREE_CODE (type) != ARRAY_TYPE || TREE_CODE (TREE_TYPE (type)) != INTEGER_TYPE - || GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (type))) != BITS_PER_UNIT + || (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (type))) + != BITS_PER_UNIT) || !tree_fits_shwi_p (TYPE_SIZE_UNIT (type))) return 0; total_bytes = tree_to_shwi (TYPE_SIZE_UNIT (type)); @@ -7350,7 +7352,7 @@ native_encode_expr (const_tree expr, uns static tree native_interpret_int (tree type, const unsigned char *ptr, int len) { - int total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); + int total_bytes = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)); if (total_bytes > len || total_bytes * BITS_PER_UNIT > HOST_BITS_PER_DOUBLE_INT) Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c 2017-07-13 09:18:34.110210088 +0100 +++ gcc/gimple-fold.c 2017-07-13 09:18:38.661812628 +0100 @@ -1197,7 +1197,7 @@ gimple_fold_builtin_memset (gimple_stmt_ return NULL_TREE; length = tree_to_uhwi (len); - if (GET_MODE_SIZE (TYPE_MODE (etype)) != length + if (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (etype)) != length || get_pointer_alignment (dest) / BITS_PER_UNIT < length) return NULL_TREE; Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2017-07-13 09:18:30.902501597 +0100 +++ gcc/internal-fn.c 2017-07-13 09:18:38.662812543 +0100 @@ -635,7 +635,7 @@ expand_addsub_overflow (location_t loc, do_pending_stack_adjust (); rtx op0 = expand_normal (arg0); rtx op1 = expand_normal (arg1); - machine_mode mode = TYPE_MODE (TREE_TYPE (arg0)); + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0)); int prec = GET_MODE_PRECISION (mode); rtx sgn = immed_wide_int_const (wi::min_value (prec, SIGNED), mode); bool do_xor = false; @@ -1085,7 +1085,7 @@ expand_neg_overflow (location_t loc, tre do_pending_stack_adjust (); op1 = expand_normal (arg1); - machine_mode mode = TYPE_MODE (TREE_TYPE (arg1)); + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg1)); if (lhs) { target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); @@ -1179,7 +1179,7 @@ expand_mul_overflow (location_t loc, tre op0 = expand_normal (arg0); op1 = expand_normal (arg1); - machine_mode mode = TYPE_MODE (TREE_TYPE (arg0)); + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0)); bool uns = unsr_p; if (lhs) { @@ -2106,7 +2106,7 @@ expand_arith_overflow (enum tree_code co /* The infinity precision result will always fit into result. */ rtx target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); write_complex_part (target, const0_rtx, true); - machine_mode mode = TYPE_MODE (type); + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type); struct separate_ops ops; ops.code = code; ops.type = type; Index: gcc/match.pd =================================================================== --- gcc/match.pd 2017-06-30 12:50:38.246662537 +0100 +++ gcc/match.pd 2017-07-13 09:18:38.662812543 +0100 @@ -3238,7 +3238,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) associated with the mode of @1, so the sign bit is specified by this mode. Check that @1 is the signed max associated with this sign bit. */ - && prec == GET_MODE_PRECISION (TYPE_MODE (arg1_type)) + && prec == GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (arg1_type)) /* signed_type does not work on pointer types. */ && INTEGRAL_TYPE_P (arg1_type)) /* The following case also applies to X < signed_max+1 Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:38.044865363 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:38.663812457 +0100 @@ -2245,7 +2245,7 @@ layout_type (tree type) case POINTER_TYPE: case REFERENCE_TYPE: { - machine_mode mode = TYPE_MODE (type); + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type); TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); TYPE_UNSIGNED (type) = 1; Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c 2017-07-03 14:21:23.797508542 +0100 +++ gcc/tree-cfg.c 2017-07-13 09:18:38.664812372 +0100 @@ -4189,7 +4189,7 @@ verify_gimple_assign_ternary (gassign *s } if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE - || GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs3_type))) + || GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs3_type))) != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1_type)))) { error ("invalid mask type in vector permute expression"); Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-07-13 09:18:22.939277409 +0100 +++ gcc/tree-ssa-math-opts.c 2017-07-13 09:18:38.664812372 +0100 @@ -3133,8 +3133,8 @@ convert_mult_to_widen (gimple *stmt, gim if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) return false; - to_mode = TYPE_MODE (type); - from_mode = TYPE_MODE (type1); + to_mode = SCALAR_INT_TYPE_MODE (type); + from_mode = SCALAR_INT_TYPE_MODE (type1); from_unsigned1 = TYPE_UNSIGNED (type1); from_unsigned2 = TYPE_UNSIGNED (type2); Index: gcc/tree-ssanames.c =================================================================== --- gcc/tree-ssanames.c 2017-07-02 09:32:32.689745274 +0100 +++ gcc/tree-ssanames.c 2017-07-13 09:18:38.664812372 +0100 @@ -405,7 +405,7 @@ get_range_info (const_tree name, wide_in /* Return VR_VARYING for SSA_NAMEs with NULL RANGE_INFO or SSA_NAMEs with integral types width > 2 * HOST_BITS_PER_WIDE_INT precision. */ - if (!ri || (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (name))) + if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (name))) > 2 * HOST_BITS_PER_WIDE_INT)) return VR_VARYING; Index: gcc/tree-switch-conversion.c =================================================================== --- gcc/tree-switch-conversion.c 2017-07-13 09:18:22.939277409 +0100 +++ gcc/tree-switch-conversion.c 2017-07-13 09:18:38.665812287 +0100 @@ -1047,7 +1047,7 @@ array_value_type (gswitch *swtch, tree t if (!INTEGRAL_TYPE_P (type)) return type; - machine_mode type_mode = TYPE_MODE (type); + scalar_int_mode type_mode = SCALAR_INT_TYPE_MODE (type); machine_mode mode = get_narrowest_mode (type_mode); if (GET_MODE_SIZE (type_mode) <= GET_MODE_SIZE (mode)) return type; @@ -1094,8 +1094,8 @@ array_value_type (gswitch *swtch, tree t if (sign == 0) sign = TYPE_UNSIGNED (type) ? 1 : -1; smaller_type = lang_hooks.types.type_for_mode (mode, sign >= 0); - if (GET_MODE_SIZE (TYPE_MODE (type)) - <= GET_MODE_SIZE (TYPE_MODE (smaller_type))) + if (GET_MODE_SIZE (type_mode) + <= GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (smaller_type))) return type; return smaller_type; Index: gcc/tree-vect-patterns.c =================================================================== --- gcc/tree-vect-patterns.c 2017-07-03 14:36:01.960352449 +0100 +++ gcc/tree-vect-patterns.c 2017-07-13 09:18:38.665812287 +0100 @@ -1882,13 +1882,14 @@ vect_recog_rotate_pattern (vec } def = NULL_TREE; + scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type); if (TREE_CODE (oprnd1) == INTEGER_CST - || TYPE_MODE (TREE_TYPE (oprnd1)) == TYPE_MODE (type)) + || TYPE_MODE (TREE_TYPE (oprnd1)) == mode) def = oprnd1; else if (def_stmt && gimple_assign_cast_p (def_stmt)) { tree rhs1 = gimple_assign_rhs1 (def_stmt); - if (TYPE_MODE (TREE_TYPE (rhs1)) == TYPE_MODE (type) + if (TYPE_MODE (TREE_TYPE (rhs1)) == mode && TYPE_PRECISION (TREE_TYPE (rhs1)) == TYPE_PRECISION (type)) def = rhs1; @@ -1909,16 +1910,16 @@ vect_recog_rotate_pattern (vec append_pattern_def_seq (stmt_vinfo, def_stmt); } stype = TREE_TYPE (def); + scalar_int_mode smode = SCALAR_INT_TYPE_MODE (stype); if (TREE_CODE (def) == INTEGER_CST) { if (!tree_fits_uhwi_p (def) - || tree_to_uhwi (def) >= GET_MODE_PRECISION (TYPE_MODE (type)) + || tree_to_uhwi (def) >= GET_MODE_PRECISION (mode) || integer_zerop (def)) return NULL; def2 = build_int_cst (stype, - GET_MODE_PRECISION (TYPE_MODE (type)) - - tree_to_uhwi (def)); + GET_MODE_PRECISION (mode) - tree_to_uhwi (def)); } else { @@ -1944,8 +1945,7 @@ vect_recog_rotate_pattern (vec } def2 = vect_recog_temp_ssa_var (stype, NULL); - tree mask - = build_int_cst (stype, GET_MODE_PRECISION (TYPE_MODE (stype)) - 1); + tree mask = build_int_cst (stype, GET_MODE_PRECISION (smode) - 1); def_stmt = gimple_build_assign (def2, BIT_AND_EXPR, gimple_assign_lhs (def_stmt), mask); if (ext_def) @@ -2588,6 +2588,7 @@ vect_recog_divmod_pattern (vec || TYPE_PRECISION (itype) != GET_MODE_PRECISION (TYPE_MODE (itype))) return NULL; + scalar_int_mode itype_mode = SCALAR_INT_TYPE_MODE (itype); vectype = get_vectype_for_scalar_type (itype); if (vectype == NULL_TREE) return NULL; @@ -2655,7 +2656,7 @@ vect_recog_divmod_pattern (vec = build_nonstandard_integer_type (prec, 1); tree vecutype = get_vectype_for_scalar_type (utype); tree shift - = build_int_cst (utype, GET_MODE_BITSIZE (TYPE_MODE (itype)) + = build_int_cst (utype, GET_MODE_BITSIZE (itype_mode) - tree_log2 (oprnd1)); tree var = vect_recog_temp_ssa_var (utype, NULL); @@ -2721,7 +2722,7 @@ vect_recog_divmod_pattern (vec unsigned HOST_WIDE_INT mh, ml; int pre_shift, post_shift; unsigned HOST_WIDE_INT d = (TREE_INT_CST_LOW (oprnd1) - & GET_MODE_MASK (TYPE_MODE (itype))); + & GET_MODE_MASK (itype_mode)); tree t1, t2, t3, t4; if (d >= (HOST_WIDE_INT_1U << (prec - 1))) @@ -3066,7 +3067,8 @@ vect_recog_mixed_size_cond_pattern (vec< HOST_WIDE_INT cmp_mode_size = GET_MODE_UNIT_BITSIZE (TYPE_MODE (comp_vectype)); - if (GET_MODE_BITSIZE (TYPE_MODE (type)) == cmp_mode_size) + scalar_int_mode type_mode = SCALAR_INT_TYPE_MODE (type); + if (GET_MODE_BITSIZE (type_mode) == cmp_mode_size) return NULL; vectype = get_vectype_for_scalar_type (type); @@ -3091,7 +3093,7 @@ vect_recog_mixed_size_cond_pattern (vec< if (!expand_vec_cond_expr_p (vecitype, comp_vectype, TREE_CODE (cond_expr))) return NULL; - if (GET_MODE_BITSIZE (TYPE_MODE (type)) > cmp_mode_size) + if (GET_MODE_BITSIZE (type_mode) > cmp_mode_size) { if ((TREE_CODE (then_clause) == INTEGER_CST && !int_fits_type_p (then_clause, itype)) Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c 2017-07-13 09:18:38.045865278 +0100 +++ gcc/tree-vrp.c 2017-07-13 09:18:38.666812201 +0100 @@ -3567,6 +3567,7 @@ extract_range_basic (value_range *vr, gi int mini, maxi, zerov = 0, prec; enum tree_code subcode = ERROR_MARK; combined_fn cfn = gimple_call_combined_fn (stmt); + scalar_int_mode mode; switch (cfn) { @@ -3627,10 +3628,9 @@ extract_range_basic (value_range *vr, gi prec = TYPE_PRECISION (TREE_TYPE (arg)); mini = 0; maxi = prec; - if (optab_handler (clz_optab, TYPE_MODE (TREE_TYPE (arg))) - != CODE_FOR_nothing - && CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (TREE_TYPE (arg)), - zerov) + mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg)); + if (optab_handler (clz_optab, mode) != CODE_FOR_nothing + && CLZ_DEFINED_VALUE_AT_ZERO (mode, zerov) /* Handle only the single common value. */ && zerov != prec) /* Magic value to give up, unless vr0 proves @@ -3679,10 +3679,9 @@ extract_range_basic (value_range *vr, gi prec = TYPE_PRECISION (TREE_TYPE (arg)); mini = 0; maxi = prec - 1; - if (optab_handler (ctz_optab, TYPE_MODE (TREE_TYPE (arg))) - != CODE_FOR_nothing - && CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (TREE_TYPE (arg)), - zerov)) + mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg)); + if (optab_handler (ctz_optab, mode) != CODE_FOR_nothing + && CTZ_DEFINED_VALUE_AT_ZERO (mode, zerov)) { /* Handle only the two common values. */ if (zerov == -1) @@ -10102,13 +10101,13 @@ simplify_float_conversion_using_ranges ( return false; /* First check if we can use a signed type in place of an unsigned. */ + scalar_int_mode rhs_mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs1)); if (TYPE_UNSIGNED (TREE_TYPE (rhs1)) - && (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), 0) - != CODE_FOR_nothing) + && can_float_p (fltmode, rhs_mode, 0) != CODE_FOR_nothing && range_fits_type_p (vr, TYPE_PRECISION (TREE_TYPE (rhs1)), SIGNED)) - mode = TYPE_MODE (TREE_TYPE (rhs1)); + mode = rhs_mode; /* If we can do the conversion in the current input mode do nothing. */ - else if (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), + else if (can_float_p (fltmode, rhs_mode, TYPE_UNSIGNED (TREE_TYPE (rhs1))) != CODE_FOR_nothing) return false; /* Otherwise search for a mode we can use, starting from the narrowest Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-07-13 09:18:26.920877340 +0100 +++ gcc/tree.c 2017-07-13 09:18:38.667812116 +0100 @@ -9254,7 +9254,7 @@ int_fits_type_p (const_tree c, const_tre /* Third, unsigned integers with top bit set never fit signed types. */ if (!TYPE_UNSIGNED (type) && sgn_c == UNSIGNED) { - int prec = GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (c))) - 1; + int prec = GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (c))) - 1; if (prec < TYPE_PRECISION (TREE_TYPE (c))) { /* When a tree_cst is converted to a wide-int, the precision Index: gcc/ubsan.c =================================================================== --- gcc/ubsan.c 2017-06-30 12:50:38.436653781 +0100 +++ gcc/ubsan.c 2017-07-13 09:18:38.668812030 +0100 @@ -1385,7 +1385,7 @@ instrument_bool_enum_load (gimple_stmt_i && TREE_TYPE (type) != NULL_TREE && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE && (TYPE_PRECISION (TREE_TYPE (type)) - < GET_MODE_PRECISION (TYPE_MODE (type)))) + < GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (type)))) { minv = TYPE_MIN_VALUE (TREE_TYPE (type)); maxv = TYPE_MAX_VALUE (TREE_TYPE (type)); @@ -1393,7 +1393,7 @@ instrument_bool_enum_load (gimple_stmt_i else return; - int modebitsize = GET_MODE_BITSIZE (TYPE_MODE (type)); + int modebitsize = GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type)); HOST_WIDE_INT bitsize, bitpos; tree offset; machine_mode mode; @@ -1405,7 +1405,7 @@ instrument_bool_enum_load (gimple_stmt_i if ((VAR_P (base) && DECL_HARD_REGISTER (base)) || (bitpos % modebitsize) != 0 || bitsize != modebitsize - || GET_MODE_BITSIZE (TYPE_MODE (utype)) != modebitsize + || GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (utype)) != modebitsize || TREE_CODE (gimple_assign_lhs (stmt)) != SSA_NAME) return; Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-07-13 09:18:25.331031958 +0100 +++ gcc/varasm.c 2017-07-13 09:18:38.669811945 +0100 @@ -783,7 +783,7 @@ mergeable_string_section (tree decl ATTR && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0 && TREE_STRING_LENGTH (decl) >= len) { - machine_mode mode; + scalar_int_mode mode; unsigned int modesize; const char *str; HOST_WIDE_INT i; @@ -791,7 +791,7 @@ mergeable_string_section (tree decl ATTR const char *prefix = function_mergeable_rodata_prefix (); char *name = (char *) alloca (strlen (prefix) + 30); - mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl))); + mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (TREE_TYPE (decl))); modesize = GET_MODE_BITSIZE (mode); if (modesize >= 8 && modesize <= 256 && (modesize & (modesize - 1)) == 0) @@ -4280,8 +4280,8 @@ narrowing_initializer_constant_valid_p ( tree inner = TREE_OPERAND (op0, 0); if (inner == error_mark_node || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner))) - || (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0))) - > GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (inner))))) + || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op0))) + > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner))))) break; op0 = inner; } @@ -4292,8 +4292,8 @@ narrowing_initializer_constant_valid_p ( tree inner = TREE_OPERAND (op1, 0); if (inner == error_mark_node || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner))) - || (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1))) - > GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (inner))))) + || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op1))) + > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner))))) break; op1 = inner; } @@ -4718,7 +4718,7 @@ output_constant (tree exp, unsigned HOST if (TREE_CODE (exp) == NOP_EXPR && POINTER_TYPE_P (TREE_TYPE (exp)) && targetm.addr_space.valid_pointer_mode - (TYPE_MODE (TREE_TYPE (exp)), + (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)), TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp))))) { tree saved_type = TREE_TYPE (exp); @@ -4728,7 +4728,7 @@ output_constant (tree exp, unsigned HOST while (TREE_CODE (exp) == NOP_EXPR && POINTER_TYPE_P (TREE_TYPE (exp)) && targetm.addr_space.valid_pointer_mode - (TYPE_MODE (TREE_TYPE (exp)), + (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)), TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp))))) exp = TREE_OPERAND (exp, 0); Index: gcc/cp/cvt.c =================================================================== --- gcc/cp/cvt.c 2017-06-12 17:05:22.947756422 +0100 +++ gcc/cp/cvt.c 2017-07-13 09:18:38.656813056 +0100 @@ -234,8 +234,8 @@ cp_convert_to_pointer (tree type, tree e /* Modes may be different but sizes should be the same. There is supposed to be some integral type that is the same width as a pointer. */ - gcc_assert (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr))) - == GET_MODE_SIZE (TYPE_MODE (type))); + gcc_assert (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr))) + == GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type))); return convert_to_pointer_maybe_fold (type, expr, dofold); } Index: gcc/fortran/target-memory.c =================================================================== --- gcc/fortran/target-memory.c 2017-07-13 09:18:24.774086700 +0100 +++ gcc/fortran/target-memory.c 2017-07-13 09:18:38.661812628 +0100 @@ -39,7 +39,7 @@ Software Foundation; either version 3, o static size_t size_integer (int kind) { - return GET_MODE_SIZE (TYPE_MODE (gfc_get_int_type (kind)));; + return GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (gfc_get_int_type (kind))); } @@ -60,7 +60,7 @@ size_complex (int kind) static size_t size_logical (int kind) { - return GET_MODE_SIZE (TYPE_MODE (gfc_get_logical_type (kind)));; + return GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (gfc_get_logical_type (kind))); } Index: gcc/objc/objc-encoding.c =================================================================== --- gcc/objc/objc-encoding.c 2017-07-13 09:18:24.775086601 +0100 +++ gcc/objc/objc-encoding.c 2017-07-13 09:18:38.662812543 +0100 @@ -626,7 +626,7 @@ encode_type (tree type, int curtype, int case INTEGER_TYPE: { char c; - switch (GET_MODE_BITSIZE (TYPE_MODE (type))) + switch (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type))) { case 8: c = TYPE_UNSIGNED (type) ? 'C' : 'c'; break; case 16: c = TYPE_UNSIGNED (type) ? 'S' : 's'; break; From patchwork Thu Jul 13 08:51:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107621 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1934042qge; Thu, 13 Jul 2017 01:52:16 -0700 (PDT) X-Received: by 10.101.90.75 with SMTP id z11mr8148130pgs.58.1499935935912; Thu, 13 Jul 2017 01:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935935; cv=none; d=google.com; s=arc-20160816; b=DvozwJ7xLOM6GSLP9hmlxvCss+tpjcWYt+R1fm1B1Q1BpFriXVgS39Rdk0qhPZ8qcL FntMo/1jahp+G/213+gymkqWkQ8TsJ5ykfmcpw4/9+YAlCZTociMvJZRsBwL7IlTBgTX 1wsdJxTdSAb6p9xquzC/N+chmgf496WhSOvwgMi2jrcJqiN/L9GOkYw9htpxF8ED0NnE TCIefd6wd+Wol5v9ETmYOw7IwXl7pXnjh7N7AzQltlM5kxN3eXVRSoliwQInQ2Jce8MG Jb9U27xKQak+/i2C0HqHOIDqxfbCmyQav6z+6onsd3KfbftuxJN/KIhv+QbBUTtQ7Q9B pDWg== 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=iCpC07z1xanz/n+UPSlVDneVi62Ce55jnbzZrqxxMGU=; b=JJVLm9GfVcEwLoGdmphxvDJ0QHZ3hrc/sTum3yXNmavo71rdtyd/2mkVOb3feJG4+L 5rdm1W20e/GgilptcxnfZd4O68UG9GauBSL7h+EkokBgmusvMORqiWlCDDkQ7yJZAiFL KH5nmdQUPuS6inGHLb+tcSxuxMnI3JadicylMdc9/xmdmOZXQQQijhHjOw2V+EvgLSk9 D0kwnEQBFSppwjVWJhMjNzKCRs+/fzoopNMMtsCEuW7IszIbNAqnp49exz9bkcIvBL7p yqmiSSFTUUlYxmf3angGSE7ZaQxKtM7QczGPSpu0N4lQwFPxzRHaF8wqxuHMwP61Ia96 Xrlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=tykx5yRM; spf=pass (google.com: domain of gcc-patches-return-458026-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458026-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 h24si3763419pfk.157.2017.07.13.01.52.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458026-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=tykx5yRM; spf=pass (google.com: domain of gcc-patches-return-458026-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458026-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=A5wHcja40LWI4FkAY7fobb4t7zm3E WGYH+trVy7/eO5wVh1kgOjKtXDRikAlBWZmGmkyoeApKYAEpYEYYKUWpNdeIkd04 m4o+CMuYR2cwuXoRbRkIN6On5sfnqAZdJhYDGOR5OTTbXfBKGj8u7Ehqe/wYopBr RJimcinLeWbbfo= 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=UC5mAYpCo5sEolAnUB5L4jq2gYo=; b=tyk x5yRMSTDUie4fdIFTuHJj7m3DPCYqtAp4zMTSEeRqAzdotwDXM+m8PikgsPWhCls i2ukwVWe5Mr9j0GG9zzFg3mUuVoqkUbxYDEDA1AM4RBCQbMyHIq7XvsnPZ8xppK9 M02fj8WiAXA/5Sb8863l+CK6By4EnW5Hl3pH+7VY= Received: (qmail 5022 invoked by alias); 13 Jul 2017 08:51:22 -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 4445 invoked by uid 89); 13 Jul 2017 08:51:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:51:12 +0000 Received: by mail-wr0-f172.google.com with SMTP id k67so49375217wrc.2 for ; Thu, 13 Jul 2017 01:51:11 -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=iCpC07z1xanz/n+UPSlVDneVi62Ce55jnbzZrqxxMGU=; b=ns4BNudQbazjfgUc/2+e7OjrBImFPJKMbYbqByruWdP3oCSAqXmnET5sU6eDQHkEBn 3qvRx5W60zMXGXxGce6n08zkAw/6BADSR+Gjc4M7AURAawUbCKrKj1tm4uj7AB1Y4vq2 WTlrTCsFJPThmG3jou6nwBA78aZkLZVllewGfk1aS+gwbhKvf8yMIWb0eUi1JVXouncg RB3mV+BU0GvU9nW1jiaVPVQM9LuDekKnVzzno9LUJ61ljnzZlIYM3EYrtIvlU98fDyFr p+ikNR9xT8rvWPSB7ctD/TLI2L5VgkMHaZw1t+U0bFJ+VW99p1/PTv7iHmT6AS8x28IS QfFA== X-Gm-Message-State: AIVw113Rmwxc7OlwhzMvOX8xmoWamM64xrhfcN/iedYb5NNt5opBZgWI l2ll0tl2dfKXEMOX0zglZA== X-Received: by 10.223.164.23 with SMTP id d23mr908291wra.58.1499935869029; Thu, 13 Jul 2017 01:51:09 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id i185sm4836069wmf.34.2017.07.13.01.51.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:51:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [35/77] Add uses of as_a References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:51:06 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87y3rshg91.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds asserting as_a conversions to contexts in which the input is known to be a scalar integer mode. In expand_divmod, op1 is always a scalar_int_mode if op1_is_constant (but might not be otherwise). In expand_binop, the patch reverses a < comparison in order to avoid splitting a long line. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * cfgexpand.c (convert_debug_memory_address): Use as_a . * combine.c (expand_compound_operation): Likewise. (make_extraction): Likewise. (change_zero_ext): Likewise. (simplify_comparison): Likewise. * cse.c (cse_insn): Likewise. * dwarf2out.c (minmax_loc_descriptor): Likewise. (mem_loc_descriptor): Likewise. (loc_descriptor): Likewise. * expmed.c (synth_mult): Likewise. (emit_store_flag_1): Likewise. (expand_divmod): Likewise. Use HWI_COMPUTABLE_MODE_P instead of a comparison with size. * expr.c (expand_assignment): Use as_a . (reduce_to_bit_field_precision): Likewise. * function.c (expand_function_end): Likewise. * internal-fn.c (expand_arith_overflow_result_store): Likewise. * loop-doloop.c (doloop_modify): Likewise. * optabs.c (expand_binop): Likewise. (expand_unop): Likewise. (expand_copysign_absneg): Likewise. (prepare_cmp_insn): Likewise. (maybe_legitimize_operand): Likewise. * recog.c (const_scalar_int_operand): Likewise. * rtlanal.c (get_address_mode): Likewise. * simplify-rtx.c (simplify_unary_operation_1): Likewise. (simplify_cond_clz_ctz): Likewise. * tree-nested.c (get_nl_goto_field): Likewise. * tree.c (build_vector_type_for_mode): Likewise. * var-tracking.c (use_narrower_mode): Likewise. gcc/c-family/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * c-common.c (c_common_type_for_mode): Use as_a . gcc/lto/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * lto-lang.c (lto_type_for_mode): Use as_a . Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:38.656813056 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:39.582734406 +0100 @@ -3963,12 +3963,10 @@ round_udiv_adjust (machine_mode mode, rt convert_debug_memory_address (machine_mode mode, rtx x, addr_space_t as) { - machine_mode xmode = GET_MODE (x); - #ifndef POINTERS_EXTEND_UNSIGNED gcc_assert (mode == Pmode || mode == targetm.addr_space.address_mode (as)); - gcc_assert (xmode == mode || xmode == VOIDmode); + gcc_assert (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode); #else rtx temp; @@ -3977,6 +3975,8 @@ convert_debug_memory_address (machine_mo if (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode) return x; + /* X must have some form of address mode already. */ + scalar_int_mode xmode = as_a (GET_MODE (x)); if (GET_MODE_PRECISION (mode) < GET_MODE_PRECISION (xmode)) x = lowpart_subreg (mode, x, xmode); else if (POINTERS_EXTEND_UNSIGNED > 0) Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:35.965045845 +0100 +++ gcc/combine.c 2017-07-13 09:18:39.584734236 +0100 @@ -7145,16 +7145,19 @@ expand_compound_operation (rtx x) default: return x; } + + /* We've rejected non-scalar operations by now. */ + scalar_int_mode mode = as_a (GET_MODE (x)); + /* Convert sign extension to zero extension, if we know that the high bit is not set, as this is easier to optimize. It will be converted back to cheaper alternative in make_extraction. */ if (GET_CODE (x) == SIGN_EXTEND - && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) + && HWI_COMPUTABLE_MODE_P (mode) && ((nonzero_bits (XEXP (x, 0), inner_mode) & ~(((unsigned HOST_WIDE_INT) GET_MODE_MASK (inner_mode)) >> 1)) == 0)) { - machine_mode mode = GET_MODE (x); rtx temp = gen_rtx_ZERO_EXTEND (mode, XEXP (x, 0)); rtx temp2 = expand_compound_operation (temp); @@ -7176,27 +7179,27 @@ expand_compound_operation (rtx x) know that the last value didn't have any inappropriate bits set. */ if (GET_CODE (XEXP (x, 0)) == TRUNCATE - && GET_MODE (XEXP (XEXP (x, 0), 0)) == GET_MODE (x) - && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) - && (nonzero_bits (XEXP (XEXP (x, 0), 0), GET_MODE (x)) + && GET_MODE (XEXP (XEXP (x, 0), 0)) == mode + && HWI_COMPUTABLE_MODE_P (mode) + && (nonzero_bits (XEXP (XEXP (x, 0), 0), mode) & ~GET_MODE_MASK (inner_mode)) == 0) return XEXP (XEXP (x, 0), 0); /* Likewise for (zero_extend:DI (subreg:SI foo:DI 0)). */ if (GET_CODE (XEXP (x, 0)) == SUBREG - && GET_MODE (SUBREG_REG (XEXP (x, 0))) == GET_MODE (x) + && GET_MODE (SUBREG_REG (XEXP (x, 0))) == mode && subreg_lowpart_p (XEXP (x, 0)) - && HWI_COMPUTABLE_MODE_P (GET_MODE (x)) - && (nonzero_bits (SUBREG_REG (XEXP (x, 0)), GET_MODE (x)) + && HWI_COMPUTABLE_MODE_P (mode) + && (nonzero_bits (SUBREG_REG (XEXP (x, 0)), mode) & ~GET_MODE_MASK (inner_mode)) == 0) return SUBREG_REG (XEXP (x, 0)); /* (zero_extend:DI (truncate:SI foo:DI)) is just foo:DI when foo is a comparison and STORE_FLAG_VALUE permits. This is like - the first case, but it works even when GET_MODE (x) is larger + the first case, but it works even when MODE is larger than HOST_WIDE_INT. */ if (GET_CODE (XEXP (x, 0)) == TRUNCATE - && GET_MODE (XEXP (XEXP (x, 0), 0)) == GET_MODE (x) + && GET_MODE (XEXP (XEXP (x, 0), 0)) == mode && COMPARISON_P (XEXP (XEXP (x, 0), 0)) && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT && (STORE_FLAG_VALUE & ~GET_MODE_MASK (inner_mode)) == 0) @@ -7204,7 +7207,7 @@ expand_compound_operation (rtx x) /* Likewise for (zero_extend:DI (subreg:SI foo:DI 0)). */ if (GET_CODE (XEXP (x, 0)) == SUBREG - && GET_MODE (SUBREG_REG (XEXP (x, 0))) == GET_MODE (x) + && GET_MODE (SUBREG_REG (XEXP (x, 0))) == mode && subreg_lowpart_p (XEXP (x, 0)) && COMPARISON_P (SUBREG_REG (XEXP (x, 0))) && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT @@ -7228,10 +7231,9 @@ expand_compound_operation (rtx x) extraction. Then the constant of 31 would be substituted in to produce such a position. */ - modewidth = GET_MODE_PRECISION (GET_MODE (x)); + modewidth = GET_MODE_PRECISION (mode); if (modewidth >= pos + len) { - machine_mode mode = GET_MODE (x); tem = gen_lowpart (mode, XEXP (x, 0)); if (!tem || GET_CODE (tem) == CLOBBER) return x; @@ -7241,10 +7243,10 @@ expand_compound_operation (rtx x) mode, tem, modewidth - len); } else if (unsignedp && len < HOST_BITS_PER_WIDE_INT) - tem = simplify_and_const_int (NULL_RTX, GET_MODE (x), + tem = simplify_and_const_int (NULL_RTX, mode, simplify_shift_const (NULL_RTX, LSHIFTRT, - GET_MODE (x), - XEXP (x, 0), pos), + mode, XEXP (x, 0), + pos), (HOST_WIDE_INT_1U << len) - 1); else /* Any other cases we can't handle. */ @@ -7745,9 +7747,13 @@ make_extraction (machine_mode mode, rtx } /* Adjust mode of POS_RTX, if needed. If we want a wider mode, we - have to zero extend. Otherwise, we can just use a SUBREG. */ + have to zero extend. Otherwise, we can just use a SUBREG. + + We dealt with constant rtxes earlier, so pos_rtx cannot + have VOIDmode at this point. */ if (pos_rtx != 0 - && GET_MODE_SIZE (pos_mode) > GET_MODE_SIZE (GET_MODE (pos_rtx))) + && (GET_MODE_SIZE (pos_mode) + > GET_MODE_SIZE (as_a (GET_MODE (pos_rtx))))) { rtx temp = simplify_gen_unary (ZERO_EXTEND, pos_mode, pos_rtx, GET_MODE (pos_rtx)); @@ -11358,7 +11364,8 @@ change_zero_ext (rtx pat) && !paradoxical_subreg_p (XEXP (x, 0)) && subreg_lowpart_p (XEXP (x, 0))) { - size = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))); + inner_mode = as_a (GET_MODE (XEXP (x, 0))); + size = GET_MODE_PRECISION (inner_mode); x = SUBREG_REG (XEXP (x, 0)); if (GET_MODE (x) != mode) x = gen_lowpart_SUBREG (mode, x); @@ -11368,7 +11375,8 @@ change_zero_ext (rtx pat) && HARD_REGISTER_P (XEXP (x, 0)) && can_change_dest_mode (XEXP (x, 0), 0, mode)) { - size = GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))); + inner_mode = as_a (GET_MODE (XEXP (x, 0))); + size = GET_MODE_PRECISION (inner_mode); x = gen_rtx_REG (mode, REGNO (XEXP (x, 0))); } else @@ -11786,8 +11794,8 @@ simplify_comparison (enum rtx_code code, rtx op1 = *pop1; rtx tem, tem1; int i; - scalar_int_mode mode, inner_mode; - machine_mode tmode; + scalar_int_mode mode, inner_mode, tmode; + opt_scalar_int_mode tmode_iter; /* Try a few ways of applying the same transformation to both operands. */ while (1) @@ -11895,7 +11903,8 @@ simplify_comparison (enum rtx_code code, } else if (c0 == c1) - FOR_EACH_MODE_UNTIL (tmode, GET_MODE (op0)) + FOR_EACH_MODE_UNTIL (tmode, + as_a (GET_MODE (op0))) if ((unsigned HOST_WIDE_INT) c0 == GET_MODE_MASK (tmode)) { op0 = gen_lowpart_or_truncate (tmode, inner_op0); @@ -12762,8 +12771,9 @@ simplify_comparison (enum rtx_code code, if (is_int_mode (GET_MODE (op0), &mode) && GET_MODE_SIZE (mode) < UNITS_PER_WORD && ! have_insn_for (COMPARE, mode)) - FOR_EACH_WIDER_MODE (tmode, mode) + FOR_EACH_WIDER_MODE (tmode_iter, mode) { + tmode = *tmode_iter; if (!HWI_COMPUTABLE_MODE_P (tmode)) break; if (have_insn_for (COMPARE, tmode)) Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-07-13 09:18:35.966045757 +0100 +++ gcc/cse.c 2017-07-13 09:18:39.584734236 +0100 @@ -4552,14 +4552,17 @@ cse_insn (rtx_insn *insn) && CONST_INT_P (XEXP (SET_DEST (sets[0].rtl), 2))) { rtx dest_reg = XEXP (SET_DEST (sets[0].rtl), 0); + /* This is the mode of XEXP (tem, 0) as well. */ + scalar_int_mode dest_mode + = as_a (GET_MODE (dest_reg)); rtx width = XEXP (SET_DEST (sets[0].rtl), 1); rtx pos = XEXP (SET_DEST (sets[0].rtl), 2); HOST_WIDE_INT val = INTVAL (XEXP (tem, 0)); HOST_WIDE_INT mask; unsigned int shift; if (BITS_BIG_ENDIAN) - shift = GET_MODE_PRECISION (GET_MODE (dest_reg)) - - INTVAL (pos) - INTVAL (width); + shift = (GET_MODE_PRECISION (dest_mode) + - INTVAL (pos) - INTVAL (width)); else shift = INTVAL (pos); if (INTVAL (width) == HOST_BITS_PER_WIDE_INT) @@ -5231,8 +5234,11 @@ cse_insn (rtx_insn *insn) HOST_WIDE_INT val = INTVAL (dest_cst); HOST_WIDE_INT mask; unsigned int shift; + /* This is the mode of DEST_CST as well. */ + scalar_int_mode dest_mode + = as_a (GET_MODE (dest_reg)); if (BITS_BIG_ENDIAN) - shift = GET_MODE_PRECISION (GET_MODE (dest_reg)) + shift = GET_MODE_PRECISION (dest_mode) - INTVAL (pos) - INTVAL (width); else shift = INTVAL (pos); @@ -5242,7 +5248,7 @@ cse_insn (rtx_insn *insn) mask = (HOST_WIDE_INT_1 << INTVAL (width)) - 1; val &= ~(mask << shift); val |= (INTVAL (trial) & mask) << shift; - val = trunc_int_for_mode (val, GET_MODE (dest_reg)); + val = trunc_int_for_mode (val, dest_mode); validate_unshare_change (insn, &SET_DEST (sets[i].rtl), dest_reg, 1); validate_unshare_change (insn, &SET_SRC (sets[i].rtl), Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:36.422005956 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:39.587733983 +0100 @@ -14085,15 +14085,17 @@ minmax_loc_descriptor (rtx rtl, machine_ add_loc_descr (&op1, new_loc_descr (DW_OP_over, 0, 0)); if (GET_CODE (rtl) == UMIN || GET_CODE (rtl) == UMAX) { - if (GET_MODE_SIZE (mode) < DWARF2_ADDR_SIZE) + /* Checked by the caller. */ + int_mode = as_a (mode); + if (GET_MODE_SIZE (int_mode) < DWARF2_ADDR_SIZE) { - HOST_WIDE_INT mask = GET_MODE_MASK (mode); + HOST_WIDE_INT mask = GET_MODE_MASK (int_mode); add_loc_descr (&op0, int_loc_descriptor (mask)); add_loc_descr (&op0, new_loc_descr (DW_OP_and, 0, 0)); add_loc_descr (&op1, int_loc_descriptor (mask)); add_loc_descr (&op1, new_loc_descr (DW_OP_and, 0, 0)); } - else if (GET_MODE_SIZE (mode) == DWARF2_ADDR_SIZE) + else if (GET_MODE_SIZE (int_mode) == DWARF2_ADDR_SIZE) { HOST_WIDE_INT bias = 1; bias <<= (DWARF2_ADDR_SIZE * BITS_PER_UNIT - 1); @@ -14976,7 +14978,8 @@ mem_loc_descriptor (rtx rtl, machine_mod break; if (CONST_INT_P (XEXP (rtl, 1)) - && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE) + && (GET_MODE_SIZE (as_a (mode)) + <= DWARF2_ADDR_SIZE)) loc_descr_plus_const (&mem_loc_result, INTVAL (XEXP (rtl, 1))); else { @@ -15759,8 +15762,11 @@ loc_descriptor (rtx rtl, machine_mode mo case CONST_INT: if (mode != VOIDmode && mode != BLKmode) - loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (mode), - INTVAL (rtl)); + { + int_mode = as_a (mode); + loc_result = address_of_int_loc_descriptor (GET_MODE_SIZE (int_mode), + INTVAL (rtl)); + } break; case CONST_DOUBLE: @@ -15805,11 +15811,12 @@ loc_descriptor (rtx rtl, machine_mode mo if (mode != VOIDmode && (dwarf_version >= 4 || !dwarf_strict)) { + int_mode = as_a (mode); loc_result = new_loc_descr (DW_OP_implicit_value, - GET_MODE_SIZE (mode), 0); + GET_MODE_SIZE (int_mode), 0); loc_result->dw_loc_oprnd2.val_class = dw_val_class_wide_int; loc_result->dw_loc_oprnd2.v.val_wide = ggc_alloc (); - *loc_result->dw_loc_oprnd2.v.val_wide = rtx_mode_t (rtl, mode); + *loc_result->dw_loc_oprnd2.v.val_wide = rtx_mode_t (rtl, int_mode); } break; Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:38.658812885 +0100 +++ gcc/expmed.c 2017-07-13 09:18:39.588733898 +0100 @@ -2523,7 +2523,7 @@ synth_mult (struct algorithm *alg_out, u bool cache_hit = false; enum alg_code cache_alg = alg_zero; bool speed = optimize_insn_for_speed_p (); - machine_mode imode; + scalar_int_mode imode; struct alg_hash_entry *entry_ptr; /* Indicate that no algorithm is yet found. If no algorithm @@ -2536,7 +2536,7 @@ synth_mult (struct algorithm *alg_out, u return; /* Be prepared for vector modes. */ - imode = GET_MODE_INNER (mode); + imode = as_a (GET_MODE_INNER (mode)); maxm = MIN (BITS_PER_WORD, GET_MODE_BITSIZE (imode)); @@ -3980,7 +3980,6 @@ expand_divmod (int rem_flag, enum tree_c rtx tquotient; rtx quotient = 0, remainder = 0; rtx_insn *last; - int size; rtx_insn *insn; optab optab1, optab2; int op1_is_constant, op1_is_pow2 = 0; @@ -4102,7 +4101,6 @@ expand_divmod (int rem_flag, enum tree_c else tquotient = gen_reg_rtx (compute_mode); - size = GET_MODE_BITSIZE (compute_mode); #if 0 /* It should be possible to restrict the precision to GET_MODE_BITSIZE (mode), and thereby get better code when OP1 is a constant. Do that @@ -4175,12 +4173,14 @@ expand_divmod (int rem_flag, enum tree_c case TRUNC_DIV_EXPR: if (op1_is_constant) { + scalar_int_mode int_mode = as_a (compute_mode); + int size = GET_MODE_BITSIZE (int_mode); if (unsignedp) { unsigned HOST_WIDE_INT mh, ml; int pre_shift, post_shift; int dummy; - wide_int wd = rtx_mode_t (op1, compute_mode); + wide_int wd = rtx_mode_t (op1, int_mode); unsigned HOST_WIDE_INT d = wd.to_uhwi (); if (wi::popcount (wd) == 1) @@ -4191,14 +4191,14 @@ expand_divmod (int rem_flag, enum tree_c unsigned HOST_WIDE_INT mask = (HOST_WIDE_INT_1U << pre_shift) - 1; remainder - = expand_binop (compute_mode, and_optab, op0, - gen_int_mode (mask, compute_mode), + = expand_binop (int_mode, and_optab, op0, + gen_int_mode (mask, int_mode), remainder, 1, OPTAB_LIB_WIDEN); if (remainder) return gen_lowpart (mode, remainder); } - quotient = expand_shift (RSHIFT_EXPR, compute_mode, op0, + quotient = expand_shift (RSHIFT_EXPR, int_mode, op0, pre_shift, tquotient, 1); } else if (size <= HOST_BITS_PER_WIDE_INT) @@ -4208,7 +4208,7 @@ expand_divmod (int rem_flag, enum tree_c /* Most significant bit of divisor is set; emit an scc insn. */ quotient = emit_store_flag_force (tquotient, GEU, op0, op1, - compute_mode, 1, 1); + int_mode, 1, 1); } else { @@ -4240,25 +4240,24 @@ expand_divmod (int rem_flag, enum tree_c goto fail1; extra_cost - = (shift_cost (speed, compute_mode, post_shift - 1) - + shift_cost (speed, compute_mode, 1) - + 2 * add_cost (speed, compute_mode)); + = (shift_cost (speed, int_mode, post_shift - 1) + + shift_cost (speed, int_mode, 1) + + 2 * add_cost (speed, int_mode)); t1 = expmed_mult_highpart - (compute_mode, op0, - gen_int_mode (ml, compute_mode), + (int_mode, op0, gen_int_mode (ml, int_mode), NULL_RTX, 1, max_cost - extra_cost); if (t1 == 0) goto fail1; - t2 = force_operand (gen_rtx_MINUS (compute_mode, + t2 = force_operand (gen_rtx_MINUS (int_mode, op0, t1), NULL_RTX); - t3 = expand_shift (RSHIFT_EXPR, compute_mode, + t3 = expand_shift (RSHIFT_EXPR, int_mode, t2, 1, NULL_RTX, 1); - t4 = force_operand (gen_rtx_PLUS (compute_mode, + t4 = force_operand (gen_rtx_PLUS (int_mode, t1, t3), NULL_RTX); quotient = expand_shift - (RSHIFT_EXPR, compute_mode, t4, + (RSHIFT_EXPR, int_mode, t4, post_shift - 1, tquotient, 1); } else @@ -4270,19 +4269,19 @@ expand_divmod (int rem_flag, enum tree_c goto fail1; t1 = expand_shift - (RSHIFT_EXPR, compute_mode, op0, + (RSHIFT_EXPR, int_mode, op0, pre_shift, NULL_RTX, 1); extra_cost - = (shift_cost (speed, compute_mode, pre_shift) - + shift_cost (speed, compute_mode, post_shift)); + = (shift_cost (speed, int_mode, pre_shift) + + shift_cost (speed, int_mode, post_shift)); t2 = expmed_mult_highpart - (compute_mode, t1, - gen_int_mode (ml, compute_mode), + (int_mode, t1, + gen_int_mode (ml, int_mode), NULL_RTX, 1, max_cost - extra_cost); if (t2 == 0) goto fail1; quotient = expand_shift - (RSHIFT_EXPR, compute_mode, t2, + (RSHIFT_EXPR, int_mode, t2, post_shift, tquotient, 1); } } @@ -4293,7 +4292,7 @@ expand_divmod (int rem_flag, enum tree_c insn = get_last_insn (); if (insn != last) set_dst_reg_note (insn, REG_EQUAL, - gen_rtx_UDIV (compute_mode, op0, op1), + gen_rtx_UDIV (int_mode, op0, op1), quotient); } else /* TRUNC_DIV, signed */ @@ -4315,36 +4314,35 @@ expand_divmod (int rem_flag, enum tree_c if (rem_flag && d < 0) { d = abs_d; - op1 = gen_int_mode (abs_d, compute_mode); + op1 = gen_int_mode (abs_d, int_mode); } if (d == 1) quotient = op0; else if (d == -1) - quotient = expand_unop (compute_mode, neg_optab, op0, + quotient = expand_unop (int_mode, neg_optab, op0, tquotient, 0); else if (size <= HOST_BITS_PER_WIDE_INT && abs_d == HOST_WIDE_INT_1U << (size - 1)) { /* This case is not handled correctly below. */ quotient = emit_store_flag (tquotient, EQ, op0, op1, - compute_mode, 1, 1); + int_mode, 1, 1); if (quotient == 0) goto fail1; } else if (EXACT_POWER_OF_2_OR_ZERO_P (d) && (size <= HOST_BITS_PER_WIDE_INT || d >= 0) && (rem_flag - ? smod_pow2_cheap (speed, compute_mode) - : sdiv_pow2_cheap (speed, compute_mode)) + ? smod_pow2_cheap (speed, int_mode) + : sdiv_pow2_cheap (speed, int_mode)) /* We assume that cheap metric is true if the optab has an expander for this mode. */ && ((optab_handler ((rem_flag ? smod_optab : sdiv_optab), - compute_mode) + int_mode) != CODE_FOR_nothing) - || (optab_handler (sdivmod_optab, - compute_mode) + || (optab_handler (sdivmod_optab, int_mode) != CODE_FOR_nothing))) ; else if (EXACT_POWER_OF_2_OR_ZERO_P (abs_d) @@ -4353,23 +4351,23 @@ expand_divmod (int rem_flag, enum tree_c { if (rem_flag) { - remainder = expand_smod_pow2 (compute_mode, op0, d); + remainder = expand_smod_pow2 (int_mode, op0, d); if (remainder) return gen_lowpart (mode, remainder); } - if (sdiv_pow2_cheap (speed, compute_mode) - && ((optab_handler (sdiv_optab, compute_mode) + if (sdiv_pow2_cheap (speed, int_mode) + && ((optab_handler (sdiv_optab, int_mode) != CODE_FOR_nothing) - || (optab_handler (sdivmod_optab, compute_mode) + || (optab_handler (sdivmod_optab, int_mode) != CODE_FOR_nothing))) quotient = expand_divmod (0, TRUNC_DIV_EXPR, - compute_mode, op0, + int_mode, op0, gen_int_mode (abs_d, - compute_mode), + int_mode), NULL_RTX, 0); else - quotient = expand_sdiv_pow2 (compute_mode, op0, abs_d); + quotient = expand_sdiv_pow2 (int_mode, op0, abs_d); /* We have computed OP0 / abs(OP1). If OP1 is negative, negate the quotient. */ @@ -4380,13 +4378,13 @@ expand_divmod (int rem_flag, enum tree_c && abs_d < (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1))) set_dst_reg_note (insn, REG_EQUAL, - gen_rtx_DIV (compute_mode, op0, + gen_rtx_DIV (int_mode, op0, gen_int_mode (abs_d, - compute_mode)), + int_mode)), quotient); - quotient = expand_unop (compute_mode, neg_optab, + quotient = expand_unop (int_mode, neg_optab, quotient, quotient, 0); } } @@ -4402,29 +4400,27 @@ expand_divmod (int rem_flag, enum tree_c || size - 1 >= BITS_PER_WORD) goto fail1; - extra_cost = (shift_cost (speed, compute_mode, post_shift) - + shift_cost (speed, compute_mode, size - 1) - + add_cost (speed, compute_mode)); + extra_cost = (shift_cost (speed, int_mode, post_shift) + + shift_cost (speed, int_mode, size - 1) + + add_cost (speed, int_mode)); t1 = expmed_mult_highpart - (compute_mode, op0, gen_int_mode (ml, compute_mode), + (int_mode, op0, gen_int_mode (ml, int_mode), NULL_RTX, 0, max_cost - extra_cost); if (t1 == 0) goto fail1; t2 = expand_shift - (RSHIFT_EXPR, compute_mode, t1, + (RSHIFT_EXPR, int_mode, t1, post_shift, NULL_RTX, 0); t3 = expand_shift - (RSHIFT_EXPR, compute_mode, op0, + (RSHIFT_EXPR, int_mode, op0, size - 1, NULL_RTX, 0); if (d < 0) quotient - = force_operand (gen_rtx_MINUS (compute_mode, - t3, t2), + = force_operand (gen_rtx_MINUS (int_mode, t3, t2), tquotient); else quotient - = force_operand (gen_rtx_MINUS (compute_mode, - t2, t3), + = force_operand (gen_rtx_MINUS (int_mode, t2, t3), tquotient); } else @@ -4436,33 +4432,30 @@ expand_divmod (int rem_flag, enum tree_c goto fail1; ml |= HOST_WIDE_INT_M1U << (size - 1); - mlr = gen_int_mode (ml, compute_mode); - extra_cost = (shift_cost (speed, compute_mode, post_shift) - + shift_cost (speed, compute_mode, size - 1) - + 2 * add_cost (speed, compute_mode)); - t1 = expmed_mult_highpart (compute_mode, op0, mlr, + mlr = gen_int_mode (ml, int_mode); + extra_cost = (shift_cost (speed, int_mode, post_shift) + + shift_cost (speed, int_mode, size - 1) + + 2 * add_cost (speed, int_mode)); + t1 = expmed_mult_highpart (int_mode, op0, mlr, NULL_RTX, 0, max_cost - extra_cost); if (t1 == 0) goto fail1; - t2 = force_operand (gen_rtx_PLUS (compute_mode, - t1, op0), + t2 = force_operand (gen_rtx_PLUS (int_mode, t1, op0), NULL_RTX); t3 = expand_shift - (RSHIFT_EXPR, compute_mode, t2, + (RSHIFT_EXPR, int_mode, t2, post_shift, NULL_RTX, 0); t4 = expand_shift - (RSHIFT_EXPR, compute_mode, op0, + (RSHIFT_EXPR, int_mode, op0, size - 1, NULL_RTX, 0); if (d < 0) quotient - = force_operand (gen_rtx_MINUS (compute_mode, - t4, t3), + = force_operand (gen_rtx_MINUS (int_mode, t4, t3), tquotient); else quotient - = force_operand (gen_rtx_MINUS (compute_mode, - t3, t4), + = force_operand (gen_rtx_MINUS (int_mode, t3, t4), tquotient); } } @@ -4472,7 +4465,7 @@ expand_divmod (int rem_flag, enum tree_c insn = get_last_insn (); if (insn != last) set_dst_reg_note (insn, REG_EQUAL, - gen_rtx_DIV (compute_mode, op0, op1), + gen_rtx_DIV (int_mode, op0, op1), quotient); } break; @@ -4484,8 +4477,10 @@ expand_divmod (int rem_flag, enum tree_c case FLOOR_DIV_EXPR: case FLOOR_MOD_EXPR: /* We will come here only for signed operations. */ - if (op1_is_constant && size <= HOST_BITS_PER_WIDE_INT) + if (op1_is_constant && HWI_COMPUTABLE_MODE_P (compute_mode)) { + scalar_int_mode int_mode = as_a (compute_mode); + int size = GET_MODE_BITSIZE (int_mode); unsigned HOST_WIDE_INT mh, ml; int pre_shift, lgup, post_shift; HOST_WIDE_INT d = INTVAL (op1); @@ -4502,14 +4497,14 @@ expand_divmod (int rem_flag, enum tree_c unsigned HOST_WIDE_INT mask = (HOST_WIDE_INT_1U << pre_shift) - 1; remainder = expand_binop - (compute_mode, and_optab, op0, - gen_int_mode (mask, compute_mode), + (int_mode, and_optab, op0, + gen_int_mode (mask, int_mode), remainder, 0, OPTAB_LIB_WIDEN); if (remainder) return gen_lowpart (mode, remainder); } quotient = expand_shift - (RSHIFT_EXPR, compute_mode, op0, + (RSHIFT_EXPR, int_mode, op0, pre_shift, tquotient, 0); } else @@ -4524,22 +4519,22 @@ expand_divmod (int rem_flag, enum tree_c && size - 1 < BITS_PER_WORD) { t1 = expand_shift - (RSHIFT_EXPR, compute_mode, op0, + (RSHIFT_EXPR, int_mode, op0, size - 1, NULL_RTX, 0); - t2 = expand_binop (compute_mode, xor_optab, op0, t1, + t2 = expand_binop (int_mode, xor_optab, op0, t1, NULL_RTX, 0, OPTAB_WIDEN); - extra_cost = (shift_cost (speed, compute_mode, post_shift) - + shift_cost (speed, compute_mode, size - 1) - + 2 * add_cost (speed, compute_mode)); + extra_cost = (shift_cost (speed, int_mode, post_shift) + + shift_cost (speed, int_mode, size - 1) + + 2 * add_cost (speed, int_mode)); t3 = expmed_mult_highpart - (compute_mode, t2, gen_int_mode (ml, compute_mode), + (int_mode, t2, gen_int_mode (ml, int_mode), NULL_RTX, 1, max_cost - extra_cost); if (t3 != 0) { t4 = expand_shift - (RSHIFT_EXPR, compute_mode, t3, + (RSHIFT_EXPR, int_mode, t3, post_shift, NULL_RTX, 1); - quotient = expand_binop (compute_mode, xor_optab, + quotient = expand_binop (int_mode, xor_optab, t4, t1, tquotient, 0, OPTAB_WIDEN); } @@ -4549,23 +4544,22 @@ expand_divmod (int rem_flag, enum tree_c else { rtx nsign, t1, t2, t3, t4; - t1 = force_operand (gen_rtx_PLUS (compute_mode, + t1 = force_operand (gen_rtx_PLUS (int_mode, op0, constm1_rtx), NULL_RTX); - t2 = expand_binop (compute_mode, ior_optab, op0, t1, NULL_RTX, + t2 = expand_binop (int_mode, ior_optab, op0, t1, NULL_RTX, 0, OPTAB_WIDEN); - nsign = expand_shift (RSHIFT_EXPR, compute_mode, t2, + nsign = expand_shift (RSHIFT_EXPR, int_mode, t2, size - 1, NULL_RTX, 0); - t3 = force_operand (gen_rtx_MINUS (compute_mode, t1, nsign), + t3 = force_operand (gen_rtx_MINUS (int_mode, t1, nsign), NULL_RTX); - t4 = expand_divmod (0, TRUNC_DIV_EXPR, compute_mode, t3, op1, + t4 = expand_divmod (0, TRUNC_DIV_EXPR, int_mode, t3, op1, NULL_RTX, 0); if (t4) { rtx t5; - t5 = expand_unop (compute_mode, one_cmpl_optab, nsign, + t5 = expand_unop (int_mode, one_cmpl_optab, nsign, NULL_RTX, 0); - quotient = force_operand (gen_rtx_PLUS (compute_mode, - t4, t5), + quotient = force_operand (gen_rtx_PLUS (int_mode, t4, t5), tquotient); } } @@ -4665,31 +4659,31 @@ expand_divmod (int rem_flag, enum tree_c { if (op1_is_constant && EXACT_POWER_OF_2_OR_ZERO_P (INTVAL (op1)) - && (size <= HOST_BITS_PER_WIDE_INT + && (HWI_COMPUTABLE_MODE_P (compute_mode) || INTVAL (op1) >= 0)) { + scalar_int_mode int_mode + = as_a (compute_mode); rtx t1, t2, t3; unsigned HOST_WIDE_INT d = INTVAL (op1); - t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0, + t1 = expand_shift (RSHIFT_EXPR, int_mode, op0, floor_log2 (d), tquotient, 1); - t2 = expand_binop (compute_mode, and_optab, op0, - gen_int_mode (d - 1, compute_mode), + t2 = expand_binop (int_mode, and_optab, op0, + gen_int_mode (d - 1, int_mode), NULL_RTX, 1, OPTAB_LIB_WIDEN); - t3 = gen_reg_rtx (compute_mode); - t3 = emit_store_flag (t3, NE, t2, const0_rtx, - compute_mode, 1, 1); + t3 = gen_reg_rtx (int_mode); + t3 = emit_store_flag (t3, NE, t2, const0_rtx, int_mode, 1, 1); if (t3 == 0) { rtx_code_label *lab; lab = gen_label_rtx (); - do_cmp_and_jump (t2, const0_rtx, EQ, compute_mode, lab); + do_cmp_and_jump (t2, const0_rtx, EQ, int_mode, lab); expand_inc (t1, const1_rtx); emit_label (lab); quotient = t1; } else - quotient = force_operand (gen_rtx_PLUS (compute_mode, - t1, t3), + quotient = force_operand (gen_rtx_PLUS (int_mode, t1, t3), tquotient); break; } @@ -4879,8 +4873,10 @@ expand_divmod (int rem_flag, enum tree_c break; case EXACT_DIV_EXPR: - if (op1_is_constant && size <= HOST_BITS_PER_WIDE_INT) + if (op1_is_constant && HWI_COMPUTABLE_MODE_P (compute_mode)) { + scalar_int_mode int_mode = as_a (compute_mode); + int size = GET_MODE_BITSIZE (int_mode); HOST_WIDE_INT d = INTVAL (op1); unsigned HOST_WIDE_INT ml; int pre_shift; @@ -4888,16 +4884,15 @@ expand_divmod (int rem_flag, enum tree_c pre_shift = ctz_or_zero (d); ml = invert_mod2n (d >> pre_shift, size); - t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0, + t1 = expand_shift (RSHIFT_EXPR, int_mode, op0, pre_shift, NULL_RTX, unsignedp); - quotient = expand_mult (compute_mode, t1, - gen_int_mode (ml, compute_mode), + quotient = expand_mult (int_mode, t1, gen_int_mode (ml, int_mode), NULL_RTX, 1); insn = get_last_insn (); set_dst_reg_note (insn, REG_EQUAL, gen_rtx_fmt_ee (unsignedp ? UDIV : DIV, - compute_mode, op0, op1), + int_mode, op0, op1), quotient); } break; @@ -4906,60 +4901,63 @@ expand_divmod (int rem_flag, enum tree_c case ROUND_MOD_EXPR: if (unsignedp) { + scalar_int_mode int_mode = as_a (compute_mode); rtx tem; rtx_code_label *label; label = gen_label_rtx (); - quotient = gen_reg_rtx (compute_mode); - remainder = gen_reg_rtx (compute_mode); + quotient = gen_reg_rtx (int_mode); + remainder = gen_reg_rtx (int_mode); if (expand_twoval_binop (udivmod_optab, op0, op1, quotient, remainder, 1) == 0) { rtx tem; - quotient = expand_binop (compute_mode, udiv_optab, op0, op1, + quotient = expand_binop (int_mode, udiv_optab, op0, op1, quotient, 1, OPTAB_LIB_WIDEN); - tem = expand_mult (compute_mode, quotient, op1, NULL_RTX, 1); - remainder = expand_binop (compute_mode, sub_optab, op0, tem, + tem = expand_mult (int_mode, quotient, op1, NULL_RTX, 1); + remainder = expand_binop (int_mode, sub_optab, op0, tem, remainder, 1, OPTAB_LIB_WIDEN); } - tem = plus_constant (compute_mode, op1, -1); - tem = expand_shift (RSHIFT_EXPR, compute_mode, tem, 1, NULL_RTX, 1); - do_cmp_and_jump (remainder, tem, LEU, compute_mode, label); + tem = plus_constant (int_mode, op1, -1); + tem = expand_shift (RSHIFT_EXPR, int_mode, tem, 1, NULL_RTX, 1); + do_cmp_and_jump (remainder, tem, LEU, int_mode, label); expand_inc (quotient, const1_rtx); expand_dec (remainder, op1); emit_label (label); } else { + scalar_int_mode int_mode = as_a (compute_mode); + int size = GET_MODE_BITSIZE (int_mode); rtx abs_rem, abs_op1, tem, mask; rtx_code_label *label; label = gen_label_rtx (); - quotient = gen_reg_rtx (compute_mode); - remainder = gen_reg_rtx (compute_mode); + quotient = gen_reg_rtx (int_mode); + remainder = gen_reg_rtx (int_mode); if (expand_twoval_binop (sdivmod_optab, op0, op1, quotient, remainder, 0) == 0) { rtx tem; - quotient = expand_binop (compute_mode, sdiv_optab, op0, op1, + quotient = expand_binop (int_mode, sdiv_optab, op0, op1, quotient, 0, OPTAB_LIB_WIDEN); - tem = expand_mult (compute_mode, quotient, op1, NULL_RTX, 0); - remainder = expand_binop (compute_mode, sub_optab, op0, tem, + tem = expand_mult (int_mode, quotient, op1, NULL_RTX, 0); + remainder = expand_binop (int_mode, sub_optab, op0, tem, remainder, 0, OPTAB_LIB_WIDEN); } - abs_rem = expand_abs (compute_mode, remainder, NULL_RTX, 1, 0); - abs_op1 = expand_abs (compute_mode, op1, NULL_RTX, 1, 0); - tem = expand_shift (LSHIFT_EXPR, compute_mode, abs_rem, + abs_rem = expand_abs (int_mode, remainder, NULL_RTX, 1, 0); + abs_op1 = expand_abs (int_mode, op1, NULL_RTX, 1, 0); + tem = expand_shift (LSHIFT_EXPR, int_mode, abs_rem, 1, NULL_RTX, 1); - do_cmp_and_jump (tem, abs_op1, LTU, compute_mode, label); - tem = expand_binop (compute_mode, xor_optab, op0, op1, + do_cmp_and_jump (tem, abs_op1, LTU, int_mode, label); + tem = expand_binop (int_mode, xor_optab, op0, op1, NULL_RTX, 0, OPTAB_WIDEN); - mask = expand_shift (RSHIFT_EXPR, compute_mode, tem, + mask = expand_shift (RSHIFT_EXPR, int_mode, tem, size - 1, NULL_RTX, 0); - tem = expand_binop (compute_mode, xor_optab, mask, const1_rtx, + tem = expand_binop (int_mode, xor_optab, mask, const1_rtx, NULL_RTX, 0, OPTAB_WIDEN); - tem = expand_binop (compute_mode, sub_optab, tem, mask, + tem = expand_binop (int_mode, sub_optab, tem, mask, NULL_RTX, 0, OPTAB_WIDEN); expand_inc (quotient, tem); - tem = expand_binop (compute_mode, xor_optab, mask, op1, + tem = expand_binop (int_mode, xor_optab, mask, op1, NULL_RTX, 0, OPTAB_WIDEN); - tem = expand_binop (compute_mode, sub_optab, tem, mask, + tem = expand_binop (int_mode, sub_optab, tem, mask, NULL_RTX, 0, OPTAB_WIDEN); expand_dec (remainder, tem); emit_label (label); @@ -5453,25 +5451,29 @@ emit_store_flag_1 (rtx target, enum rtx_ && (normalizep || STORE_FLAG_VALUE == 1 || val_signbit_p (int_mode, STORE_FLAG_VALUE))) { + scalar_int_mode int_target_mode; subtarget = target; if (!target) - target_mode = int_mode; - - /* If the result is to be wider than OP0, it is best to convert it - first. If it is to be narrower, it is *incorrect* to convert it - first. */ - else if (GET_MODE_SIZE (target_mode) > GET_MODE_SIZE (int_mode)) + int_target_mode = int_mode; + else { - op0 = convert_modes (target_mode, int_mode, op0, 0); - mode = target_mode; + /* If the result is to be wider than OP0, it is best to convert it + first. If it is to be narrower, it is *incorrect* to convert it + first. */ + int_target_mode = as_a (target_mode); + if (GET_MODE_SIZE (int_target_mode) > GET_MODE_SIZE (int_mode)) + { + op0 = convert_modes (int_target_mode, int_mode, op0, 0); + int_mode = int_target_mode; + } } - if (target_mode != mode) + if (int_target_mode != int_mode) subtarget = 0; if (code == GE) - op0 = expand_unop (mode, one_cmpl_optab, op0, + op0 = expand_unop (int_mode, one_cmpl_optab, op0, ((STORE_FLAG_VALUE == 1 || normalizep) ? 0 : subtarget), 0); @@ -5479,12 +5481,12 @@ emit_store_flag_1 (rtx target, enum rtx_ /* If we are supposed to produce a 0/1 value, we want to do a logical shift from the sign bit to the low-order bit; for a -1/0 value, we do an arithmetic shift. */ - op0 = expand_shift (RSHIFT_EXPR, mode, op0, - GET_MODE_BITSIZE (mode) - 1, + op0 = expand_shift (RSHIFT_EXPR, int_mode, op0, + GET_MODE_BITSIZE (int_mode) - 1, subtarget, normalizep != -1); - if (mode != target_mode) - op0 = convert_modes (target_mode, mode, op0, 0); + if (int_mode != int_target_mode) + op0 = convert_modes (int_target_mode, int_mode, op0, 0); return op0; } Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:38.659812799 +0100 +++ gcc/expr.c 2017-07-13 09:18:39.589733813 +0100 @@ -5243,8 +5243,8 @@ expand_assignment (tree to, tree from, b { if (POINTER_TYPE_P (TREE_TYPE (to))) value = convert_memory_address_addr_space - (GET_MODE (to_rtx), value, - TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (to)))); + (as_a (GET_MODE (to_rtx)), value, + TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (to)))); emit_move_insn (to_rtx, value); } @@ -11138,7 +11138,8 @@ expand_expr_real_1 (tree exp, rtx target } /* Subroutine of above: reduce EXP to the precision of TYPE (in the - signedness of TYPE), possibly returning the result in TARGET. */ + signedness of TYPE), possibly returning the result in TARGET. + TYPE is known to be a partial integer type. */ static rtx reduce_to_bit_field_precision (rtx exp, rtx target, tree type) { @@ -11154,18 +11155,17 @@ reduce_to_bit_field_precision (rtx exp, } else if (TYPE_UNSIGNED (type)) { - machine_mode mode = GET_MODE (exp); + scalar_int_mode mode = as_a (GET_MODE (exp)); rtx mask = immed_wide_int_const (wi::mask (prec, false, GET_MODE_PRECISION (mode)), mode); return expand_and (mode, exp, mask, target); } else { - int count = GET_MODE_PRECISION (GET_MODE (exp)) - prec; - exp = expand_shift (LSHIFT_EXPR, GET_MODE (exp), - exp, count, target, 0); - return expand_shift (RSHIFT_EXPR, GET_MODE (exp), - exp, count, target, 0); + scalar_int_mode mode = as_a (GET_MODE (exp)); + int count = GET_MODE_PRECISION (mode) - prec; + exp = expand_shift (LSHIFT_EXPR, mode, exp, count, target, 0); + return expand_shift (RSHIFT_EXPR, mode, exp, count, target, 0); } } Index: gcc/function.c =================================================================== --- gcc/function.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/function.c 2017-07-13 09:18:39.589733813 +0100 @@ -5601,8 +5601,8 @@ expand_function_end (void) REG_FUNCTION_VALUE_P (outgoing) = 1; /* The address may be ptr_mode and OUTGOING may be Pmode. */ - value_address = convert_memory_address (GET_MODE (outgoing), - value_address); + scalar_int_mode mode = as_a (GET_MODE (outgoing)); + value_address = convert_memory_address (mode, value_address); emit_move_insn (outgoing, value_address); Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2017-07-13 09:18:38.662812543 +0100 +++ gcc/internal-fn.c 2017-07-13 09:18:39.590733729 +0100 @@ -560,7 +560,8 @@ expand_arith_set_overflow (tree lhs, rtx expand_arith_overflow_result_store (tree lhs, rtx target, machine_mode mode, rtx res) { - machine_mode tgtmode = GET_MODE_INNER (GET_MODE (target)); + scalar_int_mode tgtmode + = as_a (GET_MODE_INNER (GET_MODE (target))); rtx lres = res; if (tgtmode != mode) { Index: gcc/loop-doloop.c =================================================================== --- gcc/loop-doloop.c 2017-07-03 14:21:23.796501143 +0100 +++ gcc/loop-doloop.c 2017-07-13 09:18:39.590733729 +0100 @@ -445,7 +445,8 @@ doloop_modify (struct loop *loop, struct counter_reg = XEXP (condition, 0); if (GET_CODE (counter_reg) == PLUS) counter_reg = XEXP (counter_reg, 0); - mode = GET_MODE (counter_reg); + /* These patterns must operate on integer counters. */ + mode = as_a (GET_MODE (counter_reg)); increment_count = false; switch (GET_CODE (condition)) Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:36.842969240 +0100 +++ gcc/optabs.c 2017-07-13 09:18:39.591733644 +0100 @@ -1231,8 +1231,8 @@ expand_binop (machine_mode mode, optab b it back to the proper size to fit in the broadcast vector. */ machine_mode inner_mode = GET_MODE_INNER (mode); if (!CONST_INT_P (op1) - && (GET_MODE_BITSIZE (inner_mode) - < GET_MODE_BITSIZE (GET_MODE (op1)))) + && (GET_MODE_BITSIZE (as_a (GET_MODE (op1))) + > GET_MODE_BITSIZE (inner_mode))) op1 = force_reg (inner_mode, simplify_gen_unary (TRUNCATE, inner_mode, op1, GET_MODE (op1))); @@ -1377,11 +1377,13 @@ expand_binop (machine_mode mode, optab b && optab_handler (lshr_optab, word_mode) != CODE_FOR_nothing) { unsigned HOST_WIDE_INT shift_mask, double_shift_mask; - machine_mode op1_mode; + scalar_int_mode op1_mode; double_shift_mask = targetm.shift_truncation_mask (int_mode); shift_mask = targetm.shift_truncation_mask (word_mode); - op1_mode = GET_MODE (op1) != VOIDmode ? GET_MODE (op1) : word_mode; + op1_mode = (GET_MODE (op1) != VOIDmode + ? as_a (GET_MODE (op1)) + : word_mode); /* Apply the truncation to constant shifts. */ if (double_shift_mask > 0 && CONST_INT_P (op1)) @@ -3010,24 +3012,32 @@ expand_unop (machine_mode mode, optab un result. Similarly for clrsb. */ if ((unoptab == clz_optab || unoptab == clrsb_optab) && temp != 0) - temp = expand_binop - (wider_mode, sub_optab, temp, - gen_int_mode (GET_MODE_PRECISION (wider_mode) - - GET_MODE_PRECISION (mode), - wider_mode), - target, true, OPTAB_DIRECT); + { + scalar_int_mode wider_int_mode + = as_a (wider_mode); + int_mode = as_a (mode); + temp = expand_binop + (wider_mode, sub_optab, temp, + gen_int_mode (GET_MODE_PRECISION (wider_int_mode) + - GET_MODE_PRECISION (int_mode), + wider_int_mode), + target, true, OPTAB_DIRECT); + } /* Likewise for bswap. */ if (unoptab == bswap_optab && temp != 0) { - gcc_assert (GET_MODE_PRECISION (wider_mode) - == GET_MODE_BITSIZE (wider_mode) - && GET_MODE_PRECISION (mode) - == GET_MODE_BITSIZE (mode)); - - temp = expand_shift (RSHIFT_EXPR, wider_mode, temp, - GET_MODE_BITSIZE (wider_mode) - - GET_MODE_BITSIZE (mode), + scalar_int_mode wider_int_mode + = as_a (wider_mode); + int_mode = as_a (mode); + gcc_assert (GET_MODE_PRECISION (wider_int_mode) + == GET_MODE_BITSIZE (wider_int_mode) + && GET_MODE_PRECISION (int_mode) + == GET_MODE_BITSIZE (int_mode)); + + temp = expand_shift (RSHIFT_EXPR, wider_int_mode, temp, + GET_MODE_BITSIZE (wider_int_mode) + - GET_MODE_BITSIZE (int_mode), NULL_RTX, true); } @@ -3255,7 +3265,7 @@ expand_one_cmpl_abs_nojump (machine_mode expand_copysign_absneg (scalar_float_mode mode, rtx op0, rtx op1, rtx target, int bitpos, bool op0_is_abs) { - machine_mode imode; + scalar_int_mode imode; enum insn_code icode; rtx sign; rtx_code_label *label; @@ -3268,7 +3278,7 @@ expand_copysign_absneg (scalar_float_mod icode = optab_handler (signbit_optab, mode); if (icode != CODE_FOR_nothing) { - imode = insn_data[(int) icode].operand[0].mode; + imode = as_a (insn_data[(int) icode].operand[0].mode); sign = gen_reg_rtx (imode); emit_unop_insn (icode, sign, op1, UNKNOWN); } @@ -3800,10 +3810,10 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx continue; /* Must make sure the size fits the insn's mode. */ - if ((CONST_INT_P (size) - && INTVAL (size) >= (1 << GET_MODE_BITSIZE (cmp_mode))) - || (GET_MODE_BITSIZE (GET_MODE (size)) - > GET_MODE_BITSIZE (cmp_mode))) + if (CONST_INT_P (size) + ? INTVAL (size) >= (1 << GET_MODE_BITSIZE (cmp_mode)) + : (GET_MODE_BITSIZE (as_a (GET_MODE (size))) + > GET_MODE_BITSIZE (cmp_mode))) continue; result_mode = insn_data[cmp_code].operand[0].mode; @@ -6976,8 +6986,8 @@ maybe_legitimize_operand (enum insn_code goto input; case EXPAND_ADDRESS: - gcc_assert (mode != VOIDmode); - op->value = convert_memory_address (mode, op->value); + op->value = convert_memory_address (as_a (mode), + op->value); goto input; case EXPAND_INTEGER: Index: gcc/recog.c =================================================================== --- gcc/recog.c 2017-07-13 09:18:35.050126461 +0100 +++ gcc/recog.c 2017-07-13 09:18:39.591733644 +0100 @@ -1189,8 +1189,9 @@ const_scalar_int_operand (rtx op, machin if (mode != VOIDmode) { - int prec = GET_MODE_PRECISION (mode); - int bitsize = GET_MODE_BITSIZE (mode); + scalar_int_mode int_mode = as_a (mode); + int prec = GET_MODE_PRECISION (int_mode); + int bitsize = GET_MODE_BITSIZE (int_mode); if (CONST_WIDE_INT_NUNITS (op) * HOST_BITS_PER_WIDE_INT > bitsize) return 0; Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:33.655250907 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:39.592733560 +0100 @@ -5799,7 +5799,7 @@ get_address_mode (rtx mem) gcc_assert (MEM_P (mem)); mode = GET_MODE (XEXP (mem, 0)); if (mode != VOIDmode) - return mode; + return as_a (mode); return targetm.addr_space.address_mode (MEM_ADDR_SPACE (mem)); } Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:35.969045492 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:39.593733475 +0100 @@ -917,7 +917,7 @@ simplify_unary_operation_1 (enum rtx_cod { enum rtx_code reversed; rtx temp; - scalar_int_mode inner, int_mode, op0_mode; + scalar_int_mode inner, int_mode, op_mode, op0_mode; switch (code) { @@ -1153,26 +1153,27 @@ simplify_unary_operation_1 (enum rtx_cod && XEXP (op, 1) == const0_rtx && is_a (GET_MODE (XEXP (op, 0)), &inner)) { + int_mode = as_a (mode); int isize = GET_MODE_PRECISION (inner); if (STORE_FLAG_VALUE == 1) { temp = simplify_gen_binary (ASHIFTRT, inner, XEXP (op, 0), GEN_INT (isize - 1)); - if (mode == inner) + if (int_mode == inner) return temp; - if (GET_MODE_PRECISION (mode) > isize) - return simplify_gen_unary (SIGN_EXTEND, mode, temp, inner); - return simplify_gen_unary (TRUNCATE, mode, temp, inner); + if (GET_MODE_PRECISION (int_mode) > isize) + return simplify_gen_unary (SIGN_EXTEND, int_mode, temp, inner); + return simplify_gen_unary (TRUNCATE, int_mode, temp, inner); } else if (STORE_FLAG_VALUE == -1) { temp = simplify_gen_binary (LSHIFTRT, inner, XEXP (op, 0), GEN_INT (isize - 1)); - if (mode == inner) + if (int_mode == inner) return temp; - if (GET_MODE_PRECISION (mode) > isize) - return simplify_gen_unary (ZERO_EXTEND, mode, temp, inner); - return simplify_gen_unary (TRUNCATE, mode, temp, inner); + if (GET_MODE_PRECISION (int_mode) > isize) + return simplify_gen_unary (ZERO_EXTEND, int_mode, temp, inner); + return simplify_gen_unary (TRUNCATE, int_mode, temp, inner); } } break; @@ -1492,12 +1493,13 @@ simplify_unary_operation_1 (enum rtx_cod && is_a (mode, &int_mode) && CONST_INT_P (XEXP (op, 1)) && XEXP (XEXP (op, 0), 1) == XEXP (op, 1) - && GET_MODE_BITSIZE (GET_MODE (op)) > INTVAL (XEXP (op, 1))) + && (op_mode = as_a (GET_MODE (op)), + GET_MODE_BITSIZE (op_mode) > INTVAL (XEXP (op, 1)))) { scalar_int_mode tmode; gcc_assert (GET_MODE_BITSIZE (int_mode) - > GET_MODE_BITSIZE (GET_MODE (op))); - if (int_mode_for_size (GET_MODE_BITSIZE (GET_MODE (op)) + > GET_MODE_BITSIZE (op_mode)); + if (int_mode_for_size (GET_MODE_BITSIZE (op_mode) - INTVAL (XEXP (op, 1)), 1).exists (&tmode)) { rtx inner = @@ -1609,10 +1611,11 @@ simplify_unary_operation_1 (enum rtx_cod && is_a (mode, &int_mode) && CONST_INT_P (XEXP (op, 1)) && XEXP (XEXP (op, 0), 1) == XEXP (op, 1) - && GET_MODE_PRECISION (GET_MODE (op)) > INTVAL (XEXP (op, 1))) + && (op_mode = as_a (GET_MODE (op)), + GET_MODE_PRECISION (op_mode) > INTVAL (XEXP (op, 1)))) { scalar_int_mode tmode; - if (int_mode_for_size (GET_MODE_PRECISION (GET_MODE (op)) + if (int_mode_for_size (GET_MODE_PRECISION (op_mode) - INTVAL (XEXP (op, 1)), 1).exists (&tmode)) { rtx inner = @@ -5386,10 +5389,10 @@ simplify_cond_clz_ctz (rtx x, rtx_code c return NULL_RTX; HOST_WIDE_INT op_val; - if (((op_code == CLZ - && CLZ_DEFINED_VALUE_AT_ZERO (GET_MODE (on_nonzero), op_val)) - || (op_code == CTZ - && CTZ_DEFINED_VALUE_AT_ZERO (GET_MODE (on_nonzero), op_val))) + scalar_int_mode mode ATTRIBUTE_UNUSED + = as_a (GET_MODE (XEXP (on_nonzero, 0))); + if (((op_code == CLZ && CLZ_DEFINED_VALUE_AT_ZERO (mode, op_val)) + || (op_code == CTZ && CTZ_DEFINED_VALUE_AT_ZERO (mode, op_val))) && op_val == INTVAL (on_zero)) return on_nonzero; Index: gcc/tree-nested.c =================================================================== --- gcc/tree-nested.c 2017-05-18 07:51:12.360753371 +0100 +++ gcc/tree-nested.c 2017-07-13 09:18:39.594733390 +0100 @@ -625,7 +625,9 @@ get_nl_goto_field (struct nesting_info * else type = lang_hooks.types.type_for_mode (Pmode, 1); - size = GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)); + scalar_int_mode mode + = as_a (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)); + size = GET_MODE_SIZE (mode); size = size / GET_MODE_SIZE (Pmode); size = size + 1; Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-07-13 09:18:38.667812116 +0100 +++ gcc/tree.c 2017-07-13 09:18:39.596733221 +0100 @@ -10986,6 +10986,7 @@ reconstruct_complex_type (tree type, tre build_vector_type_for_mode (tree innertype, machine_mode mode) { int nunits; + unsigned int bitsize; switch (GET_MODE_CLASS (mode)) { @@ -11000,11 +11001,9 @@ build_vector_type_for_mode (tree innerty case MODE_INT: /* Check that there are no leftover bits. */ - gcc_assert (GET_MODE_BITSIZE (mode) - % TREE_INT_CST_LOW (TYPE_SIZE (innertype)) == 0); - - nunits = GET_MODE_BITSIZE (mode) - / TREE_INT_CST_LOW (TYPE_SIZE (innertype)); + bitsize = GET_MODE_BITSIZE (as_a (mode)); + gcc_assert (bitsize % TREE_INT_CST_LOW (TYPE_SIZE (innertype)) == 0); + nunits = bitsize / TREE_INT_CST_LOW (TYPE_SIZE (innertype)); break; default: Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c 2017-07-13 09:18:32.530352523 +0100 +++ gcc/var-tracking.c 2017-07-13 09:18:39.597733136 +0100 @@ -991,7 +991,8 @@ use_narrower_mode (rtx x, machine_mode m /* Ensure shift amount is not wider than mode. */ if (GET_MODE (op1) == VOIDmode) op1 = lowpart_subreg (mode, op1, wmode); - else if (GET_MODE_PRECISION (mode) < GET_MODE_PRECISION (GET_MODE (op1))) + else if (GET_MODE_PRECISION (mode) + < GET_MODE_PRECISION (as_a (GET_MODE (op1)))) op1 = lowpart_subreg (mode, op1, GET_MODE (op1)); return simplify_gen_binary (ASHIFT, mode, op0, op1); default: Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2017-07-13 09:18:21.523430126 +0100 +++ gcc/c-family/c-common.c 2017-07-13 09:18:39.582734406 +0100 @@ -2242,15 +2242,15 @@ c_common_type_for_mode (machine_mode mod if (mode == TYPE_MODE (void_type_node)) return void_type_node; - if (mode == TYPE_MODE (build_pointer_type (char_type_node))) - return (unsignedp - ? make_unsigned_type (GET_MODE_PRECISION (mode)) - : make_signed_type (GET_MODE_PRECISION (mode))); - - if (mode == TYPE_MODE (build_pointer_type (integer_type_node))) - return (unsignedp - ? make_unsigned_type (GET_MODE_PRECISION (mode)) - : make_signed_type (GET_MODE_PRECISION (mode))); + if (mode == TYPE_MODE (build_pointer_type (char_type_node)) + || mode == TYPE_MODE (build_pointer_type (integer_type_node))) + { + unsigned int precision + = GET_MODE_PRECISION (as_a (mode)); + return (unsignedp + ? make_unsigned_type (precision) + : make_signed_type (precision)); + } if (COMPLEX_MODE_P (mode)) { Index: gcc/lto/lto-lang.c =================================================================== --- gcc/lto/lto-lang.c 2017-06-30 12:50:38.437653735 +0100 +++ gcc/lto/lto-lang.c 2017-07-13 09:18:39.590733729 +0100 @@ -927,15 +927,15 @@ lto_type_for_mode (machine_mode mode, in if (mode == TYPE_MODE (void_type_node)) return void_type_node; - if (mode == TYPE_MODE (build_pointer_type (char_type_node))) - return (unsigned_p - ? make_unsigned_type (GET_MODE_PRECISION (mode)) - : make_signed_type (GET_MODE_PRECISION (mode))); - - if (mode == TYPE_MODE (build_pointer_type (integer_type_node))) - return (unsigned_p - ? make_unsigned_type (GET_MODE_PRECISION (mode)) - : make_signed_type (GET_MODE_PRECISION (mode))); + if (mode == TYPE_MODE (build_pointer_type (char_type_node)) + || mode == TYPE_MODE (build_pointer_type (integer_type_node))) + { + unsigned int precision + = GET_MODE_PRECISION (as_a (mode)); + return (unsigned_p + ? make_unsigned_type (precision) + : make_signed_type (precision)); + } if (COMPLEX_MODE_P (mode)) { From patchwork Thu Jul 13 08:51:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107622 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1934453qge; Thu, 13 Jul 2017 01:52:46 -0700 (PDT) X-Received: by 10.98.15.220 with SMTP id 89mr60839740pfp.203.1499935965937; Thu, 13 Jul 2017 01:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935965; cv=none; d=google.com; s=arc-20160816; b=ndF/JFYAImDRF7qNO15Typf2siZ0miBfhWxfwQvbtOE/ATD4EoRjsCdzRqSRapIVs8 V+pieYlv/4FeI1OqqHtl57P+b4lbSAe/cLdhSLoWdxjmjSc79TPW4dQ6XmsKdVHJ1twk ZooBkrt01t/uAHaGRxruLgMQlGV0mak2Kgtc/TlqW3xwB/BVlttTIcZSByel0SfpSCSP PIAOYXI+wpZmqaUUzma9SZWCMlwINuTS68ZEb6YOwdwC6TkhyGbQlOcP0XV8Rd0cGTDJ 83z6nFQ98jO3MWlczI+0pu/Kl/FAjoxamdRJz9PsGbJOXR2EmP6GtyOGqMH7MDm5GUvV 0v1w== 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=cUC2q/pdGBOL8EBn4u2ccjyIaAXdcgC3yp2UcwuajAE=; b=tDV3DsEaGkZpG4DiCHvgjOxVJ7KU3xtJt4RhnE83NpsCWfCdhpCAH6e0773IATaj8t 4mn2lif5h8tmcdtZMOWUEsm0/dwZ6d2DviQsnZjbI2fsrGGZFelpWujdm0Be+OuZ5riG ywsUyFWs1cgnGmJG/kJAC1WmImMpHBx/QYDtpZcArDg2X4kYItPAxaa9UGWjuLkKc32I Wq7pFq20N36vY42dt31Cs4k0DOQUd/0isoynn+PSjfFwVjtZ2cp+ng+GpSyMaLXLgNtm cmkmT1y1d/IYXKo8pMnHrZQy0TxUeZj3xcA3NO1GSfTgZ6xrQt83ZFZlbDngyw5UehdT iJlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=iu11lZ4t; spf=pass (google.com: domain of gcc-patches-return-458027-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458027-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 v66si3816956pfv.303.2017.07.13.01.52.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458027-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=iu11lZ4t; spf=pass (google.com: domain of gcc-patches-return-458027-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458027-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=x1MGWz2SckEODSdegW0dZvlrzsoKQ fsTu2jw7hjT83O2KbhFqkj/kYKnJcxK+UrGX1JiipIfwIyoFGI0NkRghXcKHb3W3 iCTj7mr4Ifj4NxpUYqOccdsUfG4aya8wzhoVZ4rsyeDCRy4tWq/wnVLCjmvU35LF s2+fKdBsCJ87Ps= 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=yxBT4kmINXf7sZEKM5EGKkSveM8=; b=iu1 1lZ4toAGkBG8pgv4gEps1OEdcCjt1TfmB7LeCIn4XidXg2TiDcLc+0dquUULMYy7 aa4SC7A9HfpEfIrHjbZqnnihAZkTjWB5Mk9L1xSWyfd77j0pKeW5eHRoQDGpFKxb gCtlb+6IopDNoVpGkr7paC5Moi+wc2nkME2d1cqo= Received: (qmail 18006 invoked by alias); 13 Jul 2017 08:51:41 -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 17509 invoked by uid 89); 13 Jul 2017 08:51:40 -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=biv X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:51:31 +0000 Received: by mail-wm0-f52.google.com with SMTP id 62so16667353wmw.1 for ; Thu, 13 Jul 2017 01:51:31 -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=cUC2q/pdGBOL8EBn4u2ccjyIaAXdcgC3yp2UcwuajAE=; b=QpPZY04ReXkKcNOMz48Fwe0WjwJbt9GylIhS2OVAaNvvAKLu819OaW2vZGqk/I/jKz YMHMzb7hWAy7WBYg4v3IuxgMoQAb6/LLQ7/bpqU0a84TxFGsUTMlbCDpCAClr+CRFiRl l7VEFGkkcXmdwbj6doWDrSNSp4BLVoEQ3cuwSPNOSEdMVMrRgBDU+4S9rOYAjyYFoU4y q7L9tknvfHXcLCZXj79C8Ii2LEc9mjJwi2uiCMKil7ltsgMVd17ONDh4eUDmBnSZN69v XGftKXWEbTNDDs3/1HexSbgrrGDUKmEIkFxa9L4pG7zEfmk9HJmlSnkpx/tORO+93ly6 mspA== X-Gm-Message-State: AIVw1134kqdlm0T5Th5SloxhuryMMTeN7T9T9zwAYh1JnC5rbxwGqfSP mf3m/nHw4ENFtaXRAchq+w== X-Received: by 10.28.146.208 with SMTP id u199mr1147699wmd.6.1499935889093; Thu, 13 Jul 2017 01:51:29 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id y5sm3932953wrd.52.2017.07.13.01.51.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:51:28 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [36/77] Use scalar_int_mode in the RTL iv routines References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:51:27 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87tw2ghg8g.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch changes the iv modes in rtx_iv from machine_mode to scalar_int_mode. It also passes the mode of the iv down to subroutines; this avoids the previous situation in which the mode information was sometimes lost and had to be added by the caller on return. Some routines already took a mode argument, but the patch tries to standardise on passing it immediately before the argument it describes. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * cfgloop.h (rtx_iv): Change type of extend_mode and mode to scalar_int_mode. (niter_desc): Likewise mode. (iv_analyze): Add a mode parameter. (biv_p): Likewise. (iv_analyze_expr): Pass the mode paraeter before the rtx it describes and change its type to scalar_int_mode. * loop-iv.c: Update commentary at head of file. (iv_constant): Pass the mode paraeter before the rtx it describes and change its type to scalar_int_mode. Remove VOIDmode handling. (iv_subreg): Change the type of the mode parameter to scalar_int_mode. (iv_extend): Likewise. (shorten_into_mode): Likewise. (iv_add): Use scalar_int_mode. (iv_mult): Likewise. (iv_shift): Likewise. (canonicalize_iv_subregs): Likewise. (get_biv_step_1): Pass the outer_mode parameter before the rtx it describes and change its mode to scalar_int_mode. Also change the type of the returned inner_mode to scalar_int_mode. (get_biv_step): Likewise, turning outer_mode from a pointer into a direct parameter. Update call to get_biv_step_1. (iv_analyze_biv): Add an outer_mode parameter. Update calls to iv_constant and get_biv_step. (iv_analyze_expr): Pass the mode parameter before the rtx it describes and change its type to scalar_int_mode. Don't initialise iv->mode to VOIDmode and remove later checks for its still being VOIDmode. Update calls to iv_analyze_op and iv_analyze_expr. Check is_a when changing the mode under consideration. (iv_analyze_def): Ignore registers that don't have a scalar_int_mode. Update call to iv_analyze_expr. (iv_analyze_op): Add a mode parameter. Reject subregs whose inner register is not also a scalar_int_mode. Update call to iv_analyze_biv. (iv_analyze): Add a mode parameter. Update call to iv_analyze_op. (biv_p): Add a mode parameter. Update call to iv_analyze_biv. (iv_number_of_iterations): Use is_a instead of separate mode class checks. Update calls to iv_analyze. Remove fix-up of VOIDmodes after iv_analyze_biv. * loop-unroll.c (analyze_iv_to_split_insn): Reject registers that don't have a scalar_int_mode. Update call to biv_p. Index: gcc/cfgloop.h =================================================================== --- gcc/cfgloop.h 2017-07-05 16:25:08.605609122 +0100 +++ gcc/cfgloop.h 2017-07-13 09:18:40.317672476 +0100 @@ -421,10 +421,10 @@ struct rtx_iv rtx delta, mult; /* The mode it is extended to. */ - machine_mode extend_mode; + scalar_int_mode extend_mode; /* The mode the variable iterates in. */ - machine_mode mode; + scalar_int_mode mode; /* Whether the first iteration needs to be handled specially. */ unsigned first_special : 1; @@ -465,19 +465,19 @@ struct GTY(()) niter_desc bool signed_p; /* The mode in that niter_expr should be computed. */ - machine_mode mode; + scalar_int_mode mode; /* The number of iterations of the loop. */ rtx niter_expr; }; extern void iv_analysis_loop_init (struct loop *); -extern bool iv_analyze (rtx_insn *, rtx, struct rtx_iv *); +extern bool iv_analyze (rtx_insn *, scalar_int_mode, rtx, struct rtx_iv *); extern bool iv_analyze_result (rtx_insn *, rtx, struct rtx_iv *); -extern bool iv_analyze_expr (rtx_insn *, rtx, machine_mode, +extern bool iv_analyze_expr (rtx_insn *, scalar_int_mode, rtx, struct rtx_iv *); extern rtx get_iv_value (struct rtx_iv *, rtx); -extern bool biv_p (rtx_insn *, rtx); +extern bool biv_p (rtx_insn *, scalar_int_mode, rtx); extern void find_simple_exit (struct loop *, struct niter_desc *); extern void iv_analysis_done (void); Index: gcc/loop-iv.c =================================================================== --- gcc/loop-iv.c 2017-07-13 09:18:35.049126549 +0100 +++ gcc/loop-iv.c 2017-07-13 09:18:40.317672476 +0100 @@ -35,16 +35,17 @@ Free Software Foundation; either version The available functions are: - iv_analyze (insn, reg, iv): Stores the description of the induction variable - corresponding to the use of register REG in INSN to IV. Returns true if - REG is an induction variable in INSN. false otherwise. - If use of REG is not found in INSN, following insns are scanned (so that - we may call this function on insn returned by get_condition). + iv_analyze (insn, mode, reg, iv): Stores the description of the induction + variable corresponding to the use of register REG in INSN to IV, given + that REG has mode MODE. Returns true if REG is an induction variable + in INSN. false otherwise. If a use of REG is not found in INSN, + the following insns are scanned (so that we may call this function + on insns returned by get_condition). iv_analyze_result (insn, def, iv): Stores to IV the description of the iv corresponding to DEF, which is a register defined in INSN. - iv_analyze_expr (insn, rhs, mode, iv): Stores to IV the description of iv + iv_analyze_expr (insn, mode, expr, iv): Stores to IV the description of iv corresponding to expression EXPR evaluated at INSN. All registers used bu - EXPR must also be used in INSN. + EXPR must also be used in INSN. MODE is the mode of EXPR. */ #include "config.h" @@ -133,7 +134,7 @@ biv_entry_hasher::equal (const biv_entry static hash_table *bivs; -static bool iv_analyze_op (rtx_insn *, rtx, struct rtx_iv *); +static bool iv_analyze_op (rtx_insn *, scalar_int_mode, rtx, struct rtx_iv *); /* Return the RTX code corresponding to the IV extend code EXTEND. */ static inline enum rtx_code @@ -383,11 +384,8 @@ iv_get_reaching_def (rtx_insn *insn, rtx consistency with other iv manipulation functions that may fail). */ static bool -iv_constant (struct rtx_iv *iv, rtx cst, machine_mode mode) +iv_constant (struct rtx_iv *iv, scalar_int_mode mode, rtx cst) { - if (mode == VOIDmode) - mode = GET_MODE (cst); - iv->mode = mode; iv->base = cst; iv->step = const0_rtx; @@ -403,7 +401,7 @@ iv_constant (struct rtx_iv *iv, rtx cst, /* Evaluates application of subreg to MODE on IV. */ static bool -iv_subreg (struct rtx_iv *iv, machine_mode mode) +iv_subreg (struct rtx_iv *iv, scalar_int_mode mode) { /* If iv is invariant, just calculate the new value. */ if (iv->step == const0_rtx @@ -445,7 +443,7 @@ iv_subreg (struct rtx_iv *iv, machine_mo /* Evaluates application of EXTEND to MODE on IV. */ static bool -iv_extend (struct rtx_iv *iv, enum iv_extend_code extend, machine_mode mode) +iv_extend (struct rtx_iv *iv, enum iv_extend_code extend, scalar_int_mode mode) { /* If iv is invariant, just calculate the new value. */ if (iv->step == const0_rtx @@ -508,7 +506,7 @@ iv_neg (struct rtx_iv *iv) static bool iv_add (struct rtx_iv *iv0, struct rtx_iv *iv1, enum rtx_code op) { - machine_mode mode; + scalar_int_mode mode; rtx arg; /* Extend the constant to extend_mode of the other operand if necessary. */ @@ -578,7 +576,7 @@ iv_add (struct rtx_iv *iv0, struct rtx_i static bool iv_mult (struct rtx_iv *iv, rtx mby) { - machine_mode mode = iv->extend_mode; + scalar_int_mode mode = iv->extend_mode; if (GET_MODE (mby) != VOIDmode && GET_MODE (mby) != mode) @@ -603,7 +601,7 @@ iv_mult (struct rtx_iv *iv, rtx mby) static bool iv_shift (struct rtx_iv *iv, rtx mby) { - machine_mode mode = iv->extend_mode; + scalar_int_mode mode = iv->extend_mode; if (GET_MODE (mby) != VOIDmode && GET_MODE (mby) != mode) @@ -628,9 +626,9 @@ iv_shift (struct rtx_iv *iv, rtx mby) at get_biv_step. */ static bool -get_biv_step_1 (df_ref def, rtx reg, - rtx *inner_step, machine_mode *inner_mode, - enum iv_extend_code *extend, machine_mode outer_mode, +get_biv_step_1 (df_ref def, scalar_int_mode outer_mode, rtx reg, + rtx *inner_step, scalar_int_mode *inner_mode, + enum iv_extend_code *extend, rtx *outer_step) { rtx set, rhs, op0 = NULL_RTX, op1 = NULL_RTX; @@ -732,8 +730,8 @@ get_biv_step_1 (df_ref def, rtx reg, *inner_mode = outer_mode; *outer_step = const0_rtx; } - else if (!get_biv_step_1 (next_def, reg, - inner_step, inner_mode, extend, outer_mode, + else if (!get_biv_step_1 (next_def, outer_mode, reg, + inner_step, inner_mode, extend, outer_step)) return false; @@ -793,19 +791,17 @@ get_biv_step_1 (df_ref def, rtx reg, LAST_DEF is the definition of REG that dominates loop latch. */ static bool -get_biv_step (df_ref last_def, rtx reg, rtx *inner_step, - machine_mode *inner_mode, enum iv_extend_code *extend, - machine_mode *outer_mode, rtx *outer_step) +get_biv_step (df_ref last_def, scalar_int_mode outer_mode, rtx reg, + rtx *inner_step, scalar_int_mode *inner_mode, + enum iv_extend_code *extend, rtx *outer_step) { - *outer_mode = GET_MODE (reg); - - if (!get_biv_step_1 (last_def, reg, - inner_step, inner_mode, extend, *outer_mode, + if (!get_biv_step_1 (last_def, outer_mode, reg, + inner_step, inner_mode, extend, outer_step)) return false; - gcc_assert ((*inner_mode == *outer_mode) != (*extend != IV_UNKNOWN_EXTEND)); - gcc_assert (*inner_mode != *outer_mode || *outer_step == const0_rtx); + gcc_assert ((*inner_mode == outer_mode) != (*extend != IV_UNKNOWN_EXTEND)); + gcc_assert (*inner_mode != outer_mode || *outer_step == const0_rtx); return true; } @@ -850,13 +846,13 @@ record_biv (rtx def, struct rtx_iv *iv) } /* Determines whether DEF is a biv and if so, stores its description - to *IV. */ + to *IV. OUTER_MODE is the mode of DEF. */ static bool -iv_analyze_biv (rtx def, struct rtx_iv *iv) +iv_analyze_biv (scalar_int_mode outer_mode, rtx def, struct rtx_iv *iv) { rtx inner_step, outer_step; - machine_mode inner_mode, outer_mode; + scalar_int_mode inner_mode; enum iv_extend_code extend; df_ref last_def; @@ -872,7 +868,7 @@ iv_analyze_biv (rtx def, struct rtx_iv * if (!CONSTANT_P (def)) return false; - return iv_constant (iv, def, VOIDmode); + return iv_constant (iv, outer_mode, def); } if (!latch_dominating_def (def, &last_def)) @@ -883,7 +879,7 @@ iv_analyze_biv (rtx def, struct rtx_iv * } if (!last_def) - return iv_constant (iv, def, VOIDmode); + return iv_constant (iv, outer_mode, def); if (analyzed_for_bivness_p (def, iv)) { @@ -892,8 +888,8 @@ iv_analyze_biv (rtx def, struct rtx_iv * return iv->base != NULL_RTX; } - if (!get_biv_step (last_def, def, &inner_step, &inner_mode, &extend, - &outer_mode, &outer_step)) + if (!get_biv_step (last_def, outer_mode, def, &inner_step, &inner_mode, + &extend, &outer_step)) { iv->base = NULL_RTX; goto end; @@ -930,16 +926,15 @@ iv_analyze_biv (rtx def, struct rtx_iv * The mode of the induction variable is MODE. */ bool -iv_analyze_expr (rtx_insn *insn, rtx rhs, machine_mode mode, +iv_analyze_expr (rtx_insn *insn, scalar_int_mode mode, rtx rhs, struct rtx_iv *iv) { rtx mby = NULL_RTX; rtx op0 = NULL_RTX, op1 = NULL_RTX; struct rtx_iv iv0, iv1; enum rtx_code code = GET_CODE (rhs); - machine_mode omode = mode; + scalar_int_mode omode = mode; - iv->mode = VOIDmode; iv->base = NULL_RTX; iv->step = NULL_RTX; @@ -948,18 +943,7 @@ iv_analyze_expr (rtx_insn *insn, rtx rhs if (CONSTANT_P (rhs) || REG_P (rhs) || code == SUBREG) - { - if (!iv_analyze_op (insn, rhs, iv)) - return false; - - if (iv->mode == VOIDmode) - { - iv->mode = mode; - iv->extend_mode = mode; - } - - return true; - } + return iv_analyze_op (insn, mode, rhs, iv); switch (code) { @@ -971,7 +955,9 @@ iv_analyze_expr (rtx_insn *insn, rtx rhs case ZERO_EXTEND: case NEG: op0 = XEXP (rhs, 0); - omode = GET_MODE (op0); + /* We don't know how many bits there are in a sign-extended constant. */ + if (!is_a (GET_MODE (op0), &omode)) + return false; break; case PLUS: @@ -1001,11 +987,11 @@ iv_analyze_expr (rtx_insn *insn, rtx rhs } if (op0 - && !iv_analyze_expr (insn, op0, omode, &iv0)) + && !iv_analyze_expr (insn, omode, op0, &iv0)) return false; if (op1 - && !iv_analyze_expr (insn, op1, omode, &iv1)) + && !iv_analyze_expr (insn, omode, op1, &iv1)) return false; switch (code) @@ -1075,11 +1061,11 @@ iv_analyze_def (df_ref def, struct rtx_i return iv->base != NULL_RTX; } - iv->mode = VOIDmode; iv->base = NULL_RTX; iv->step = NULL_RTX; - if (!REG_P (reg)) + scalar_int_mode mode; + if (!REG_P (reg) || !is_a (GET_MODE (reg), &mode)) return false; set = single_set (insn); @@ -1096,7 +1082,7 @@ iv_analyze_def (df_ref def, struct rtx_i else rhs = SET_SRC (set); - iv_analyze_expr (insn, rhs, GET_MODE (reg), iv); + iv_analyze_expr (insn, mode, rhs, iv); record_iv (def, iv); if (dump_file) @@ -1112,10 +1098,11 @@ iv_analyze_def (df_ref def, struct rtx_i return iv->base != NULL_RTX; } -/* Analyzes operand OP of INSN and stores the result to *IV. */ +/* Analyzes operand OP of INSN and stores the result to *IV. MODE is the + mode of OP. */ static bool -iv_analyze_op (rtx_insn *insn, rtx op, struct rtx_iv *iv) +iv_analyze_op (rtx_insn *insn, scalar_int_mode mode, rtx op, struct rtx_iv *iv) { df_ref def = NULL; enum iv_grd_result res; @@ -1132,13 +1119,15 @@ iv_analyze_op (rtx_insn *insn, rtx op, s res = GRD_INVARIANT; else if (GET_CODE (op) == SUBREG) { - if (!subreg_lowpart_p (op)) + scalar_int_mode inner_mode; + if (!subreg_lowpart_p (op) + || !is_a (GET_MODE (SUBREG_REG (op)), &inner_mode)) return false; - if (!iv_analyze_op (insn, SUBREG_REG (op), iv)) + if (!iv_analyze_op (insn, inner_mode, SUBREG_REG (op), iv)) return false; - return iv_subreg (iv, GET_MODE (op)); + return iv_subreg (iv, mode); } else { @@ -1153,7 +1142,7 @@ iv_analyze_op (rtx_insn *insn, rtx op, s if (res == GRD_INVARIANT) { - iv_constant (iv, op, VOIDmode); + iv_constant (iv, mode, op); if (dump_file) { @@ -1165,15 +1154,16 @@ iv_analyze_op (rtx_insn *insn, rtx op, s } if (res == GRD_MAYBE_BIV) - return iv_analyze_biv (op, iv); + return iv_analyze_biv (mode, op, iv); return iv_analyze_def (def, iv); } -/* Analyzes value VAL at INSN and stores the result to *IV. */ +/* Analyzes value VAL at INSN and stores the result to *IV. MODE is the + mode of VAL. */ bool -iv_analyze (rtx_insn *insn, rtx val, struct rtx_iv *iv) +iv_analyze (rtx_insn *insn, scalar_int_mode mode, rtx val, struct rtx_iv *iv) { rtx reg; @@ -1192,7 +1182,7 @@ iv_analyze (rtx_insn *insn, rtx val, str insn = NEXT_INSN (insn); } - return iv_analyze_op (insn, val, iv); + return iv_analyze_op (insn, mode, val, iv); } /* Analyzes definition of DEF in INSN and stores the result to IV. */ @@ -1210,11 +1200,13 @@ iv_analyze_result (rtx_insn *insn, rtx d } /* Checks whether definition of register REG in INSN is a basic induction - variable. IV analysis must have been initialized (via a call to + variable. MODE is the mode of REG. + + IV analysis must have been initialized (via a call to iv_analysis_loop_init) for this function to produce a result. */ bool -biv_p (rtx_insn *insn, rtx reg) +biv_p (rtx_insn *insn, scalar_int_mode mode, rtx reg) { struct rtx_iv iv; df_ref def, last_def; @@ -1229,7 +1221,7 @@ biv_p (rtx_insn *insn, rtx reg) if (last_def != def) return false; - if (!iv_analyze_biv (reg, &iv)) + if (!iv_analyze_biv (mode, reg, &iv)) return false; return iv.step != const0_rtx; @@ -2078,7 +2070,7 @@ simplify_using_initial_values (struct lo is SIGNED_P to DESC. */ static void -shorten_into_mode (struct rtx_iv *iv, machine_mode mode, +shorten_into_mode (struct rtx_iv *iv, scalar_int_mode mode, enum rtx_code cond, bool signed_p, struct niter_desc *desc) { rtx mmin, mmax, cond_over, cond_under; @@ -2140,7 +2132,7 @@ shorten_into_mode (struct rtx_iv *iv, ma canonicalize_iv_subregs (struct rtx_iv *iv0, struct rtx_iv *iv1, enum rtx_code cond, struct niter_desc *desc) { - machine_mode comp_mode; + scalar_int_mode comp_mode; bool signed_p; /* If the ivs behave specially in the first iteration, or are @@ -2318,7 +2310,8 @@ iv_number_of_iterations (struct loop *lo struct rtx_iv iv0, iv1; rtx assumption, may_not_xform; enum rtx_code cond; - machine_mode mode, comp_mode; + machine_mode nonvoid_mode; + scalar_int_mode comp_mode; rtx mmin, mmax, mode_mmin, mode_mmax; uint64_t s, size, d, inv, max, up, down; int64_t inc, step_val; @@ -2343,28 +2336,24 @@ iv_number_of_iterations (struct loop *lo cond = GET_CODE (condition); gcc_assert (COMPARISON_P (condition)); - mode = GET_MODE (XEXP (condition, 0)); - if (mode == VOIDmode) - mode = GET_MODE (XEXP (condition, 1)); + nonvoid_mode = GET_MODE (XEXP (condition, 0)); + if (nonvoid_mode == VOIDmode) + nonvoid_mode = GET_MODE (XEXP (condition, 1)); /* The constant comparisons should be folded. */ - gcc_assert (mode != VOIDmode); + gcc_assert (nonvoid_mode != VOIDmode); /* We only handle integers or pointers. */ - if (GET_MODE_CLASS (mode) != MODE_INT - && GET_MODE_CLASS (mode) != MODE_PARTIAL_INT) + scalar_int_mode mode; + if (!is_a (nonvoid_mode, &mode)) goto fail; op0 = XEXP (condition, 0); - if (!iv_analyze (insn, op0, &iv0)) + if (!iv_analyze (insn, mode, op0, &iv0)) goto fail; - if (iv0.extend_mode == VOIDmode) - iv0.mode = iv0.extend_mode = mode; op1 = XEXP (condition, 1); - if (!iv_analyze (insn, op1, &iv1)) + if (!iv_analyze (insn, mode, op1, &iv1)) goto fail; - if (iv1.extend_mode == VOIDmode) - iv1.mode = iv1.extend_mode = mode; if (GET_MODE_BITSIZE (iv0.extend_mode) > HOST_BITS_PER_WIDE_INT || GET_MODE_BITSIZE (iv1.extend_mode) > HOST_BITS_PER_WIDE_INT) Index: gcc/loop-unroll.c =================================================================== --- gcc/loop-unroll.c 2017-06-30 12:50:38.433653920 +0100 +++ gcc/loop-unroll.c 2017-07-13 09:18:40.318672392 +0100 @@ -1509,6 +1509,7 @@ analyze_iv_to_split_insn (rtx_insn *insn rtx set, dest; struct rtx_iv iv; struct iv_to_split *ivts; + scalar_int_mode mode; bool ok; /* For now we just split the basic induction variables. Later this may be @@ -1518,10 +1519,10 @@ analyze_iv_to_split_insn (rtx_insn *insn return NULL; dest = SET_DEST (set); - if (!REG_P (dest)) + if (!REG_P (dest) || !is_a (GET_MODE (dest), &mode)) return NULL; - if (!biv_p (insn, dest)) + if (!biv_p (insn, mode, dest)) return NULL; ok = iv_analyze_result (insn, dest, &iv); 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; From patchwork Thu Jul 13 08:52:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107624 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1934939qge; Thu, 13 Jul 2017 01:53:28 -0700 (PDT) X-Received: by 10.84.170.67 with SMTP id i61mr8906037plb.114.1499936007978; Thu, 13 Jul 2017 01:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936007; cv=none; d=google.com; s=arc-20160816; b=Sa/BIWJlqGTm6msc7tJdM6IowDCJuKZJqEi2oqwm02yd4TfjJ3Uin5ErKIXQkFhba6 DR0/QjMQkU86zbOWguJVS/CRCAIkLe3w67X/voYGU0QEg1d8Pzxa9nW5ZPrLSHzdSvjN b3/AYboLus5/cS6uVH8L9QSM42EFJGNLN4OnZS3+pePhR/1qAVIQeC5A6g92F55s3roG NSUjh7aelFmOrokSGjNww7gwUqrBmNGZofiAid6Q2dPrZ2Vq/vsztbd/KRRDWPwWeCCW kf7Qx2/B7PpsazeGZk1QHlWAkQGuFkLHZxXmH/m64YdMVMDEvkZmDVhtoyVXnjfxZt/P g5DA== 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=HAUFq7sUVaxFPXA6W9P40v7/eR9ete3QyK7PDPyBor4=; b=rQ59yibS/8xv0Xpnzy+i0kQvSHUad16uGhbfK78gu0TtPTpdc6d923bNNtG1JgGy3G I2JBUbrwZRYsOaO7YojjkMg4wuq7UxdBa8KFhapO5Ccgz+KDVLKV3j/3JXDns8IotiaH jzbKwgLcAn3kMqcffWRR/+rueWOY9ml4T9lUeC4vP0BNXLAgXQBeVVXuRL1kC2TUJ+uu CMxrvahG9y0Nx+3z3Jhq9akyXSdMCWUJZT81c6fyyj/CKDQ6IRzpCk3XSedCXgoBFkAk l4UIwN7rUYE6STaELSoa9ON7Sid70axjoN7MX7zgDZV3anZHiWvZLrCiZiHZ+YdUmOud 0PKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=bwf5Dy4x; spf=pass (google.com: domain of gcc-patches-return-458029-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458029-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 k28si3801596pfg.175.2017.07.13.01.53.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458029-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=bwf5Dy4x; spf=pass (google.com: domain of gcc-patches-return-458029-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458029-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=AyJ26p/JraKhxQdbI1KQzjh0fSHj7 LCwYjsJGADAr1/FfHmcBep8HcnRnETmVHzdKA2s63MbhAu7aUpskhk5Tvx1NGZ7t VjhNe/MSj30nPEdqc3fDg28XxTlASzv5ieiWyyXYN17bhkVQ3sBLeKjpoPyGfn3R hrR1E6GpGaipwk= 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=Y4YumD2ztqEzgpe0EVfIKBPgGZA=; b=bwf 5Dy4xr5sEvgtULsySLLcNvTy4hhHlbqYExg2Q+HZrkecgOgphxx9UJ1eKm4vUW9X 1hMdlajkxQVItOOMvMYZqbRJFNX9sToqDxiHRPgO9qy9hE2/OUCosauiBdYAFD+N QzTk3YMneYPSJibqZPus6bSvUF5JaB/tNy2WSu4M= Received: (qmail 44622 invoked by alias); 13 Jul 2017 08:52:17 -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 44137 invoked by uid 89); 13 Jul 2017 08:52:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:52:12 +0000 Received: by mail-wr0-f177.google.com with SMTP id 77so49668639wrb.1 for ; Thu, 13 Jul 2017 01:52:11 -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=HAUFq7sUVaxFPXA6W9P40v7/eR9ete3QyK7PDPyBor4=; b=gjYkTOL4QKwANiT3kLxZ8zUwaxJTwI29nlN3ONzCo/Wz7/PCLpHCVbCova/yOcB43H NEYvrgwOzFeVi3tNh79FuyGlX6mDh6Iw3qqJA+58pWSRIt0jQHgXEwIPnu+P1paDU5gV JusQUhKCQjzF/O/wF0n/NOe6PxF9F+5BYwMpzOBAsIQcpwZH8yeERc5ASqTjYdQcMf3Q zR4oXD5OiKMQ7fSq0xs5dFnup0buWUl70pCnC8lNQC+/AogfHzkdH/BiDygRAmDvdRn0 uKiFtOKks/fdMSxwz10wjTCcuDcxZRisRfSYFhn3n7OsCDmaJ836VjV5uLPOKYvcrNvj 5JDQ== X-Gm-Message-State: AIVw113xrqjxZbUzNaVxgRY52O1BPMnu/ZOmhVzZF5QU82x6prYChMLE TDQHTvQOUB2+cBm/CHPcsA== X-Received: by 10.223.133.239 with SMTP id 44mr900114wru.177.1499935929936; Thu, 13 Jul 2017 01:52:09 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id q70sm4594434wrb.3.2017.07.13.01.52.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:52:09 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [38/77] Move SCALAR_INT_MODE_P out of strict_volatile_bitfield_p References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:52:07 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87lgnshg7c.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 strict_volatile_bitfield_p returns false for any mode that isn't a scalar integer. This patch moves the check to the caller and makes strict_volatile_bitfield_p take the mode as a scalar_int_mode. The handling of a true return can then also use the mode as a scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expmed.c (strict_volatile_bitfield_p): Change the type of fieldmode to scalar_int_mode. Remove check for SCALAR_INT_MODE_P. (store_bit_field): Check is_a before calling strict_volatile_bitfield_p. (extract_bit_field): Likewise. Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:40.784633351 +0100 +++ gcc/expmed.c 2017-07-13 09:18:41.241595261 +0100 @@ -514,7 +514,7 @@ lowpart_bit_field_p (unsigned HOST_WIDE_ static bool strict_volatile_bitfield_p (rtx op0, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, - machine_mode fieldmode, + scalar_int_mode fieldmode, unsigned HOST_WIDE_INT bitregion_start, unsigned HOST_WIDE_INT bitregion_end) { @@ -527,11 +527,6 @@ strict_volatile_bitfield_p (rtx op0, uns || flag_strict_volatile_bitfields <= 0) return false; - /* Non-integral modes likely only happen with packed structures. - Punt. */ - if (!SCALAR_INT_MODE_P (fieldmode)) - return false; - /* The bit size must not be larger than the field mode, and the field mode must not be larger than a word. */ if (bitsize > modesize || modesize > BITS_PER_WORD) @@ -1056,19 +1051,21 @@ store_bit_field (rtx str_rtx, unsigned H rtx value, bool reverse) { /* Handle -fstrict-volatile-bitfields in the cases where it applies. */ - if (strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, fieldmode, - bitregion_start, bitregion_end)) + scalar_int_mode int_mode; + if (is_a (fieldmode, &int_mode) + && strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, int_mode, + bitregion_start, bitregion_end)) { /* Storing of a full word can be done with a simple store. We know here that the field can be accessed with one single instruction. For targets that support unaligned memory, an unaligned access may be necessary. */ - if (bitsize == GET_MODE_BITSIZE (fieldmode)) + if (bitsize == GET_MODE_BITSIZE (int_mode)) { - str_rtx = adjust_bitfield_address (str_rtx, fieldmode, + str_rtx = adjust_bitfield_address (str_rtx, int_mode, bitnum / BITS_PER_UNIT); if (reverse) - value = flip_storage_order (fieldmode, value); + value = flip_storage_order (int_mode, value); gcc_assert (bitnum % BITS_PER_UNIT == 0); emit_move_insn (str_rtx, value); } @@ -1076,12 +1073,12 @@ store_bit_field (rtx str_rtx, unsigned H { rtx temp; - str_rtx = narrow_bit_field_mem (str_rtx, fieldmode, bitsize, bitnum, + str_rtx = narrow_bit_field_mem (str_rtx, int_mode, bitsize, bitnum, &bitnum); - gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (fieldmode)); + gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (int_mode)); temp = copy_to_reg (str_rtx); if (!store_bit_field_1 (temp, bitsize, bitnum, 0, 0, - fieldmode, value, reverse, true)) + int_mode, value, reverse, true)) gcc_unreachable (); emit_move_insn (str_rtx, temp); @@ -1899,25 +1896,27 @@ extract_bit_field (rtx str_rtx, unsigned else mode1 = tmode; - if (strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, mode1, 0, 0)) + scalar_int_mode int_mode; + if (is_a (mode1, &int_mode) + && strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, int_mode, 0, 0)) { - /* Extraction of a full MODE1 value can be done with a simple load. + /* Extraction of a full INT_MODE value can be done with a simple load. We know here that the field can be accessed with one single instruction. For targets that support unaligned memory, an unaligned access may be necessary. */ - if (bitsize == GET_MODE_BITSIZE (mode1)) + if (bitsize == GET_MODE_BITSIZE (int_mode)) { - rtx result = adjust_bitfield_address (str_rtx, mode1, + rtx result = adjust_bitfield_address (str_rtx, int_mode, bitnum / BITS_PER_UNIT); if (reverse) - result = flip_storage_order (mode1, result); + result = flip_storage_order (int_mode, result); gcc_assert (bitnum % BITS_PER_UNIT == 0); return convert_extracted_bit_field (result, mode, tmode, unsignedp); } - str_rtx = narrow_bit_field_mem (str_rtx, mode1, bitsize, bitnum, + str_rtx = narrow_bit_field_mem (str_rtx, int_mode, bitsize, bitnum, &bitnum); - gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (mode1)); + gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (int_mode)); str_rtx = copy_to_reg (str_rtx); } From patchwork Thu Jul 13 08:52:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107625 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1935177qge; Thu, 13 Jul 2017 01:53:47 -0700 (PDT) X-Received: by 10.98.39.2 with SMTP id n2mr47355920pfn.35.1499936026980; Thu, 13 Jul 2017 01:53:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936026; cv=none; d=google.com; s=arc-20160816; b=ORXhtmya88/O8gdHxia2aai0CvFDUhv1BrgZyiAOhs4Ez5f4UE7YYf6z/YzTKLjQXn 8bCKWtzdifldrDYPDzsxfym2HDQTd1jxAkaF4RHmosE/gbe0kvYtTS7bvG1WeiPrTctK SidQ6/bOZFBm5JBIPrzoTalVZyWUu9V9yo28hEOKeE5SpZa0sTvlhgM+UOk7oj7jUo09 ISPCFsAw9lf/fRVcF78H+8dyShfTeFrBgZx7q8B8v1SMMwCDhapWLjuqnWjy6p5/e2h+ /Bzr7YsaGIbB0oH7OdBsZ2V9OsUqecJijou7Rde9Xz9iHSPEYuK42AopQqTttvcIPxSe zSPw== 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=GzTo5o7iHXOGo8Yy9JHka0iv4U+qJwIxfXRCFLpbOfg=; b=thZK3DZG8JZ0SU3RGbPZJ6N2isSB5n5abBqgS1qmQDcUFfyhdgqjB/ZV91MkFKMcyZ N/8FP6RVcq0OwEqsUDnv6dDl3RWstGIpFSYDK217zgN1pTg7HBSRxw6iItmV1NjYrDnN e5w7HfwKI1qXXjcunpZlHzgXUS6jSzfrOsgGGSzbyjH0F9JFvJkSH1VN1ioTufYPzKa7 HlVjFGDCBlcIgkdPPCibtHyI9VXrf3Y5SQCqEnYOxD7/IJXJJDModKw4WeP1iL1Pm25A JSwB7J/xbV4Kqiacnw88xMyVi+LWgWQKrkDpRbOEIAMmeeL4OEyOI4O4wD3QW/Ggm77/ 4YpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=snm20J63; spf=pass (google.com: domain of gcc-patches-return-458030-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458030-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 q85si3763147pfa.458.2017.07.13.01.53.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:53:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458030-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=snm20J63; spf=pass (google.com: domain of gcc-patches-return-458030-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458030-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=pGkBce72vBbId55xBDONr63lhiTJJ m2qOIDfzJAT17GKhSUCXlVhP5ouSQrVLHuQrMFrTLvvo0LNI3K0JrKtB4PfTxeI+ frQXcDUXDawh9YWR0fW21VVzdlRWYu8e0CR7DDL7vDP60Josuqh0t5eY/oqajNtx inZ9jTN8uhaE9U= 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=BlGwCWzp4XaatGZq0dJNz06xmIM=; b=snm 20J63ojXrK3logSs4fKbJQ+dggpvGooDsCczSVRS5MN57JshGxNZzay7IxGvlF3A tSdObDQHUnDmV9o3sBGd1uxglAjCL44Cf4RjM2GREtVVdaMVZU1mrlu9LC8a4VEk CznXZW1zleYKzziWUCC8dDMWAiRbsLBhYXhgc6+E= Received: (qmail 69815 invoked by alias); 13 Jul 2017 08:52: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 69080 invoked by uid 89); 13 Jul 2017 08:52:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=boundaries X-HELO: mail-wr0-f178.google.com Received: from mail-wr0-f178.google.com (HELO mail-wr0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:52:34 +0000 Received: by mail-wr0-f178.google.com with SMTP id r103so49559213wrb.0 for ; Thu, 13 Jul 2017 01:52:33 -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=GzTo5o7iHXOGo8Yy9JHka0iv4U+qJwIxfXRCFLpbOfg=; b=cbR4qvNY5j+B0De5FicOKvtTr96aGtGDfc708jxs547E8Yur2eMyhJCkfz4Zop3Qdk 5x1K1XU/UT44phSERGJttP0cjs1oSfxMBFkmdsouZvyNRBraEKZEaOeDd5ayVfqD9kVA wxPHpykWhP9SwQO7VMeHD8gC8Mqp+9BG4a7HK4LHcss9RsgKIGOGIIZBZAcKDq5ros+N rsJNo0FN/SIdD7AMHvCQQ2EZGDNw8E9K9Jt29R8gdE3M3B6AhcMF1gMXx+7zmQ6Xnlad 4xgERGOVw/qvAYJb9pFQDKF8cBPgLUlbwB43bQ8q2AUyR5tdHoyyqkXS0emHGGR/8NvS u1/g== X-Gm-Message-State: AIVw112JpFHtUxkJkDoVBDTDvjVMJ+vdVlHGDMH+lD2eAOisNN2TkuOW EGkCa89QZedqmk/5XdWZ2g== X-Received: by 10.223.164.23 with SMTP id d23mr911579wra.58.1499935951621; Thu, 13 Jul 2017 01:52:31 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id m26sm4661872wrm.4.2017.07.13.01.52.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:52:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [39/77] Two changes to the get_best_mode interface References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:52:29 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87h8yghg6q.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 get_best_mode always returns a scalar_int_mode on success, so this patch makes that explicit in the type system. Also, the "largest_mode" argument is used simply to provide a maximum size, and in practice that size is always a compile-time constant, even when the concept of variable-sized modes is added later. The patch therefore passes the size directly. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (bit_field_mode_iterator::next_mode): Take a pointer to a scalar_int_mode instead of a machine_mode. (bit_field_mode_iterator::m_mode): Change type to opt_scalar_int_mode. (get_best_mode): Return a boolean and use a pointer argument to store the selected mode. Replace the limit mode parameter with a bit limit. * expmed.c (adjust_bit_field_mem_for_reg): Use scalar_int_mode for the values returned by bit_field_mode_iterator::next_mode. (store_bit_field): Update call to get_best_mode. (store_fixed_bit_field): Likewise. (extract_fixed_bit_field): Likewise. * expr.c (optimize_bitfield_assignment_op): Likewise. * fold-const.c (optimize_bit_field_compare): Likewise. (fold_truth_andor_1): Likewise. * stor-layout.c (bit_field_mode_iterator::next_mode): As above. Update for new type of m_mode. (get_best_mode): As above. Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:38.043865449 +0100 +++ gcc/machmode.h 2017-07-13 09:18:41.680558844 +0100 @@ -618,11 +618,11 @@ extern machine_mode mode_for_vector (mac bit_field_mode_iterator (HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT, unsigned int, bool); - bool next_mode (machine_mode *); + bool next_mode (scalar_int_mode *); bool prefer_smaller_modes (); private: - machine_mode m_mode; + opt_scalar_int_mode m_mode; /* We use signed values here because the bit position can be negative for invalid input such as gcc.dg/pr48335-8.c. */ HOST_WIDE_INT m_bitsize; @@ -636,11 +636,9 @@ extern machine_mode mode_for_vector (mac /* Find the best mode to use to access a bit field. */ -extern machine_mode get_best_mode (int, int, - unsigned HOST_WIDE_INT, - unsigned HOST_WIDE_INT, - unsigned int, - machine_mode, bool); +extern bool get_best_mode (int, int, unsigned HOST_WIDE_INT, + unsigned HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT, bool, scalar_int_mode *); /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:41.241595261 +0100 +++ gcc/expmed.c 2017-07-13 09:18:41.678559010 +0100 @@ -459,7 +459,7 @@ adjust_bit_field_mem_for_reg (enum extra bit_field_mode_iterator iter (bitsize, bitnum, bitregion_start, bitregion_end, MEM_ALIGN (op0), MEM_VOLATILE_P (op0)); - machine_mode best_mode; + scalar_int_mode best_mode; if (iter.next_mode (&best_mode)) { /* We can use a memory in BEST_MODE. See whether this is true for @@ -477,7 +477,7 @@ adjust_bit_field_mem_for_reg (enum extra fieldmode)) limit_mode = insn.field_mode; - machine_mode wider_mode; + scalar_int_mode wider_mode; while (iter.next_mode (&wider_mode) && GET_MODE_SIZE (wider_mode) <= GET_MODE_SIZE (limit_mode)) best_mode = wider_mode; @@ -1092,7 +1092,8 @@ store_bit_field (rtx str_rtx, unsigned H bit region. */ if (MEM_P (str_rtx) && bitregion_start > 0) { - machine_mode bestmode; + scalar_int_mode best_mode; + machine_mode addr_mode = VOIDmode; HOST_WIDE_INT offset, size; gcc_assert ((bitregion_start % BITS_PER_UNIT) == 0); @@ -1102,11 +1103,13 @@ store_bit_field (rtx str_rtx, unsigned H size = (bitnum + bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT; bitregion_end -= bitregion_start; bitregion_start = 0; - bestmode = get_best_mode (bitsize, bitnum, - bitregion_start, bitregion_end, - MEM_ALIGN (str_rtx), VOIDmode, - MEM_VOLATILE_P (str_rtx)); - str_rtx = adjust_bitfield_address_size (str_rtx, bestmode, offset, size); + if (get_best_mode (bitsize, bitnum, + bitregion_start, bitregion_end, + MEM_ALIGN (str_rtx), INT_MAX, + MEM_VOLATILE_P (str_rtx), &best_mode)) + addr_mode = best_mode; + str_rtx = adjust_bitfield_address_size (str_rtx, addr_mode, + offset, size); } if (!store_bit_field_1 (str_rtx, bitsize, bitnum, @@ -1140,10 +1143,10 @@ store_fixed_bit_field (rtx op0, unsigned if (GET_MODE_BITSIZE (mode) == 0 || GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (word_mode)) mode = word_mode; - mode = get_best_mode (bitsize, bitnum, bitregion_start, bitregion_end, - MEM_ALIGN (op0), mode, MEM_VOLATILE_P (op0)); - - if (mode == VOIDmode) + scalar_int_mode best_mode; + if (!get_best_mode (bitsize, bitnum, bitregion_start, bitregion_end, + MEM_ALIGN (op0), GET_MODE_BITSIZE (mode), + MEM_VOLATILE_P (op0), &best_mode)) { /* The only way this should occur is if the field spans word boundaries. */ @@ -1152,7 +1155,7 @@ store_fixed_bit_field (rtx op0, unsigned return; } - op0 = narrow_bit_field_mem (op0, mode, bitsize, bitnum, &bitnum); + op0 = narrow_bit_field_mem (op0, best_mode, bitsize, bitnum, &bitnum); } store_fixed_bit_field_1 (op0, bitsize, bitnum, value, reverse); @@ -1942,11 +1945,9 @@ extract_fixed_bit_field (machine_mode tm { if (MEM_P (op0)) { - machine_mode mode - = get_best_mode (bitsize, bitnum, 0, 0, MEM_ALIGN (op0), word_mode, - MEM_VOLATILE_P (op0)); - - if (mode == VOIDmode) + scalar_int_mode mode; + if (!get_best_mode (bitsize, bitnum, 0, 0, MEM_ALIGN (op0), + BITS_PER_WORD, MEM_VOLATILE_P (op0), &mode)) /* The only way this should occur is if the field spans word boundaries. */ return extract_split_bit_field (op0, bitsize, bitnum, unsignedp, Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:39.589733813 +0100 +++ gcc/expr.c 2017-07-13 09:18:41.678559010 +0100 @@ -4682,13 +4682,14 @@ optimize_bitfield_assignment_op (unsigne unsigned HOST_WIDE_INT offset1; if (str_bitsize == 0 || str_bitsize > BITS_PER_WORD) - str_mode = word_mode; - str_mode = get_best_mode (bitsize, bitpos, - bitregion_start, bitregion_end, - MEM_ALIGN (str_rtx), str_mode, 0); - if (str_mode == VOIDmode) + str_bitsize = BITS_PER_WORD; + + scalar_int_mode best_mode; + if (!get_best_mode (bitsize, bitpos, bitregion_start, bitregion_end, + MEM_ALIGN (str_rtx), str_bitsize, false, &best_mode)) return false; - str_bitsize = GET_MODE_BITSIZE (str_mode); + str_mode = best_mode; + str_bitsize = GET_MODE_BITSIZE (best_mode); offset1 = bitpos; bitpos %= str_bitsize; Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-07-13 09:18:38.661812628 +0100 +++ gcc/fold-const.c 2017-07-13 09:18:41.680558844 +0100 @@ -3966,7 +3966,8 @@ optimize_bit_field_compare (location_t l tree type = TREE_TYPE (lhs); tree unsigned_type; int const_p = TREE_CODE (rhs) == INTEGER_CST; - machine_mode lmode, rmode, nmode; + machine_mode lmode, rmode; + scalar_int_mode nmode; int lunsignedp, runsignedp; int lreversep, rreversep; int lvolatilep = 0, rvolatilep = 0; @@ -4013,12 +4014,11 @@ optimize_bit_field_compare (location_t l /* See if we can find a mode to refer to this field. We should be able to, but fail if we can't. */ - nmode = get_best_mode (lbitsize, lbitpos, bitstart, bitend, - const_p ? TYPE_ALIGN (TREE_TYPE (linner)) - : MIN (TYPE_ALIGN (TREE_TYPE (linner)), - TYPE_ALIGN (TREE_TYPE (rinner))), - word_mode, false); - if (nmode == VOIDmode) + if (!get_best_mode (lbitsize, lbitpos, bitstart, bitend, + const_p ? TYPE_ALIGN (TREE_TYPE (linner)) + : MIN (TYPE_ALIGN (TREE_TYPE (linner)), + TYPE_ALIGN (TREE_TYPE (rinner))), + BITS_PER_WORD, false, &nmode)) return 0; /* Set signed and unsigned types of the precision of this mode for the @@ -5621,7 +5621,7 @@ fold_truth_andor_1 (location_t loc, enum int ll_unsignedp, lr_unsignedp, rl_unsignedp, rr_unsignedp; int ll_reversep, lr_reversep, rl_reversep, rr_reversep; machine_mode ll_mode, lr_mode, rl_mode, rr_mode; - machine_mode lnmode, rnmode; + scalar_int_mode lnmode, rnmode; tree ll_mask, lr_mask, rl_mask, rr_mask; tree ll_and_mask, lr_and_mask, rl_and_mask, rr_and_mask; tree l_const, r_const; @@ -5807,10 +5807,9 @@ fold_truth_andor_1 (location_t loc, enum to be relative to a field of that size. */ first_bit = MIN (ll_bitpos, rl_bitpos); end_bit = MAX (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize); - lnmode = get_best_mode (end_bit - first_bit, first_bit, 0, 0, - TYPE_ALIGN (TREE_TYPE (ll_inner)), word_mode, - volatilep); - if (lnmode == VOIDmode) + if (!get_best_mode (end_bit - first_bit, first_bit, 0, 0, + TYPE_ALIGN (TREE_TYPE (ll_inner)), BITS_PER_WORD, + volatilep, &lnmode)) return 0; lnbitsize = GET_MODE_BITSIZE (lnmode); @@ -5872,10 +5871,9 @@ fold_truth_andor_1 (location_t loc, enum first_bit = MIN (lr_bitpos, rr_bitpos); end_bit = MAX (lr_bitpos + lr_bitsize, rr_bitpos + rr_bitsize); - rnmode = get_best_mode (end_bit - first_bit, first_bit, 0, 0, - TYPE_ALIGN (TREE_TYPE (lr_inner)), word_mode, - volatilep); - if (rnmode == VOIDmode) + if (!get_best_mode (end_bit - first_bit, first_bit, 0, 0, + TYPE_ALIGN (TREE_TYPE (lr_inner)), BITS_PER_WORD, + volatilep, &rnmode)) return 0; rnbitsize = GET_MODE_BITSIZE (rnmode); Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:38.663812457 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:41.680558844 +0100 @@ -2722,15 +2722,15 @@ fixup_unsigned_type (tree type) available, storing it in *OUT_MODE if so. */ bool -bit_field_mode_iterator::next_mode (machine_mode *out_mode) +bit_field_mode_iterator::next_mode (scalar_int_mode *out_mode) { - for (; m_mode != VOIDmode; - m_mode = GET_MODE_WIDER_MODE (m_mode).else_void ()) + for (; m_mode.exists (); m_mode = GET_MODE_WIDER_MODE (*m_mode)) { - unsigned int unit = GET_MODE_BITSIZE (m_mode); + scalar_int_mode mode = *m_mode; + unsigned int unit = GET_MODE_BITSIZE (mode); /* Skip modes that don't have full precision. */ - if (unit != GET_MODE_PRECISION (m_mode)) + if (unit != GET_MODE_PRECISION (mode)) continue; /* Stop if the mode is too wide to handle efficiently. */ @@ -2757,12 +2757,12 @@ bit_field_mode_iterator::next_mode (mach break; /* Stop if the mode requires too much alignment. */ - if (GET_MODE_ALIGNMENT (m_mode) > m_align - && SLOW_UNALIGNED_ACCESS (m_mode, m_align)) + if (GET_MODE_ALIGNMENT (mode) > m_align + && SLOW_UNALIGNED_ACCESS (mode, m_align)) break; - *out_mode = m_mode; - m_mode = GET_MODE_WIDER_MODE (m_mode).else_void (); + *out_mode = mode; + m_mode = GET_MODE_WIDER_MODE (mode); m_count++; return true; } @@ -2789,12 +2789,14 @@ bit_field_mode_iterator::prefer_smaller_ memory access to that range. Otherwise, we are allowed to touch any adjacent non bit-fields. - The underlying object is known to be aligned to a boundary of ALIGN bits. - If LARGEST_MODE is not VOIDmode, it means that we should not use a mode - larger than LARGEST_MODE (usually SImode). + The chosen mode must have no more than LARGEST_MODE_BITSIZE bits. + INT_MAX is a suitable value for LARGEST_MODE_BITSIZE if the caller + doesn't want to apply a specific limit. If no mode meets all these conditions, we return VOIDmode. + The underlying object is known to be aligned to a boundary of ALIGN bits. + If VOLATILEP is false and SLOW_BYTE_ACCESS is false, we return the smallest mode meeting these conditions. @@ -2805,17 +2807,18 @@ bit_field_mode_iterator::prefer_smaller_ If VOLATILEP is true the narrow_volatile_bitfields target hook is used to decide which of the above modes should be used. */ -machine_mode +bool get_best_mode (int bitsize, int bitpos, unsigned HOST_WIDE_INT bitregion_start, unsigned HOST_WIDE_INT bitregion_end, unsigned int align, - machine_mode largest_mode, bool volatilep) + unsigned HOST_WIDE_INT largest_mode_bitsize, bool volatilep, + scalar_int_mode *best_mode) { bit_field_mode_iterator iter (bitsize, bitpos, bitregion_start, bitregion_end, align, volatilep); - machine_mode widest_mode = VOIDmode; - machine_mode mode; + scalar_int_mode mode; + bool found = false; while (iter.next_mode (&mode) /* ??? For historical reasons, reject modes that would normally receive greater alignment, even if unaligned accesses are @@ -2874,14 +2877,15 @@ get_best_mode (int bitsize, int bitpos, so that the final bitfield reference still has a MEM_EXPR and MEM_OFFSET. */ && GET_MODE_ALIGNMENT (mode) <= align - && (largest_mode == VOIDmode - || GET_MODE_SIZE (mode) <= GET_MODE_SIZE (largest_mode))) + && GET_MODE_BITSIZE (mode) <= largest_mode_bitsize) { - widest_mode = mode; + *best_mode = mode; + found = true; if (iter.prefer_smaller_modes ()) break; } - return widest_mode; + + return found; } /* Gets minimal and maximal values for MODE (signed or unsigned depending on From patchwork Thu Jul 13 08:52:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107626 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1935460qge; Thu, 13 Jul 2017 01:54:07 -0700 (PDT) X-Received: by 10.98.207.2 with SMTP id b2mr60205761pfg.16.1499936047295; Thu, 13 Jul 2017 01:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936047; cv=none; d=google.com; s=arc-20160816; b=auPTEmJm/KxZEbdhVcQ3T3topG/VDZI2FEmOa5RMDbplWB/qLVnsHQTcI61gP/sysZ qj9wGwYNzeSYp2sJMhhDJDsddtC0ZgY1drWwdPF4PDIWXql1N+vlJV9QOprceX3J+/Fd WOs9TpusJZ2EmC0RaYyL4+XdACJEM0DRiUe9k2k1MJSLooPhVHeDjdpWeEss+8ZJ/ESf fTV0M2rSI6aGqgNMGhXSubQnQOx36JoNN/SNvNwXyN6xO9XYqtpQSM3taBJKVtm6Jhn2 3cc1OB3lPlS2L19PMUR0RnJcc7AvGYz7UyMrCNR1zbbj2zDrsGf2tNDQfDWu1aTaRL4P uikw== 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=d8SQ8o5FYKESZseoZAPmegiry43RJt0ZsORobWotHZk=; b=Y9Tby5csZToG+Ci1cHnpTvTRNiCWVRDvlUsTYpgH1qaJlaZzJLSfdf3MAnhmnxb7xZ EXjCsUwZfV1Qq51RnGKUxdEKyDr0dSZ9Df8C7aypGjPE/cyH4rGMXNqnjNE6udDi6A9y Du4jM9F1axQxWChMEdl8i7KNvQI5fI9HYD9cLUMzBoFNKIj4ekqwd1RWXtE+5ZZEk4xu cLPzinoNgJ16uSD6F9kYpB6DNrZHlvAMjvyu6D5rsOdOh1o++p3vaGsLinhXPMyeFiAq +Lxq873HLt2NbsKqQQpqGRWTyQr2d8Mb6ZZla5/nDu+Ir0ycD3NgE1M+6Os1KHKWqbwI Nmxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=CcK4yesP; spf=pass (google.com: domain of gcc-patches-return-458031-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458031-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 e127si3758126pgc.44.2017.07.13.01.54.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:54:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458031-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=CcK4yesP; spf=pass (google.com: domain of gcc-patches-return-458031-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458031-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=IUX3FBNGJ6fEERj3U+Z9xmJoptjsV QfofbuBiJo5dqOUgANM4ocir0FobqrhIzbtdwtvQ2t63Sy7+r+k00Tca3tS/YI97 grOSWdbG2zg9Q81aVUokjpVseHkGMJCxzs+CB3qYCVSUp4Y1//eNL/rPd897Cq3F GsZEExRrPaAGWA= 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=YM/LbJx1raqTlfCRZFKJ7iUIe54=; b=CcK 4yesPYuFHQeUXPvyeB4nDEfApCKkaaeRrZwoXjJIOE3XQDAKrFP6sul2/9WCOqmx 3V1zKfKR/ZaAKofnGoUEmQu+ubVZNYnkfEZkQA13z55pG/Ia2DA2NLS8D2WPd2qq 4stG65lHs8khYQtAja3Wg+R7rbY5nxdJY0mEAW/I= Received: (qmail 84253 invoked by alias); 13 Jul 2017 08:52: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 82892 invoked by uid 89); 13 Jul 2017 08:52: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=1009 X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:52:53 +0000 Received: by mail-wm0-f52.google.com with SMTP id i127so18289157wma.0 for ; Thu, 13 Jul 2017 01:52: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=d8SQ8o5FYKESZseoZAPmegiry43RJt0ZsORobWotHZk=; b=iBh6ldP9B/vnUaiUHeqgnUjZ+6Lt9fiOvfF9kNF0rvFi0uybktOwqO2YKcCOuY9/94 m/s01z1/vuiJXVxFVL6YNBbUIiVzmc4nvSLxTcQ0BOUkHpH0SpWq/QpTaiQJv/0R46Z/ O7oT9KIpZOiVS9drIVnAy+l9ASa5Mr9K+v135G4oCl8bOiee2oF7IVV6LU6AGzQg+FPk KgSsVB1z2gn9ExaOWUQ7tYMpryqkU9XwNbuEFdab2g8Nq4ODTATRnIhAF7RxYkRkGMQi R1cDlSyQS97UY/0zqwI1MlqiTmloi22PAmIOeUIZgPDv+g6nULBGE0NrfV5YFzE+L6Zl 29lA== X-Gm-Message-State: AIVw110HRIZCgeF9bZBPt8SIhziJzYejwAN54HMCV71aWeveixUU9uLW 8zt7pf0c6j/vQM+PbYpkqw== X-Received: by 10.28.142.133 with SMTP id q127mr1173983wmd.4.1499935970978; Thu, 13 Jul 2017 01:52:50 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id n2sm6338898wmd.19.2017.07.13.01.52.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:52:50 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [40/77] Use scalar_int_mode for extraction_insn fields References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:52:48 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87d194hg67.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 insv, extv and eztzv modify or read a field in a register or memory. The field always has a scalar integer mode, while the register or memory either has a scalar integer mode or BLKmode. The mode of the bit position is also a scalar integer. This patch uses the type system to make that explicit. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * optabs-query.h (extraction_insn::struct_mode): Change type to opt_scalar_int_mode and update comment. (extraction_insn::field_mode): Change type to scalar_int_mode. (extraction_insn::pos_mode): Likewise. * combine.c (make_extraction): Update accordingly. * optabs-query.c (get_traditional_extraction_insn): Likewise. (get_optab_extraction_insn): Likewise. * recog.c (simplify_while_replacing): Likewise. * expmed.c (narrow_bit_field_mem): Chane the type of the mode parameter to opt_scalar_int_mode. Index: gcc/optabs-query.h =================================================================== --- gcc/optabs-query.h 2017-02-23 19:54:15.000000000 +0000 +++ gcc/optabs-query.h 2017-07-13 09:18:42.162518990 +0100 @@ -141,16 +141,17 @@ struct extraction_insn enum insn_code icode; /* The mode that the structure operand should have. This is byte_mode - when using the legacy insv, extv and extzv patterns to access memory. */ - machine_mode struct_mode; + when using the legacy insv, extv and extzv patterns to access memory. + If no mode is given, the structure is a BLKmode memory. */ + opt_scalar_int_mode struct_mode; /* The mode of the field to be inserted or extracted, and by extension the mode of the insertion or extraction itself. */ - machine_mode field_mode; + scalar_int_mode field_mode; /* The mode of the field's bit position. This is only important when the position is variable rather than constant. */ - machine_mode pos_mode; + scalar_int_mode pos_mode; }; bool get_best_reg_extraction_insn (extraction_insn *, Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:39.584734236 +0100 +++ gcc/combine.c 2017-07-13 09:18:42.160519154 +0100 @@ -7632,7 +7632,7 @@ make_extraction (machine_mode mode, rtx if (get_best_reg_extraction_insn (&insn, pattern, GET_MODE_BITSIZE (inner_mode), mode)) { - wanted_inner_reg_mode = insn.struct_mode; + wanted_inner_reg_mode = *insn.struct_mode; pos_mode = insn.pos_mode; extraction_mode = insn.field_mode; } Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-07-13 09:18:30.902501597 +0100 +++ gcc/optabs-query.c 2017-07-13 09:18:42.161519072 +0100 @@ -100,9 +100,14 @@ get_traditional_extraction_insn (extract pos_mode = word_mode; insn->icode = icode; - insn->field_mode = field_mode; - insn->struct_mode = (type == ET_unaligned_mem ? byte_mode : struct_mode); - insn->pos_mode = pos_mode; + insn->field_mode = as_a (field_mode); + if (type == ET_unaligned_mem) + insn->struct_mode = byte_mode; + else if (struct_mode == BLKmode) + insn->struct_mode = opt_scalar_int_mode (); + else + insn->struct_mode = as_a (struct_mode); + insn->pos_mode = as_a (pos_mode); return true; } @@ -126,12 +131,17 @@ get_optab_extraction_insn (struct extrac const struct insn_data_d *data = &insn_data[icode]; + machine_mode pos_mode = data->operand[pos_op].mode; + if (pos_mode == VOIDmode) + pos_mode = word_mode; + insn->icode = icode; - insn->field_mode = mode; - insn->struct_mode = (type == ET_unaligned_mem ? BLKmode : mode); - insn->pos_mode = data->operand[pos_op].mode; - if (insn->pos_mode == VOIDmode) - insn->pos_mode = word_mode; + insn->field_mode = as_a (mode); + if (type == ET_unaligned_mem) + insn->struct_mode = opt_scalar_int_mode (); + else + insn->struct_mode = insn->field_mode; + insn->pos_mode = as_a (pos_mode); return true; } Index: gcc/recog.c =================================================================== --- gcc/recog.c 2017-07-13 09:18:39.591733644 +0100 +++ gcc/recog.c 2017-07-13 09:18:42.162518990 +0100 @@ -663,25 +663,18 @@ simplify_while_replacing (rtx *loc, rtx MEM_ADDR_SPACE (XEXP (x, 0))) && !MEM_VOLATILE_P (XEXP (x, 0))) { - machine_mode wanted_mode = VOIDmode; int pos = INTVAL (XEXP (x, 2)); - + machine_mode new_mode = is_mode; if (GET_CODE (x) == ZERO_EXTRACT && targetm.have_extzv ()) - { - wanted_mode = insn_data[targetm.code_for_extzv].operand[1].mode; - if (wanted_mode == VOIDmode) - wanted_mode = word_mode; - } + new_mode = insn_data[targetm.code_for_extzv].operand[1].mode; else if (GET_CODE (x) == SIGN_EXTRACT && targetm.have_extv ()) - { - wanted_mode = insn_data[targetm.code_for_extv].operand[1].mode; - if (wanted_mode == VOIDmode) - wanted_mode = word_mode; - } + new_mode = insn_data[targetm.code_for_extv].operand[1].mode; + scalar_int_mode wanted_mode = (new_mode == VOIDmode + ? word_mode + : as_a (new_mode)); /* If we have a narrower mode, we can do something. */ - if (wanted_mode != VOIDmode - && GET_MODE_SIZE (wanted_mode) < GET_MODE_SIZE (is_mode)) + if (GET_MODE_SIZE (wanted_mode) < GET_MODE_SIZE (is_mode)) { int offset = pos / BITS_PER_UNIT; rtx newmem; Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:41.678559010 +0100 +++ gcc/expmed.c 2017-07-13 09:18:42.161519072 +0100 @@ -409,31 +409,32 @@ flip_storage_order (machine_mode mode, r return result; } -/* Adjust bitfield memory MEM so that it points to the first unit of mode - MODE that contains a bitfield of size BITSIZE at bit position BITNUM. - If MODE is BLKmode, return a reference to every byte in the bitfield. - Set *NEW_BITNUM to the bit position of the field within the new memory. */ +/* If MODE is set, adjust bitfield memory MEM so that it points to the + first unit of mode MODE that contains a bitfield of size BITSIZE at + bit position BITNUM. If MODE is not set, return a BLKmode reference + to every byte in the bitfield. Set *NEW_BITNUM to the bit position + of the field within the new memory. */ static rtx -narrow_bit_field_mem (rtx mem, machine_mode mode, +narrow_bit_field_mem (rtx mem, opt_scalar_int_mode mode, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, unsigned HOST_WIDE_INT *new_bitnum) { - if (mode == BLKmode) + if (mode.exists ()) + { + unsigned int unit = GET_MODE_BITSIZE (*mode); + *new_bitnum = bitnum % unit; + HOST_WIDE_INT offset = (bitnum - *new_bitnum) / BITS_PER_UNIT; + return adjust_bitfield_address (mem, *mode, offset); + } + else { *new_bitnum = bitnum % BITS_PER_UNIT; HOST_WIDE_INT offset = bitnum / BITS_PER_UNIT; HOST_WIDE_INT size = ((*new_bitnum + bitsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT); - return adjust_bitfield_address_size (mem, mode, offset, size); - } - else - { - unsigned int unit = GET_MODE_BITSIZE (mode); - *new_bitnum = bitnum % unit; - HOST_WIDE_INT offset = (bitnum - *new_bitnum) / BITS_PER_UNIT; - return adjust_bitfield_address (mem, mode, offset); + return adjust_bitfield_address_size (mem, BLKmode, offset, size); } } From patchwork Thu Jul 13 08:53:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107627 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1935726qge; Thu, 13 Jul 2017 01:54:27 -0700 (PDT) X-Received: by 10.98.147.69 with SMTP id b66mr38119045pfe.148.1499936067817; Thu, 13 Jul 2017 01:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936067; cv=none; d=google.com; s=arc-20160816; b=fxNa9QneigE+QGbujxU0yn9DRMCImnbg3SaS8JFfDJwW5TOOmY8cpxRdEkXTUtQfG8 xnNeNdzaM8WbgG8znCheIRQIE3/HYpaANLs7PZBe0SZYkGh1QDaexlmysMRKjUZXoIX5 1Vu1Q0fxG/kttcecd1qt9ZQeIC2JxRSlj/fG/s01OtrRrmj6Iwy+pe0cKEtuTbWOwLw5 VTVDk+ipcrA0+0sOCQGvZHyYV0sMKxQI0jsMjzbQKhh8Z1Q0IlPNJugc+Ssncc5WSj2b KEPxJ6xnKhFwKSigF29h3fPcq63PAbCRXOrCHD8y413XfIq+KS5Gudx40+xrhmNMlFB/ trUA== 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=AxxiR52/YTsBP24eyOk1LARQGEd1EGXWVQL5PwekURY=; b=Fc3uYgxIPQxZ7GJAh+dezBiX5TxM5hi9f+I4LXqPJkLu7equ9Wsry1+TGOXZ8sWYA+ Sp537RY7QfqoFs0ww74VABg1lqTW/SJ7wFaRiLyzdT9ruOpdnc5ZOLqP7hCoZ9NUSHYn X0SHzmTEs5mC16mV/oayx/cw9zP2fzFCm6R8EH6nRiSWmiMAdh2E0eHQntfcrhMkxg6+ vHklDhCBj9J0uWhrn8SHIf5a14bzomcP5H5IeC9e+nzkCtl2lpYHzNOGG2MT28FE+NiY t8no4kIfsJ/uAizbVLVHOfD7VO+1hmO/xvpj3FhPknllc4+mTgpLg63ighwvuWHAahS2 ok0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=xNE2EnhS; spf=pass (google.com: domain of gcc-patches-return-458032-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458032-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 o33si3998112plb.384.2017.07.13.01.54.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:54:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458032-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=xNE2EnhS; spf=pass (google.com: domain of gcc-patches-return-458032-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458032-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=Z0EIuRqkeOYYD2/x5LPI2rbbHPc5N MiVLF+Gkc5nEZI7EkOMs3uoUgfk9x2jIZ1YRJny0pSczVFS9eJN7+F7Dq5SeuRS1 QkjOmcdvtb6jbc78xvh4uwAUmoYG96aUgWY7a5QCs0pVnndCvL5FWlKy8mzH/0PE mfbMpKIdpbUfgk= 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=6j0fvPZy+RGBXE/+xYIxVDoPkms=; b=xNE 2EnhShqA8ZXioR7LIrWI5jmVYZsCRgUxTWSkamIoDCUNXvqK7pBiPVG7tx6+0rXo hDeYIZt+ioUGkVOIZQAjw8rLgyEr0kTLQ8gXFnUzKOaHV4cE5R97PoqegYAjUDC9 veb4D315AD9Ln/vWdybEa6NBkad73O4GsrzoL4q8= Received: (qmail 106073 invoked by alias); 13 Jul 2017 08:53:21 -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 105381 invoked by uid 89); 13 Jul 2017 08:53:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:53:13 +0000 Received: by mail-wm0-f48.google.com with SMTP id f67so18326979wmh.1 for ; Thu, 13 Jul 2017 01:53:12 -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=AxxiR52/YTsBP24eyOk1LARQGEd1EGXWVQL5PwekURY=; b=CN/PwVkP4batsLD7pQXwb4/F7KOU0STh9paTRz22k4X+UF/HTWa6DME9gklqU1VVXL Mfl/XwYBmLX5nNy39hvUwit+7d4ekrLXEaqGI7B3eifSqTNUmSDlEtU9oOn7/LZL3vqd MQ6AQONMdL83czkj3byVu3ce7+TAU7dqdraFnw6DHr9BGpBEG5O/p4xr/0TcDFifkfLo ckEJVeWpxOl/qyo4fA+rz5My9p5L19yyL0JfTrW3YcGdx2krTprvs+ZAPqQRTBmdStPD ztl5LMigjXOZJ087n6+64vCfi5B5dqsBy9KBKKnvxPgnU/Csd9hdP9N5m2r4LHHAS6pY kGgA== X-Gm-Message-State: AIVw111vbr8rTJPgPGdJsxoU6QEpaKtL0farqXA9rFp3nHTa25PQjfuM 0+jsmXPu6hs/e42YPOifGQ== X-Received: by 10.28.47.67 with SMTP id v64mr1137582wmv.84.1499935990656; Thu, 13 Jul 2017 01:53:10 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 21sm6149459wmo.16.2017.07.13.01.53.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:53:09 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [41/77] Split scalar integer handling out of force_to_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:53:08 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <878tjshg5n.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 force_to_mode exits partway through for modes that aren't scalar integers. This patch splits the remainder of the function out into a subroutine, force_int_to_mode, so that the modes from that point on can have type scalar_int_mode. The patch also makes sure that xmode is kept up-to-date with x and uses xmode instead of GET_MODE (x) throughout. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (force_int_to_mode): New function, split out from... (force_to_mode): ...here. Keep xmode up-to-date and use it instead of GET_MODE (x). Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:42.160519154 +0100 +++ gcc/combine.c 2017-07-13 09:18:42.622481204 +0100 @@ -449,6 +449,8 @@ static rtx extract_left_shift (rtx, int) static int get_pos_from_mask (unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *); static rtx canon_reg_for_combine (rtx, rtx); +static rtx force_int_to_mode (rtx, scalar_int_mode, scalar_int_mode, + scalar_int_mode, unsigned HOST_WIDE_INT, int); static rtx force_to_mode (rtx, machine_mode, unsigned HOST_WIDE_INT, int); static rtx if_then_else_cond (rtx, rtx *, rtx *); @@ -8517,8 +8519,7 @@ force_to_mode (rtx x, machine_mode mode, enum rtx_code code = GET_CODE (x); int next_select = just_select || code == XOR || code == NOT || code == NEG; machine_mode op_mode; - unsigned HOST_WIDE_INT fuller_mask, nonzero; - rtx op0, op1, temp; + unsigned HOST_WIDE_INT nonzero; /* If this is a CALL or ASM_OPERANDS, don't do anything. Some of the code below will do the wrong thing since the mode of such an @@ -8546,15 +8547,6 @@ force_to_mode (rtx x, machine_mode mode, if (op_mode) mask &= GET_MODE_MASK (op_mode); - /* When we have an arithmetic operation, or a shift whose count we - do not know, we need to assume that all bits up to the highest-order - bit in MASK will be needed. This is how we form such a mask. */ - if (mask & (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1))) - fuller_mask = HOST_WIDE_INT_M1U; - else - fuller_mask = ((HOST_WIDE_INT_1U << (floor_log2 (mask) + 1)) - - 1); - /* Determine what bits of X are guaranteed to be (non)zero. */ nonzero = nonzero_bits (x, mode); @@ -8592,9 +8584,42 @@ force_to_mode (rtx x, machine_mode mode, & ~GET_MODE_MASK (GET_MODE (SUBREG_REG (x))))))) return force_to_mode (SUBREG_REG (x), mode, mask, next_select); - /* The arithmetic simplifications here only work for scalar integer modes. */ - if (!SCALAR_INT_MODE_P (mode) || !SCALAR_INT_MODE_P (GET_MODE (x))) - return gen_lowpart_or_truncate (mode, x); + scalar_int_mode int_mode, xmode; + if (is_a (mode, &int_mode) + && is_a (GET_MODE (x), &xmode)) + /* OP_MODE is either MODE or XMODE, so it must be a scalar + integer too. */ + return force_int_to_mode (x, int_mode, xmode, + as_a (op_mode), + mask, just_select); + + return gen_lowpart_or_truncate (mode, x); +} + +/* Subroutine of force_to_mode that handles cases in which both X and + the result are scalar integers. MODE is the mode of the result, + XMODE is the mode of X, and OP_MODE says which of MODE or XMODE + is preferred for simplified versions of X. The other arguments + are as for force_to_mode. */ + +static rtx +force_int_to_mode (rtx x, scalar_int_mode mode, scalar_int_mode xmode, + scalar_int_mode op_mode, unsigned HOST_WIDE_INT mask, + int just_select) +{ + enum rtx_code code = GET_CODE (x); + int next_select = just_select || code == XOR || code == NOT || code == NEG; + unsigned HOST_WIDE_INT fuller_mask; + rtx op0, op1, temp; + + /* When we have an arithmetic operation, or a shift whose count we + do not know, we need to assume that all bits up to the highest-order + bit in MASK will be needed. This is how we form such a mask. */ + if (mask & (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1))) + fuller_mask = HOST_WIDE_INT_M1U; + else + fuller_mask = ((HOST_WIDE_INT_1U << (floor_log2 (mask) + 1)) + - 1); switch (code) { @@ -8625,14 +8650,14 @@ force_to_mode (rtx x, machine_mode mode, { x = simplify_and_const_int (x, op_mode, XEXP (x, 0), mask & INTVAL (XEXP (x, 1))); + xmode = op_mode; /* If X is still an AND, see if it is an AND with a mask that is just some low-order bits. If so, and it is MASK, we don't need it. */ if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)) - && ((INTVAL (XEXP (x, 1)) & GET_MODE_MASK (GET_MODE (x))) - == mask)) + && (INTVAL (XEXP (x, 1)) & GET_MODE_MASK (xmode)) == mask) x = XEXP (x, 0); /* If it remains an AND, try making another AND with the bits @@ -8641,18 +8666,17 @@ force_to_mode (rtx x, machine_mode mode, cheaper constant. */ if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)) - && GET_MODE_MASK (GET_MODE (x)) != mask - && HWI_COMPUTABLE_MODE_P (GET_MODE (x))) + && GET_MODE_MASK (xmode) != mask + && HWI_COMPUTABLE_MODE_P (xmode)) { unsigned HOST_WIDE_INT cval - = UINTVAL (XEXP (x, 1)) - | (GET_MODE_MASK (GET_MODE (x)) & ~mask); + = UINTVAL (XEXP (x, 1)) | (GET_MODE_MASK (xmode) & ~mask); rtx y; - y = simplify_gen_binary (AND, GET_MODE (x), XEXP (x, 0), - gen_int_mode (cval, GET_MODE (x))); - if (set_src_cost (y, GET_MODE (x), optimize_this_for_speed_p) - < set_src_cost (x, GET_MODE (x), optimize_this_for_speed_p)) + y = simplify_gen_binary (AND, xmode, XEXP (x, 0), + gen_int_mode (cval, xmode)); + if (set_src_cost (y, xmode, optimize_this_for_speed_p) + < set_src_cost (x, xmode, optimize_this_for_speed_p)) x = y; } @@ -8682,7 +8706,7 @@ force_to_mode (rtx x, machine_mode mode, && pow2p_hwi (- smask) && (nonzero_bits (XEXP (x, 0), mode) & ~smask) == 0 && (INTVAL (XEXP (x, 1)) & ~smask) != 0) - return force_to_mode (plus_constant (GET_MODE (x), XEXP (x, 0), + return force_to_mode (plus_constant (xmode, XEXP (x, 0), (INTVAL (XEXP (x, 1)) & smask)), mode, smask, next_select); } @@ -8713,8 +8737,7 @@ force_to_mode (rtx x, machine_mode mode, if (CONST_INT_P (XEXP (x, 0)) && least_bit_hwi (UINTVAL (XEXP (x, 0))) > mask) { - x = simplify_gen_unary (NEG, GET_MODE (x), XEXP (x, 1), - GET_MODE (x)); + x = simplify_gen_unary (NEG, xmode, XEXP (x, 1), xmode); return force_to_mode (x, mode, mask, next_select); } @@ -8723,8 +8746,7 @@ force_to_mode (rtx x, machine_mode mode, if (CONST_INT_P (XEXP (x, 0)) && ((UINTVAL (XEXP (x, 0)) | fuller_mask) == UINTVAL (XEXP (x, 0)))) { - x = simplify_gen_unary (NOT, GET_MODE (x), - XEXP (x, 1), GET_MODE (x)); + x = simplify_gen_unary (NOT, xmode, XEXP (x, 1), xmode); return force_to_mode (x, mode, mask, next_select); } @@ -8745,16 +8767,16 @@ force_to_mode (rtx x, machine_mode mode, && CONST_INT_P (XEXP (x, 1)) && ((INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (INTVAL (XEXP (x, 1)))) - < GET_MODE_PRECISION (GET_MODE (x))) + < GET_MODE_PRECISION (xmode)) && (UINTVAL (XEXP (x, 1)) - & ~nonzero_bits (XEXP (x, 0), GET_MODE (x))) == 0) + & ~nonzero_bits (XEXP (x, 0), xmode)) == 0) { temp = gen_int_mode ((INTVAL (XEXP (x, 1)) & mask) << INTVAL (XEXP (XEXP (x, 0), 1)), - GET_MODE (x)); - temp = simplify_gen_binary (GET_CODE (x), GET_MODE (x), + xmode); + temp = simplify_gen_binary (GET_CODE (x), xmode, XEXP (XEXP (x, 0), 0), temp); - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), temp, + x = simplify_gen_binary (LSHIFTRT, xmode, temp, XEXP (XEXP (x, 0), 1)); return force_to_mode (x, mode, mask, next_select); } @@ -8778,8 +8800,11 @@ force_to_mode (rtx x, machine_mode mode, op0 = gen_lowpart_or_truncate (op_mode, op0); op1 = gen_lowpart_or_truncate (op_mode, op1); - if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0) || op1 != XEXP (x, 1)) - x = simplify_gen_binary (code, op_mode, op0, op1); + if (op_mode != xmode || op0 != XEXP (x, 0) || op1 != XEXP (x, 1)) + { + x = simplify_gen_binary (code, op_mode, op0, op1); + xmode = op_mode; + } break; case ASHIFT: @@ -8812,8 +8837,11 @@ force_to_mode (rtx x, machine_mode mode, force_to_mode (XEXP (x, 0), op_mode, mask, next_select)); - if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0)) - x = simplify_gen_binary (code, op_mode, op0, XEXP (x, 1)); + if (op_mode != xmode || op0 != XEXP (x, 0)) + { + x = simplify_gen_binary (code, op_mode, op0, XEXP (x, 1)); + xmode = op_mode; + } break; case LSHIFTRT: @@ -8835,13 +8863,16 @@ force_to_mode (rtx x, machine_mode mode, /* We can only change the mode of the shift if we can do arithmetic in the mode of the shift and INNER_MASK is no wider than the width of X's mode. */ - if ((inner_mask & ~GET_MODE_MASK (GET_MODE (x))) != 0) - op_mode = GET_MODE (x); + if ((inner_mask & ~GET_MODE_MASK (xmode)) != 0) + op_mode = xmode; inner = force_to_mode (inner, op_mode, inner_mask, next_select); - if (GET_MODE (x) != op_mode || inner != XEXP (x, 0)) - x = simplify_gen_binary (LSHIFTRT, op_mode, inner, XEXP (x, 1)); + if (xmode != op_mode || inner != XEXP (x, 0)) + { + x = simplify_gen_binary (LSHIFTRT, op_mode, inner, XEXP (x, 1)); + xmode = op_mode; + } } /* If we have (and (lshiftrt FOO C1) C2) where the combination of the @@ -8854,17 +8885,17 @@ force_to_mode (rtx x, machine_mode mode, bit. */ && ((INTVAL (XEXP (x, 1)) + num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))) - >= GET_MODE_PRECISION (GET_MODE (x))) + >= GET_MODE_PRECISION (xmode)) && pow2p_hwi (mask + 1) /* Number of bits left after the shift must be more than the mask needs. */ && ((INTVAL (XEXP (x, 1)) + exact_log2 (mask + 1)) - <= GET_MODE_PRECISION (GET_MODE (x))) + <= GET_MODE_PRECISION (xmode)) /* Must be more sign bit copies than the mask needs. */ && ((int) num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0))) >= exact_log2 (mask + 1))) - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), XEXP (x, 0), - GEN_INT (GET_MODE_PRECISION (GET_MODE (x)) + x = simplify_gen_binary (LSHIFTRT, xmode, XEXP (x, 0), + GEN_INT (GET_MODE_PRECISION (xmode) - exact_log2 (mask + 1))); goto shiftrt; @@ -8872,7 +8903,7 @@ force_to_mode (rtx x, machine_mode mode, case ASHIFTRT: /* If we are just looking for the sign bit, we don't need this shift at all, even if it has a variable count. */ - if (val_signbit_p (GET_MODE (x), mask)) + if (val_signbit_p (xmode, mask)) return force_to_mode (XEXP (x, 0), mode, mask, next_select); /* If this is a shift by a constant, get a mask that contains those bits @@ -8885,13 +8916,14 @@ force_to_mode (rtx x, machine_mode mode, if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0 && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT) { + unsigned HOST_WIDE_INT nonzero; int i; /* If the considered data is wider than HOST_WIDE_INT, we can't represent a mask for all its bits in a single scalar. But we only care about the lower bits, so calculate these. */ - if (GET_MODE_PRECISION (GET_MODE (x)) > HOST_BITS_PER_WIDE_INT) + if (GET_MODE_PRECISION (xmode) > HOST_BITS_PER_WIDE_INT) { nonzero = HOST_WIDE_INT_M1U; @@ -8900,21 +8932,21 @@ force_to_mode (rtx x, machine_mode mode, We need only shift if these are fewer than nonzero can hold. If not, we must keep all bits set in nonzero. */ - if (GET_MODE_PRECISION (GET_MODE (x)) - INTVAL (XEXP (x, 1)) + if (GET_MODE_PRECISION (xmode) - INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT) nonzero >>= INTVAL (XEXP (x, 1)) + HOST_BITS_PER_WIDE_INT - - GET_MODE_PRECISION (GET_MODE (x)) ; + - GET_MODE_PRECISION (xmode); } else { - nonzero = GET_MODE_MASK (GET_MODE (x)); + nonzero = GET_MODE_MASK (xmode); nonzero >>= INTVAL (XEXP (x, 1)); } if ((mask & ~nonzero) == 0) { - x = simplify_shift_const (NULL_RTX, LSHIFTRT, GET_MODE (x), + x = simplify_shift_const (NULL_RTX, LSHIFTRT, xmode, XEXP (x, 0), INTVAL (XEXP (x, 1))); if (GET_CODE (x) != ASHIFTRT) return force_to_mode (x, mode, mask, next_select); @@ -8923,8 +8955,8 @@ force_to_mode (rtx x, machine_mode mode, else if ((i = exact_log2 (mask)) >= 0) { x = simplify_shift_const - (NULL_RTX, LSHIFTRT, GET_MODE (x), XEXP (x, 0), - GET_MODE_PRECISION (GET_MODE (x)) - 1 - i); + (NULL_RTX, LSHIFTRT, xmode, XEXP (x, 0), + GET_MODE_PRECISION (xmode) - 1 - i); if (GET_CODE (x) != ASHIFTRT) return force_to_mode (x, mode, mask, next_select); @@ -8934,8 +8966,7 @@ force_to_mode (rtx x, machine_mode mode, /* If MASK is 1, convert this to an LSHIFTRT. This can be done even if the shift count isn't a constant. */ if (mask == 1) - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), - XEXP (x, 0), XEXP (x, 1)); + x = simplify_gen_binary (LSHIFTRT, xmode, XEXP (x, 0), XEXP (x, 1)); shiftrt: @@ -8947,7 +8978,7 @@ force_to_mode (rtx x, machine_mode mode, && CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0 && (INTVAL (XEXP (x, 1)) - <= GET_MODE_PRECISION (GET_MODE (x)) - (floor_log2 (mask) + 1)) + <= GET_MODE_PRECISION (xmode) - (floor_log2 (mask) + 1)) && GET_CODE (XEXP (x, 0)) == ASHIFT && XEXP (XEXP (x, 0), 1) == XEXP (x, 1)) return force_to_mode (XEXP (XEXP (x, 0), 0), mode, mask, @@ -8965,12 +8996,11 @@ force_to_mode (rtx x, machine_mode mode, && INTVAL (XEXP (x, 1)) >= 0) { temp = simplify_binary_operation (code == ROTATE ? ROTATERT : ROTATE, - GET_MODE (x), - gen_int_mode (mask, GET_MODE (x)), + xmode, gen_int_mode (mask, xmode), XEXP (x, 1)); if (temp && CONST_INT_P (temp)) - x = simplify_gen_binary (code, GET_MODE (x), - force_to_mode (XEXP (x, 0), GET_MODE (x), + x = simplify_gen_binary (code, xmode, + force_to_mode (XEXP (x, 0), xmode, INTVAL (temp), next_select), XEXP (x, 1)); } @@ -8997,14 +9027,12 @@ force_to_mode (rtx x, machine_mode mode, && CONST_INT_P (XEXP (XEXP (x, 0), 1)) && INTVAL (XEXP (XEXP (x, 0), 1)) >= 0 && (INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (mask) - < GET_MODE_PRECISION (GET_MODE (x))) + < GET_MODE_PRECISION (xmode)) && INTVAL (XEXP (XEXP (x, 0), 1)) < HOST_BITS_PER_WIDE_INT) { - temp = gen_int_mode (mask << INTVAL (XEXP (XEXP (x, 0), 1)), - GET_MODE (x)); - temp = simplify_gen_binary (XOR, GET_MODE (x), - XEXP (XEXP (x, 0), 0), temp); - x = simplify_gen_binary (LSHIFTRT, GET_MODE (x), + temp = gen_int_mode (mask << INTVAL (XEXP (XEXP (x, 0), 1)), xmode); + temp = simplify_gen_binary (XOR, xmode, XEXP (XEXP (x, 0), 0), temp); + x = simplify_gen_binary (LSHIFTRT, xmode, temp, XEXP (XEXP (x, 0), 1)); return force_to_mode (x, mode, mask, next_select); @@ -9018,8 +9046,11 @@ force_to_mode (rtx x, machine_mode mode, op0 = gen_lowpart_or_truncate (op_mode, force_to_mode (XEXP (x, 0), mode, mask, next_select)); - if (op_mode != GET_MODE (x) || op0 != XEXP (x, 0)) - x = simplify_gen_unary (code, op_mode, op0, op_mode); + if (op_mode != xmode || op0 != XEXP (x, 0)) + { + x = simplify_gen_unary (code, op_mode, op0, op_mode); + xmode = op_mode; + } break; case NE: @@ -9040,14 +9071,14 @@ force_to_mode (rtx x, machine_mode mode, /* We have no way of knowing if the IF_THEN_ELSE can itself be written in a narrower mode. We play it safe and do not do so. */ - op0 = gen_lowpart_or_truncate (GET_MODE (x), + op0 = gen_lowpart_or_truncate (xmode, force_to_mode (XEXP (x, 1), mode, mask, next_select)); - op1 = gen_lowpart_or_truncate (GET_MODE (x), + op1 = gen_lowpart_or_truncate (xmode, force_to_mode (XEXP (x, 2), mode, mask, next_select)); if (op0 != XEXP (x, 1) || op1 != XEXP (x, 2)) - x = simplify_gen_ternary (IF_THEN_ELSE, GET_MODE (x), + x = simplify_gen_ternary (IF_THEN_ELSE, xmode, GET_MODE (XEXP (x, 0)), XEXP (x, 0), op0, op1); break; From patchwork Thu Jul 13 08:53:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107628 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1935954qge; Thu, 13 Jul 2017 01:54:49 -0700 (PDT) X-Received: by 10.99.168.5 with SMTP id o5mr7935802pgf.207.1499936089404; Thu, 13 Jul 2017 01:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936089; cv=none; d=google.com; s=arc-20160816; b=J6LGG6MOaeOpi4g5UMlp0n6+fJhFckjhuDvfxKq6YCi7PXByO5TVbRTL0c9nE9VHb6 Z+JlZh2GFvpglyPbSfDbwzLWirEOu8sGwYFjtZdWJRlB5C6S0bYAWkMDV9qPFiEWwtpu WoBHFHlelwY9FT2mIEzn/EPrUvkfnWqWEo2XYSeZztqD8UggKNF4t3dpewaO4hPzJv8y QF593IJ+idvSPsDM2ToJAlleHDwcwD2d/xIIhBhi7i+Cfv5DmRDwnspFhr7hudyqp1HM erToYHhRmYPZ+gKozWUtwMY20G9gG0brSvwkZ00EFkb+q3rEmLwkoWZnjuCfuHCBZkcW TsgQ== 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=NtcrsbW3VUU0R2dNpnV7UH3oQwsBHzLhzYCOntmwOsY=; b=DX7q15Y21OUGJI1zEyQGp9nTrxI/OyaYuAQbGgvFHhOCSpeKSStSStqJAQWVi08yPL Cy3hr7flvGgbenOSuhZX0JYcadkngqp4IjBRZZh/QMySR0A6xRVVezNtN4ONsfKbCqmO wzeQkhC4LEwcwq55l0dJo/DiIdzSPljMteROKSvjbqnSewae8wCnD/hWRUkn3AYGkcvx 1txFJtaXJybUyhNRFGVRyA0lPU5fq6Qki53x0B7qGE0luHed8MVnKa9Gmn8yiZViFnyD DZzLqMpdBjF7ovAJuIzpcBV5dB3beeDyqoz5wN28iGHGBe9NCib0K+5iJvOXlZcfB0T4 +9Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=NR1pOoV4; spf=pass (google.com: domain of gcc-patches-return-458033-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458033-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 e21si3740374pfh.275.2017.07.13.01.54.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:54:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458033-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=NR1pOoV4; spf=pass (google.com: domain of gcc-patches-return-458033-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458033-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=JigQlH2dp9Orgb15C0FvFSKItuSNc T3FFFOn4X9+NitYYe3ZQW9CkRW2omD4kPhuokJy/K0BwJUqh7Vs8YR7lV1IkfksR QtO+J1dYvup5C2db+Jts4Co9mrBiq23A5/6dHSZU92xFqcMA2GYgsAPWeYqCUq8/ a71of87KWuuVzo= 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=N/pFhtSOY8Icjn37Ft0B9nIIaiM=; b=NR1 pOoV4GL6rujzOSrWRh5ovh+RIpQ1h98wcvqopKlcXTEklbQngWFV5RrYjVNdQh8f 2lRDT42IXnnvoew6KmKVrnu7mnbPbD27M5o5F6aHe/7cFld2sTlsrKAieB1u3wQc lLhPuZ0jZiLuDTyWg1IkgRLMFaMrk1Nv/lqYu+d4= Received: (qmail 123551 invoked by alias); 13 Jul 2017 08:53:42 -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 123039 invoked by uid 89); 13 Jul 2017 08:53:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:53:34 +0000 Received: by mail-wm0-f45.google.com with SMTP id f67so18336043wmh.1 for ; Thu, 13 Jul 2017 01:53:33 -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=NtcrsbW3VUU0R2dNpnV7UH3oQwsBHzLhzYCOntmwOsY=; b=BLK3jWDhiz8D/HSH6UdA16+T4vc7nIU1X46BYymcZ4s11uPfYPHf/H+GWd3ulDz+h0 xp34c2kEMwTO9xvY4ptsiN4NAHnTE70bZ8+aZw9a2Db5hjrINmpaCHHBaP58njWT+JHb ECOLh/1G5sf09b1TgmxQVaRch9XuRzJRxYPDF0AiiWOkERk5agw8YxqcV3Irw00ET1Xl ICKQoNN9EV8TNO8SZp7jX60EK9OXp6HQOoZ9+0aQkaQ70ZApgQ9XynOkMa2OWqVn4xfQ lv36X2RHFA8l6E/O1zqHFW7D3JJEyY0ZrlrUAEq+dWwVVdhTUmC1WwXznuVD2tn1d/LE 6Ttg== X-Gm-Message-State: AIVw112YulrNnI8NSVt7KrrDlUzSg12nWkbWTwU4KKEgrUCmOi0AjSK6 d6wt/LwcbVRMMoHbDc0sOA== X-Received: by 10.28.15.135 with SMTP id 129mr1250460wmp.38.1499936011138; Thu, 13 Jul 2017 01:53:31 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id a31sm6494363wrc.64.2017.07.13.01.53.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:53:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [42/77] Use scalar_int_mode in simplify_shift_const_1 References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:53:28 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <874lughg53.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes simplify_shift_const_1 use scalar_int_modes for all code that is specific to scalars rather than vectors. This includes situations in which the new shift mode is different from the original one, since the function never changes the mode of vector shifts. That in turn makes it more natural to test for equal modes in simplify_shift_const_1 rather than try_widen_shift_mode (which only applies to scalars). 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (try_widen_shift_mode): Move check for equal modes to... (simplify_shift_const_1): ...here. Use scalar_int_mode for shift_unit_mode and for modes involved in scalar shifts. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:42.622481204 +0100 +++ gcc/combine.c 2017-07-13 09:18:43.037447143 +0100 @@ -10343,8 +10343,6 @@ try_widen_shift_mode (enum rtx_code code machine_mode orig_mode, machine_mode mode, enum rtx_code outer_code, HOST_WIDE_INT outer_const) { - if (orig_mode == mode) - return mode; gcc_assert (GET_MODE_PRECISION (mode) > GET_MODE_PRECISION (orig_mode)); /* In general we can't perform in wider mode for right shift and rotate. */ @@ -10405,7 +10403,7 @@ simplify_shift_const_1 (enum rtx_code co int count; machine_mode mode = result_mode; machine_mode shift_mode; - scalar_int_mode tmode, inner_mode; + scalar_int_mode tmode, inner_mode, int_mode, int_varop_mode, int_result_mode; unsigned int mode_words = (GET_MODE_SIZE (mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD; /* We form (outer_op (code varop count) (outer_const)). */ @@ -10445,9 +10443,19 @@ simplify_shift_const_1 (enum rtx_code co count = bitsize - count; } - shift_mode = try_widen_shift_mode (code, varop, count, result_mode, - mode, outer_op, outer_const); - machine_mode shift_unit_mode = GET_MODE_INNER (shift_mode); + shift_mode = result_mode; + if (shift_mode != mode) + { + /* We only change the modes of scalar shifts. */ + int_mode = as_a (mode); + int_result_mode = as_a (result_mode); + shift_mode = try_widen_shift_mode (code, varop, count, + int_result_mode, int_mode, + outer_op, outer_const); + } + + scalar_int_mode shift_unit_mode + = as_a (GET_MODE_INNER (shift_mode)); /* Handle cases where the count is greater than the size of the mode minus 1. For ASHIFT, use the size minus one as the count (this can @@ -10542,6 +10550,7 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_mode = as_a (mode); /* If we have (xshiftrt (mem ...) C) and C is MODE_WIDTH minus the width of a smaller mode, we can do this with a @@ -10550,15 +10559,15 @@ simplify_shift_const_1 (enum rtx_code co && ! mode_dependent_address_p (XEXP (varop, 0), MEM_ADDR_SPACE (varop)) && ! MEM_VOLATILE_P (varop) - && (int_mode_for_size (GET_MODE_BITSIZE (mode) - count, 1) + && (int_mode_for_size (GET_MODE_BITSIZE (int_mode) - count, 1) .exists (&tmode))) { new_rtx = adjust_address_nv (varop, tmode, - BYTES_BIG_ENDIAN ? 0 - : count / BITS_PER_UNIT); + BYTES_BIG_ENDIAN ? 0 + : count / BITS_PER_UNIT); varop = gen_rtx_fmt_e (code == ASHIFTRT ? SIGN_EXTEND - : ZERO_EXTEND, mode, new_rtx); + : ZERO_EXTEND, int_mode, new_rtx); count = 0; continue; } @@ -10568,20 +10577,22 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_mode = as_a (mode); + int_varop_mode = as_a (GET_MODE (varop)); /* If VAROP is a SUBREG, strip it as long as the inner operand has the same number of words as what we've seen so far. Then store the widest mode in MODE. */ if (subreg_lowpart_p (varop) && is_int_mode (GET_MODE (SUBREG_REG (varop)), &inner_mode) - && GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (GET_MODE (varop)) + && GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (int_varop_mode) && (unsigned int) ((GET_MODE_SIZE (inner_mode) + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD) == mode_words - && GET_MODE_CLASS (GET_MODE (varop)) == MODE_INT) + && GET_MODE_CLASS (int_varop_mode) == MODE_INT) { varop = SUBREG_REG (varop); - if (GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (mode)) + if (GET_MODE_SIZE (inner_mode) > GET_MODE_SIZE (int_mode)) mode = inner_mode; continue; } @@ -10640,14 +10651,17 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_mode = as_a (mode); + int_varop_mode = as_a (GET_MODE (varop)); + int_result_mode = as_a (result_mode); /* Here we have two nested shifts. The result is usually the AND of a new shift with a mask. We compute the result below. */ if (CONST_INT_P (XEXP (varop, 1)) && INTVAL (XEXP (varop, 1)) >= 0 - && INTVAL (XEXP (varop, 1)) < GET_MODE_PRECISION (GET_MODE (varop)) - && HWI_COMPUTABLE_MODE_P (result_mode) - && HWI_COMPUTABLE_MODE_P (mode)) + && INTVAL (XEXP (varop, 1)) < GET_MODE_PRECISION (int_varop_mode) + && HWI_COMPUTABLE_MODE_P (int_result_mode) + && HWI_COMPUTABLE_MODE_P (int_mode)) { enum rtx_code first_code = GET_CODE (varop); unsigned int first_count = INTVAL (XEXP (varop, 1)); @@ -10662,18 +10676,18 @@ simplify_shift_const_1 (enum rtx_code co (ashiftrt:M1 (ashift:M1 (and:M1 (subreg:M1 FOO 0) C3) C2) C1). This simplifies certain SIGN_EXTEND operations. */ if (code == ASHIFT && first_code == ASHIFTRT - && count == (GET_MODE_PRECISION (result_mode) - - GET_MODE_PRECISION (GET_MODE (varop)))) + && count == (GET_MODE_PRECISION (int_result_mode) + - GET_MODE_PRECISION (int_varop_mode))) { /* C3 has the low-order C1 bits zero. */ - mask = GET_MODE_MASK (mode) + mask = GET_MODE_MASK (int_mode) & ~((HOST_WIDE_INT_1U << first_count) - 1); - varop = simplify_and_const_int (NULL_RTX, result_mode, + varop = simplify_and_const_int (NULL_RTX, int_result_mode, XEXP (varop, 0), mask); - varop = simplify_shift_const (NULL_RTX, ASHIFT, result_mode, - varop, count); + varop = simplify_shift_const (NULL_RTX, ASHIFT, + int_result_mode, varop, count); count = first_count; code = ASHIFTRT; continue; @@ -10684,11 +10698,11 @@ simplify_shift_const_1 (enum rtx_code co this to either an ASHIFT or an ASHIFTRT depending on the two counts. - We cannot do this if VAROP's mode is not SHIFT_MODE. */ + We cannot do this if VAROP's mode is not SHIFT_UNIT_MODE. */ if (code == ASHIFTRT && first_code == ASHIFT - && GET_MODE (varop) == shift_mode - && (num_sign_bit_copies (XEXP (varop, 0), shift_mode) + && int_varop_mode == shift_unit_mode + && (num_sign_bit_copies (XEXP (varop, 0), shift_unit_mode) > first_count)) { varop = XEXP (varop, 0); @@ -10719,7 +10733,7 @@ simplify_shift_const_1 (enum rtx_code co if (code == first_code) { - if (GET_MODE (varop) != result_mode + if (int_varop_mode != int_result_mode && (code == ASHIFTRT || code == LSHIFTRT || code == ROTATE)) break; @@ -10731,8 +10745,8 @@ simplify_shift_const_1 (enum rtx_code co if (code == ASHIFTRT || (code == ROTATE && first_code == ASHIFTRT) - || GET_MODE_PRECISION (mode) > HOST_BITS_PER_WIDE_INT - || (GET_MODE (varop) != result_mode + || GET_MODE_PRECISION (int_mode) > HOST_BITS_PER_WIDE_INT + || (int_varop_mode != int_result_mode && (first_code == ASHIFTRT || first_code == LSHIFTRT || first_code == ROTATE || code == ROTATE))) @@ -10742,19 +10756,19 @@ simplify_shift_const_1 (enum rtx_code co nonzero bits of the inner shift the same way the outer shift will. */ - mask_rtx = gen_int_mode (nonzero_bits (varop, GET_MODE (varop)), - result_mode); + mask_rtx = gen_int_mode (nonzero_bits (varop, int_varop_mode), + int_result_mode); mask_rtx - = simplify_const_binary_operation (code, result_mode, mask_rtx, - GEN_INT (count)); + = simplify_const_binary_operation (code, int_result_mode, + mask_rtx, GEN_INT (count)); /* Give up if we can't compute an outer operation to use. */ if (mask_rtx == 0 || !CONST_INT_P (mask_rtx) || ! merge_outer_ops (&outer_op, &outer_const, AND, INTVAL (mask_rtx), - result_mode, &complement_p)) + int_result_mode, &complement_p)) break; /* If the shifts are in the same direction, we add the @@ -10791,22 +10805,22 @@ simplify_shift_const_1 (enum rtx_code co /* For ((unsigned) (cstULL >> count)) >> cst2 we have to make sure the result will be masked. See PR70222. */ if (code == LSHIFTRT - && mode != result_mode + && int_mode != int_result_mode && !merge_outer_ops (&outer_op, &outer_const, AND, - GET_MODE_MASK (result_mode) - >> orig_count, result_mode, + GET_MODE_MASK (int_result_mode) + >> orig_count, int_result_mode, &complement_p)) break; /* For ((int) (cstLL >> count)) >> cst2 just give up. Queuing up outer sign extension (often left and right shift) is hardly more efficient than the original. See PR70429. */ - if (code == ASHIFTRT && mode != result_mode) + if (code == ASHIFTRT && int_mode != int_result_mode) break; - rtx new_rtx = simplify_const_binary_operation (code, mode, + rtx new_rtx = simplify_const_binary_operation (code, int_mode, XEXP (varop, 0), GEN_INT (count)); - varop = gen_rtx_fmt_ee (code, mode, new_rtx, XEXP (varop, 1)); + varop = gen_rtx_fmt_ee (code, int_mode, new_rtx, XEXP (varop, 1)); count = 0; continue; } @@ -10827,6 +10841,8 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_varop_mode = as_a (GET_MODE (varop)); + int_result_mode = as_a (result_mode); /* If we have (xshiftrt (ior (plus X (const_int -1)) X) C) with C the size of VAROP - 1 and the shift is logical if @@ -10839,15 +10855,15 @@ simplify_shift_const_1 (enum rtx_code co && XEXP (XEXP (varop, 0), 1) == constm1_rtx && (STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1) && (code == LSHIFTRT || code == ASHIFTRT) - && count == (GET_MODE_PRECISION (GET_MODE (varop)) - 1) + && count == (GET_MODE_PRECISION (int_varop_mode) - 1) && rtx_equal_p (XEXP (XEXP (varop, 0), 0), XEXP (varop, 1))) { count = 0; - varop = gen_rtx_LE (GET_MODE (varop), XEXP (varop, 1), + varop = gen_rtx_LE (int_varop_mode, XEXP (varop, 1), const0_rtx); if (STORE_FLAG_VALUE == 1 ? code == ASHIFTRT : code == LSHIFTRT) - varop = gen_rtx_NEG (GET_MODE (varop), varop); + varop = gen_rtx_NEG (int_varop_mode, varop); continue; } @@ -10860,19 +10876,20 @@ simplify_shift_const_1 (enum rtx_code co if (CONST_INT_P (XEXP (varop, 1)) /* We can't do this if we have (ashiftrt (xor)) and the - constant has its sign bit set in shift_mode with shift_mode - wider than result_mode. */ + constant has its sign bit set in shift_unit_mode with + shift_unit_mode wider than result_mode. */ && !(code == ASHIFTRT && GET_CODE (varop) == XOR - && result_mode != shift_mode + && int_result_mode != shift_unit_mode && 0 > trunc_int_for_mode (INTVAL (XEXP (varop, 1)), - shift_mode)) + shift_unit_mode)) && (new_rtx = simplify_const_binary_operation - (code, result_mode, - gen_int_mode (INTVAL (XEXP (varop, 1)), result_mode), + (code, int_result_mode, + gen_int_mode (INTVAL (XEXP (varop, 1)), int_result_mode), GEN_INT (count))) != 0 && CONST_INT_P (new_rtx) && merge_outer_ops (&outer_op, &outer_const, GET_CODE (varop), - INTVAL (new_rtx), result_mode, &complement_p)) + INTVAL (new_rtx), int_result_mode, + &complement_p)) { varop = XEXP (varop, 0); continue; @@ -10885,16 +10902,16 @@ simplify_shift_const_1 (enum rtx_code co changes the sign bit. */ if (CONST_INT_P (XEXP (varop, 1)) && !(code == ASHIFTRT && GET_CODE (varop) == XOR - && result_mode != shift_mode + && int_result_mode != shift_unit_mode && 0 > trunc_int_for_mode (INTVAL (XEXP (varop, 1)), - shift_mode))) + shift_unit_mode))) { - rtx lhs = simplify_shift_const (NULL_RTX, code, shift_mode, + rtx lhs = simplify_shift_const (NULL_RTX, code, shift_unit_mode, XEXP (varop, 0), count); - rtx rhs = simplify_shift_const (NULL_RTX, code, shift_mode, + rtx rhs = simplify_shift_const (NULL_RTX, code, shift_unit_mode, XEXP (varop, 1), count); - varop = simplify_gen_binary (GET_CODE (varop), shift_mode, + varop = simplify_gen_binary (GET_CODE (varop), shift_unit_mode, lhs, rhs); varop = apply_distributive_law (varop); @@ -10907,6 +10924,7 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_result_mode = as_a (result_mode); /* Convert (lshiftrt (eq FOO 0) C) to (xor FOO 1) if STORE_FLAG_VALUE says that the sign bit can be tested, FOO has mode MODE, C is @@ -10914,13 +10932,13 @@ simplify_shift_const_1 (enum rtx_code co that may be nonzero. */ if (code == LSHIFTRT && XEXP (varop, 1) == const0_rtx - && GET_MODE (XEXP (varop, 0)) == result_mode - && count == (GET_MODE_PRECISION (result_mode) - 1) - && HWI_COMPUTABLE_MODE_P (result_mode) + && GET_MODE (XEXP (varop, 0)) == int_result_mode + && count == (GET_MODE_PRECISION (int_result_mode) - 1) + && HWI_COMPUTABLE_MODE_P (int_result_mode) && STORE_FLAG_VALUE == -1 - && nonzero_bits (XEXP (varop, 0), result_mode) == 1 - && merge_outer_ops (&outer_op, &outer_const, XOR, 1, result_mode, - &complement_p)) + && nonzero_bits (XEXP (varop, 0), int_result_mode) == 1 + && merge_outer_ops (&outer_op, &outer_const, XOR, 1, + int_result_mode, &complement_p)) { varop = XEXP (varop, 0); count = 0; @@ -10932,12 +10950,13 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_result_mode = as_a (result_mode); /* (lshiftrt (neg A) C) where A is either 0 or 1 and C is one less than the number of bits in the mode is equivalent to A. */ if (code == LSHIFTRT - && count == (GET_MODE_PRECISION (result_mode) - 1) - && nonzero_bits (XEXP (varop, 0), result_mode) == 1) + && count == (GET_MODE_PRECISION (int_result_mode) - 1) + && nonzero_bits (XEXP (varop, 0), int_result_mode) == 1) { varop = XEXP (varop, 0); count = 0; @@ -10947,8 +10966,8 @@ simplify_shift_const_1 (enum rtx_code co /* NEG commutes with ASHIFT since it is multiplication. Move the NEG outside to allow shifts to combine. */ if (code == ASHIFT - && merge_outer_ops (&outer_op, &outer_const, NEG, 0, result_mode, - &complement_p)) + && merge_outer_ops (&outer_op, &outer_const, NEG, 0, + int_result_mode, &complement_p)) { varop = XEXP (varop, 0); continue; @@ -10959,16 +10978,17 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_result_mode = as_a (result_mode); /* (lshiftrt (plus A -1) C) where A is either 0 or 1 and C is one less than the number of bits in the mode is equivalent to (xor A 1). */ if (code == LSHIFTRT - && count == (GET_MODE_PRECISION (result_mode) - 1) + && count == (GET_MODE_PRECISION (int_result_mode) - 1) && XEXP (varop, 1) == constm1_rtx - && nonzero_bits (XEXP (varop, 0), result_mode) == 1 - && merge_outer_ops (&outer_op, &outer_const, XOR, 1, result_mode, - &complement_p)) + && nonzero_bits (XEXP (varop, 0), int_result_mode) == 1 + && merge_outer_ops (&outer_op, &outer_const, XOR, 1, + int_result_mode, &complement_p)) { count = 0; varop = XEXP (varop, 0); @@ -10983,21 +11003,20 @@ simplify_shift_const_1 (enum rtx_code co if ((code == ASHIFTRT || code == LSHIFTRT) && count < HOST_BITS_PER_WIDE_INT - && nonzero_bits (XEXP (varop, 1), result_mode) >> count == 0 - && (nonzero_bits (XEXP (varop, 1), result_mode) - & nonzero_bits (XEXP (varop, 0), result_mode)) == 0) + && nonzero_bits (XEXP (varop, 1), int_result_mode) >> count == 0 + && (nonzero_bits (XEXP (varop, 1), int_result_mode) + & nonzero_bits (XEXP (varop, 0), int_result_mode)) == 0) { varop = XEXP (varop, 0); continue; } else if ((code == ASHIFTRT || code == LSHIFTRT) && count < HOST_BITS_PER_WIDE_INT - && HWI_COMPUTABLE_MODE_P (result_mode) - && 0 == (nonzero_bits (XEXP (varop, 0), result_mode) + && HWI_COMPUTABLE_MODE_P (int_result_mode) + && 0 == (nonzero_bits (XEXP (varop, 0), int_result_mode) >> count) - && 0 == (nonzero_bits (XEXP (varop, 0), result_mode) - & nonzero_bits (XEXP (varop, 1), - result_mode))) + && 0 == (nonzero_bits (XEXP (varop, 0), int_result_mode) + & nonzero_bits (XEXP (varop, 1), int_result_mode))) { varop = XEXP (varop, 1); continue; @@ -11007,12 +11026,13 @@ simplify_shift_const_1 (enum rtx_code co if (code == ASHIFT && CONST_INT_P (XEXP (varop, 1)) && (new_rtx = simplify_const_binary_operation - (ASHIFT, result_mode, - gen_int_mode (INTVAL (XEXP (varop, 1)), result_mode), + (ASHIFT, int_result_mode, + gen_int_mode (INTVAL (XEXP (varop, 1)), int_result_mode), GEN_INT (count))) != 0 && CONST_INT_P (new_rtx) && merge_outer_ops (&outer_op, &outer_const, PLUS, - INTVAL (new_rtx), result_mode, &complement_p)) + INTVAL (new_rtx), int_result_mode, + &complement_p)) { varop = XEXP (varop, 0); continue; @@ -11025,14 +11045,15 @@ simplify_shift_const_1 (enum rtx_code co for reasoning in doing so. */ if (code == LSHIFTRT && CONST_INT_P (XEXP (varop, 1)) - && mode_signbit_p (result_mode, XEXP (varop, 1)) + && mode_signbit_p (int_result_mode, XEXP (varop, 1)) && (new_rtx = simplify_const_binary_operation - (code, result_mode, - gen_int_mode (INTVAL (XEXP (varop, 1)), result_mode), + (code, int_result_mode, + gen_int_mode (INTVAL (XEXP (varop, 1)), int_result_mode), GEN_INT (count))) != 0 && CONST_INT_P (new_rtx) && merge_outer_ops (&outer_op, &outer_const, XOR, - INTVAL (new_rtx), result_mode, &complement_p)) + INTVAL (new_rtx), int_result_mode, + &complement_p)) { varop = XEXP (varop, 0); continue; @@ -11044,6 +11065,7 @@ simplify_shift_const_1 (enum rtx_code co /* The following rules apply only to scalars. */ if (shift_mode != shift_unit_mode) break; + int_varop_mode = as_a (GET_MODE (varop)); /* If we have (xshiftrt (minus (ashiftrt X C)) X) C) with C the size of VAROP - 1 and the shift is logical if @@ -11054,18 +11076,18 @@ simplify_shift_const_1 (enum rtx_code co if ((STORE_FLAG_VALUE == 1 || STORE_FLAG_VALUE == -1) && GET_CODE (XEXP (varop, 0)) == ASHIFTRT - && count == (GET_MODE_PRECISION (GET_MODE (varop)) - 1) + && count == (GET_MODE_PRECISION (int_varop_mode) - 1) && (code == LSHIFTRT || code == ASHIFTRT) && CONST_INT_P (XEXP (XEXP (varop, 0), 1)) && INTVAL (XEXP (XEXP (varop, 0), 1)) == count && rtx_equal_p (XEXP (XEXP (varop, 0), 0), XEXP (varop, 1))) { count = 0; - varop = gen_rtx_GT (GET_MODE (varop), XEXP (varop, 1), + varop = gen_rtx_GT (int_varop_mode, XEXP (varop, 1), const0_rtx); if (STORE_FLAG_VALUE == 1 ? code == ASHIFTRT : code == LSHIFTRT) - varop = gen_rtx_NEG (GET_MODE (varop), varop); + varop = gen_rtx_NEG (int_varop_mode, varop); continue; } @@ -11101,8 +11123,15 @@ simplify_shift_const_1 (enum rtx_code co break; } - shift_mode = try_widen_shift_mode (code, varop, count, result_mode, mode, - outer_op, outer_const); + shift_mode = result_mode; + if (shift_mode != mode) + { + /* We only change the modes of scalar shifts. */ + int_mode = as_a (mode); + int_result_mode = as_a (result_mode); + shift_mode = try_widen_shift_mode (code, varop, count, int_result_mode, + int_mode, outer_op, outer_const); + } /* We have now finished analyzing the shift. The result should be a shift of type CODE with SHIFT_MODE shifting VAROP COUNT places. If @@ -11137,8 +11166,9 @@ simplify_shift_const_1 (enum rtx_code co /* If we were doing an LSHIFTRT in a wider mode than it was originally, turn off all the bits that the shift would have turned off. */ if (orig_code == LSHIFTRT && result_mode != shift_mode) - x = simplify_and_const_int (NULL_RTX, shift_mode, x, - GET_MODE_MASK (result_mode) >> orig_count); + /* We only change the modes of scalar shifts. */ + x = simplify_and_const_int (NULL_RTX, as_a (shift_mode), + x, GET_MODE_MASK (result_mode) >> orig_count); /* Do the remainder of the processing in RESULT_MODE. */ x = gen_lowpart_or_truncate (result_mode, x); @@ -11150,12 +11180,14 @@ simplify_shift_const_1 (enum rtx_code co if (outer_op != UNKNOWN) { + int_result_mode = as_a (result_mode); + if (GET_RTX_CLASS (outer_op) != RTX_UNARY - && GET_MODE_PRECISION (result_mode) < HOST_BITS_PER_WIDE_INT) - outer_const = trunc_int_for_mode (outer_const, result_mode); + && GET_MODE_PRECISION (int_result_mode) < HOST_BITS_PER_WIDE_INT) + outer_const = trunc_int_for_mode (outer_const, int_result_mode); if (outer_op == AND) - x = simplify_and_const_int (NULL_RTX, result_mode, x, outer_const); + x = simplify_and_const_int (NULL_RTX, int_result_mode, x, outer_const); else if (outer_op == SET) { /* This means that we have determined that the result is @@ -11164,9 +11196,9 @@ simplify_shift_const_1 (enum rtx_code co x = GEN_INT (outer_const); } else if (GET_RTX_CLASS (outer_op) == RTX_UNARY) - x = simplify_gen_unary (outer_op, result_mode, x, result_mode); + x = simplify_gen_unary (outer_op, int_result_mode, x, int_result_mode); else - x = simplify_gen_binary (outer_op, result_mode, x, + x = simplify_gen_binary (outer_op, int_result_mode, x, GEN_INT (outer_const)); } From patchwork Thu Jul 13 08:53:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107629 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1936270qge; Thu, 13 Jul 2017 01:55:13 -0700 (PDT) X-Received: by 10.84.175.132 with SMTP id t4mr8906564plb.135.1499936112973; Thu, 13 Jul 2017 01:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936112; cv=none; d=google.com; s=arc-20160816; b=h93JVI7RqL9b2Iv199h/C/vEJL4SRscnVyBec4VPU9bMZuchPk0udr/kg/CjwpMm7q +p+8OSQjr7MsttDkfEKGiva+JsMjCJmmlZqw+JT6XikryDy08JxfFc+pbPsrg/q7F5kp 3mqoYADOMPNXAn/gCvZ2/H1UwKJprtsyuDVYyAwGBdFuXbNshNdwcrsuXuEnz32Kh8jM gSmcD/ZForhlAxlTPz4RA54+kEN2PGLZlD/sAKrIKuQ0LsZRU+AZBrRvtAmDCRDclLxk UnVebGkSIqjLDy8sxnJptKpj8BCsqWJ8jbH6yMHHtH1yWUVVdt9Lcx0PEjBi6iOtgn/4 63HQ== 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=m/gQ0lx2+CiYzdFm04dMSVd45W7RjEXZbBLIGXIEUKE=; b=u5rVis6HyG83Hqs6x6EIvzyVO5d3+f8qFHmhhb+pqHoqTvp5dEZEwuvtNWIBiyjiOU wd4x+CXib/9ZAuJXIzxAgoFtrzYnta86KDXndlZeJD7/iCwKe9fIzUGO3838ruyTb0Up id1mfPFMtN9eJBYGeqtNIVHsXCmFFhl9iI/5gN7PWrtAuJIXTbLLtJhM7P9JNH5IjJo7 z8IsXhk6/5whRSbAy10DI9anB8/tEJmNwVq9KWgy/O/1/CO8f29NCSbx1D85MwlsNiTL zJhIGkj8DZhwQkIqopCIG2NsrzTpjoV8RwDr0cT6PyYj0eoeC4P4AfCA6J2sWcsC/xBG 2dUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=CPNp3k06; spf=pass (google.com: domain of gcc-patches-return-458034-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458034-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 z7si3867101pgr.83.2017.07.13.01.55.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458034-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=CPNp3k06; spf=pass (google.com: domain of gcc-patches-return-458034-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458034-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=PdBfXUg38WUj5oF8RPV5qIh7O4ZHg Ch+n/GL9yGYfwSlwWrbNOnBe72BI7AvUlxWS0jlNs9wSxxodL4QiBTdfTLcALg7F t8QO1sNuPU+7RmezHIJc4cCAAj6zds/vCDcbuCu7iS3HV/oYNfvstzEkD+BEHyEb EmTWU52nxCX1cI= 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=wyspCpWbv/82JSSyaFchYWUfQAE=; b=CPN p3k06J+lQpCwU/FOI+rtmf0tNmb26iNnQDqL4rNyB2NlzKM36DXvt3MR42DVgqMZ G8yjqrgdTvtdRTmxCtlxO9+WnaSyePCEQ+9u1aY5gmNxGOCFhdpO1S4c12YA9MfI l5IgGyJD867zLChjfopy9088H0S3SFYzgSumIsGg= Received: (qmail 11332 invoked by alias); 13 Jul 2017 08:54:00 -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 10590 invoked by uid 89); 13 Jul 2017 08:54:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, 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:53:53 +0000 Received: by mail-wr0-f180.google.com with SMTP id 77so49691668wrb.1 for ; Thu, 13 Jul 2017 01:53:53 -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=m/gQ0lx2+CiYzdFm04dMSVd45W7RjEXZbBLIGXIEUKE=; b=G6mSp6D0qo4whG8sYZnATBGR9IJFvcXFqawzat5DXFP9BrH5U78HEBkx60j0ALXX3s kWRr5643zbSSUkdxV/xZ+QCP/BDv/GIXEtFZaNo7ufaztD1jpt5naHWE7U5nSdP9DLOZ rrc36kjhLywI2DsWQZHDBrnFosjhxufMZydBqsZ6FQXIYjacmQ0BjamY3yItSOSx86j0 A70IHKJujkqGa4GU2HP++nE/I1fYH9Iwap9FJnZhdb2xCxyTVXInZ827nL9k5oHlYVRM HYwQQDyU+1z9i0By2duiAgQT9fltciZGGohQonADtClqmuSQ4sGWyZz4ZDDFOcQgfYDC pgDg== X-Gm-Message-State: AIVw111vHCQKR1uV/U+0vuEs9xB5Eiqr4bc41Fr6y2729Pkibp23zPVs 5AaHQS1U74sOLxPmOs/JXw== X-Received: by 10.223.135.112 with SMTP id 45mr1064813wrz.133.1499936030864; Thu, 13 Jul 2017 01:53:50 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id r132sm4252342wma.27.2017.07.13.01.53.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:53:50 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [43/77] Use scalar_int_mode in simplify_comparison References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:53:48 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87zic8g1k3.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The main loop of simplify_comparison starts with: if (GET_MODE_CLASS (mode) != MODE_INT && ! (mode == VOIDmode && (GET_CODE (op0) == COMPARE || COMPARISON_P (op0)))) break; So VOIDmode is only acceptable when comparing a COMPARE, EQ, NE, etc. operand against a constant. After this, the loop calls simplify_compare_const to: (a) bring the constant op1 closer to 0 where possible and (b) use nonzero_bits and num_sign_bit_copies to get a simpler constant. (a) works for both integer and VOID modes, (b) is specific to integer modes. The loop then has a big switch statement that handles further simplifications. This switch statement checks for COMPARISON_P codes but not for COMPARE. This patch uses scalar_int_mode to make the split between (a) and (b) more explicit. It also takes the COMPARISON_P handling out of the switch statement and does it first, so that the rest of the loop can treat the mode as a scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (simplify_compare_const): Check that the mode is a scalar_int_mode (rather than VOIDmode) before testing its precision. (simplify_comparison): Move COMPARISON_P handling out of the loop and restrict the latter part of the loop to scalar_int_modes. Check is_a before calling HWI_COMPUTABLE_MODE_P and when considering SUBREG_REGs. Use is_int_mode instead of checking GET_MODE_CLASS against MODE_INT. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:43.037447143 +0100 +++ gcc/combine.c 2017-07-13 09:18:43.379419324 +0100 @@ -11662,7 +11662,7 @@ gen_lowpart_for_combine (machine_mode om simplify_compare_const (enum rtx_code code, machine_mode mode, rtx op0, rtx *pop1) { - unsigned int mode_width = GET_MODE_PRECISION (mode); + scalar_int_mode int_mode; HOST_WIDE_INT const_op = INTVAL (*pop1); /* Get the constant we are comparing against and turn off all bits @@ -11677,10 +11677,11 @@ simplify_compare_const (enum rtx_code co if (const_op && (code == EQ || code == NE || code == GE || code == GEU || code == LT || code == LTU) - && mode_width - 1 < HOST_BITS_PER_WIDE_INT - && pow2p_hwi (const_op & GET_MODE_MASK (mode)) - && (nonzero_bits (op0, mode) - == (unsigned HOST_WIDE_INT) (const_op & GET_MODE_MASK (mode)))) + && is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && pow2p_hwi (const_op & GET_MODE_MASK (int_mode)) + && (nonzero_bits (op0, int_mode) + == (unsigned HOST_WIDE_INT) (const_op & GET_MODE_MASK (int_mode)))) { code = (code == EQ || code == GE || code == GEU ? NE : EQ); const_op = 0; @@ -11691,7 +11692,8 @@ simplify_compare_const (enum rtx_code co if (const_op == -1 && (code == EQ || code == NE || code == GT || code == LE || code == GEU || code == LTU) - && num_sign_bit_copies (op0, mode) == mode_width) + && is_a (mode, &int_mode) + && num_sign_bit_copies (op0, int_mode) == GET_MODE_PRECISION (int_mode)) { code = (code == EQ || code == LE || code == GEU ? NE : EQ); const_op = 0; @@ -11725,9 +11727,10 @@ simplify_compare_const (enum rtx_code co /* If we are doing a <= 0 comparison on a value known to have a zero sign bit, we can replace this with == 0. */ else if (const_op == 0 - && mode_width - 1 < HOST_BITS_PER_WIDE_INT - && (nonzero_bits (op0, mode) - & (HOST_WIDE_INT_1U << (mode_width - 1))) + && is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && (nonzero_bits (op0, int_mode) + & (HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) == 0) code = EQ; break; @@ -11755,9 +11758,10 @@ simplify_compare_const (enum rtx_code co /* If we are doing a > 0 comparison on a value known to have a zero sign bit, we can replace this with != 0. */ else if (const_op == 0 - && mode_width - 1 < HOST_BITS_PER_WIDE_INT - && (nonzero_bits (op0, mode) - & (HOST_WIDE_INT_1U << (mode_width - 1))) + && is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && (nonzero_bits (op0, int_mode) + & (HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) == 0) code = NE; break; @@ -11771,9 +11775,10 @@ simplify_compare_const (enum rtx_code co /* ... fall through ... */ } /* (unsigned) < 0x80000000 is equivalent to >= 0. */ - else if (mode_width - 1 < HOST_BITS_PER_WIDE_INT - && (unsigned HOST_WIDE_INT) const_op - == HOST_WIDE_INT_1U << (mode_width - 1)) + else if (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && ((unsigned HOST_WIDE_INT) const_op + == HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) { const_op = 0; code = GE; @@ -11787,9 +11792,11 @@ simplify_compare_const (enum rtx_code co if (const_op == 0) code = EQ; /* (unsigned) <= 0x7fffffff is equivalent to >= 0. */ - else if (mode_width - 1 < HOST_BITS_PER_WIDE_INT - && (unsigned HOST_WIDE_INT) const_op - == (HOST_WIDE_INT_1U << (mode_width - 1)) - 1) + else if (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && ((unsigned HOST_WIDE_INT) const_op + == ((HOST_WIDE_INT_1U + << (GET_MODE_PRECISION (int_mode) - 1)) - 1))) { const_op = 0; code = GE; @@ -11806,9 +11813,10 @@ simplify_compare_const (enum rtx_code co } /* (unsigned) >= 0x80000000 is equivalent to < 0. */ - else if (mode_width - 1 < HOST_BITS_PER_WIDE_INT - && (unsigned HOST_WIDE_INT) const_op - == HOST_WIDE_INT_1U << (mode_width - 1)) + else if (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && ((unsigned HOST_WIDE_INT) const_op + == HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) { const_op = 0; code = LT; @@ -11822,9 +11830,11 @@ simplify_compare_const (enum rtx_code co if (const_op == 0) code = NE; /* (unsigned) > 0x7fffffff is equivalent to < 0. */ - else if (mode_width - 1 < HOST_BITS_PER_WIDE_INT - && (unsigned HOST_WIDE_INT) const_op - == (HOST_WIDE_INT_1U << (mode_width - 1)) - 1) + else if (is_a (mode, &int_mode) + && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT + && ((unsigned HOST_WIDE_INT) const_op + == (HOST_WIDE_INT_1U + << (GET_MODE_PRECISION (int_mode) - 1)) - 1)) { const_op = 0; code = LT; @@ -12009,9 +12019,8 @@ simplify_comparison (enum rtx_code code, while (CONST_INT_P (op1)) { - machine_mode mode = GET_MODE (op0); - unsigned int mode_width = GET_MODE_PRECISION (mode); - unsigned HOST_WIDE_INT mask = GET_MODE_MASK (mode); + machine_mode raw_mode = GET_MODE (op0); + scalar_int_mode int_mode; int equality_comparison_p; int sign_bit_comparison_p; int unsigned_comparison_p; @@ -12022,14 +12031,14 @@ simplify_comparison (enum rtx_code code, can handle VOIDmode if OP0 is a COMPARE or a comparison operation. */ - if (GET_MODE_CLASS (mode) != MODE_INT - && ! (mode == VOIDmode + if (GET_MODE_CLASS (raw_mode) != MODE_INT + && ! (raw_mode == VOIDmode && (GET_CODE (op0) == COMPARE || COMPARISON_P (op0)))) break; /* Try to simplify the compare to constant, possibly changing the comparison op, and/or changing op1 to zero. */ - code = simplify_compare_const (code, mode, op0, &op1); + code = simplify_compare_const (code, raw_mode, op0, &op1); const_op = INTVAL (op1); /* Compute some predicates to simplify code below. */ @@ -12041,16 +12050,62 @@ simplify_comparison (enum rtx_code code, /* If this is a sign bit comparison and we can do arithmetic in MODE, say that we will only be needing the sign bit of OP0. */ - if (sign_bit_comparison_p && HWI_COMPUTABLE_MODE_P (mode)) - op0 = force_to_mode (op0, mode, + if (sign_bit_comparison_p + && is_a (raw_mode, &int_mode) + && HWI_COMPUTABLE_MODE_P (int_mode)) + op0 = force_to_mode (op0, int_mode, HOST_WIDE_INT_1U - << (GET_MODE_PRECISION (mode) - 1), + << (GET_MODE_PRECISION (int_mode) - 1), 0); + if (COMPARISON_P (op0)) + { + /* We can't do anything if OP0 is a condition code value, rather + than an actual data value. */ + if (const_op != 0 + || CC0_P (XEXP (op0, 0)) + || GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) + break; + + /* Get the two operands being compared. */ + if (GET_CODE (XEXP (op0, 0)) == COMPARE) + tem = XEXP (XEXP (op0, 0), 0), tem1 = XEXP (XEXP (op0, 0), 1); + else + tem = XEXP (op0, 0), tem1 = XEXP (op0, 1); + + /* Check for the cases where we simply want the result of the + earlier test or the opposite of that result. */ + if (code == NE || code == EQ + || (val_signbit_known_set_p (raw_mode, STORE_FLAG_VALUE) + && (code == LT || code == GE))) + { + enum rtx_code new_code; + if (code == LT || code == NE) + new_code = GET_CODE (op0); + else + new_code = reversed_comparison_code (op0, NULL); + + if (new_code != UNKNOWN) + { + code = new_code; + op0 = tem; + op1 = tem1; + continue; + } + } + break; + } + + if (raw_mode == VOIDmode) + break; + scalar_int_mode mode = as_a (raw_mode); + /* Now try cases based on the opcode of OP0. If none of the cases does a "continue", we exit this loop immediately after the switch. */ + unsigned int mode_width = GET_MODE_PRECISION (mode); + unsigned HOST_WIDE_INT mask = GET_MODE_MASK (mode); switch (GET_CODE (op0)) { case ZERO_EXTRACT: @@ -12195,8 +12250,7 @@ simplify_comparison (enum rtx_code code, insn of the given mode, since we'd have to revert it later on, and then we wouldn't know whether to sign- or zero-extend. */ - mode = GET_MODE (XEXP (op0, 0)); - if (GET_MODE_CLASS (mode) == MODE_INT + if (is_int_mode (GET_MODE (XEXP (op0, 0)), &mode) && ! unsigned_comparison_p && HWI_COMPUTABLE_MODE_P (mode) && trunc_int_for_mode (const_op, mode) == const_op @@ -12230,11 +12284,12 @@ simplify_comparison (enum rtx_code code, if (mode_width <= HOST_BITS_PER_WIDE_INT && subreg_lowpart_p (op0) - && GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op0))) > mode_width + && is_a (GET_MODE (SUBREG_REG (op0)), + &inner_mode) + && GET_MODE_PRECISION (inner_mode) > mode_width && GET_CODE (SUBREG_REG (op0)) == PLUS && CONST_INT_P (XEXP (SUBREG_REG (op0), 1))) { - machine_mode inner_mode = GET_MODE (SUBREG_REG (op0)); rtx a = XEXP (SUBREG_REG (op0), 0); HOST_WIDE_INT c1 = -INTVAL (XEXP (SUBREG_REG (op0), 1)); @@ -12271,19 +12326,19 @@ simplify_comparison (enum rtx_code code, && GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op0))) < mode_width) ; else if (subreg_lowpart_p (op0) - && GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT + && GET_MODE_CLASS (mode) == MODE_INT && is_int_mode (GET_MODE (SUBREG_REG (op0)), &inner_mode) && (code == NE || code == EQ) && GET_MODE_PRECISION (inner_mode) <= HOST_BITS_PER_WIDE_INT && !paradoxical_subreg_p (op0) && (nonzero_bits (SUBREG_REG (op0), inner_mode) - & ~GET_MODE_MASK (GET_MODE (op0))) == 0) + & ~GET_MODE_MASK (mode)) == 0) { /* Remove outer subregs that don't do anything. */ tem = gen_lowpart (inner_mode, op1); if ((nonzero_bits (tem, inner_mode) - & ~GET_MODE_MASK (GET_MODE (op0))) == 0) + & ~GET_MODE_MASK (mode)) == 0) { op0 = SUBREG_REG (op0); op1 = tem; @@ -12297,8 +12352,7 @@ simplify_comparison (enum rtx_code code, /* FALLTHROUGH */ case ZERO_EXTEND: - mode = GET_MODE (XEXP (op0, 0)); - if (GET_MODE_CLASS (mode) == MODE_INT + if (is_int_mode (GET_MODE (XEXP (op0, 0)), &mode) && (unsigned_comparison_p || equality_comparison_p) && HWI_COMPUTABLE_MODE_P (mode) && (unsigned HOST_WIDE_INT) const_op <= GET_MODE_MASK (mode) @@ -12387,45 +12441,6 @@ simplify_comparison (enum rtx_code code, } break; - case EQ: case NE: - case UNEQ: case LTGT: - case LT: case LTU: case UNLT: case LE: case LEU: case UNLE: - case GT: case GTU: case UNGT: case GE: case GEU: case UNGE: - case UNORDERED: case ORDERED: - /* We can't do anything if OP0 is a condition code value, rather - than an actual data value. */ - if (const_op != 0 - || CC0_P (XEXP (op0, 0)) - || GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) - break; - - /* Get the two operands being compared. */ - if (GET_CODE (XEXP (op0, 0)) == COMPARE) - tem = XEXP (XEXP (op0, 0), 0), tem1 = XEXP (XEXP (op0, 0), 1); - else - tem = XEXP (op0, 0), tem1 = XEXP (op0, 1); - - /* Check for the cases where we simply want the result of the - earlier test or the opposite of that result. */ - if (code == NE || code == EQ - || (val_signbit_known_set_p (GET_MODE (op0), STORE_FLAG_VALUE) - && (code == LT || code == GE))) - { - enum rtx_code new_code; - if (code == LT || code == NE) - new_code = GET_CODE (op0); - else - new_code = reversed_comparison_code (op0, NULL); - - if (new_code != UNKNOWN) - { - code = new_code; - op0 = tem; - op1 = tem1; - continue; - } - } - break; case IOR: /* The sign bit of (ior (plus X (const_int -1)) X) is nonzero @@ -12697,7 +12712,7 @@ simplify_comparison (enum rtx_code code, { rtx inner = XEXP (XEXP (XEXP (op0, 0), 0), 0); rtx add_const = XEXP (XEXP (op0, 0), 1); - rtx new_const = simplify_gen_binary (ASHIFTRT, GET_MODE (op0), + rtx new_const = simplify_gen_binary (ASHIFTRT, mode, add_const, XEXP (op0, 1)); op0 = simplify_gen_binary (PLUS, tmode, From patchwork Thu Jul 13 08:54:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107630 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1936425qge; Thu, 13 Jul 2017 01:55:29 -0700 (PDT) X-Received: by 10.98.135.140 with SMTP id i134mr58972024pfe.237.1499936129024; Thu, 13 Jul 2017 01:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936129; cv=none; d=google.com; s=arc-20160816; b=qmu4WoE3LglSZbqySfAgl2tv5dxU5NBkxb32oYl2VvXFc0ThG8vx85qYEOJxf2cHql Sbsl+/HS7aiB2OtieWsljHNcwADrvcsk5EjI4r0AGjOlpK9jKpYFdXqlkRwdMY6oRpv0 5SGhB6RYPkqAD0F4zM1HXm8+uXnRD5SWvnnDjQ9mf21JxEgE5rX7L6B8189cGEERVL+B 24Neq1GTB3Z511dwdS25lF6TtPljy9HoxY8bU8oA51YDZhAONjUq+birsBJHJZHaptec h94CecCsMgNj8NRSxl3Kpx8rbmpbZcRMP0gpokIyb2zqNbvbZUa0YvMT6KgZZW0tnLrr vvyQ== 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=/ykRtvuc2VGj8D/cCXkg03wFNUGwD44jx4airOrf/8o=; b=Cl5yNYdt2XD7qNnw2+kH42rYqeEnZxovtD2ZXfU4aCgA0g8kDnKRJePlXaeNll50zd TzeWgGLAa8OZvR4lF4NV4hC8XoUIqT/ggzhgAe9BMzvWZrtrvS+ghPrNsWILMUN3iZHJ /6T5t2Ff1mULfdpWwbWwHwJIQUmREmzvvYdE6SXwCiIKPiz1CJFo5xiR2gEEsk9es+1o 3GZIqKZxFcirFi5m2g/vmv9oY0UDc49aPY3J/09stflsNOeuSPDQCzHDcG7ChR+/5mhP qsIX1oIc3fwavGscRBJ944CrUlR+XrueM0uXYnh4kkwI2CQ/u3udnZJ5U0Xs9vr0+xHT iKuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=FOV8+PVV; spf=pass (google.com: domain of gcc-patches-return-458035-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458035-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 z8si3779329pfj.338.2017.07.13.01.55.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458035-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=FOV8+PVV; spf=pass (google.com: domain of gcc-patches-return-458035-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458035-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=mFShnUHLM6JJ/HGvi5tTAu+OJ8/VZ cmODjtwQEf6GQnQM47jnM5H9viDxfDst0fomiNiqOVcq8ZRycgyYQPCBF7oPQMxl 3/0fEUdtQH8AtakgpWEn3nHTefuzAtW1SlaGWiFmIQHJf2W6oOJ/EVadVhmtLk9c LQVcS6Gn5URFec= 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=2y7B3jNwXNJzvgMEPPdF4y6Yc+A=; b=FOV 8+PVV0Pi35AluTUnyrk8kdfY3K4zNB2MRNuzgzVkNZ9rdINBBo3HQ5p4UtU6Kfmo LnmWUpwAVnVOhvQhTBakpTlzGEHmJtE6gDWgJPIjr9Lw/qWGXSui8i2mzpR6Bx8h AuD38uEegaCxvbRSJHKTQMoc00TJqVXvaigrP3Eo= Received: (qmail 27715 invoked by alias); 13 Jul 2017 08:54:15 -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 26262 invoked by uid 89); 13 Jul 2017 08:54:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:54:11 +0000 Received: by mail-wm0-f45.google.com with SMTP id f67so18352679wmh.1 for ; Thu, 13 Jul 2017 01:54:10 -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=/ykRtvuc2VGj8D/cCXkg03wFNUGwD44jx4airOrf/8o=; b=ccPQKGycUv+UVw02jDGyyw5wuWhSyF2pXK/jsfsE4PYo9DJgDeDVP2rjcmWYdWEABu 5DONr9xv5dB+/lfh8pzz5kdgM9tZ6ukBwDylx7Wj6PtCEcbvFJBnxIkxLky/vPA32m9q zxWiGK+xvrL4OG3mYFhg/4DKR2/GhLWjvWWmmt6QTuhL/0nIDl014otUs8jDthQ6shRH gYeKNXsVeMyeid3Cj6N2uCXQ0E+6qS9InR+f/HGrJ9kgmCyV13d+L8dKOUS+xySU+chl xqZQcyHrkgYh4AbGD44sB84n5W/Gj/LODxthciicQMqCn/8gtyYUNtaVVV9W1Rkj6346 mhSQ== X-Gm-Message-State: AIVw110vefzjg5FYqIUc/OrGm5rpLHdM+ADSLOZ4tbDHgOZ0dcNCEOe4 iw9I5W9KF+VfBV5JORy5/A== X-Received: by 10.28.143.10 with SMTP id r10mr1263771wmd.10.1499936049141; Thu, 13 Jul 2017 01:54:09 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id t125sm4956677wmt.20.2017.07.13.01.54.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:54:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [44/77] Make simplify_and_const_int take a scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:54:06 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87vamwg1jl.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 After previous patches, top-level calls to simplify_and_const_int always pass a scalar_int_mode. The only call site that needs to be updated is the recursive one in simplify_and_const_int_1, at which point we know "varop" has a scalar integer mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (simplify_and_const_int): Change the type of the mode parameter to scalar_int_mode. (simplify_and_const_int_1): Likewise. Update recursive call. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:43.379419324 +0100 +++ gcc/combine.c 2017-07-13 09:18:43.779386786 +0100 @@ -459,9 +459,9 @@ static int rtx_equal_for_field_assignmen static rtx make_field_assignment (rtx); static rtx apply_distributive_law (rtx); static rtx distribute_and_simplify_rtx (rtx, int); -static rtx simplify_and_const_int_1 (machine_mode, rtx, +static rtx simplify_and_const_int_1 (scalar_int_mode, rtx, unsigned HOST_WIDE_INT); -static rtx simplify_and_const_int (rtx, machine_mode, rtx, +static rtx simplify_and_const_int (rtx, scalar_int_mode, rtx, unsigned HOST_WIDE_INT); static int merge_outer_ops (enum rtx_code *, HOST_WIDE_INT *, enum rtx_code, HOST_WIDE_INT, machine_mode, int *); @@ -9927,7 +9927,7 @@ distribute_and_simplify_rtx (rtx x, int (const_int CONSTOP)). Otherwise, return NULL_RTX. */ static rtx -simplify_and_const_int_1 (machine_mode mode, rtx varop, +simplify_and_const_int_1 (scalar_int_mode mode, rtx varop, unsigned HOST_WIDE_INT constop) { unsigned HOST_WIDE_INT nonzero; @@ -9987,19 +9987,20 @@ simplify_and_const_int_1 (machine_mode m won't match a pattern either with or without this. */ if (GET_CODE (varop) == IOR || GET_CODE (varop) == XOR) - return - gen_lowpart - (mode, - apply_distributive_law - (simplify_gen_binary (GET_CODE (varop), GET_MODE (varop), - simplify_and_const_int (NULL_RTX, - GET_MODE (varop), - XEXP (varop, 0), - constop), - simplify_and_const_int (NULL_RTX, - GET_MODE (varop), - XEXP (varop, 1), - constop)))); + { + scalar_int_mode varop_mode = as_a (GET_MODE (varop)); + return + gen_lowpart + (mode, + apply_distributive_law + (simplify_gen_binary (GET_CODE (varop), varop_mode, + simplify_and_const_int (NULL_RTX, varop_mode, + XEXP (varop, 0), + constop), + simplify_and_const_int (NULL_RTX, varop_mode, + XEXP (varop, 1), + constop)))); + } /* If VAROP is PLUS, and the constant is a mask of low bits, distribute the AND and see if one of the operands simplifies to zero. If so, we @@ -10042,7 +10043,7 @@ simplify_and_const_int_1 (machine_mode m X is zero, we are to always construct the equivalent form. */ static rtx -simplify_and_const_int (rtx x, machine_mode mode, rtx varop, +simplify_and_const_int (rtx x, scalar_int_mode mode, rtx varop, unsigned HOST_WIDE_INT constop) { rtx tem = simplify_and_const_int_1 (mode, varop, constop); From patchwork Thu Jul 13 08:54:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107631 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1936653qge; Thu, 13 Jul 2017 01:55:46 -0700 (PDT) X-Received: by 10.98.158.29 with SMTP id s29mr60829844pfd.126.1499936146633; Thu, 13 Jul 2017 01:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936146; cv=none; d=google.com; s=arc-20160816; b=i6/9mrkICpjgnM6yWCT1/G1yq74+XN7J+SdCTyaUSoP2JB1srU3f3uVur9ZBxLWFTq HgbgGH5oDLJHlHZfidnlmuXPU4Fuz4/FfMlAYXPHRNYgrjcqi2iYQeEyOOeqKR30rJVA Xr/p0hnNdDFD0ciEvaR6MBnwjUoUTvnWuvc+NfZ0rxlLPK/CXM+wJ1DN3GdCzBodVs/a rd8YV6w/uv9qOzsLhEZN0cAJGmVRyG4HUt606tzET8SxrLITLx63c9LtBSGTGNoBikZJ NJw1w5dMluPB/iQ+dTpdB2XroUiBVoon7N5buVTOIcfa7ttaN7Pld7Gu6EY0RC17DAzr +ZhA== 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=dN9zilmCTBoAuIhOpgZV7Lw5xeg059V2oQvNNJliLqg=; b=ED//eG1SYtsJGrEy6f+TZewnH0lsPGnauBcC55c9348DjKz00mu3OTQ8WOJgr9Y7q5 3blNbM/qTWNJHcH/Nz/TsuJLRm5PKQY98VBr1KWRFg757WaY0hd3OhbJYPL4YZVdIe2h /ht8+M7yUPnlSbB39UdCxR6AzTCHq4iTb8YYSdI3FENybbC6xg0cT8XGcWItQKZWD7kn AuH1NIZPuhLaE7q8bhe/BVDexv7SLmhmdZC3GaHpkX7pP3Lc2ep/v31Pv1gxaTJJ3TMN BqXlkDtD7Rwluc4bFHFkkcfF7K1sqe/gUf13b70sou7ukTed/f5ZyjcNocotVpAWLYcv oyow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=owJQsaB2; spf=pass (google.com: domain of gcc-patches-return-458036-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458036-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 a10si4012449plt.344.2017.07.13.01.55.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458036-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=owJQsaB2; spf=pass (google.com: domain of gcc-patches-return-458036-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458036-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=mornEbQ52v+M64rnRNSb1ndOjbtF+ J51dIqs1l2bbJ+3w4MgRhE/6AW7COEKOsZxb0sGSaQYsXYzjbnlb0svEd6GZcL7f ifaHvolj3IWUIr3L4L+5HIO/Wp5S/RlvH/qBjLTBzTYf914Hwk/4lMC7KZb2THJv gnS4tyAt40Ojtk= 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=YfaHPTw8ZuWFAjr1J0hIwgRNPwo=; b=owJ QsaB2sEBPVsZqu91jLUjxUMCL6I6j8Wgc3gUxvKcLrG3j4wsETeyzk3/FqrTG6RL dywvWdoXnCpSi0EcDP7fvyIvjmzhrWPwJ211j+YgeD+DwLiBL66RlXR/C0A3HGA9 3Vb8Qz8nWs8/ULDbpl7V9woNpc+8VoKa5cZYtyNY= Received: (qmail 49802 invoked by alias); 13 Jul 2017 08:54:39 -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 48856 invoked by uid 89); 13 Jul 2017 08:54:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=4456 X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:54:34 +0000 Received: by mail-wm0-f49.google.com with SMTP id w126so16701756wme.0 for ; Thu, 13 Jul 2017 01:54:34 -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=dN9zilmCTBoAuIhOpgZV7Lw5xeg059V2oQvNNJliLqg=; b=KEO4W6r4UjMqExPU730ZtPLOQZEOjbQ1qK+ziuJp/bZPdQnuW8GIuWiZlqSfNgcXrT umMePRO1I/a9KVcngLcgQm4Ll+QVw7NEvs7G0VZqKDoGgISkLEGSUaaPRS6kkIhdSK1d VJyNGQBr7fTfRXJP21mmbV840hSGUHyMXXENvcOAYbMUn6tdR50tV8q/ppGgBvCsePks p/77MWTLtQJuRJs5fiUTRSiPGBOo0wUPQVg81h+fmZbT0CttF+4sFAnWBp3TsQCRTvhZ 579effXj5ql60cf892V5oCz4xdF+C+Xc4lCmnecRlfXBCuAQ5OQKK2BobPJS/Eq88Eqc zmCg== X-Gm-Message-State: AIVw112JwHtrKiABkhSQIIrMNmxegQyutm/HXH3M0VGUQeK1FDSjlpc8 NejZswf58oA12zvKRvit1g== X-Received: by 10.28.146.208 with SMTP id u199mr1157317wmd.6.1499936072618; Thu, 13 Jul 2017 01:54:32 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 32sm5649670wry.31.2017.07.13.01.54.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:54:31 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [45/77] Make extract_left_shift take a scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:54:30 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87r2xkg1ix.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch passes the mode of the shifted value to extract_left_shift and updates the only caller so that the mode is a scalar_int_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (extract_left_shift): Add a mode argument and update recursive calls. (make_compound_operation_int): Change the type of the mode parameter to scalar_int_mode and update the call to extract_left_shift. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:43.779386786 +0100 +++ gcc/combine.c 2017-07-13 09:18:44.175354711 +0100 @@ -445,7 +445,6 @@ static rtx expand_compound_operation (rt static const_rtx expand_field_assignment (const_rtx); static rtx make_extraction (machine_mode, rtx, HOST_WIDE_INT, rtx, unsigned HOST_WIDE_INT, int, int, int); -static rtx extract_left_shift (rtx, int); static int get_pos_from_mask (unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *); static rtx canon_reg_for_combine (rtx, rtx); @@ -7802,14 +7801,14 @@ make_extraction (machine_mode mode, rtx return new_rtx; } -/* See if X contains an ASHIFT of COUNT or more bits that can be commuted - with any other operations in X. Return X without that shift if so. */ +/* See if X (of mode MODE) contains an ASHIFT of COUNT or more bits that + can be commuted with any other operations in X. Return X without + that shift if so. */ static rtx -extract_left_shift (rtx x, int count) +extract_left_shift (scalar_int_mode mode, rtx x, int count) { enum rtx_code code = GET_CODE (x); - machine_mode mode = GET_MODE (x); rtx tem; switch (code) @@ -7825,7 +7824,7 @@ extract_left_shift (rtx x, int count) break; case NEG: case NOT: - if ((tem = extract_left_shift (XEXP (x, 0), count)) != 0) + if ((tem = extract_left_shift (mode, XEXP (x, 0), count)) != 0) return simplify_gen_unary (code, mode, tem, mode); break; @@ -7836,7 +7835,7 @@ extract_left_shift (rtx x, int count) if (CONST_INT_P (XEXP (x, 1)) && (UINTVAL (XEXP (x, 1)) & (((HOST_WIDE_INT_1U << count)) - 1)) == 0 - && (tem = extract_left_shift (XEXP (x, 0), count)) != 0) + && (tem = extract_left_shift (mode, XEXP (x, 0), count)) != 0) { HOST_WIDE_INT val = INTVAL (XEXP (x, 1)) >> count; return simplify_gen_binary (code, mode, tem, @@ -7864,7 +7863,7 @@ extract_left_shift (rtx x, int count) - Return a new rtx, which the caller returns directly. */ static rtx -make_compound_operation_int (machine_mode mode, rtx *x_ptr, +make_compound_operation_int (scalar_int_mode mode, rtx *x_ptr, enum rtx_code in_code, enum rtx_code *next_code_ptr) { @@ -8171,7 +8170,7 @@ make_compound_operation_int (machine_mod && INTVAL (rhs) >= 0 && INTVAL (rhs) < HOST_BITS_PER_WIDE_INT && INTVAL (rhs) < mode_width - && (new_rtx = extract_left_shift (lhs, INTVAL (rhs))) != 0) + && (new_rtx = extract_left_shift (mode, lhs, INTVAL (rhs))) != 0) new_rtx = make_extraction (mode, make_compound_operation (new_rtx, next_code), 0, NULL_RTX, mode_width - INTVAL (rhs), code == LSHIFTRT, 0, in_code == COMPARE); From patchwork Thu Jul 13 08:54:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107632 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1936998qge; Thu, 13 Jul 2017 01:56:13 -0700 (PDT) X-Received: by 10.84.232.197 with SMTP id x5mr8946431plm.159.1499936173842; Thu, 13 Jul 2017 01:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936173; cv=none; d=google.com; s=arc-20160816; b=NeILYBr2yLE1M+mKbl4B+V29J2qBD5LDUs9jshIi00TCPlRlkWR7b9krFj29P77Y/R bIajKf66CRsMnLyBWEL6g2ROK8mV18/iIhrBgBn9zIVNsK+H4Eif9oT9xxu4Ik0wjWLF nwccTTQ/UkGY6dSLKigNCJZwYTpk8VzQwiDrA+2auZ8PrC6inpFxJYHW7ocOofgFC74j cLYfRNAphKOpTti7AJf9hEVTcUCyJrLfW3r82dRImArA/xlWv0Tm2BHz0c751tJGuhxh YDIzXgI77qs2eVLz5SJWKMwbefJzZJ8FP/zplqFqWaCSJ5I25l3ifWR8HTJVXZbvtDJo SvhA== 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=Mr7EAMiIb/5Nezt9vKaAudQ0gaXhJyJgWKIBgXX6kRg=; b=nOt6ty/P6GYtw0TkgqIJbo+ZWKVkg+91bThN6CdAXVELRcjAZOe84CcZqsVUogMgeS T4cPHPRkEhM+67nxxUsyvLQVYZI6Lj72d50krgwI0GAvHV482o4fQavSGsABC5P9THnV xc62hQsHjkATcgxee5PP6DZZOJ9tb10DXQ3fqzPPy9h9qjRGrAUXv1jH0FBDZNjWwlBA ahzLA82y2KRc8aQnx0Rymi7S1Ki9/M2+s932aZ79IP5Hxkhgi31JMa/M65sN9nZ91cJA c2RgrhqgJHaC39JU1ix0qHyDcr1f6UnFsvvju68j56H4EhOZkD7qR1JpFl1/wNkJfzEk 3/PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=iGJtAcTd; spf=pass (google.com: domain of gcc-patches-return-458037-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458037-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 c19si3902908pgk.501.2017.07.13.01.56.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458037-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=iGJtAcTd; spf=pass (google.com: domain of gcc-patches-return-458037-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458037-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=uFjtb227fA5bCzN4ZbHVvWC387yXy hV20yIss33QLpZ9x/93X057k6YNeR4qLFG84lxKDAvChfQkufI5CknRP4rtFr+nQ wQdjlCteugHNupJxobAFlSirq5Y0OEE/KuCUEcUsOphEypsYPW/fT8kPAT8DWw55 l/eEKB5CAnrulk= 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=3WRAkKcy13YYxFHRmkANqFYDLpc=; b=iGJ tAcTdPn6S0ZwOuD1Ws4gPkxP/2Ax9kbBbwMtSxxe85RWABdMCaM5LWbYHXphmnvu CyAe702JZmZPEkR+9lHl7UMlBbcvd5fYLSJLhdvYNZYvIBrmbaMmn9UizpjSq4ea rbRemr4WdaM7eiytzFzePfFSYQzJ56qSapifQmmI= Received: (qmail 70185 invoked by alias); 13 Jul 2017 08:54:59 -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 69338 invoked by uid 89); 13 Jul 2017 08:54:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:54:54 +0000 Received: by mail-wr0-f170.google.com with SMTP id r103so49590508wrb.0 for ; Thu, 13 Jul 2017 01:54:53 -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=Mr7EAMiIb/5Nezt9vKaAudQ0gaXhJyJgWKIBgXX6kRg=; b=cSXlk8N/VZqjmCTPGwlzZQ0mS7ZhCk+ttsV/69sFrxmt0RDjZaEGclcOmoPvJiElQu KrzSGkZtJmRudQwRKTXLyXGdymZCpKUdx+uCUdGkwgxVhe2mLqy4YcmWK8LzYtGIhoeF Xt+3Ie3WnCM6Inq1XMpOoUdVshvTwdWVSW0FBm+DGgD86EUAgTTChDDpYY3Kc4fqDcYZ xXlN9a5jyWVRKMac4wtFuP+I4fIwXNAfzqZZh3WN4tNbLmuQ+cQuWnW3Usp4W+CV8cfL b9795UB+4Bsg1y266hPMt1aR6bu3W5QovGrxjEtKhDupAQ5dxYW8YitWkgmf4XL1U+yx MMKQ== X-Gm-Message-State: AIVw113uddqeFAsqIu3Vf4NKjiaEtrmsEmwRl+JyhaCFZCj3MxMZfr7d mXtZP4s9h05nnAwRhU4mWQ== X-Received: by 10.223.163.135 with SMTP id l7mr898071wrb.88.1499936092095; Thu, 13 Jul 2017 01:54:52 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 143sm5825851wmg.9.2017.07.13.01.54.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:54:51 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [46/77] Make widest_int_mode_for_size return a scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:54:50 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87mv88g1id.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The comment for widest_int_mode said that it returns "the widest integer mode no wider than SIZE", but it actually returns the widest integer mode that is narrower than SIZE. In practice SIZE is always greater than 1, so it can always pick QImode in the worst case. The VOIDmode paths seem to be dead. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * expr.c (widest_int_mode_for_size): Make the comment match the code. Return a scalar_int_mode and assert that the size is greater than one byte. (by_pieces_ninsns): Update accordingly and remove VOIDmode handling. (op_by_pieces_d::op_by_pieces_d): Likewise. (op_by_pieces_d::run): Likewise. (can_store_by_pieces): Likewise. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:41.678559010 +0100 +++ gcc/expr.c 2017-07-13 09:18:44.578322246 +0100 @@ -722,19 +722,21 @@ alignment_for_piecewise_move (unsigned i return align; } -/* Return the widest integer mode no wider than SIZE. If no such mode - can be found, return VOIDmode. */ +/* Return the widest integer mode that is narrower than SIZE bytes. */ -static machine_mode +static scalar_int_mode widest_int_mode_for_size (unsigned int size) { - machine_mode tmode, mode = VOIDmode; + scalar_int_mode result = NARROWEST_INT_MODE; + gcc_checking_assert (size > 1); + + opt_scalar_int_mode tmode; FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) - if (GET_MODE_SIZE (tmode) < size) - mode = tmode; + if (GET_MODE_SIZE (*tmode) < size) + result = *tmode; - return mode; + return result; } /* Determine whether an operation OP on LEN bytes with alignment ALIGN can @@ -771,13 +773,9 @@ by_pieces_ninsns (unsigned HOST_WIDE_INT while (max_size > 1 && l > 0) { - machine_mode mode; + scalar_int_mode mode = widest_int_mode_for_size (max_size); enum insn_code icode; - mode = widest_int_mode_for_size (max_size); - - if (mode == VOIDmode) - break; unsigned int modesize = GET_MODE_SIZE (mode); icode = optab_handler (mov_optab, mode); @@ -1053,7 +1051,7 @@ op_by_pieces_d::op_by_pieces_d (rtx to, if (by_pieces_ninsns (len, align, m_max_size, MOVE_BY_PIECES) > 2) { /* Find the mode of the largest comparison. */ - machine_mode mode = widest_int_mode_for_size (m_max_size); + scalar_int_mode mode = widest_int_mode_for_size (m_max_size); m_from.decide_autoinc (mode, m_reverse, len); m_to.decide_autoinc (mode, m_reverse, len); @@ -1073,10 +1071,7 @@ op_by_pieces_d::run () { while (m_max_size > 1 && m_len > 0) { - machine_mode mode = widest_int_mode_for_size (m_max_size); - - if (mode == VOIDmode) - break; + scalar_int_mode mode = widest_int_mode_for_size (m_max_size); if (prepare_mode (mode, m_align)) { @@ -1287,7 +1282,6 @@ can_store_by_pieces (unsigned HOST_WIDE_ unsigned HOST_WIDE_INT l; unsigned int max_size; HOST_WIDE_INT offset = 0; - machine_mode mode; enum insn_code icode; int reverse; /* cst is set but not used if LEGITIMATE_CONSTANT doesn't use it. */ @@ -1316,10 +1310,7 @@ can_store_by_pieces (unsigned HOST_WIDE_ max_size = STORE_MAX_PIECES + 1; while (max_size > 1 && l > 0) { - mode = widest_int_mode_for_size (max_size); - - if (mode == VOIDmode) - break; + scalar_int_mode mode = widest_int_mode_for_size (max_size); icode = optab_handler (mov_optab, mode); if (icode != CODE_FOR_nothing From patchwork Thu Jul 13 08:55:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107633 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1937360qge; Thu, 13 Jul 2017 01:56:44 -0700 (PDT) X-Received: by 10.84.217.156 with SMTP id p28mr9146734pli.206.1499936204223; Thu, 13 Jul 2017 01:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936204; cv=none; d=google.com; s=arc-20160816; b=vr8miqWtm2G1cCllG5ZiugapQKf7IcQeFtXthS/s+fG1zw0/TdBBgfHYtFwxcMlcNL resetQQgeX5646LzHEspzxSWCm+o213LXp/PiC+iJFCxCs8wxgb2TdDUZ116NjzHoxda iH6wYPy8Rd2f1CsYrucwKKmaiIs2ufXlkqeXo/OQsXeY1uqi/n5JlwMxv5femMk1QHyN NgsiyQcYecgxbUTGLfIjkajxqppzfqLnHzMP0x0bo0KCaP0jjawybi/Ci2KjCZVq0fO3 uZuimLy+4JZ76qvh/dJoRmVU9PCblK/qigZYlRXI4a6PqJpq6SF5v177NozE0uFHxhVt O52g== 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=Jwh9clJZYYhAumWwU15CR1m8LHEG4PILcFATORV4fDM=; b=LS2vWjbTqpU2krP0LfGHsMOWWocN0xNQW4JVECrj1Kzp+FsEOaY/f8TkGUYY04gxyM zrlE32t5a3K4nmzKccqpu4OWsE9+781pZDSjyGmd8dCyV49INMWHfHZsi2WcXUtTCmKk 4Ufi7wpl/oHCeYkpXFWk0xjTYNFx3/dsmXt2CaAxYwcyzP2OQ+3DOBXMdvRinscNody3 6tcwXSbVOpyaAJT4PjX5xHHiB/JuUPvDfBo+zAQQGsxLEz79xiudU45CzCYUTS9dn4Xg q2orXQn03vghtEa3Wqucj4E+2xd4ixcP9Twtd6NCKQ7zhD5PsMT/N9tfnw9Yly9TSyfD wdHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=Tbe7CsR1; spf=pass (google.com: domain of gcc-patches-return-458038-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458038-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 c63si3794816pfk.286.2017.07.13.01.56.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458038-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=Tbe7CsR1; spf=pass (google.com: domain of gcc-patches-return-458038-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458038-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=QXxydec1FUDnJtCIO6T1T95Yc7/63 cgIr1/Sk85UpJEkBcS2Hww42ZxZKlApN5FKeNeGp4OVOqAuLqhZL2hCfw2FmqCQb zKrd00qVPsnH4Ut5qdyB9CgIS5C8XkZrOXUFv7+Mc7J9OKWviQvBrFFg09mHZctH 0psY48S/kvM03k= 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=4vHg7HyD4jvqckxyCBYmfuDUIVw=; b=Tbe 7CsR19rcF6U4PMrzcSg+GbmrknhC/bfxsuOCIF59W1JhCkyEmy4wJfWdf+0CYIZV Nju6e3up9L8OWPuOhBrXLompex85Na9bpyCoFkBg7u1/FYEYX1k+HPUM2EQGnhmP Z9VPXwwsko0tVEB1UrQT8sQUR+r6R2mZxXV43v+I= Received: (qmail 91777 invoked by alias); 13 Jul 2017 08:55:19 -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 91141 invoked by uid 89); 13 Jul 2017 08:55:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, 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:55:12 +0000 Received: by mail-wr0-f180.google.com with SMTP id c11so49476820wrc.3 for ; Thu, 13 Jul 2017 01:55:12 -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=Jwh9clJZYYhAumWwU15CR1m8LHEG4PILcFATORV4fDM=; b=mQQke/nWIb+RE1OikNDWt0YHtpM7yEk3Vhj6xeFWisf6qspdeGCttnLeMdAfwkFG/U MKpLzjxgVoePIhaeXQcu/uTOlX+T5+0Rhthyw08sYnqEWUZXH6JL5o29/VzpwuzAeodV Fp/64gqSrOshZ4lls5CZk+XEolRDW/YhEQg2v9X6YuUrc6xiHMLC3nglVIHLz/mOwGY0 90m6SiLR5Lu6zYtE6OkI09/XqOYfe5a6GUOBsG/6V5dBFnnt+qwMrtAMfPq8gzSeuwgE Z8I+wu5nBh95yBAnKx0gUz4jTfuqtefvF5+eUP9WVL1wlghVHEqFX2E/IrbaMZDfH7eZ V5FQ== X-Gm-Message-State: AIVw1118LHugMSS9ZFZuulF3D/LlazegS9I5LljBjQefg4kXobPiHzGx AnJLFP2RJDCmvggEjF7sHw== X-Received: by 10.223.128.42 with SMTP id 39mr1086239wrk.175.1499936110263; Thu, 13 Jul 2017 01:55:10 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id p7sm5902831wmf.11.2017.07.13.01.55.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:55:09 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [47/77] Make subroutines of nonzero_bits operate on scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:55:07 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87iniwg1hw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 nonzero_bits1 assumed that all bits of a floating-point or vector mode were needed. It seems likely that fixed-point modes should have been handled in the same way. After excluding those, the only remaining modes that are likely to be useful are scalar integer ones. This patch moves the mode class check to nonzero_bits itself, along with the handling of mode == VOIDmode. The subroutines of nonzero_bits can then take scalar_int_modes. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * rtlanal.c (nonzero_bits): Handle VOIDmode here rather than in subroutines. Return the mode mask for non-integer modes. (cached_nonzero_bits): Change the type of the mode parameter to scalar_int_mode. (nonzero_bits1): Likewise. Remove early exit for other mode classes. Handle CONST_INT_P first and then check whether X also has a scalar integer mode. Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:39.592733560 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:44.976290184 +0100 @@ -43,10 +43,10 @@ static bool covers_regno_no_parallel_p ( static int computed_jump_p_1 (const_rtx); static void parms_set (rtx, const_rtx, void *); -static unsigned HOST_WIDE_INT cached_nonzero_bits (const_rtx, machine_mode, +static unsigned HOST_WIDE_INT cached_nonzero_bits (const_rtx, scalar_int_mode, const_rtx, machine_mode, unsigned HOST_WIDE_INT); -static unsigned HOST_WIDE_INT nonzero_bits1 (const_rtx, machine_mode, +static unsigned HOST_WIDE_INT nonzero_bits1 (const_rtx, scalar_int_mode, const_rtx, machine_mode, unsigned HOST_WIDE_INT); static unsigned int cached_num_sign_bit_copies (const_rtx, machine_mode, const_rtx, @@ -4237,7 +4237,12 @@ default_address_cost (rtx x, machine_mod unsigned HOST_WIDE_INT nonzero_bits (const_rtx x, machine_mode mode) { - return cached_nonzero_bits (x, mode, NULL_RTX, VOIDmode, 0); + if (mode == VOIDmode) + mode = GET_MODE (x); + scalar_int_mode int_mode; + if (!is_a (mode, &int_mode)) + return GET_MODE_MASK (mode); + return cached_nonzero_bits (x, int_mode, NULL_RTX, VOIDmode, 0); } unsigned int @@ -4281,7 +4286,7 @@ nonzero_bits_binary_arith_p (const_rtx x identical subexpressions on the first or the second level. */ static unsigned HOST_WIDE_INT -cached_nonzero_bits (const_rtx x, machine_mode mode, const_rtx known_x, +cached_nonzero_bits (const_rtx x, scalar_int_mode mode, const_rtx known_x, machine_mode known_mode, unsigned HOST_WIDE_INT known_ret) { @@ -4334,7 +4339,7 @@ #define cached_num_sign_bit_copies sorry an arithmetic operation, we can do better. */ static unsigned HOST_WIDE_INT -nonzero_bits1 (const_rtx x, machine_mode mode, const_rtx known_x, +nonzero_bits1 (const_rtx x, scalar_int_mode mode, const_rtx known_x, machine_mode known_mode, unsigned HOST_WIDE_INT known_ret) { @@ -4342,19 +4347,31 @@ nonzero_bits1 (const_rtx x, machine_mode unsigned HOST_WIDE_INT inner_nz; enum rtx_code code; machine_mode inner_mode; + scalar_int_mode xmode; + unsigned int mode_width = GET_MODE_PRECISION (mode); - /* For floating-point and vector values, assume all bits are needed. */ - if (FLOAT_MODE_P (GET_MODE (x)) || FLOAT_MODE_P (mode) - || VECTOR_MODE_P (GET_MODE (x)) || VECTOR_MODE_P (mode)) + if (CONST_INT_P (x)) + { + if (SHORT_IMMEDIATES_SIGN_EXTEND + && INTVAL (x) > 0 + && mode_width < BITS_PER_WORD + && (UINTVAL (x) & (HOST_WIDE_INT_1U << (mode_width - 1))) != 0) + return UINTVAL (x) | (HOST_WIDE_INT_M1U << mode_width); + + return UINTVAL (x); + } + + if (!is_a (GET_MODE (x), &xmode)) return nonzero; + unsigned int xmode_width = GET_MODE_PRECISION (xmode); /* If X is wider than MODE, use its mode instead. */ - if (GET_MODE_PRECISION (GET_MODE (x)) > mode_width) + if (xmode_width > mode_width) { - mode = GET_MODE (x); + mode = xmode; nonzero = GET_MODE_MASK (mode); - mode_width = GET_MODE_PRECISION (mode); + mode_width = xmode_width; } if (mode_width > HOST_BITS_PER_WIDE_INT) @@ -4370,15 +4387,13 @@ nonzero_bits1 (const_rtx x, machine_mode not known to be zero. */ if (!WORD_REGISTER_OPERATIONS - && GET_MODE (x) != VOIDmode - && GET_MODE (x) != mode - && GET_MODE_PRECISION (GET_MODE (x)) <= BITS_PER_WORD - && GET_MODE_PRECISION (GET_MODE (x)) <= HOST_BITS_PER_WIDE_INT - && GET_MODE_PRECISION (mode) > GET_MODE_PRECISION (GET_MODE (x))) + && mode_width > xmode_width + && xmode_width <= BITS_PER_WORD + && xmode_width <= HOST_BITS_PER_WIDE_INT) { - nonzero &= cached_nonzero_bits (x, GET_MODE (x), + nonzero &= cached_nonzero_bits (x, xmode, known_x, known_mode, known_ret); - nonzero |= GET_MODE_MASK (mode) & ~GET_MODE_MASK (GET_MODE (x)); + nonzero |= GET_MODE_MASK (mode) & ~GET_MODE_MASK (xmode); return nonzero; } @@ -4395,7 +4410,8 @@ nonzero_bits1 (const_rtx x, machine_mode we can do this only if the target does not support different pointer or address modes depending on the address space. */ if (target_default_pointer_address_modes_p () - && POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode + && POINTERS_EXTEND_UNSIGNED + && xmode == Pmode && REG_POINTER (x) && !targetm.have_ptr_extend ()) nonzero &= GET_MODE_MASK (ptr_mode); @@ -4438,22 +4454,12 @@ nonzero_bits1 (const_rtx x, machine_mode return nonzero_for_hook; } - case CONST_INT: - /* If X is negative in MODE, sign-extend the value. */ - if (SHORT_IMMEDIATES_SIGN_EXTEND && INTVAL (x) > 0 - && mode_width < BITS_PER_WORD - && (UINTVAL (x) & (HOST_WIDE_INT_1U << (mode_width - 1))) - != 0) - return UINTVAL (x) | (HOST_WIDE_INT_M1U << mode_width); - - return UINTVAL (x); - case MEM: /* In many, if not most, RISC machines, reading a byte from memory zeros the rest of the register. Noticing that fact saves a lot of extra zero-extends. */ - if (load_extend_op (GET_MODE (x)) == ZERO_EXTEND) - nonzero &= GET_MODE_MASK (GET_MODE (x)); + if (load_extend_op (xmode) == ZERO_EXTEND) + nonzero &= GET_MODE_MASK (xmode); break; case EQ: case NE: @@ -4470,7 +4476,7 @@ nonzero_bits1 (const_rtx x, machine_mode operation in, and not the actual operation mode. We can wind up with (subreg:DI (gt:V4HI x y)), and we don't have anything that describes the results of a vector compare. */ - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT + if (GET_MODE_CLASS (xmode) == MODE_INT && mode_width <= HOST_BITS_PER_WIDE_INT) nonzero = STORE_FLAG_VALUE; break; @@ -4479,21 +4485,19 @@ nonzero_bits1 (const_rtx x, machine_mode #if 0 /* Disabled to avoid exponential mutual recursion between nonzero_bits and num_sign_bit_copies. */ - if (num_sign_bit_copies (XEXP (x, 0), GET_MODE (x)) - == GET_MODE_PRECISION (GET_MODE (x))) + if (num_sign_bit_copies (XEXP (x, 0), xmode) == xmode_width) nonzero = 1; #endif - if (GET_MODE_PRECISION (GET_MODE (x)) < mode_width) - nonzero |= (GET_MODE_MASK (mode) & ~GET_MODE_MASK (GET_MODE (x))); + if (xmode_width < mode_width) + nonzero |= (GET_MODE_MASK (mode) & ~GET_MODE_MASK (xmode)); break; case ABS: #if 0 /* Disabled to avoid exponential mutual recursion between nonzero_bits and num_sign_bit_copies. */ - if (num_sign_bit_copies (XEXP (x, 0), GET_MODE (x)) - == GET_MODE_PRECISION (GET_MODE (x))) + if (num_sign_bit_copies (XEXP (x, 0), xmode) == xmode_width) nonzero = 1; #endif break; @@ -4566,7 +4570,7 @@ nonzero_bits1 (const_rtx x, machine_mode unsigned HOST_WIDE_INT nz1 = cached_nonzero_bits (XEXP (x, 1), mode, known_x, known_mode, known_ret); - int sign_index = GET_MODE_PRECISION (GET_MODE (x)) - 1; + int sign_index = xmode_width - 1; int width0 = floor_log2 (nz0) + 1; int width1 = floor_log2 (nz1) + 1; int low0 = ctz_or_zero (nz0); @@ -4638,8 +4642,8 @@ nonzero_bits1 (const_rtx x, machine_mode been zero-extended, we know that at least the high-order bits are zero, though others might be too. */ if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x)) - nonzero = GET_MODE_MASK (GET_MODE (x)) - & cached_nonzero_bits (SUBREG_REG (x), GET_MODE (x), + nonzero = GET_MODE_MASK (xmode) + & cached_nonzero_bits (SUBREG_REG (x), xmode, known_x, known_mode, known_ret); /* If the inner mode is a single word for both the host and target @@ -4663,10 +4667,8 @@ nonzero_bits1 (const_rtx x, machine_mode ? val_signbit_known_set_p (inner_mode, nonzero) : extend_op != ZERO_EXTEND) || (!MEM_P (SUBREG_REG (x)) && !REG_P (SUBREG_REG (x)))) - && GET_MODE_PRECISION (GET_MODE (x)) - > GET_MODE_PRECISION (inner_mode)) - nonzero - |= (GET_MODE_MASK (GET_MODE (x)) & ~GET_MODE_MASK (inner_mode)); + && xmode_width > GET_MODE_PRECISION (inner_mode)) + nonzero |= (GET_MODE_MASK (xmode) & ~GET_MODE_MASK (inner_mode)); } break; @@ -4675,7 +4677,7 @@ nonzero_bits1 (const_rtx x, machine_mode case ASHIFT: case ROTATE: /* The nonzero bits are in two classes: any bits within MODE - that aren't in GET_MODE (x) are always significant. The rest of the + that aren't in xmode are always significant. The rest of the nonzero bits are those that are significant in the operand of the shift when shifted the appropriate number of bits. This shows that high-order bits are cleared by the right shift and @@ -4683,19 +4685,17 @@ nonzero_bits1 (const_rtx x, machine_mode if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) >= 0 && INTVAL (XEXP (x, 1)) < HOST_BITS_PER_WIDE_INT - && INTVAL (XEXP (x, 1)) < GET_MODE_PRECISION (GET_MODE (x))) + && INTVAL (XEXP (x, 1)) < xmode_width) { - machine_mode inner_mode = GET_MODE (x); - unsigned int width = GET_MODE_PRECISION (inner_mode); int count = INTVAL (XEXP (x, 1)); - unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (inner_mode); + unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (xmode); unsigned HOST_WIDE_INT op_nonzero = cached_nonzero_bits (XEXP (x, 0), mode, known_x, known_mode, known_ret); unsigned HOST_WIDE_INT inner = op_nonzero & mode_mask; unsigned HOST_WIDE_INT outer = 0; - if (mode_width > width) + if (mode_width > xmode_width) outer = (op_nonzero & nonzero & ~mode_mask); if (code == LSHIFTRT) @@ -4707,15 +4707,16 @@ nonzero_bits1 (const_rtx x, machine_mode /* If the sign bit may have been nonzero before the shift, we need to mark all the places it could have been copied to by the shift as possibly nonzero. */ - if (inner & (HOST_WIDE_INT_1U << (width - 1 - count))) - inner |= ((HOST_WIDE_INT_1U << count) - 1) - << (width - count); + if (inner & (HOST_WIDE_INT_1U << (xmode_width - 1 - count))) + inner |= (((HOST_WIDE_INT_1U << count) - 1) + << (xmode_width - count)); } else if (code == ASHIFT) inner <<= count; else - inner = ((inner << (count % width) - | (inner >> (width - (count % width)))) & mode_mask); + inner = ((inner << (count % xmode_width) + | (inner >> (xmode_width - (count % xmode_width)))) + & mode_mask); nonzero &= (outer | inner); } From patchwork Thu Jul 13 08:55:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107634 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1937743qge; Thu, 13 Jul 2017 01:57:13 -0700 (PDT) X-Received: by 10.101.73.197 with SMTP id t5mr8131311pgs.160.1499936233736; Thu, 13 Jul 2017 01:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936233; cv=none; d=google.com; s=arc-20160816; b=Wz4vYm8HwPp0gJnPEYpdwTJVLGGoILCMKpTQxMW9QzmAzM5wSeCMwgJSabRcZHYoew wJW8yDJA73JuP3LyPOg2SbDZTTZAVj4oNwIv+Lyqw3jdljQkc/beNNoe7BqrAByeLrO5 5WYETIBYB1IMlkYsNGLEm0iC8XnlxuN+OSQDkgZa3wY1tNJY9PkHCspaKzvgXv93VT4C 2qbCqRWyIK41N+9Z7KFBu3PBHs196tPBHVqddxrJxvYLoVVhMEUhRVWcJNUDW6Gk69yL qNoLZdGCFA//QKaA2n4uuw9zq5ZaqaDxXaZUq/gYuiL2yiwt2OHslq/DgAhp8SBBBlXh J6Jw== 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=G2Xy9gfqEa6BbUshq9299tI0RAj8gFsYpsBTEe9nKlQ=; b=NtJbr6WI1JYhybbwZkFxdMxDYTg6rNWaBCClzBrKr4m4nsFvmMayV5EPZIm2xkwSWW MQjIRvpNGTfmXZ+kxXfIEqR87yp/0lcLTsbyP3izO+KR/vnuWUUAZCkJY2FYazn4kZEo 68diHqnit8jZ8WuIY9IN34Mn9M15U85Y2FvMkBc3PzjCbWVDC2dRO2vA9+w/r2UFgsn8 ztpj1O3DdQ3te5+kkWSZMsLCMlQXrdkT6Cka3OflXUV2KGVVRJklazHP4HRVKNqzaygt E+jIoE+NF36U0d2ap7Fuc079LEAHP2wXGyysjSKKiwvJ8dIJ+L0kHyXXrQo34sBEuW9V 88bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=JBq9wG6H; spf=pass (google.com: domain of gcc-patches-return-458039-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458039-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 k15si4161329pln.461.2017.07.13.01.57.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458039-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=JBq9wG6H; spf=pass (google.com: domain of gcc-patches-return-458039-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458039-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=P//S7x2OvNw9HidKwkLMausp07ehi QzuccGMS+QKqmh82Cd/dgz2lsDjT8RsV4+yOCATxiWXUpDzEBFaRWaNC0iLp963T kEVhx6rtTZbhwEGWSUU4rzU9z8PLTxvqwFvI+4YiDd36oHt8dOQRjcID2Cnt+F76 nI4yTFZzOgF/rc= 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=ommkP8hXhRRgUESEvXMxFjxeHwM=; b=JBq 9wG6HxXkzr2wYt7B3pnvhhEFzqVDa903UA0WrJ9Rb0AHIYbD4qrxpJbvW7GzLZKO ZWY35Kvyyor8Vyl2hlnqMtpKhyBc47QwkGJ2SG/BVHhWyOSRZPUNDsAMKy2Mn8SZ C6Oelj6/D9sRtTK76UffO4/MKvkLPzoT7gZf47Js= Received: (qmail 109967 invoked by alias); 13 Jul 2017 08:55:39 -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 109115 invoked by uid 89); 13 Jul 2017 08:55:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:55:33 +0000 Received: by mail-wm0-f50.google.com with SMTP id i127so18362846wma.0 for ; Thu, 13 Jul 2017 01:55:32 -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=G2Xy9gfqEa6BbUshq9299tI0RAj8gFsYpsBTEe9nKlQ=; b=dxsPkrYz2yLuWu2pIaL3+bJoNtKv15cC2cSk0Y/FfVIgSICCqbOKWtXyAQtM4KgElk DHIKHMCZm0LvzT40FGiig1W5dDYtZWuNTCESbali1kfOV9PK++PDq/MgLloiO6N78Qkq bgjb95OVwA/wpeVZck+pbm8uutKpvJyK0k0d87oA7H4rE45ZWd/I0XY1XHJ/oWVmZqnB E4n9DlXxpjAebH+CJbXZrRNIZEOPaV/F9v4E87kK9ijq0yude2CVxpXpPJeBztlZIcRa 3H2gc9392v3iXyCP+o+04GV3rEObfj9w+FmNNRodzGeFevq7YtuTj7ZdBgLNkMANDQLK A5kw== X-Gm-Message-State: AIVw111ZBpEVkjYZP6qNzmocjb4S7A+N60f9U1J7eulX1hztIHc8X/sX PXCcKMnA8XgQIcs2ZiG+1w== X-Received: by 10.28.66.153 with SMTP id k25mr1128003wmi.129.1499936130898; Thu, 13 Jul 2017 01:55:30 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id w198sm6122850wme.21.2017.07.13.01.55.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:55:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [48/77] Make subroutines of num_sign_bit_copies operate on scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:55:28 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87eftkg1hb.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Similarly to the nonzero_bits patch, this one moves the mode class check and VOIDmode handling from num_sign_bit_copies1 to num_sign_bit_copies itself, then changes the subroutines to operate on scalar_int_modes. gcc/ 2017-07-13 Richard Sandiford Alan Hayward David Sherwood * rtlanal.c (num_sign_bit_copies): Handle VOIDmode here rather than in subroutines. Return 1 for non-integer modes. (cached_num_sign_bit_copies): Change the type of the mode parameter to scalar_int_mode. (num_sign_bit_copies1): Likewise. Remove early exit for other mode classes. Handle CONST_INT_P first and then check whether X also has a scalar integer mode. Check the same thing for inner registers of a SUBREG and for values that are being extended or truncated. Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:44.976290184 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:45.323262480 +0100 @@ -49,11 +49,12 @@ static unsigned HOST_WIDE_INT cached_non static unsigned HOST_WIDE_INT nonzero_bits1 (const_rtx, scalar_int_mode, const_rtx, machine_mode, unsigned HOST_WIDE_INT); -static unsigned int cached_num_sign_bit_copies (const_rtx, machine_mode, const_rtx, - machine_mode, +static unsigned int cached_num_sign_bit_copies (const_rtx, scalar_int_mode, + const_rtx, machine_mode, unsigned int); -static unsigned int num_sign_bit_copies1 (const_rtx, machine_mode, const_rtx, - machine_mode, unsigned int); +static unsigned int num_sign_bit_copies1 (const_rtx, scalar_int_mode, + const_rtx, machine_mode, + unsigned int); rtx_subrtx_bound_info rtx_all_subrtx_bounds[NUM_RTX_CODE]; rtx_subrtx_bound_info rtx_nonconst_subrtx_bounds[NUM_RTX_CODE]; @@ -4248,7 +4249,12 @@ nonzero_bits (const_rtx x, machine_mode unsigned int num_sign_bit_copies (const_rtx x, machine_mode mode) { - return cached_num_sign_bit_copies (x, mode, NULL_RTX, VOIDmode, 0); + if (mode == VOIDmode) + mode = GET_MODE (x); + scalar_int_mode int_mode; + if (!is_a (mode, &int_mode)) + return 1; + return cached_num_sign_bit_copies (x, int_mode, NULL_RTX, VOIDmode, 0); } /* Return true if nonzero_bits1 might recurse into both operands @@ -4815,8 +4821,8 @@ num_sign_bit_copies_binary_arith_p (cons first or the second level. */ static unsigned int -cached_num_sign_bit_copies (const_rtx x, machine_mode mode, const_rtx known_x, - machine_mode known_mode, +cached_num_sign_bit_copies (const_rtx x, scalar_int_mode mode, + const_rtx known_x, machine_mode known_mode, unsigned int known_ret) { if (x == known_x && mode == known_mode) @@ -4861,44 +4867,46 @@ cached_num_sign_bit_copies (const_rtx x, } /* Return the number of bits at the high-order end of X that are known to - be equal to the sign bit. X will be used in mode MODE; if MODE is - VOIDmode, X will be used in its own mode. The returned value will always - be between 1 and the number of bits in MODE. */ + be equal to the sign bit. X will be used in mode MODE. The returned + value will always be between 1 and the number of bits in MODE. */ static unsigned int -num_sign_bit_copies1 (const_rtx x, machine_mode mode, const_rtx known_x, +num_sign_bit_copies1 (const_rtx x, scalar_int_mode mode, const_rtx known_x, machine_mode known_mode, unsigned int known_ret) { enum rtx_code code = GET_CODE (x); - machine_mode inner_mode; + unsigned int bitwidth = GET_MODE_PRECISION (mode); int num0, num1, result; unsigned HOST_WIDE_INT nonzero; - /* If we weren't given a mode, use the mode of X. If the mode is still - VOIDmode, we don't know anything. Likewise if one of the modes is - floating-point. */ - - if (mode == VOIDmode) - mode = GET_MODE (x); + if (CONST_INT_P (x)) + { + /* If the constant is negative, take its 1's complement and remask. + Then see how many zero bits we have. */ + nonzero = UINTVAL (x) & GET_MODE_MASK (mode); + if (bitwidth <= HOST_BITS_PER_WIDE_INT + && (nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0) + nonzero = (~nonzero) & GET_MODE_MASK (mode); - gcc_checking_assert (mode != BLKmode); + return (nonzero == 0 ? bitwidth : bitwidth - floor_log2 (nonzero) - 1); + } - if (mode == VOIDmode || FLOAT_MODE_P (mode) || FLOAT_MODE_P (GET_MODE (x)) - || VECTOR_MODE_P (GET_MODE (x)) || VECTOR_MODE_P (mode)) + scalar_int_mode xmode, inner_mode; + if (!is_a (GET_MODE (x), &xmode)) return 1; + unsigned int xmode_width = GET_MODE_PRECISION (xmode); + /* For a smaller mode, just ignore the high bits. */ - unsigned int bitwidth = GET_MODE_PRECISION (mode); - if (bitwidth < GET_MODE_PRECISION (GET_MODE (x))) + if (bitwidth < xmode_width) { - num0 = cached_num_sign_bit_copies (x, GET_MODE (x), + num0 = cached_num_sign_bit_copies (x, xmode, known_x, known_mode, known_ret); - return MAX (1, - num0 - (int) (GET_MODE_PRECISION (GET_MODE (x)) - bitwidth)); + return MAX (1, num0 - (int) (xmode_width - bitwidth)); } - if (GET_MODE (x) != VOIDmode && bitwidth > GET_MODE_PRECISION (GET_MODE (x))) + if (bitwidth > xmode_width) { /* If this machine does not do all register operations on the entire register and MODE is wider than the mode of X, we can say nothing @@ -4909,8 +4917,8 @@ num_sign_bit_copies1 (const_rtx x, machi /* Likewise on machines that do, if the mode of the object is smaller than a word and loads of that size don't sign extend, we can say nothing about the high order bits. */ - if (GET_MODE_PRECISION (GET_MODE (x)) < BITS_PER_WORD - && load_extend_op (GET_MODE (x)) != SIGN_EXTEND) + if (xmode_width < BITS_PER_WORD + && load_extend_op (xmode) != SIGN_EXTEND) return 1; } @@ -4927,7 +4935,7 @@ num_sign_bit_copies1 (const_rtx x, machi we can do this only if the target does not support different pointer or address modes depending on the address space. */ if (target_default_pointer_address_modes_p () - && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode + && ! POINTERS_EXTEND_UNSIGNED && xmode == Pmode && mode == Pmode && REG_POINTER (x) && !targetm.have_ptr_extend ()) return GET_MODE_PRECISION (Pmode) - GET_MODE_PRECISION (ptr_mode) + 1; @@ -4952,21 +4960,10 @@ num_sign_bit_copies1 (const_rtx x, machi case MEM: /* Some RISC machines sign-extend all loads of smaller than a word. */ - if (load_extend_op (GET_MODE (x)) == SIGN_EXTEND) - return MAX (1, ((int) bitwidth - - (int) GET_MODE_PRECISION (GET_MODE (x)) + 1)); + if (load_extend_op (xmode) == SIGN_EXTEND) + return MAX (1, ((int) bitwidth - (int) xmode_width + 1)); break; - case CONST_INT: - /* If the constant is negative, take its 1's complement and remask. - Then see how many zero bits we have. */ - nonzero = UINTVAL (x) & GET_MODE_MASK (mode); - if (bitwidth <= HOST_BITS_PER_WIDE_INT - && (nonzero & (HOST_WIDE_INT_1U << (bitwidth - 1))) != 0) - nonzero = (~nonzero) & GET_MODE_MASK (mode); - - return (nonzero == 0 ? bitwidth : bitwidth - floor_log2 (nonzero) - 1); - case SUBREG: /* If this is a SUBREG for a promoted object that is sign-extended and we are looking at it in a wider mode, we know that at least the @@ -4976,37 +4973,38 @@ num_sign_bit_copies1 (const_rtx x, machi { num0 = cached_num_sign_bit_copies (SUBREG_REG (x), mode, known_x, known_mode, known_ret); - return MAX ((int) bitwidth - - (int) GET_MODE_PRECISION (GET_MODE (x)) + 1, - num0); + return MAX ((int) bitwidth - (int) xmode_width + 1, num0); } - /* For a smaller object, just ignore the high bits. */ - inner_mode = GET_MODE (SUBREG_REG (x)); - if (bitwidth <= GET_MODE_PRECISION (inner_mode)) + if (is_a (GET_MODE (SUBREG_REG (x)), &inner_mode)) { - num0 = cached_num_sign_bit_copies (SUBREG_REG (x), VOIDmode, - known_x, known_mode, known_ret); - return - MAX (1, num0 - (int) (GET_MODE_PRECISION (inner_mode) - bitwidth)); - } + /* For a smaller object, just ignore the high bits. */ + if (bitwidth <= GET_MODE_PRECISION (inner_mode)) + { + num0 = cached_num_sign_bit_copies (SUBREG_REG (x), inner_mode, + known_x, known_mode, + known_ret); + return MAX (1, num0 - (int) (GET_MODE_PRECISION (inner_mode) + - bitwidth)); + } - /* For paradoxical SUBREGs on machines where all register operations - affect the entire register, just look inside. Note that we are - passing MODE to the recursive call, so the number of sign bit copies - will remain relative to that mode, not the inner mode. */ - - /* This works only if loads sign extend. Otherwise, if we get a - reload for the inner part, it may be loaded from the stack, and - then we lose all sign bit copies that existed before the store - to the stack. */ - - if (WORD_REGISTER_OPERATIONS - && load_extend_op (inner_mode) == SIGN_EXTEND - && paradoxical_subreg_p (x) - && (MEM_P (SUBREG_REG (x)) || REG_P (SUBREG_REG (x)))) - return cached_num_sign_bit_copies (SUBREG_REG (x), mode, - known_x, known_mode, known_ret); + /* For paradoxical SUBREGs on machines where all register operations + affect the entire register, just look inside. Note that we are + passing MODE to the recursive call, so the number of sign bit + copies will remain relative to that mode, not the inner mode. */ + + /* This works only if loads sign extend. Otherwise, if we get a + reload for the inner part, it may be loaded from the stack, and + then we lose all sign bit copies that existed before the store + to the stack. */ + + if (WORD_REGISTER_OPERATIONS + && load_extend_op (inner_mode) == SIGN_EXTEND + && paradoxical_subreg_p (x) + && (MEM_P (SUBREG_REG (x)) || REG_P (SUBREG_REG (x)))) + return cached_num_sign_bit_copies (SUBREG_REG (x), mode, + known_x, known_mode, known_ret); + } break; case SIGN_EXTRACT: @@ -5015,15 +5013,18 @@ num_sign_bit_copies1 (const_rtx x, machi break; case SIGN_EXTEND: - return (bitwidth - GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) - + cached_num_sign_bit_copies (XEXP (x, 0), VOIDmode, - known_x, known_mode, known_ret)); + if (is_a (GET_MODE (XEXP (x, 0)), &inner_mode)) + return (bitwidth - GET_MODE_PRECISION (inner_mode) + + cached_num_sign_bit_copies (XEXP (x, 0), inner_mode, + known_x, known_mode, known_ret)); + break; case TRUNCATE: /* For a smaller object, just ignore the high bits. */ - num0 = cached_num_sign_bit_copies (XEXP (x, 0), VOIDmode, + inner_mode = as_a (GET_MODE (XEXP (x, 0))); + num0 = cached_num_sign_bit_copies (XEXP (x, 0), inner_mode, known_x, known_mode, known_ret); - return MAX (1, (num0 - (int) (GET_MODE_PRECISION (GET_MODE (XEXP (x, 0))) + return MAX (1, (num0 - (int) (GET_MODE_PRECISION (inner_mode) - bitwidth))); case NOT: @@ -5200,7 +5201,7 @@ num_sign_bit_copies1 (const_rtx x, machi known_x, known_mode, known_ret); if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) > 0 - && INTVAL (XEXP (x, 1)) < GET_MODE_PRECISION (GET_MODE (x))) + && INTVAL (XEXP (x, 1)) < xmode_width) num0 = MIN ((int) bitwidth, num0 + INTVAL (XEXP (x, 1))); return num0; @@ -5210,7 +5211,7 @@ num_sign_bit_copies1 (const_rtx x, machi if (!CONST_INT_P (XEXP (x, 1)) || INTVAL (XEXP (x, 1)) < 0 || INTVAL (XEXP (x, 1)) >= (int) bitwidth - || INTVAL (XEXP (x, 1)) >= GET_MODE_PRECISION (GET_MODE (x))) + || INTVAL (XEXP (x, 1)) >= xmode_width) return 1; num0 = cached_num_sign_bit_copies (XEXP (x, 0), mode, From patchwork Thu Jul 13 08:55:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107635 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938100qge; Thu, 13 Jul 2017 01:57:40 -0700 (PDT) X-Received: by 10.99.185.25 with SMTP id z25mr8068860pge.273.1499936260435; Thu, 13 Jul 2017 01:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936260; cv=none; d=google.com; s=arc-20160816; b=ESk1p/azw7Omghs6jJzqqWCG2IEk9Z7tmnRsSE+sApAdrOGNUY7Vip7NsUZ21uwn+G e8g6uZX/Zu9NiniN4a7VUzPtP8MVeUo4cmEz8eqj7SJDwX9B6BlLaxX5b7qEdw1D9I+Z PWVvEFCT/nH667B5X7IWIgksrxrrFR/DvN93ICjZ92jBNGSaUgu9jjyWb4xRiU91tx5m UY3PGbXFRyBLHeJriRpdoSyoCRMh4yu8NtG58uwBXuLSnksOMxB640TDDM29y8F55toH hLQ/eHOvgsHlLFLDrEae422kVagBeEzTj9AyP1tsGBJ8VXeJxvo8y5JbOz2xd/+9hF2N g0rg== 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=77ocFSiCmtipTKD1YA1muEw6q2LMtd6EWJA8BN+9KE0=; b=VdTyC06mRWto24MpWVWaeo9deuK8nC0x/xaQKe3wIVOnneg5NiAoCtn17PF8n6BaiZ QoW2uYLgUPbGKZionywnprxNLl1ghdlbcT1Sr1eSmmm9qzJV/bBRIgcbigdtQskTa76c oRbHYq0P9fr0AZ+FNWzu3HqSCzaoHmFiVW8E2l5mAv6mcJ1jiTXP4JpKTqO5YvUbfg+N izuXy5UsEHyb22F8LB6+NBlb7Eo4AcGuIW5CPOrA1lUdTz6oua64YdQdEBsSX/zHThzQ DrsGYfhEhZSM1pt8EZI9LvOgLU2ysUS4WJ5jWSkxdRnoQPz7B3ZOaj7IURA8sVn0lKRk 6H3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=MLEavWUw; spf=pass (google.com: domain of gcc-patches-return-458040-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458040-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 p7si3952917pll.609.2017.07.13.01.57.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458040-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=MLEavWUw; spf=pass (google.com: domain of gcc-patches-return-458040-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458040-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=ogVx36zvBkopMLJsXUP6ActmY43D6 3FIPiLCBLPExg5GnKlWMffCaAC8w2yvAv7Xo/tmXw2Xt96rGhp24/zrkOhDBRwo/ 7IklePRnUf35yUItJg7QZNsKfh6k9pGmiQAAfUjFyQJ11fAniUvuSRQIsAkjmaI+ 7CveFzB5poA6Gc= 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=GYsWmFSM8YFrtKXlLOWZsLpLnks=; b=MLE avWUwd73GNREgA2jtcuy9FX+7Bn+Vti/LzW6SKNQxHgODMUDABRaDxFv5eZz6Vy5 /ibi39zTd99qWyWRO8vgHgmKf3s2VvhsrO+4Klffy/XMMayas7ER+hAzSbF1wt+2 6V6rrLleRxF4+QIZroBMqfgu5GDBW/NJHEkcr5xc= Received: (qmail 125078 invoked by alias); 13 Jul 2017 08:55:54 -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 124329 invoked by uid 89); 13 Jul 2017 08:55:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=8615 X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:55:50 +0000 Received: by mail-wr0-f171.google.com with SMTP id c11so49485208wrc.3 for ; Thu, 13 Jul 2017 01:55:50 -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=77ocFSiCmtipTKD1YA1muEw6q2LMtd6EWJA8BN+9KE0=; b=OzA8ZA1fGymFTHbmCN0jFA7F9fNhx8jl2K1HHXXrZDXBq4W092+evJ5hT1rR7Selp/ OXaGyJcvYLM4D/JXmYUjegvLPFkfCMOBt2ewCkyQnPIX5hLXn9kXpSP9bNiWjbP7FCI3 bg+S8Vodc+h54St3g6fZbEJ+WhQ3v11HSqJ0UcDTvMiNy1v6YHxtqDFvvBuMOGL4yGuk INmWzx1/IQmCtSSzJl7xUrQV0/q2NXRQkiQ6ufH+llR8EMDWKQUi6pew8JxlIPEMe25D tIMVNZlbv9lK1NSBI2Hdhl+JPDssz/WtGpHoP9CCFr9VixXg3x+TzsDz7Dl6rbggnmHw TSyQ== X-Gm-Message-State: AIVw111kCzJkI/selzD0fp3O/21gyQe9N1Cf6+bLRpw3gG4fxH4quEHP nwfM5wGQb4vE+qZFzX3ZAg== X-Received: by 10.223.170.194 with SMTP id i2mr1039688wrc.143.1499936148545; Thu, 13 Jul 2017 01:55:48 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id n31sm4983220wrn.59.2017.07.13.01.55.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:55:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [49/77] Simplify nonzero/num_sign_bits hooks References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:55:46 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87a848g1gt.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The two implementations of the reg_nonzero_bits and reg_num_sign_bits hooks ignored the "known_x", "known_mode" and "known_ret" arguments, so this patch removes them. It adds a new scalar_int_mode parameter that specifies the mode of "x". (This mode might be different from "mode", which is the mode in which "x" is used.) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * rtl.h (rtl_hooks::reg_nonzero_bits): Add a scalar_int_mode parameter for the mode of "x". Remove the "known_x", "known_mode" and "known_ret" arguments. Change the type of the mode argument to scalar_int_mode. (rtl_hooks:reg_num_sign_bit_copies): Likewise. * combine.c (reg_nonzero_bits_for_combine): Update accordingly. (reg_num_sign_bit_copies_for_combine): Likewise. * rtlanal.c (nonzero_bits1): Likewise. (num_sign_bit_copies1): Likewise. * rtlhooks-def.h (reg_nonzero_bits_general): Likewise. (reg_num_sign_bit_copies_general): Likewise. * rtlhooks.c (reg_num_sign_bit_copies_general): Likewise. (reg_nonzero_bits_general): Likewise. Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-13 09:18:32.528352705 +0100 +++ gcc/rtl.h 2017-07-13 09:18:45.761227536 +0100 @@ -3764,10 +3764,10 @@ struct rtl_hooks { rtx (*gen_lowpart) (machine_mode, rtx); rtx (*gen_lowpart_no_emit) (machine_mode, rtx); - rtx (*reg_nonzero_bits) (const_rtx, machine_mode, const_rtx, machine_mode, - unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT *); - rtx (*reg_num_sign_bit_copies) (const_rtx, machine_mode, const_rtx, machine_mode, - unsigned int, unsigned int *); + rtx (*reg_nonzero_bits) (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned HOST_WIDE_INT *); + rtx (*reg_num_sign_bit_copies) (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned int *); bool (*reg_truncated_to_mode) (machine_mode, const_rtx); /* Whenever you add entries here, make sure you adjust rtlhooks-def.h. */ Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:44.175354711 +0100 +++ gcc/combine.c 2017-07-13 09:18:45.761227536 +0100 @@ -414,13 +414,12 @@ struct undobuf static int n_occurrences; -static rtx reg_nonzero_bits_for_combine (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned HOST_WIDE_INT, +static rtx reg_nonzero_bits_for_combine (const_rtx, scalar_int_mode, + scalar_int_mode, unsigned HOST_WIDE_INT *); -static rtx reg_num_sign_bit_copies_for_combine (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned int, unsigned int *); +static rtx reg_num_sign_bit_copies_for_combine (const_rtx, scalar_int_mode, + scalar_int_mode, + unsigned int *); static void do_SUBST (rtx *, rtx); static void do_SUBST_INT (int *, int); static void init_reg_last (void); @@ -10057,17 +10056,15 @@ simplify_and_const_int (rtx x, scalar_in return x; } -/* Given a REG, X, compute which bits in X can be nonzero. +/* Given a REG X of mode XMODE, compute which bits in X can be nonzero. We don't care about bits outside of those defined in MODE. For most X this is simply GET_MODE_MASK (GET_MODE (MODE)), but if X is a shift, AND, or zero_extract, we can do better. */ static rtx -reg_nonzero_bits_for_combine (const_rtx x, machine_mode mode, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode ATTRIBUTE_UNUSED, - unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED, +reg_nonzero_bits_for_combine (const_rtx x, scalar_int_mode xmode, + scalar_int_mode mode, unsigned HOST_WIDE_INT *nonzero) { rtx tem; @@ -10108,8 +10105,7 @@ reg_nonzero_bits_for_combine (const_rtx if (tem) { if (SHORT_IMMEDIATES_SIGN_EXTEND) - tem = sign_extend_short_imm (tem, GET_MODE (x), - GET_MODE_PRECISION (mode)); + tem = sign_extend_short_imm (tem, xmode, GET_MODE_PRECISION (mode)); return tem; } @@ -10118,9 +10114,9 @@ reg_nonzero_bits_for_combine (const_rtx { unsigned HOST_WIDE_INT mask = rsp->nonzero_bits; - if (GET_MODE_PRECISION (GET_MODE (x)) < GET_MODE_PRECISION (mode)) + if (GET_MODE_PRECISION (xmode) < GET_MODE_PRECISION (mode)) /* We don't know anything about the upper bits. */ - mask |= GET_MODE_MASK (mode) ^ GET_MODE_MASK (GET_MODE (x)); + mask |= GET_MODE_MASK (mode) ^ GET_MODE_MASK (xmode); *nonzero &= mask; } @@ -10128,17 +10124,14 @@ reg_nonzero_bits_for_combine (const_rtx return NULL; } -/* Return the number of bits at the high-order end of X that are known to - be equal to the sign bit. X will be used in mode MODE; if MODE is - VOIDmode, X will be used in its own mode. The returned value will always - be between 1 and the number of bits in MODE. */ +/* Given a reg X of mode XMODE, return the number of bits at the high-order + end of X that are known to be equal to the sign bit. X will be used + in mode MODE; the returned value will always be between 1 and the + number of bits in MODE. */ static rtx -reg_num_sign_bit_copies_for_combine (const_rtx x, machine_mode mode, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode - ATTRIBUTE_UNUSED, - unsigned int known_ret ATTRIBUTE_UNUSED, +reg_num_sign_bit_copies_for_combine (const_rtx x, scalar_int_mode xmode, + scalar_int_mode mode, unsigned int *result) { rtx tem; @@ -10167,7 +10160,7 @@ reg_num_sign_bit_copies_for_combine (con return tem; if (nonzero_sign_valid && rsp->sign_bit_copies != 0 - && GET_MODE_PRECISION (GET_MODE (x)) == GET_MODE_PRECISION (mode)) + && GET_MODE_PRECISION (xmode) == GET_MODE_PRECISION (mode)) *result = rsp->sign_bit_copies; return NULL; Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:45.323262480 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:45.762227456 +0100 @@ -4449,9 +4449,8 @@ nonzero_bits1 (const_rtx x, scalar_int_m { unsigned HOST_WIDE_INT nonzero_for_hook = nonzero; - rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, mode, known_x, - known_mode, known_ret, - &nonzero_for_hook); + rtx new_rtx = rtl_hooks.reg_nonzero_bits (x, xmode, mode, + &nonzero_for_hook); if (new_rtx) nonzero_for_hook &= cached_nonzero_bits (new_rtx, mode, known_x, @@ -4943,9 +4942,8 @@ num_sign_bit_copies1 (const_rtx x, scala { unsigned int copies_for_hook = 1, copies = 1; - rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, mode, known_x, - known_mode, known_ret, - &copies_for_hook); + rtx new_rtx = rtl_hooks.reg_num_sign_bit_copies (x, xmode, mode, + &copies_for_hook); if (new_rtx) copies = cached_num_sign_bit_copies (new_rtx, mode, known_x, Index: gcc/rtlhooks-def.h =================================================================== --- gcc/rtlhooks-def.h 2017-02-23 19:54:15.000000000 +0000 +++ gcc/rtlhooks-def.h 2017-07-13 09:18:45.762227456 +0100 @@ -38,13 +38,11 @@ #define RTL_HOOKS_INITIALIZER { \ } extern rtx gen_lowpart_general (machine_mode, rtx); -extern rtx reg_nonzero_bits_general (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned HOST_WIDE_INT, +extern rtx reg_nonzero_bits_general (const_rtx, scalar_int_mode, + scalar_int_mode, unsigned HOST_WIDE_INT *); -extern rtx reg_num_sign_bit_copies_general (const_rtx, machine_mode, const_rtx, - machine_mode, - unsigned int, unsigned int *); +extern rtx reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, + scalar_int_mode, unsigned int *); extern bool reg_truncated_to_mode_general (machine_mode, const_rtx); #endif /* GCC_RTL_HOOKS_DEF_H */ Index: gcc/rtlhooks.c =================================================================== --- gcc/rtlhooks.c 2017-07-13 09:18:32.528352705 +0100 +++ gcc/rtlhooks.c 2017-07-13 09:18:45.762227456 +0100 @@ -86,23 +86,15 @@ gen_lowpart_general (machine_mode mode, } rtx -reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED, - machine_mode mode ATTRIBUTE_UNUSED, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode ATTRIBUTE_UNUSED, - unsigned int known_ret ATTRIBUTE_UNUSED, - unsigned int *result ATTRIBUTE_UNUSED) +reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned int *) { return NULL; } rtx -reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED, - machine_mode mode ATTRIBUTE_UNUSED, - const_rtx known_x ATTRIBUTE_UNUSED, - machine_mode known_mode ATTRIBUTE_UNUSED, - unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED, - unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED) +reg_nonzero_bits_general (const_rtx, scalar_int_mode, scalar_int_mode, + unsigned HOST_WIDE_INT *) { return NULL; } From patchwork Thu Jul 13 08:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107636 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938351qge; Thu, 13 Jul 2017 01:58:05 -0700 (PDT) X-Received: by 10.98.30.194 with SMTP id e185mr28769407pfe.158.1499936284540; Thu, 13 Jul 2017 01:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936284; cv=none; d=google.com; s=arc-20160816; b=ZC2WtYFFxv03YkDH/nhp7Jshu1/TGdaC1sHl7JVeIE9Hp99y8dIjuBSPyLxsJ7KUpa Qh8Z7PsclM/NfhduiRD8SC8nT0rhIjkEkOfhJGwpzZTRgnLs89PWh0xYwLqQ2LFHdIfw hGQ+tpH05S6Iw12/QAAIv0bLPfjgDPiob6tcr5mhpNitArtPkpudY4nwxIH83qO13Soq hFpoGXO/R7MCzCCu/x3xlBOhhFR7xHjYCu7IQ8QGAC3NKEZsd2PfVDjeXezFBzfnCtpF 42Kp3mwJelwaZJeRNUEK8FSf9NB7S/U1b5sypcJRP9Nakc3MlF4HGeEAV21FM3dkYU24 Wvug== 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=PtxwxGU3OHhpdiFgKdF9HTrJsBaH9dEIliw4BmYKHHY=; b=bNAEVM3LT9HEKmvilaOKxdma4ecGItc4y6pFOA3ke+XIoRWv3U73eyfOPx55OjtU4+ kS9Stcm8ZJmeQVkPXjbcRLl5D7kY0sGKJlBJr/0TqnnSRAYwIv2W03Gp43fEFZgUWA/Z S8B+P8wY4jwllVS5EbKTfXj84VVEdDmwV26s4nw37SRV7iBWfBja0aC4GBTI/AbelOcd nE49/LtidSn7FSDzTRtaex/oXYDv+C+f5QsKUR76/1lcDpEvDO441ZDhbu9T5Qmp9Xvz Av2MSxJ3h28KTAtpRp9SXPvULjUGxlOXWoFNl3I7i4C1+mCijOY1UZcc96JFZ7UhpNzL SX9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=LwNdmFQQ; spf=pass (google.com: domain of gcc-patches-return-458041-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458041-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 l21si3769480pfj.297.2017.07.13.01.58.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458041-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=LwNdmFQQ; spf=pass (google.com: domain of gcc-patches-return-458041-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458041-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=EsPvhj+aaWSdpLX8wskIuTsXR2PyQ pYG0ybB1A0An6V3X8F/Xmx4v27E0Vzu0ui4rNlHF/60ArMR4XBchwUkFI27VLoDg UJBM0SRGPMqc8trlXfO20swmQ6NZq8C6q+tRGhi5cFnl1BJT6KtJCinKBxe7qKc9 lTi3fZxT/5Hg9w= 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=no0UDiEfaZlSp9RcQkATolupD0s=; b=LwN dmFQQ6NV5pSjykm+uEf0jdyF/7vTsYlrtsuCLvtvyQfwJHZfGaUEuXUKwQFWlE1w W7sNNjoPN//p/+8EfZIkeKwe6PcL4ywCdr0m7fAouN8XpalHub1Sz8o4rCyEkfTS ZTHMBNjGz9rI4rYU30dCpeXNpEPEU6RoONzBJVK4= Received: (qmail 14425 invoked by alias); 13 Jul 2017 08:56:17 -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 13753 invoked by uid 89); 13 Jul 2017 08:56:16 -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:56:13 +0000 Received: by mail-wr0-f180.google.com with SMTP id c11so49489961wrc.3 for ; Thu, 13 Jul 2017 01:56:12 -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=PtxwxGU3OHhpdiFgKdF9HTrJsBaH9dEIliw4BmYKHHY=; b=sYsC4FPgOugHTMf30IEiCQjV+JMeKocRYVGBjUD5nFDUtsWz5GTEQMV+eH8SaukFmS gs9q/EjznIHOd2VWlXlnQjw4G+P/uKvTSrQBOf30noheijCnbuzFxe+eGI/5xvMRX/dc B8EVDY+vIrQYyMh3VxEzDxZ4/AIaaIWNEmhS6A5QztAc/um0tLve60HKxCyTGNfRlssH acr4o6yNnwQTZa7SOeEQb6S7DRSn/2vddyB4FhJ1aJOXJY/qsxHu87AZzDxlapbRzbPh HJ0xmDdf9O45peoCWDQRFM8Kum/8HfPMtZozFRClOcCxR/sVBlZMB/BdBc16y5GbZj1I CpHA== X-Gm-Message-State: AIVw110MlABkN+UUAoPD4PNNeOP+Rc5YoZ897yTbFVGbcDchpX46Pt4a iKkjcp8wQbtlGSS2lRPs6g== X-Received: by 10.223.175.229 with SMTP id y37mr1040000wrd.61.1499936170139; Thu, 13 Jul 2017 01:56:10 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id y35sm4712452wrc.51.2017.07.13.01.56.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:56:09 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [50/77] Add helper routines for SUBREG_PROMOTED_VAR_P subregs References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:56:07 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8760ewg1g8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 When subregs contain promoted values, as indicated by SUBREG_PROMOTED_VAR_P, both the unpromoted (outer) and promoted (inner) values are known to be scalar integers. This patch adds helper routines that get the modes as scalar_int_modes. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * rtl.h (subreg_unpromoted_mode, subreg_promoted_mode): New functions. * expr.c (convert_move): Use them. (convert_modes): Likewise. (store_expr_with_bounds): Likewise. Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-13 09:18:45.761227536 +0100 +++ gcc/rtl.h 2017-07-13 09:18:46.226190608 +0100 @@ -2766,6 +2766,24 @@ unwrap_const_vec_duplicate (T x) return x; } +/* Return the unpromoted (outer) mode of SUBREG_PROMOTED_VAR_P subreg X. */ + +inline scalar_int_mode +subreg_unpromoted_mode (rtx x) +{ + gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x)); + return as_a (GET_MODE (x)); +} + +/* Return the promoted (inner) mode of SUBREG_PROMOTED_VAR_P subreg X. */ + +inline scalar_int_mode +subreg_promoted_mode (rtx x) +{ + gcc_checking_assert (SUBREG_PROMOTED_VAR_P (x)); + return as_a (GET_MODE (SUBREG_REG (x))); +} + /* In emit-rtl.c */ extern rtvec gen_rtvec_v (int, rtx *); extern rtvec gen_rtvec_v (int, rtx_insn **); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:44.578322246 +0100 +++ gcc/expr.c 2017-07-13 09:18:46.226190608 +0100 @@ -243,7 +243,7 @@ convert_move (rtx to, rtx from, int unsi if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) && is_a (to_mode, &to_int_mode) - && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) + && (GET_MODE_PRECISION (subreg_promoted_mode (from)) >= GET_MODE_PRECISION (to_int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (from, unsignedp)) from = gen_lowpart (to_int_mode, from), from_mode = to_int_mode; @@ -641,7 +641,8 @@ convert_modes (machine_mode mode, machin if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x) && is_a (mode, &int_mode) - && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (int_mode) + && (GET_MODE_PRECISION (subreg_promoted_mode (x)) + >= GET_MODE_PRECISION (int_mode)) && SUBREG_CHECK_PROMOTED_SIGN (x, unsignedp)) x = gen_lowpart (int_mode, SUBREG_REG (x)); @@ -5422,6 +5423,8 @@ store_expr_with_bounds (tree exp, rtx ta expression. */ { rtx inner_target = 0; + scalar_int_mode outer_mode = subreg_unpromoted_mode (target); + scalar_int_mode inner_mode = subreg_promoted_mode (target); /* We can do the conversion inside EXP, which will often result in some optimizations. Do the conversion in two steps: first @@ -5431,7 +5434,7 @@ store_expr_with_bounds (tree exp, rtx ta converting modes. */ if (INTEGRAL_TYPE_P (TREE_TYPE (exp)) && TREE_TYPE (TREE_TYPE (exp)) == 0 - && GET_MODE_PRECISION (GET_MODE (target)) + && GET_MODE_PRECISION (outer_mode) == TYPE_PRECISION (TREE_TYPE (exp))) { if (!SUBREG_CHECK_PROMOTED_SIGN (target, @@ -5451,8 +5454,7 @@ store_expr_with_bounds (tree exp, rtx ta } exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode - (GET_MODE (SUBREG_REG (target)), - SUBREG_PROMOTED_SIGN (target)), + (inner_mode, SUBREG_PROMOTED_SIGN (target)), exp); inner_target = SUBREG_REG (target); @@ -5478,10 +5480,9 @@ store_expr_with_bounds (tree exp, rtx ta sure that we properly convert it. */ if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode) { - temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)), + temp = convert_modes (outer_mode, TYPE_MODE (TREE_TYPE (exp)), temp, SUBREG_PROMOTED_SIGN (target)); - temp = convert_modes (GET_MODE (SUBREG_REG (target)), - GET_MODE (target), temp, + temp = convert_modes (inner_mode, outer_mode, temp, SUBREG_PROMOTED_SIGN (target)); } From patchwork Thu Jul 13 08:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107637 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938609qge; Thu, 13 Jul 2017 01:58:24 -0700 (PDT) X-Received: by 10.98.79.130 with SMTP id f2mr60517717pfj.133.1499936304210; Thu, 13 Jul 2017 01:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936304; cv=none; d=google.com; s=arc-20160816; b=s7RmmixdyDnUAa6XJqxD87xKDW5qZnsXunFT3QzaY8KtWBcYFD9k/yYMEvMaXvHtu0 ZRb+R/O2XhxcOWgrOnIwrCDmsX4jJhXX2TgJ8rZDeBcqhWuTWHYK/RRoystbfs0k6v2V otyJoGlD5GLLm0mc1yt+/QZA0+CzQq84Wj0v88AzzqGwAyQS4DJBjF+3+k0KPF61Waan 9eW+peD9SfZnU/UEsr7mNE03WsaTaxKx0mpXJ4VqjOYaETOd2DWVPlLbergwHZGLgJSc fWCKHl8bNDum7iMNAI8+wPrU4rg9S3CZxwe+2hn2GBclLJk3d10G21BPtgqO9klXDuaz sPxA== 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=uz8MrBJ6Rc29vj4ZCz2H9f4Jv0jCbj3g2iofJbCim/I=; b=AAJPQkbB9SaK0lUpzeD/v6tsePj8KKN6b1UgG6ekA/AyuchFsWdhMP2YwweeSBVr8a nOA9RHi3bcwtJF3vyP9Z/speWT60kKj5i/0fgk+NjfsZQOkYf7fCZXFrFc2sz4UZpJ67 OoFtv/06xPJpQksoScbXEXX8a32UAKJrgHYLDk2PvbRTOLjo4q4rofZ9uByg0dLj69Y6 SB0fUPtSeB8yZiuuOltlqNyXOUFYGsrTTxwEBHP3urAggP1hnY9rh6QoOhzLpDFMpTAC Vj2FZXK0X+lT7dswX7lGep9/aYvcxjJ3h6cwoZU47Y8/pVi9jk7gkMJmJqQGWViH5/Ov LGaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=UBiRUD5b; spf=pass (google.com: domain of gcc-patches-return-458042-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458042-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 w9si3790582pfk.85.2017.07.13.01.58.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:58:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458042-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=UBiRUD5b; spf=pass (google.com: domain of gcc-patches-return-458042-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458042-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=Z9ywAq4x4zThN4+Giegp8OwOoMpst GQt/XJiUQ02pzruHCS095t09hhYKvrZ0tfz5/SO6ThkOFWF53C9VD0AseYDk5zgJ yEqV8rJDfB9rh5gVTN5iU203MJRp5MYjbRvcmp/D8DeTZJA+QqEfznII9cw3ADRX 24HeQrYiGn1UzA= 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=LZiQv98bZqjho0w2SvBL0CIhdpw=; b=UBi RUD5bfEgHBcTl/U/6b3860VDQNMsuXBZU5PvHiUMxDjN+wxE0ZjcSrQ3DgB/lJ5x Utm6AoOO2hMkQhv+XCtpzx9FxybZDeX/DQIA9B6Rgav3+S1IsWAJEcFv4aLOxweY f4Hp57p6HizxLrO7Pn9hwbsQk5ASHo2gKjQVOrvo= Received: (qmail 30354 invoked by alias); 13 Jul 2017 08:56:35 -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 29518 invoked by uid 89); 13 Jul 2017 08:56:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, 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-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:56:30 +0000 Received: by mail-wm0-f48.google.com with SMTP id w126so16749119wme.0 for ; Thu, 13 Jul 2017 01:56:29 -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=uz8MrBJ6Rc29vj4ZCz2H9f4Jv0jCbj3g2iofJbCim/I=; b=fpwxMqejn+Cc1Ue8uNpDBNCiZ86iH6w/Azra5dvdPv5cvRdQcf0kS4DExY+CX8/Sri 7afspaEkh/9O3lsRStJlKBkd5ODUxNYKYccCoBUyQ5WJv5mg2k1xRrWho7nHqpNQEzds CkKrCkoOpy8IKFR1qBaXDHSx97Q1Ei7nRlFSYo0Lo7S5ZCs1MJ3C2FnBwLK1uYhBOYXP 3KYA8ubMOz4zwBWdLpFD6v60/g2EtYhaI2KpPFH2x7iQ5PSWq58hxvXoeTjo5i382tnC lFWh8tFuLNd8psn5oi9d7okt7vfD76iSGPiAGeScbHDIkHvgo8akcJoXIuJ7ha6RFV/P U8tg== X-Gm-Message-State: AIVw111jH2OW4WR+tbhYH+XhRRX7PJcekTXWh7ucsG3lozGDItbQp0BE sWzXP4vvd17qZQriS2VzKw== X-Received: by 10.28.95.137 with SMTP id t131mr1162317wmb.102.1499936187448; Thu, 13 Jul 2017 01:56:27 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 1sm5429235wmn.32.2017.07.13.01.56.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:56:26 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [51/77] Use opt_scalar_int_mode when iterating over integer modes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:56:24 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <871spkg1fr.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses opt_scalar_int_mode rather than machine_mode when iterating over scalar_int_modes, in cases where that helps with future patches. (Using machine_mode is still OK in places that don't really care about the mode being a scalar integer.) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * cse.c (cse_insn): Use opt_scalar_int_mode for the mode iterator. * explow.c (hard_function_value): Likewise. * expmed.c (init_expmed_one_mode): Likewise. (extract_fixed_bit_field_1): Likewise. Move the convert_to_mode call outside the loop. * expr.c (alignment_for_piecewise_move): Use opt_scalar_int_mode for the mode iterator. Require the mode specified by max_pieces to exist. (emit_block_move_via_movmem): Use opt_scalar_int_mode for the mode iterator. (copy_blkmode_to_reg): Likewise. (set_storage_via_setmem): Likewise. * optabs.c (prepare_cmp_insn): Likewise. * rtlanal.c (init_num_sign_bit_copies_in_rep): Likewise. * stor-layout.c (finish_bitfield_representative): Likewise. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use opt_scalar_int_mode for the mode iterator. Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-07-13 09:18:39.584734236 +0100 +++ gcc/cse.c 2017-07-13 09:18:46.699153232 +0100 @@ -4885,11 +4885,12 @@ cse_insn (rtx_insn *insn) && GET_CODE (src) == AND && CONST_INT_P (XEXP (src, 1)) && GET_MODE_SIZE (int_mode) < UNITS_PER_WORD) { - machine_mode tmode; + opt_scalar_int_mode tmode_iter; rtx new_and = gen_rtx_AND (VOIDmode, NULL_RTX, XEXP (src, 1)); - FOR_EACH_WIDER_MODE (tmode, int_mode) + FOR_EACH_WIDER_MODE (tmode_iter, int_mode) { + scalar_int_mode tmode = *tmode_iter; if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) break; @@ -4932,7 +4933,6 @@ cse_insn (rtx_insn *insn) { struct rtx_def memory_extend_buf; rtx memory_extend_rtx = &memory_extend_buf; - machine_mode tmode; /* Set what we are trying to extend and the operation it might have been extended with. */ @@ -4940,10 +4940,12 @@ cse_insn (rtx_insn *insn) PUT_CODE (memory_extend_rtx, extend_op); XEXP (memory_extend_rtx, 0) = src; - FOR_EACH_WIDER_MODE (tmode, int_mode) + opt_scalar_int_mode tmode_iter; + FOR_EACH_WIDER_MODE (tmode_iter, int_mode) { struct table_elt *larger_elt; + scalar_int_mode tmode = *tmode_iter; if (GET_MODE_SIZE (tmode) > UNITS_PER_WORD) break; Index: gcc/explow.c =================================================================== --- gcc/explow.c 2017-07-13 09:18:21.531429258 +0100 +++ gcc/explow.c 2017-07-13 09:18:46.700153153 +0100 @@ -1906,7 +1906,7 @@ hard_function_value (const_tree valtype, && GET_MODE (val) == BLKmode) { unsigned HOST_WIDE_INT bytes = int_size_in_bytes (valtype); - machine_mode tmpmode; + opt_scalar_int_mode tmpmode; /* int_size_in_bytes can return -1. We don't need a check here since the value of bytes will then be large enough that no @@ -1915,14 +1915,11 @@ hard_function_value (const_tree valtype, FOR_EACH_MODE_IN_CLASS (tmpmode, MODE_INT) { /* Have we found a large enough mode? */ - if (GET_MODE_SIZE (tmpmode) >= bytes) + if (GET_MODE_SIZE (*tmpmode) >= bytes) break; } - /* No suitable mode found. */ - gcc_assert (tmpmode != VOIDmode); - - PUT_MODE (val, tmpmode); + PUT_MODE (val, *tmpmode); } return val; } Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:42.161519072 +0100 +++ gcc/expmed.c 2017-07-13 09:18:46.700153153 +0100 @@ -147,7 +147,6 @@ init_expmed_one_mode (struct init_expmed machine_mode mode, int speed) { int m, n, mode_bitsize; - machine_mode mode_from; mode_bitsize = GET_MODE_UNIT_BITSIZE (mode); @@ -205,8 +204,9 @@ init_expmed_one_mode (struct init_expmed scalar_int_mode int_mode_to; if (is_a (mode, &int_mode_to)) { - FOR_EACH_MODE_IN_CLASS (mode_from, MODE_INT) - init_expmed_one_conv (all, int_mode_to, mode_from, speed); + opt_scalar_int_mode int_mode_from; + FOR_EACH_MODE_IN_CLASS (int_mode_from, MODE_INT) + init_expmed_one_conv (all, int_mode_to, *int_mode_from, speed); scalar_int_mode wider_mode; if (GET_MODE_CLASS (int_mode_to) == MODE_INT @@ -2019,12 +2019,13 @@ extract_fixed_bit_field_1 (machine_mode /* Find the narrowest integer mode that contains the field. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) - if (GET_MODE_BITSIZE (mode) >= bitsize + bitnum) - { - op0 = convert_to_mode (mode, op0, 0); - break; - } + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) + if (GET_MODE_BITSIZE (*mode_iter) >= bitsize + bitnum) + break; + + mode = *mode_iter; + op0 = convert_to_mode (mode, op0, 0); if (mode != tmode) target = 0; Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:46.226190608 +0100 +++ gcc/expr.c 2017-07-13 09:18:46.702152995 +0100 @@ -699,18 +699,17 @@ convert_modes (machine_mode mode, machin static unsigned int alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align) { - machine_mode tmode; + scalar_int_mode tmode = *int_mode_for_size (max_pieces * BITS_PER_UNIT, 1); - tmode = mode_for_size (max_pieces * BITS_PER_UNIT, MODE_INT, 1); if (align >= GET_MODE_ALIGNMENT (tmode)) align = GET_MODE_ALIGNMENT (tmode); else { - machine_mode tmode, xmode; - - xmode = NARROWEST_INT_MODE; - FOR_EACH_MODE_IN_CLASS (tmode, MODE_INT) + scalar_int_mode xmode = NARROWEST_INT_MODE; + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + tmode = *mode_iter; if (GET_MODE_SIZE (tmode) > max_pieces || SLOW_UNALIGNED_ACCESS (tmode, align)) break; @@ -1707,7 +1706,6 @@ emit_block_move_via_movmem (rtx x, rtx y unsigned HOST_WIDE_INT probable_max_size) { int save_volatile_ok = volatile_ok; - machine_mode mode; if (expected_align < align) expected_align = align; @@ -1726,8 +1724,10 @@ emit_block_move_via_movmem (rtx x, rtx y including more than one in the machine description unless the more limited one has some advantage. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + scalar_int_mode mode = *mode_iter; enum insn_code code = direct_optab_handler (movmem_optab, mode); if (code != CODE_FOR_nothing @@ -2791,13 +2791,13 @@ copy_blkmode_to_reg (machine_mode mode, { /* Find the smallest integer mode large enough to hold the entire structure. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) - /* Have we found a large enough mode? */ - if (GET_MODE_SIZE (mode) >= bytes) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) + if (GET_MODE_SIZE (*mode_iter) >= bytes) break; /* A suitable mode should have been found. */ - gcc_assert (mode != VOIDmode); + mode = *mode_iter; } if (GET_MODE_SIZE (mode) < GET_MODE_SIZE (word_mode)) @@ -3035,8 +3035,6 @@ set_storage_via_setmem (rtx object, rtx including more than one in the machine description unless the more limited one has some advantage. */ - machine_mode mode; - if (expected_align < align) expected_align = align; if (expected_size != -1) @@ -3047,8 +3045,10 @@ set_storage_via_setmem (rtx object, rtx expected_size = min_size; } - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + scalar_int_mode mode = *mode_iter; enum insn_code code = direct_optab_handler (setmem_optab, mode); if (code != CODE_FOR_nothing Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:39.591733644 +0100 +++ gcc/optabs.c 2017-07-13 09:18:46.703152916 +0100 @@ -3799,8 +3799,10 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx /* Try to use a memory block compare insn - either cmpstr or cmpmem will do. */ - FOR_EACH_MODE_IN_CLASS (cmp_mode, MODE_INT) + opt_scalar_int_mode cmp_mode_iter; + FOR_EACH_MODE_IN_CLASS (cmp_mode_iter, MODE_INT) { + scalar_int_mode cmp_mode = *cmp_mode_iter; cmp_code = direct_optab_handler (cmpmem_optab, cmp_mode); if (cmp_code == CODE_FOR_nothing) cmp_code = direct_optab_handler (cmpstr_optab, cmp_mode); Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:45.762227456 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:46.703152916 +0100 @@ -5660,12 +5660,14 @@ get_condition (rtx_insn *jump, rtx_insn static void init_num_sign_bit_copies_in_rep (void) { - machine_mode mode, in_mode; + opt_scalar_int_mode in_mode_iter; + scalar_int_mode mode; - FOR_EACH_MODE_IN_CLASS (in_mode, MODE_INT) - FOR_EACH_MODE_UNTIL (mode, in_mode) + FOR_EACH_MODE_IN_CLASS (in_mode_iter, MODE_INT) + FOR_EACH_MODE_UNTIL (mode, *in_mode_iter) { - machine_mode i; + scalar_int_mode in_mode = *in_mode_iter; + scalar_int_mode i; /* Currently, it is assumed that TARGET_MODE_REP_EXTENDED extends to the next widest mode. */ @@ -5678,7 +5680,7 @@ init_num_sign_bit_copies_in_rep (void) { /* This must always exist (for the last iteration it will be IN_MODE). */ - machine_mode wider = *GET_MODE_WIDER_MODE (i); + scalar_int_mode wider = *GET_MODE_WIDER_MODE (i); if (targetm.mode_rep_extended (i, wider) == SIGN_EXTEND /* We can only check sign-bit copies starting from the Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:41.680558844 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:46.704152837 +0100 @@ -1827,7 +1827,6 @@ start_bitfield_representative (tree fiel finish_bitfield_representative (tree repr, tree field) { unsigned HOST_WIDE_INT bitsize, maxbitsize; - machine_mode mode; tree nextf, size; size = size_diffop (DECL_FIELD_OFFSET (field), @@ -1892,15 +1891,15 @@ finish_bitfield_representative (tree rep gcc_assert (maxbitsize % BITS_PER_UNIT == 0); /* Find the smallest nice mode to use. */ - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) - if (GET_MODE_BITSIZE (mode) >= bitsize) + opt_scalar_int_mode mode_iter; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) + if (GET_MODE_BITSIZE (*mode_iter) >= bitsize) break; - if (mode != VOIDmode - && (GET_MODE_BITSIZE (mode) > maxbitsize - || GET_MODE_BITSIZE (mode) > MAX_FIXED_MODE_SIZE)) - mode = VOIDmode; - if (mode == VOIDmode) + scalar_int_mode mode; + if (!mode_iter.exists (&mode) + || GET_MODE_BITSIZE (mode) > maxbitsize + || GET_MODE_BITSIZE (mode) > MAX_FIXED_MODE_SIZE) { /* We really want a BLKmode representative only as a last resort, considering the member b in Index: gcc/fortran/trans-types.c =================================================================== --- gcc/fortran/trans-types.c 2017-07-13 09:18:32.525352977 +0100 +++ gcc/fortran/trans-types.c 2017-07-13 09:18:46.702152995 +0100 @@ -362,15 +362,16 @@ #define NAMED_SUBROUTINE(a,b,c,d) \ void gfc_init_kinds (void) { - machine_mode mode; + opt_scalar_int_mode int_mode_iter; opt_scalar_float_mode float_mode_iter; int i_index, r_index, kind; bool saw_i4 = false, saw_i8 = false; bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false; - for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT; - mode = (machine_mode) ((int) mode + 1)) + i_index = 0; + FOR_EACH_MODE_IN_CLASS (int_mode_iter, MODE_INT) { + scalar_int_mode mode = *int_mode_iter; int kind, bitsize; if (!targetm.scalar_mode_supported_p (mode)) From patchwork Thu Jul 13 08:56:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107638 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1938895qge; Thu, 13 Jul 2017 01:58:47 -0700 (PDT) X-Received: by 10.98.93.136 with SMTP id n8mr59760626pfj.211.1499936327574; Thu, 13 Jul 2017 01:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936327; cv=none; d=google.com; s=arc-20160816; b=AqzmcedurL0uUwjyDrE2Sqb6yQcQ1B/uRzaZM0293ZUBmCJzcwRnCgU39ptepimyhm g4OS37Bnit8KEll2XX1TLnM9QmWp66g8d4DBH7gThdtAZzs6KL8zZFjjU6hWN+2exVpH A65Ftc8WW3ArRBqZ6Hisoj7b9c5yRMVdOQ2GlMZT0r9Ylj0tJqSTPC0RFApaFXy0YVFV wfWFOU7EqjnVeULh8OVPod5FnfMggbebosRWHmSTmCXyALT1q1ZBfmCYHpuSoJRzOdnQ MtuT/Yv6t7s4HPzJFQ5zvo3RfaEpOB5KNiDZMMTHMHiwomiW9btpK/pKySNwLXqjDVLK ROHw== 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=na+fmqzQr+jPXnVXUzqge6XS96/C96UPMfsnPZb5tyk=; b=NWRxdjnMOV+AMEWMmah3Bn4M2ZbmgJyLH6rr7jgl6IazsvoDkRuwl6zyqwouXP63o2 Kn4GwwiMHR82AKCbmdYG06x/RAoDjp/AtXWIKZNwGPgtzug9OmvccrsAIm5Sx9JLGbUH K5iZgVcS0f0aDvWKuIe+ulXrlcZyQWY62r2GD16jPaOgropIIpnG24kXeT9nxJWesg1Y aGRs4zhLj1/4urmOfaZTZH+8mNHf0hk5FOGNZFElrgs6RJ/IOWyA0yiHzYzFhFvpdom2 eItsNeqpK1xEOuuH+eyL/nlVar3Inj+sK+ty222pMO/JvQ1lsM/k+SPyfQCyCg2ca6F3 TWSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=TH3HGDL5; spf=pass (google.com: domain of gcc-patches-return-458043-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458043-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 r2si3805211pfd.185.2017.07.13.01.58.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:58:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458043-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=TH3HGDL5; spf=pass (google.com: domain of gcc-patches-return-458043-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458043-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=S0j8JCK0j9dLubG1xX6hHQ1BmPr3e +grQKoNQujQVuAxjvbhEQgxynkps1Jg/YViwTguSlqZkKR4fYbEKE6OHQI1EaoVq wXRCjSqaVC6yAdgIGc7G8N+qOSetLy/6MQy4NX3+rlUcVjsSgPVc/VMJqsPC0NIO CvFr5cVoSJvc4I= 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=9sCPS3AIXAPZMloOiPzpu1z0Bys=; b=TH3 HGDL5QUzWrc+L6dnAqBdOnrGKcmyvXvmVRlVt3beKgsD/REIjSDQMI1OXJ7zHoGu dGCWjEylDkflXG9RR2FM3ajvXY5U5AXlXSfUI4c5aO/+V23uB/+V7VTqTvA+6xKM i6Szxg0ckUbLkb7/MSCeUrG/Yo87tgsjFAwDFyEU= Received: (qmail 47512 invoked by alias); 13 Jul 2017 08:56:56 -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 46814 invoked by uid 89); 13 Jul 2017 08:56:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:56:47 +0000 Received: by mail-wr0-f179.google.com with SMTP id c11so49497286wrc.3 for ; Thu, 13 Jul 2017 01:56:47 -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=na+fmqzQr+jPXnVXUzqge6XS96/C96UPMfsnPZb5tyk=; b=iQp//IQoyT1HBXg32K6PopqmXXfxVWi3RrWd2ES9wCBEQ4H5oGHyzIMnmn6ertbiyC JYibG8nJZuHjc+mA7u6mNys7OwebLWtMoyBtwDMPJWWr4vdLh5yodcveele8TeuOO+bj sy1pn52oWUwv8xLz5QOC74FdeLX6Tml54zISTKDj0qz4jQQstm/0zqo4cKsKzZuKqjlE DBkwZL2EMWEscgwcr5PMocF0JQr0SlQZakBZoHpP6y1WV0Y2Tp8RsH6SaL2nNoRIjffD St9jXi7UYUBEX+Qct8RIhPk86ru28zqckC5q1K721w9SLz6x0YkHM+Z42joq1s1cbO7I DvUQ== X-Gm-Message-State: AIVw1114UXsm9O6/n8Impv/HpebQZsVO0ce8tt8TGbKR3Q1HmZHERC7r PayaKbjBxMJO6CqHNnopAA== X-Received: by 10.223.171.69 with SMTP id r5mr898120wrc.57.1499936204294; Thu, 13 Jul 2017 01:56:44 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id n71sm3907708wrb.62.2017.07.13.01.56.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:56:43 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [52/77] Use scalar_int_mode in extract/store_bit_field References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:56:41 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87wp7cemuu.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 After a certain point, extract_bit_field and store_bit_field ensure that they're dealing with integer modes or BLKmode MEMs. This patch uses scalar_int_mode and opt_scalar_int_mode for those parts. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expmed.c (store_bit_field_using_insv): Add op0_mode and value_mode arguments. Use scalar_int_mode internally. (store_bit_field_1): Rename the new integer mode from imode to op0_mode and use it instead of GET_MODE (op0). Update calls to store_split_bit_field, store_bit_field_using_insv and store_fixed_bit_field. (store_fixed_bit_field): Add op0_mode and value_mode arguments. Use scalar_int_mode internally. Use a bit count rather than a mode when calculating the largest bit size for get_best_mode. Update calls to store_split_bit_field and store_fixed_bit_field_1. (store_fixed_bit_field_1): Add mode and value_mode arguments. Remove assertion that OP0 has a scalar integer mode. (store_split_bit_field): Add op0_mode and value_mode arguments. Update calls to extract_fixed_bit_field. (extract_bit_field_using_extv): Add an op0_mode argument. Use scalar_int_mode internally. (extract_bit_field_1): Rename the new integer mode from imode to op0_mode and use it instead of GET_MODE (op0). Update calls to extract_split_bit_field, extract_bit_field_using_extv and extract_fixed_bit_field. (extract_fixed_bit_field): Add an op0_mode argument. Update calls to extract_split_bit_field and extract_fixed_bit_field_1. (extract_fixed_bit_field_1): Add a mode argument. Remove assertion that OP0 has a scalar integer mode. Use as_a on the target mode. (extract_split_bit_field): Add an op0_mode argument. Update call to extract_fixed_bit_field. Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:46.700153153 +0100 +++ gcc/expmed.c 2017-07-13 09:18:47.197114027 +0100 @@ -45,27 +45,31 @@ struct target_expmed default_target_expm struct target_expmed *this_target_expmed = &default_target_expmed; #endif -static void store_fixed_bit_field (rtx, unsigned HOST_WIDE_INT, +static void store_fixed_bit_field (rtx, opt_scalar_int_mode, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, - rtx, bool); -static void store_fixed_bit_field_1 (rtx, unsigned HOST_WIDE_INT, + unsigned HOST_WIDE_INT, + rtx, scalar_int_mode, bool); +static void store_fixed_bit_field_1 (rtx, scalar_int_mode, + unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, - rtx, bool); -static void store_split_bit_field (rtx, unsigned HOST_WIDE_INT, + rtx, scalar_int_mode, bool); +static void store_split_bit_field (rtx, opt_scalar_int_mode, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, - rtx, bool); -static rtx extract_fixed_bit_field (machine_mode, rtx, + unsigned HOST_WIDE_INT, + rtx, scalar_int_mode, bool); +static rtx extract_fixed_bit_field (machine_mode, rtx, opt_scalar_int_mode, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, rtx, int, bool); -static rtx extract_fixed_bit_field_1 (machine_mode, rtx, +static rtx extract_fixed_bit_field_1 (machine_mode, rtx, scalar_int_mode, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, rtx, int, bool); static rtx lshift_value (machine_mode, unsigned HOST_WIDE_INT, int); -static rtx extract_split_bit_field (rtx, unsigned HOST_WIDE_INT, +static rtx extract_split_bit_field (rtx, opt_scalar_int_mode, + unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT, int, bool); static void do_cmp_and_jump (rtx, rtx, enum rtx_code, machine_mode, rtx_code_label *); static rtx expand_smod_pow2 (machine_mode, rtx, HOST_WIDE_INT); @@ -568,13 +572,16 @@ simple_mem_bitfield_p (rtx op0, unsigned } /* Try to use instruction INSV to store VALUE into a field of OP0. - BITSIZE and BITNUM are as for store_bit_field. */ + If OP0_MODE is defined, it is the mode of OP0, otherwise OP0 is a + BLKmode MEM. VALUE_MODE is the mode of VALUE. BITSIZE and BITNUM + are as for store_bit_field. */ static bool store_bit_field_using_insv (const extraction_insn *insv, rtx op0, + opt_scalar_int_mode op0_mode, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, - rtx value) + rtx value, scalar_int_mode value_mode) { struct expand_operand ops[4]; rtx value1; @@ -582,7 +589,7 @@ store_bit_field_using_insv (const extrac rtx_insn *last = get_last_insn (); bool copy_back = false; - machine_mode op_mode = insv->field_mode; + scalar_int_mode op_mode = insv->field_mode; unsigned int unit = GET_MODE_BITSIZE (op_mode); if (bitsize == 0 || bitsize > unit) return false; @@ -595,7 +602,7 @@ store_bit_field_using_insv (const extrac { /* Convert from counting within OP0 to counting in OP_MODE. */ if (BYTES_BIG_ENDIAN) - bitnum += unit - GET_MODE_BITSIZE (GET_MODE (op0)); + bitnum += unit - GET_MODE_BITSIZE (*op0_mode); /* If xop0 is a register, we need it in OP_MODE to make it acceptable to the format of insv. */ @@ -648,30 +655,28 @@ store_bit_field_using_insv (const extrac /* Convert VALUE to op_mode (which insv insn wants) in VALUE1. */ value1 = value; - if (GET_MODE (value) != op_mode) + if (value_mode != op_mode) { - if (GET_MODE_BITSIZE (GET_MODE (value)) >= bitsize) + if (GET_MODE_BITSIZE (value_mode) >= bitsize) { rtx tmp; /* Optimization: Don't bother really extending VALUE if it has all the bits we will actually use. However, if we must narrow it, be sure we do it correctly. */ - if (GET_MODE_SIZE (GET_MODE (value)) < GET_MODE_SIZE (op_mode)) + if (GET_MODE_SIZE (value_mode) < GET_MODE_SIZE (op_mode)) { - tmp = simplify_subreg (op_mode, value1, GET_MODE (value), 0); + tmp = simplify_subreg (op_mode, value1, value_mode, 0); if (! tmp) tmp = simplify_gen_subreg (op_mode, - force_reg (GET_MODE (value), - value1), - GET_MODE (value), 0); + force_reg (value_mode, value1), + value_mode, 0); } else { tmp = gen_lowpart_if_possible (op_mode, value1); if (! tmp) - tmp = gen_lowpart (op_mode, force_reg (GET_MODE (value), - value1)); + tmp = gen_lowpart (op_mode, force_reg (value_mode, value1)); } value1 = tmp; } @@ -826,14 +831,14 @@ store_bit_field_1 (rtx str_rtx, unsigned if we aren't. This must come after the entire register case above, since that case is valid for any mode. The following cases are only valid for integral modes. */ - opt_scalar_int_mode imode = int_mode_for_mode (GET_MODE (op0)); - if (!imode.exists () || *imode != GET_MODE (op0)) + opt_scalar_int_mode op0_mode = int_mode_for_mode (GET_MODE (op0)); + if (!op0_mode.exists () || *op0_mode != GET_MODE (op0)) { if (MEM_P (op0)) - op0 = adjust_bitfield_address_size (op0, imode.else_blk (), + op0 = adjust_bitfield_address_size (op0, op0_mode.else_blk (), 0, MEM_SIZE (op0)); else - op0 = gen_lowpart (*imode, op0); + op0 = gen_lowpart (*op0_mode, op0); } /* Storing an lsb-aligned field in a register @@ -945,11 +950,15 @@ store_bit_field_1 (rtx str_rtx, unsigned with 64 bit registers that uses SFmode for float. It can also occur for unaligned float or complex fields. */ orig_value = value; - if (GET_MODE (value) != VOIDmode - && GET_MODE_CLASS (GET_MODE (value)) != MODE_INT - && GET_MODE_CLASS (GET_MODE (value)) != MODE_PARTIAL_INT) + scalar_int_mode value_mode; + if (GET_MODE (value) == VOIDmode) + /* By this point we've dealt with values that are bigger than a word, + so word_mode is a conservatively correct choice. */ + value_mode = word_mode; + else if (!is_a (GET_MODE (value), &value_mode)) { - value = gen_reg_rtx (*int_mode_for_mode (GET_MODE (value))); + value_mode = *int_mode_for_mode (GET_MODE (value)); + value = gen_reg_rtx (value_mode); emit_move_insn (gen_lowpart (GET_MODE (orig_value), value), orig_value); } @@ -958,23 +967,25 @@ store_bit_field_1 (rtx str_rtx, unsigned Don't do this if op0 is a single hard register wider than word such as a float or vector register. */ if (!MEM_P (op0) - && GET_MODE_SIZE (GET_MODE (op0)) > UNITS_PER_WORD + && GET_MODE_SIZE (*op0_mode) > UNITS_PER_WORD && (!REG_P (op0) || !HARD_REGISTER_P (op0) - || HARD_REGNO_NREGS (REGNO (op0), GET_MODE (op0)) != 1)) + || HARD_REGNO_NREGS (REGNO (op0), *op0_mode) != 1)) { if (bitnum % BITS_PER_WORD + bitsize > BITS_PER_WORD) { if (!fallback_p) return false; - store_split_bit_field (op0, bitsize, bitnum, bitregion_start, - bitregion_end, value, reverse); + store_split_bit_field (op0, op0_mode, bitsize, bitnum, + bitregion_start, bitregion_end, + value, value_mode, reverse); return true; } - op0 = simplify_gen_subreg (word_mode, op0, GET_MODE (op0), + op0 = simplify_gen_subreg (word_mode, op0, *op0_mode, bitnum / BITS_PER_WORD * UNITS_PER_WORD); gcc_assert (op0); + op0_mode = word_mode; bitnum %= BITS_PER_WORD; } @@ -986,9 +997,10 @@ store_bit_field_1 (rtx str_rtx, unsigned if (!MEM_P (op0) && !reverse && get_best_reg_extraction_insn (&insv, EP_insv, - GET_MODE_BITSIZE (GET_MODE (op0)), + GET_MODE_BITSIZE (*op0_mode), fieldmode) - && store_bit_field_using_insv (&insv, op0, bitsize, bitnum, value)) + && store_bit_field_using_insv (&insv, op0, op0_mode, + bitsize, bitnum, value, value_mode)) return true; /* If OP0 is a memory, try copying it to a register and seeing if a @@ -997,7 +1009,8 @@ store_bit_field_1 (rtx str_rtx, unsigned { if (get_best_mem_extraction_insn (&insv, EP_insv, bitsize, bitnum, fieldmode) - && store_bit_field_using_insv (&insv, op0, bitsize, bitnum, value)) + && store_bit_field_using_insv (&insv, op0, op0_mode, + bitsize, bitnum, value, value_mode)) return true; rtx_insn *last = get_last_insn (); @@ -1025,8 +1038,8 @@ store_bit_field_1 (rtx str_rtx, unsigned if (!fallback_p) return false; - store_fixed_bit_field (op0, bitsize, bitnum, bitregion_start, - bitregion_end, value, reverse); + store_fixed_bit_field (op0, op0_mode, bitsize, bitnum, bitregion_start, + bitregion_end, value, value_mode, reverse); return true; } @@ -1120,16 +1133,19 @@ store_bit_field (rtx str_rtx, unsigned H } /* Use shifts and boolean operations to store VALUE into a bit field of - width BITSIZE in OP0, starting at bit BITNUM. + width BITSIZE in OP0, starting at bit BITNUM. If OP0_MODE is defined, + it is the mode of OP0, otherwise OP0 is a BLKmode MEM. VALUE_MODE is + the mode of VALUE. If REVERSE is true, the store is to be done in reverse order. */ static void -store_fixed_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize, +store_fixed_bit_field (rtx op0, opt_scalar_int_mode op0_mode, + unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, unsigned HOST_WIDE_INT bitregion_start, unsigned HOST_WIDE_INT bitregion_end, - rtx value, bool reverse) + rtx value, scalar_int_mode value_mode, bool reverse) { /* There is a case not handled here: a structure with a known alignment of just a halfword @@ -1138,46 +1154,48 @@ store_fixed_bit_field (rtx op0, unsigned and a field split across two bytes. Such cases are not supposed to be able to occur. */ + scalar_int_mode best_mode; if (MEM_P (op0)) { - machine_mode mode = GET_MODE (op0); - if (GET_MODE_BITSIZE (mode) == 0 - || GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (word_mode)) - mode = word_mode; - scalar_int_mode best_mode; + unsigned int max_bitsize = BITS_PER_WORD; + if (op0_mode.exists () && GET_MODE_BITSIZE (*op0_mode) < max_bitsize) + max_bitsize = GET_MODE_BITSIZE (*op0_mode); + if (!get_best_mode (bitsize, bitnum, bitregion_start, bitregion_end, - MEM_ALIGN (op0), GET_MODE_BITSIZE (mode), - MEM_VOLATILE_P (op0), &best_mode)) + MEM_ALIGN (op0), max_bitsize, MEM_VOLATILE_P (op0), + &best_mode)) { /* The only way this should occur is if the field spans word boundaries. */ - store_split_bit_field (op0, bitsize, bitnum, bitregion_start, - bitregion_end, value, reverse); + store_split_bit_field (op0, op0_mode, bitsize, bitnum, + bitregion_start, bitregion_end, + value, value_mode, reverse); return; } op0 = narrow_bit_field_mem (op0, best_mode, bitsize, bitnum, &bitnum); } + else + best_mode = *op0_mode; - store_fixed_bit_field_1 (op0, bitsize, bitnum, value, reverse); + store_fixed_bit_field_1 (op0, best_mode, bitsize, bitnum, + value, value_mode, reverse); } /* Helper function for store_fixed_bit_field, stores - the bit field always using the MODE of OP0. */ + the bit field always using MODE, which is the mode of OP0. The other + arguments are as for store_fixed_bit_field. */ static void -store_fixed_bit_field_1 (rtx op0, unsigned HOST_WIDE_INT bitsize, +store_fixed_bit_field_1 (rtx op0, scalar_int_mode mode, + unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, - rtx value, bool reverse) + rtx value, scalar_int_mode value_mode, bool reverse) { - machine_mode mode; rtx temp; int all_zero = 0; int all_one = 0; - mode = GET_MODE (op0); - gcc_assert (SCALAR_INT_MODE_P (mode)); - /* Note that bitsize + bitnum can be greater than GET_MODE_BITSIZE (mode) for invalid input, such as f5 from gcc.dg/pr48335-2.c. */ @@ -1212,10 +1230,10 @@ store_fixed_bit_field_1 (rtx op0, unsign } else { - int must_and = (GET_MODE_BITSIZE (GET_MODE (value)) != bitsize + int must_and = (GET_MODE_BITSIZE (value_mode) != bitsize && bitnum + bitsize != GET_MODE_BITSIZE (mode)); - if (GET_MODE (value) != mode) + if (value_mode != mode) value = convert_to_mode (mode, value, 1); if (must_and) @@ -1268,18 +1286,21 @@ store_fixed_bit_field_1 (rtx op0, unsign OP0 is the REG, SUBREG or MEM rtx for the first of the objects. BITSIZE is the field width; BITPOS the position of its first bit (within the word). - VALUE is the value to store. + VALUE is the value to store, which has mode VALUE_MODE. + If OP0_MODE is defined, it is the mode of OP0, otherwise OP0 is + a BLKmode MEM. If REVERSE is true, the store is to be done in reverse order. This does not yet handle fields wider than BITS_PER_WORD. */ static void -store_split_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize, +store_split_bit_field (rtx op0, opt_scalar_int_mode op0_mode, + unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitpos, unsigned HOST_WIDE_INT bitregion_start, unsigned HOST_WIDE_INT bitregion_end, - rtx value, bool reverse) + rtx value, scalar_int_mode value_mode, bool reverse) { unsigned int unit, total_bits, bitsdone = 0; @@ -1293,8 +1314,8 @@ store_split_bit_field (rtx op0, unsigned /* If OP0 is a memory with a mode, then UNIT must not be larger than OP0's mode as well. Otherwise, store_fixed_bit_field will call us again, and we will mutually recurse forever. */ - if (MEM_P (op0) && GET_MODE_BITSIZE (GET_MODE (op0)) > 0) - unit = MIN (unit, GET_MODE_BITSIZE (GET_MODE (op0))); + if (MEM_P (op0) && op0_mode.exists ()) + unit = MIN (unit, GET_MODE_BITSIZE (*op0_mode)); /* If VALUE is a constant other than a CONST_INT, get it into a register in WORD_MODE. If we can do this using gen_lowpart_common, do so. Note @@ -1306,20 +1327,18 @@ store_split_bit_field (rtx op0, unsigned if (word && (value != word)) value = word; else - value = gen_lowpart_common (word_mode, - force_reg (GET_MODE (value) != VOIDmode - ? GET_MODE (value) - : word_mode, value)); + value = gen_lowpart_common (word_mode, force_reg (value_mode, value)); + value_mode = word_mode; } - total_bits = GET_MODE_BITSIZE (GET_MODE (value)); + total_bits = GET_MODE_BITSIZE (value_mode); while (bitsdone < bitsize) { unsigned HOST_WIDE_INT thissize; unsigned HOST_WIDE_INT thispos; unsigned HOST_WIDE_INT offset; - rtx part, word; + rtx part; offset = (bitpos + bitsdone) / unit; thispos = (bitpos + bitsdone) % unit; @@ -1353,19 +1372,18 @@ store_split_bit_field (rtx op0, unsigned & ((HOST_WIDE_INT_1 << thissize) - 1)); /* Likewise, but the source is little-endian. */ else if (reverse) - part = extract_fixed_bit_field (word_mode, value, thissize, + part = extract_fixed_bit_field (word_mode, value, value_mode, + thissize, bitsize - bitsdone - thissize, NULL_RTX, 1, false); else - { - int total_bits = GET_MODE_BITSIZE (GET_MODE (value)); - /* The args are chosen so that the last part includes the - lsb. Give extract_bit_field the value it needs (with - endianness compensation) to fetch the piece we want. */ - part = extract_fixed_bit_field (word_mode, value, thissize, - total_bits - bitsize + bitsdone, - NULL_RTX, 1, false); - } + /* The args are chosen so that the last part includes the + lsb. Give extract_bit_field the value it needs (with + endianness compensation) to fetch the piece we want. */ + part = extract_fixed_bit_field (word_mode, value, value_mode, + thissize, + total_bits - bitsize + bitsdone, + NULL_RTX, 1, false); } else { @@ -1376,34 +1394,42 @@ store_split_bit_field (rtx op0, unsigned & ((HOST_WIDE_INT_1 << thissize) - 1)); /* Likewise, but the source is big-endian. */ else if (reverse) - part = extract_fixed_bit_field (word_mode, value, thissize, + part = extract_fixed_bit_field (word_mode, value, value_mode, + thissize, total_bits - bitsdone - thissize, NULL_RTX, 1, false); else - part = extract_fixed_bit_field (word_mode, value, thissize, - bitsdone, NULL_RTX, 1, false); + part = extract_fixed_bit_field (word_mode, value, value_mode, + thissize, bitsdone, NULL_RTX, + 1, false); } /* If OP0 is a register, then handle OFFSET here. */ + rtx op0_piece = op0; + opt_scalar_int_mode op0_piece_mode = op0_mode; if (SUBREG_P (op0) || REG_P (op0)) { - machine_mode op0_mode = GET_MODE (op0); - if (op0_mode != BLKmode && GET_MODE_SIZE (op0_mode) < UNITS_PER_WORD) - word = offset ? const0_rtx : op0; + if (op0_mode.exists () && GET_MODE_SIZE (*op0_mode) < UNITS_PER_WORD) + { + if (offset) + op0_piece = const0_rtx; + } else - word = operand_subword_force (op0, offset * unit / BITS_PER_WORD, - GET_MODE (op0)); + { + op0_piece = operand_subword_force (op0, + offset * unit / BITS_PER_WORD, + GET_MODE (op0)); + op0_piece_mode = word_mode; + } offset &= BITS_PER_WORD / unit - 1; } - else - word = op0; /* OFFSET is in UNITs, and UNIT is in bits. If WORD is const0_rtx, it is just an out-of-bounds access. Ignore it. */ - if (word != const0_rtx) - store_fixed_bit_field (word, thissize, offset * unit + thispos, - bitregion_start, bitregion_end, part, - reverse); + if (op0_piece != const0_rtx) + store_fixed_bit_field (op0_piece, op0_piece_mode, thissize, + offset * unit + thispos, bitregion_start, + bitregion_end, part, word_mode, reverse); bitsdone += thissize; } } @@ -1435,11 +1461,13 @@ convert_extracted_bit_field (rtx x, mach /* Try to use an ext(z)v pattern to extract a field from OP0. Return the extracted value on success, otherwise return null. - EXT_MODE is the mode of the extraction and the other arguments - are as for extract_bit_field. */ + EXTV describes the extraction instruction to use. If OP0_MODE + is defined, it is the mode of OP0, otherwise OP0 is a BLKmode MEM. + The other arguments are as for extract_bit_field. */ static rtx extract_bit_field_using_extv (const extraction_insn *extv, rtx op0, + opt_scalar_int_mode op0_mode, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, int unsignedp, rtx target, @@ -1448,7 +1476,7 @@ extract_bit_field_using_extv (const extr struct expand_operand ops[4]; rtx spec_target = target; rtx spec_target_subreg = 0; - machine_mode ext_mode = extv->field_mode; + scalar_int_mode ext_mode = extv->field_mode; unsigned unit = GET_MODE_BITSIZE (ext_mode); if (bitsize == 0 || unit < bitsize) @@ -1462,13 +1490,13 @@ extract_bit_field_using_extv (const extr { /* Convert from counting within OP0 to counting in EXT_MODE. */ if (BYTES_BIG_ENDIAN) - bitnum += unit - GET_MODE_BITSIZE (GET_MODE (op0)); + bitnum += unit - GET_MODE_BITSIZE (*op0_mode); /* If op0 is a register, we need it in EXT_MODE to make it acceptable to the format of ext(z)v. */ - if (GET_CODE (op0) == SUBREG && GET_MODE (op0) != ext_mode) + if (GET_CODE (op0) == SUBREG && *op0_mode != ext_mode) return NULL_RTX; - if (REG_P (op0) && GET_MODE (op0) != ext_mode) + if (REG_P (op0) && *op0_mode != ext_mode) op0 = gen_lowpart_SUBREG (ext_mode, op0); } @@ -1617,20 +1645,20 @@ extract_bit_field_1 (rtx str_rtx, unsign /* Make sure we are playing with integral modes. Pun with subregs if we aren't. */ - opt_scalar_int_mode imode = int_mode_for_mode (GET_MODE (op0)); - if (!imode.exists () || *imode != GET_MODE (op0)) + opt_scalar_int_mode op0_mode = int_mode_for_mode (GET_MODE (op0)); + if (!op0_mode.exists () || *op0_mode != GET_MODE (op0)) { if (MEM_P (op0)) - op0 = adjust_bitfield_address_size (op0, imode.else_blk (), + op0 = adjust_bitfield_address_size (op0, op0_mode.else_blk (), 0, MEM_SIZE (op0)); - else if (imode.exists ()) + else if (op0_mode.exists ()) { - op0 = gen_lowpart (*imode, op0); + op0 = gen_lowpart (*op0_mode, op0); /* If we got a SUBREG, force it into a register since we aren't going to be able to do another SUBREG on it. */ if (GET_CODE (op0) == SUBREG) - op0 = force_reg (*imode, op0); + op0 = force_reg (*op0_mode, op0); } else { @@ -1662,11 +1690,11 @@ extract_bit_field_1 (rtx str_rtx, unsign bit of either OP0 or a word of OP0. */ if (!MEM_P (op0) && !reverse - && lowpart_bit_field_p (bitnum, bitsize, GET_MODE (op0)) + && lowpart_bit_field_p (bitnum, bitsize, *op0_mode) && bitsize == GET_MODE_BITSIZE (mode1) - && TRULY_NOOP_TRUNCATION_MODES_P (mode1, GET_MODE (op0))) + && TRULY_NOOP_TRUNCATION_MODES_P (mode1, *op0_mode)) { - rtx sub = simplify_gen_subreg (mode1, op0, GET_MODE (op0), + rtx sub = simplify_gen_subreg (mode1, op0, *op0_mode, bitnum / BITS_PER_UNIT); if (sub) return convert_extracted_bit_field (sub, mode, tmode, unsignedp); @@ -1769,18 +1797,19 @@ extract_bit_field_1 (rtx str_rtx, unsign /* If OP0 is a multi-word register, narrow it to the affected word. If the region spans two words, defer to extract_split_bit_field. */ - if (!MEM_P (op0) && GET_MODE_SIZE (GET_MODE (op0)) > UNITS_PER_WORD) + if (!MEM_P (op0) && GET_MODE_SIZE (*op0_mode) > UNITS_PER_WORD) { if (bitnum % BITS_PER_WORD + bitsize > BITS_PER_WORD) { if (!fallback_p) return NULL_RTX; - target = extract_split_bit_field (op0, bitsize, bitnum, unsignedp, - reverse); + target = extract_split_bit_field (op0, op0_mode, bitsize, bitnum, + unsignedp, reverse); return convert_extracted_bit_field (target, mode, tmode, unsignedp); } - op0 = simplify_gen_subreg (word_mode, op0, GET_MODE (op0), + op0 = simplify_gen_subreg (word_mode, op0, *op0_mode, bitnum / BITS_PER_WORD * UNITS_PER_WORD); + op0_mode = word_mode; bitnum %= BITS_PER_WORD; } @@ -1794,10 +1823,10 @@ extract_bit_field_1 (rtx str_rtx, unsign contains the field, with appropriate checks for endianness and TRULY_NOOP_TRUNCATION. */ && get_best_reg_extraction_insn (&extv, pattern, - GET_MODE_BITSIZE (GET_MODE (op0)), - tmode)) + GET_MODE_BITSIZE (*op0_mode), tmode)) { - rtx result = extract_bit_field_using_extv (&extv, op0, bitsize, bitnum, + rtx result = extract_bit_field_using_extv (&extv, op0, op0_mode, + bitsize, bitnum, unsignedp, target, mode, tmode); if (result) @@ -1811,9 +1840,9 @@ extract_bit_field_1 (rtx str_rtx, unsign if (get_best_mem_extraction_insn (&extv, pattern, bitsize, bitnum, tmode)) { - rtx result = extract_bit_field_using_extv (&extv, op0, bitsize, - bitnum, unsignedp, - target, mode, + rtx result = extract_bit_field_using_extv (&extv, op0, op0_mode, + bitsize, bitnum, + unsignedp, target, mode, tmode); if (result) return result; @@ -1849,8 +1878,8 @@ extract_bit_field_1 (rtx str_rtx, unsign do a load. */ int_mode = *int_mode_for_mode (mode); - target = extract_fixed_bit_field (int_mode, op0, bitsize, bitnum, target, - unsignedp, reverse); + target = extract_fixed_bit_field (int_mode, op0, op0_mode, bitsize, + bitnum, target, unsignedp, reverse); /* Complex values must be reversed piecewise, so we need to undo the global reversal, convert to the complex mode and reverse again. */ @@ -1929,7 +1958,8 @@ extract_bit_field (rtx str_rtx, unsigned } /* Use shifts and boolean operations to extract a field of BITSIZE bits - from bit BITNUM of OP0. + from bit BITNUM of OP0. If OP0_MODE is defined, it is the mode of OP0, + otherwise OP0 is a BLKmode MEM. UNSIGNEDP is nonzero for an unsigned bit field (don't sign-extend value). If REVERSE is true, the extraction is to be done in reverse order. @@ -1940,39 +1970,40 @@ extract_bit_field (rtx str_rtx, unsigned static rtx extract_fixed_bit_field (machine_mode tmode, rtx op0, + opt_scalar_int_mode op0_mode, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, rtx target, int unsignedp, bool reverse) { + scalar_int_mode mode; if (MEM_P (op0)) { - scalar_int_mode mode; if (!get_best_mode (bitsize, bitnum, 0, 0, MEM_ALIGN (op0), BITS_PER_WORD, MEM_VOLATILE_P (op0), &mode)) /* The only way this should occur is if the field spans word boundaries. */ - return extract_split_bit_field (op0, bitsize, bitnum, unsignedp, - reverse); + return extract_split_bit_field (op0, op0_mode, bitsize, bitnum, + unsignedp, reverse); op0 = narrow_bit_field_mem (op0, mode, bitsize, bitnum, &bitnum); } + else + mode = *op0_mode; - return extract_fixed_bit_field_1 (tmode, op0, bitsize, bitnum, + return extract_fixed_bit_field_1 (tmode, op0, mode, bitsize, bitnum, target, unsignedp, reverse); } /* Helper function for extract_fixed_bit_field, extracts - the bit field always using the MODE of OP0. */ + the bit field always using MODE, which is the mode of OP0. + The other arguments are as for extract_fixed_bit_field. */ static rtx -extract_fixed_bit_field_1 (machine_mode tmode, rtx op0, +extract_fixed_bit_field_1 (machine_mode tmode, rtx op0, scalar_int_mode mode, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, rtx target, int unsignedp, bool reverse) { - machine_mode mode = GET_MODE (op0); - gcc_assert (SCALAR_INT_MODE_P (mode)); - /* Note that bitsize + bitnum can be greater than GET_MODE_BITSIZE (mode) for invalid input, such as extract equivalent of f5 from gcc.dg/pr48335-2.c. */ @@ -1999,16 +2030,19 @@ extract_fixed_bit_field_1 (machine_mode subtarget = 0; op0 = expand_shift (RSHIFT_EXPR, mode, op0, bitnum, subtarget, 1); } - /* Convert the value to the desired mode. */ - if (mode != tmode) - op0 = convert_to_mode (tmode, op0, 1); + /* Convert the value to the desired mode. TMODE must also be a + scalar integer for this conversion to make sense, since we + shouldn't reinterpret the bits. */ + scalar_int_mode new_mode = as_a (tmode); + if (mode != new_mode) + op0 = convert_to_mode (new_mode, op0, 1); /* Unless the msb of the field used to be the msb when we shifted, mask out the upper bits. */ if (GET_MODE_BITSIZE (mode) != bitnum + bitsize) - return expand_binop (GET_MODE (op0), and_optab, op0, - mask_rtx (GET_MODE (op0), 0, bitsize, 0), + return expand_binop (new_mode, and_optab, op0, + mask_rtx (new_mode, 0, bitsize, 0), target, 1, OPTAB_LIB_WIDEN); return op0; } @@ -2058,11 +2092,14 @@ lshift_value (machine_mode mode, unsigne OP0 is the REG, SUBREG or MEM rtx for the first of the two words. BITSIZE is the field width; BITPOS, position of its first bit, in the word. UNSIGNEDP is 1 if should zero-extend the contents; else sign-extend. + If OP0_MODE is defined, it is the mode of OP0, otherwise OP0 is + a BLKmode MEM. If REVERSE is true, the extraction is to be done in reverse order. */ static rtx -extract_split_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize, +extract_split_bit_field (rtx op0, opt_scalar_int_mode op0_mode, + unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitpos, int unsignedp, bool reverse) { @@ -2081,7 +2118,7 @@ extract_split_bit_field (rtx op0, unsign while (bitsdone < bitsize) { unsigned HOST_WIDE_INT thissize; - rtx part, word; + rtx part; unsigned HOST_WIDE_INT thispos; unsigned HOST_WIDE_INT offset; @@ -2095,19 +2132,21 @@ extract_split_bit_field (rtx op0, unsign thissize = MIN (thissize, unit - thispos); /* If OP0 is a register, then handle OFFSET here. */ + rtx op0_piece = op0; + opt_scalar_int_mode op0_piece_mode = op0_mode; if (SUBREG_P (op0) || REG_P (op0)) { - word = operand_subword_force (op0, offset, GET_MODE (op0)); + op0_piece = operand_subword_force (op0, offset, *op0_mode); + op0_piece_mode = word_mode; offset = 0; } - else - word = op0; /* Extract the parts in bit-counting order, whose meaning is determined by BYTES_PER_UNIT. OFFSET is in UNITs, and UNIT is in bits. */ - part = extract_fixed_bit_field (word_mode, word, thissize, - offset * unit + thispos, 0, 1, reverse); + part = extract_fixed_bit_field (word_mode, op0_piece, op0_piece_mode, + thissize, offset * unit + thispos, + 0, 1, reverse); bitsdone += thissize; /* Shift this part into place for the result. */ From patchwork Thu Jul 13 08:57:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107639 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1939115qge; Thu, 13 Jul 2017 01:59:08 -0700 (PDT) X-Received: by 10.84.247.15 with SMTP id n15mr9118312pll.296.1499936348365; Thu, 13 Jul 2017 01:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936348; cv=none; d=google.com; s=arc-20160816; b=yrQ25D/V6ZWeXrE6MPz0MAmTwU6ZnmljCckzYoDCnD8kGupiFvs//jsCj+arcfEzkH i1Z+MiYdjAPt0OTWZJ88JBlmXmSahvPrngc+W6eIQXj9UhXZvpBEdXi0wO6zK6DCyNXw e67ZuhfBcPtc4qH/EEMcQBkJhaLQ2Zud8OHa0fp30MsL0r3HvRb91k3BagEQV5G3T9uP kA/AK0KTroui88D+atVLUTGq5rhOdd3cpXfQcgFe75ArFQ6vWz/33OUQEScTvDWBfFJ9 VlqZ9IppjEXUSgp2MjjNBDycyr68EIMk6WJte78NNJw5IhcD9nlgiD8Ko7iZrsXbcBb6 e8Iw== 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=3YtU3Adj/l2E339VubgqZD3n+AK5l55ZjAbDjXzRwAs=; b=Nu0xFtUx87AFyS23RvGrHvMrIAUYOM58ibM6q+RRLI2sz67g2ZDUXumHBNoqKmEHng ey3an2yqla2ldZehucDQDZgmzhVV2u88brnrYbk3d7qypjdzToqUNwqwmnHy4CMmoBlz xkdfWcSiSPSrTbfsWUqfKOqzaeD+ksyljy+i+MQLKUINGMjOp9uzUL6yBYWV4cNu904n nW7y5TSNTzubtf6EfeXZ41+bB5Ps/PA0Vpdc37cdXhwi2Scr+HSy3yv1rQ8ezR4S3znd bLHJAybl20M0Pol9pE9pow6YvjWuDvIwadrPhd7ifafRaC2YuUA6wfCdB9Z5x49ol4Ni MxYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=MFFGu6DX; spf=pass (google.com: domain of gcc-patches-return-458044-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458044-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 p7si3972021pli.398.2017.07.13.01.59.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458044-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=MFFGu6DX; spf=pass (google.com: domain of gcc-patches-return-458044-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458044-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=yi7VIzdxBzXAw8zQ3gQR0P6nRda27 2AZtoTir/Yl+8UQTo+9LgmFnKl5MeZaT4iPuNZsSban9XoJJrLtnhiaqy/ZvToMx W2yjw0/+zOsj+PzUSytfheLWn/v5PoGik0Ks9nCIQT1crV04OdhuhycPAuRg1u2e NcRjetTe1qm0Nk= 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=pxzooOvz6Q2IHQn9FgGTxzO8Av8=; b=MFF Gu6DX6YMMuz6PoFaLT6RzG37zd8sbAd1PtLrX0dGULerUyAUxwRkiXpxbiBCD3ZD AVwl0t6XZbH9/OPPT2fRbyfrNTjf5Y7S2Tm3q7pAo706hPoJcTbVmXeqGogf6qUD JzMqz7OXJVQojTOXPNWttRD+DoK7uQ8RPH4cxvmg= Received: (qmail 72902 invoked by alias); 13 Jul 2017 08:57:30 -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 72209 invoked by uid 89); 13 Jul 2017 08:57:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1949 X-HELO: mail-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:57:27 +0000 Received: by mail-wm0-f46.google.com with SMTP id i127so18415801wma.0 for ; Thu, 13 Jul 2017 01:57:27 -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=3YtU3Adj/l2E339VubgqZD3n+AK5l55ZjAbDjXzRwAs=; b=CD8NXP6zzlbEMlH470OeZhC7z84n9zU1V3NXLZbw1grFbWNAUqg+GN/HaOngFWgspF kwEQfRAcic1+uyHWht6K+k3wtYTp92q5v8udofuOfiQGdXViUehj2p2mFZP9w1FVUqoY WUUA1RgeGYIbXZzJh6zTicK/CU1P4ZMsalWmzzftWCUiu62zdt5HqjFxshhrBrIM0O82 Iy+tB4O1L57Hakq2b7u/aNQNMZ6TTvBWTM+278i9ygjJEv4RqjOmbugFEOatTpLMMvhW Zpg340sVN5SiYkNuDrEuJHhPtp7oE+i8IIiZp7XtooWzZtePOHpYNbbvFaq7J3/QkhIZ LkSA== X-Gm-Message-State: AIVw113glYYhH3wWrJQ1eWqb7y6oDSVocovNgxV33F8Pwzid317exlUH MK0OXb3zPu5ezfEoW8uhiQ== X-Received: by 10.28.94.201 with SMTP id s192mr1154388wmb.100.1499936245374; Thu, 13 Jul 2017 01:57:25 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b30sm5079725wra.42.2017.07.13.01.57.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:57:24 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [53/77] Pass a mode to const_scalar_mask_from_tree References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:57:23 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87shi0emto.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The caller of const_scalar_mask_from_tree has proven that the mode is a MODE_INT, so this patch passes it down as a scalar_int_mode. It also expands the comment a little. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (const_scalar_mask_from_tree): Add a mode argument. Expand commentary. (expand_expr_real_1): Update call accordingly. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:46.702152995 +0100 +++ gcc/expr.c 2017-07-13 09:18:47.609081780 +0100 @@ -99,7 +99,7 @@ static void emit_single_push_insn (machi static void do_tablejump (rtx, machine_mode, rtx, rtx, rtx, profile_probability); static rtx const_vector_from_tree (tree); -static rtx const_scalar_mask_from_tree (tree); +static rtx const_scalar_mask_from_tree (scalar_int_mode, tree); static tree tree_expr_size (const_tree); static HOST_WIDE_INT int_expr_size (tree); @@ -9962,7 +9962,7 @@ expand_expr_real_1 (tree exp, rtx target if (is_int_mode (mode, &int_mode)) { if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))) - return const_scalar_mask_from_tree (exp); + return const_scalar_mask_from_tree (int_mode, exp); else { tree type_for_mode @@ -11717,12 +11717,12 @@ const_vector_mask_from_tree (tree exp) return gen_rtx_CONST_VECTOR (mode, v); } -/* Return a CONST_INT rtx representing vector mask for - a VECTOR_CST of booleans. */ +/* EXP is a VECTOR_CST in which each element is either all-zeros or all-ones. + Return a constant scalar rtx of mode MODE in which bit X is set if element + X of EXP is nonzero. */ static rtx -const_scalar_mask_from_tree (tree exp) +const_scalar_mask_from_tree (scalar_int_mode mode, tree exp) { - machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); wide_int res = wi::zero (GET_MODE_PRECISION (mode)); tree elt; unsigned i; From patchwork Thu Jul 13 08:57:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107640 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1939439qge; Thu, 13 Jul 2017 01:59:32 -0700 (PDT) X-Received: by 10.99.121.75 with SMTP id u72mr8163884pgc.53.1499936372335; Thu, 13 Jul 2017 01:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936372; cv=none; d=google.com; s=arc-20160816; b=mCk+0zxUHkqgOvp2WebtMM6UuUnuEn7x1vptaswy5JMz1KBk7erA+EyreoWb/IK0BI phoj0R0ezS1jzcBWCimwC/DfPyk9oarvQFc1G1/XLEcot1TJGoj6w4z6tk+zQ4GWHgf9 dmEaKTCGfKWGGW6e4vapMtQYmKNnPlzq8vb6l674zZHt9owA93vC6M3VUAsk3ukYkSu6 0Y4He8/FwKRxvPe2M2LrqYSCXrAP68tXPgClzfmWa+7/GqNRbY61YdFdk6ivNP1aS6Tf kcNM4fHYXo1rqTkOz7RnBz5zuUQTlfm/uihSHTvSB31/V8A6WhaUIJ6jy7vipnzVr4hq 6Uzw== 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=Icc/VBe6gl1TqrOemeZKLs4vsEVMxOrtLFW9iLOk3us=; b=gifNO9kmGvRDdW5DWPqp2Xgn3xaKi4KP6DX0sEAkpFidKsTnVDFcorbDZ80CT3tRn4 Ij5eEMZEIkigX6BMrCsPQhzAT8Q8HrXHxPGQ5zd8cHzRntEJNVnF6gZ7LYcgY43ABMHi rLs2i+4lbvTg1TFjYqF36P/3tPxwJL+oWPLnyEA6NJVEAkFI5rTj1tL8KN8eOouG3rDc MJYvvdpvyylFX6lOHe/dgRV26YqTo1yNOwCG5DMnVbmrHy8VC0b5aISmsZa/vWgSEsum O0UlcNvNVV0ZF6N70Eim6UkhpguQ2rZJH2IHAmTC7NcHMsezpHmAXhRPU9pM2BvqizIu ggVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=ra9k9prx; spf=pass (google.com: domain of gcc-patches-return-458045-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458045-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 e5si3787970pgk.350.2017.07.13.01.59.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:59:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458045-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=ra9k9prx; spf=pass (google.com: domain of gcc-patches-return-458045-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458045-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=pttj0a/84Ld5lBAOWiZBs38stfTLr FDhWYkSA/vhQsLGBtygOYBOPLaEU0tA1UA43WSVXJMWYveIxW4AyBTTy8hHEVyZs VhaMKQw7QCiH4eG2zHmE/oMcqcX+IWWO6WPqLcp1gd9wtejPUmd4r10/FVF62TEC p9M+ZvYUmxdSVc= 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=9/aRbVV2K4dzOCcj1yC1mP9z0gw=; b=ra9 k9prx1RfOigzui8Xs1aIOQXAdTGPqaODMZOtr8NOykCXO94u/InuC7Bdf7HEAmbk tv2yUohzvB+J+gtf3WdRMRS17TQNuciLp/hVWDz7oQkgjbTrFsv9sObSwvQeT4H2 n+3Xp8jB6Fg0zMOXs+r9T/KhEQneYPGyZIV+NJkY= Received: (qmail 92183 invoked by alias); 13 Jul 2017 08:57:55 -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 91689 invoked by uid 89); 13 Jul 2017 08:57:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:57:51 +0000 Received: by mail-wm0-f44.google.com with SMTP id 70so2199474wmo.1 for ; Thu, 13 Jul 2017 01:57:50 -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=Icc/VBe6gl1TqrOemeZKLs4vsEVMxOrtLFW9iLOk3us=; b=c9MdzUKYDPGtlMBOKiyTPCgcUnZtDcgXPh1p89f6C6ZT/xJjWiK+kbLMuQY0+WBQKt DuF7bMA/jow6H/MB4Z5LNa7YLGLmc1oRMfG9aggFLRB81fnRsfG4wOXOWPPVOvG+gDIv +/iAr//zjU8EKoBph5hH67PuE1vhhEiI5LSYrA9ZyGABaGPK/WWsXnoEY9Rux0Yxl7pg 7KF9FDKL4Bx+iHjhSsP9WqSKVD4QhNr+8AVMOFuvuNULMzDbQZa4OkJ+pA/H17u329Cd V1crctJBq2BmEkggLNqgdlKmYkdE31BCQyiJdgvkinSzHcZy8tS6VKdOwRPaQ62EXt0k 2vJg== X-Gm-Message-State: AIVw110uf4hl1O56G9PuytQrdrc+NDk7pzJJCiK8JLD/7CTidUf+LHp5 yJRCUuS5hTuFYf143U859Q== X-Received: by 10.28.144.6 with SMTP id s6mr1179400wmd.16.1499936268626; Thu, 13 Jul 2017 01:57:48 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id j190sm6170328wmd.22.2017.07.13.01.57.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:57:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [54/77] Add explicit int checks for alternative optab implementations References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:57:46 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87o9soemt1.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 expand_unop can expand narrow clz, clrsb, ctz, bswap, parity and ffs operations using optabs for wider modes. These expansions apply only to scalar integer modes (and not for example to vectors), so the patch adds explicit checks for that. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * optabs.c (widen_leading): Change the type of the mode argument to scalar_int_mode. Use opt_scalar_int_mode for the mode iterator. (widen_bswap): Likewise. (expand_parity): Likewise. (expand_ctz): Change the type of the mode argument to scalar_int_mode. (expand_ffs): Likewise. (epand_unop): Check for scalar integer modes before calling the above routines. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:46.703152916 +0100 +++ gcc/optabs.c 2017-07-13 09:18:48.024049315 +0100 @@ -2128,39 +2128,36 @@ expand_simple_unop (machine_mode mode, e A similar operation can be used for clrsb. UNOPTAB says which operation we are trying to expand. */ static rtx -widen_leading (machine_mode mode, rtx op0, rtx target, optab unoptab) +widen_leading (scalar_int_mode mode, rtx op0, rtx target, optab unoptab) { - enum mode_class mclass = GET_MODE_CLASS (mode); - if (CLASS_HAS_WIDER_MODES_P (mclass)) + opt_scalar_int_mode wider_mode_iter; + FOR_EACH_WIDER_MODE (wider_mode_iter, mode) { - machine_mode wider_mode; - FOR_EACH_WIDER_MODE (wider_mode, mode) + scalar_int_mode wider_mode = *wider_mode_iter; + if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) { - if (optab_handler (unoptab, wider_mode) != CODE_FOR_nothing) - { - rtx xop0, temp; - rtx_insn *last; + rtx xop0, temp; + rtx_insn *last; - last = get_last_insn (); + last = get_last_insn (); - if (target == 0) - target = gen_reg_rtx (mode); - xop0 = widen_operand (op0, wider_mode, mode, - unoptab != clrsb_optab, false); - temp = expand_unop (wider_mode, unoptab, xop0, NULL_RTX, - unoptab != clrsb_optab); - if (temp != 0) - temp = expand_binop - (wider_mode, sub_optab, temp, - gen_int_mode (GET_MODE_PRECISION (wider_mode) - - GET_MODE_PRECISION (mode), - wider_mode), - target, true, OPTAB_DIRECT); - if (temp == 0) - delete_insns_since (last); + if (target == 0) + target = gen_reg_rtx (mode); + xop0 = widen_operand (op0, wider_mode, mode, + unoptab != clrsb_optab, false); + temp = expand_unop (wider_mode, unoptab, xop0, NULL_RTX, + unoptab != clrsb_optab); + if (temp != 0) + temp = expand_binop + (wider_mode, sub_optab, temp, + gen_int_mode (GET_MODE_PRECISION (wider_mode) + - GET_MODE_PRECISION (mode), + wider_mode), + target, true, OPTAB_DIRECT); + if (temp == 0) + delete_insns_since (last); - return temp; - } + return temp; } } return 0; @@ -2294,22 +2291,20 @@ expand_doubleword_parity (machine_mode m as (lshiftrt:wide (bswap:wide x) ((width wide) - (width narrow))). */ static rtx -widen_bswap (machine_mode mode, rtx op0, rtx target) +widen_bswap (scalar_int_mode mode, rtx op0, rtx target) { - enum mode_class mclass = GET_MODE_CLASS (mode); - machine_mode wider_mode; rtx x; rtx_insn *last; + opt_scalar_int_mode wider_mode_iter; - if (!CLASS_HAS_WIDER_MODES_P (mclass)) - return NULL_RTX; + FOR_EACH_WIDER_MODE (wider_mode_iter, mode) + if (optab_handler (bswap_optab, *wider_mode_iter) != CODE_FOR_nothing) + break; - FOR_EACH_WIDER_MODE (wider_mode, mode) - if (optab_handler (bswap_optab, wider_mode) != CODE_FOR_nothing) - goto found; - return NULL_RTX; + if (!wider_mode_iter.exists ()) + return NULL_RTX; - found: + scalar_int_mode wider_mode = *wider_mode_iter; last = get_last_insn (); x = widen_operand (op0, wider_mode, mode, true, true); @@ -2360,42 +2355,40 @@ expand_doubleword_bswap (machine_mode mo /* Try calculating (parity x) as (and (popcount x) 1), where popcount can also be done in a wider mode. */ static rtx -expand_parity (machine_mode mode, rtx op0, rtx target) +expand_parity (scalar_int_mode mode, rtx op0, rtx target) { enum mode_class mclass = GET_MODE_CLASS (mode); - if (CLASS_HAS_WIDER_MODES_P (mclass)) + opt_scalar_int_mode wider_mode_iter; + FOR_EACH_MODE_FROM (wider_mode_iter, mode) { - machine_mode wider_mode; - FOR_EACH_MODE_FROM (wider_mode, mode) + scalar_int_mode wider_mode = *wider_mode_iter; + if (optab_handler (popcount_optab, wider_mode) != CODE_FOR_nothing) { - if (optab_handler (popcount_optab, wider_mode) != CODE_FOR_nothing) - { - rtx xop0, temp; - rtx_insn *last; + rtx xop0, temp; + rtx_insn *last; - last = get_last_insn (); + last = get_last_insn (); - if (target == 0 || GET_MODE (target) != wider_mode) - target = gen_reg_rtx (wider_mode); + if (target == 0 || GET_MODE (target) != wider_mode) + target = gen_reg_rtx (wider_mode); - xop0 = widen_operand (op0, wider_mode, mode, true, false); - temp = expand_unop (wider_mode, popcount_optab, xop0, NULL_RTX, - true); - if (temp != 0) - temp = expand_binop (wider_mode, and_optab, temp, const1_rtx, - target, true, OPTAB_DIRECT); + xop0 = widen_operand (op0, wider_mode, mode, true, false); + temp = expand_unop (wider_mode, popcount_optab, xop0, NULL_RTX, + true); + if (temp != 0) + temp = expand_binop (wider_mode, and_optab, temp, const1_rtx, + target, true, OPTAB_DIRECT); - if (temp) - { - if (mclass != MODE_INT - || !TRULY_NOOP_TRUNCATION_MODES_P (mode, wider_mode)) - return convert_to_mode (mode, temp, 0); - else - return gen_lowpart (mode, temp); - } + if (temp) + { + if (mclass != MODE_INT + || !TRULY_NOOP_TRUNCATION_MODES_P (mode, wider_mode)) + return convert_to_mode (mode, temp, 0); else - delete_insns_since (last); + return gen_lowpart (mode, temp); } + else + delete_insns_since (last); } } return 0; @@ -2414,7 +2407,7 @@ expand_parity (machine_mode mode, rtx op less convenient for expand_ffs anyway. */ static rtx -expand_ctz (machine_mode mode, rtx op0, rtx target) +expand_ctz (scalar_int_mode mode, rtx op0, rtx target) { rtx_insn *seq; rtx temp; @@ -2457,7 +2450,7 @@ expand_ctz (machine_mode mode, rtx op0, may have an undefined value in that case. If they do not give us a convenient value, we have to generate a test and branch. */ static rtx -expand_ffs (machine_mode mode, rtx op0, rtx target) +expand_ffs (scalar_int_mode mode, rtx op0, rtx target) { HOST_WIDE_INT val = 0; bool defined_at_zero = false; @@ -2714,16 +2707,19 @@ expand_unop (machine_mode mode, optab un /* Widening (or narrowing) clz needs special treatment. */ if (unoptab == clz_optab) { - temp = widen_leading (mode, op0, target, unoptab); - if (temp) - return temp; - - if (GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD - && optab_handler (unoptab, word_mode) != CODE_FOR_nothing) + if (is_a (mode, &int_mode)) { - temp = expand_doubleword_clz (mode, op0, target); + temp = widen_leading (int_mode, op0, target, unoptab); if (temp) return temp; + + if (GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD + && optab_handler (unoptab, word_mode) != CODE_FOR_nothing) + { + temp = expand_doubleword_clz (int_mode, op0, target); + if (temp) + return temp; + } } goto try_libcall; @@ -2731,9 +2727,12 @@ expand_unop (machine_mode mode, optab un if (unoptab == clrsb_optab) { - temp = widen_leading (mode, op0, target, unoptab); - if (temp) - return temp; + if (is_a (mode, &int_mode)) + { + temp = widen_leading (int_mode, op0, target, unoptab); + if (temp) + return temp; + } goto try_libcall; } @@ -2805,16 +2804,19 @@ expand_unop (machine_mode mode, optab un delete_insns_since (last); } - temp = widen_bswap (mode, op0, target); - if (temp) - return temp; - - if (GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD - && optab_handler (unoptab, word_mode) != CODE_FOR_nothing) + if (is_a (mode, &int_mode)) { - temp = expand_doubleword_bswap (mode, op0, target); + temp = widen_bswap (int_mode, op0, target); if (temp) return temp; + + if (GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD + && optab_handler (unoptab, word_mode) != CODE_FOR_nothing) + { + temp = expand_doubleword_bswap (mode, op0, target); + if (temp) + return temp; + } } goto try_libcall; @@ -2915,25 +2917,25 @@ expand_unop (machine_mode mode, optab un } /* Try calculating parity (x) as popcount (x) % 2. */ - if (unoptab == parity_optab) + if (unoptab == parity_optab && is_a (mode, &int_mode)) { - temp = expand_parity (mode, op0, target); + temp = expand_parity (int_mode, op0, target); if (temp) return temp; } /* Try implementing ffs (x) in terms of clz (x). */ - if (unoptab == ffs_optab) + if (unoptab == ffs_optab && is_a (mode, &int_mode)) { - temp = expand_ffs (mode, op0, target); + temp = expand_ffs (int_mode, op0, target); if (temp) return temp; } /* Try implementing ctz (x) in terms of clz (x). */ - if (unoptab == ctz_optab) + if (unoptab == ctz_optab && is_a (mode, &int_mode)) { - temp = expand_ctz (mode, op0, target); + temp = expand_ctz (int_mode, op0, target); if (temp) return temp; } From patchwork Thu Jul 13 08:58:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107641 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1939755qge; Thu, 13 Jul 2017 01:59:59 -0700 (PDT) X-Received: by 10.98.245.207 with SMTP id b76mr60998279pfm.113.1499936399303; Thu, 13 Jul 2017 01:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936399; cv=none; d=google.com; s=arc-20160816; b=Tqot0OMC0HxLlBMsI71BjXljQ3PusJV8jpY5j7+ru0lieSgxg/r0BYAEOYFLwcRtrI /8kqtsKyKc6Sn/GUpuYQYJiyVGu4Mr+N+aPIGNynL7N8r2gQTKn+dpeSD0vG32RnrEfg YWlNrvHVbpyWEw3AMOGkvOJ6l48dWt0arHtE5pkrGkO2ktQIKPWazFPRZr0vsgEd3KN6 ImvI9RDVa6tT5JE9DKqSkGq9nz9XUfezC7EeHBgWvj5K4sjo3s3HPh3sj6WAlrSV0e7w j59UtpLWAxnzZgpS5pOaB+qQX+3+JDYBxua8q7qtzsuYfR/ZnvcncoPedfV/cRnMZtb7 4gEg== 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=RCvh/H+IhPk+WI2jpQSuJ0+OsqxcgfYaVKAfPfLEyoc=; b=NnLwJnKegYAIRPC3j1UPHm1X71+VERQYD4PzBfh/zHPQ+4yFSdKKB7NTUDwaBenVKH opamjrGNWO/PkctQOrodmVWV7b5458JUsLpzXPKgJ/3WkgJCd7LlczWhgdIZy1d/qB1c M8shPCfX+8hYIwGhg5iAAnHreSC83I5VQ3l86V5VwDdOcGWQzQxRAHY1JYWnV09qLZkE whOYtABuKBf6vpAXALmbRJcXZB4cFSs2PXg2OudCIBqvd7SYTaqg1ST2MK75ujoEvPsd q0uTY9+XFUCTZLbS0CaZLFepPHZsOkp/q6qhywgeV31x9Diml+2u5hZLwmJBc72MVwfd nEwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=NJ3yQqCT; spf=pass (google.com: domain of gcc-patches-return-458046-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458046-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 u19si3819734pgj.527.2017.07.13.01.59.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:59:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458046-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=NJ3yQqCT; spf=pass (google.com: domain of gcc-patches-return-458046-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458046-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=A5CsHTPko8XxLxltx2ol80uzbE5vh 4oRdr0xod65eQyIAM3P0tLlRd+IRvUS6WHm3c5Y9Y1J/SBO40UEEvGeB01vs976+ ORcmA3sCkPynl2wRmOvFz/dh2mGMtA2rE9jgyyb17f6rVgCKzUSeKoUZZh4qMIP+ K8oG5jUqjoXehA= 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=kI1DDk7R8cbpYmP/ACvYQd4I34A=; b=NJ3 yQqCT9hbv2EZoUILTbV44Y566xdZnvZpnys+PJHQ0trSftumbFhKr+7SlnihaWHd F7bk7wq+SycEDkT8n4ka2i3I8eUgz1Pnc/DPtFpWCCGauxksI15Ka+S0yS8v33X1 Ultkc92en8MsBjKWDX6WqRWJyNNWEeiWJNIv4qAo= Received: (qmail 106614 invoked by alias); 13 Jul 2017 08:58:12 -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 105867 invoked by uid 89); 13 Jul 2017 08:58:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=16857 X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:58:09 +0000 Received: by mail-wm0-f54.google.com with SMTP id 62so16829907wmw.1 for ; Thu, 13 Jul 2017 01:58:08 -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=RCvh/H+IhPk+WI2jpQSuJ0+OsqxcgfYaVKAfPfLEyoc=; b=I47lnnZ3yTXP6+hi7PNvxb5qxzzZZ/dOG/ShEGBs48Ay/gOn1u+2vv/njkH5kEdYyc aXfIXQ52APAxwXHonJW2/DQJNWJD7aT2OXZmnyfMe9uEhXblBq0lLskVCbm1CwriiOBv Z4NOl5bWbs68W4C5Gq4jYlY9KsPLjzUQS1ZPJ9cKX7ntykdRa+4da1xyJYvAvB1JUMwN CS3EY3lCOmRtY45hJodWDS7jnlbw6ncdjeF5v+eDCFgK393/Vh7cOGLVLbkwZchcTuoH bzUJgFB+rK0jhHMEGz6wtf5kRE9k34qNrDJ6wwj13bPBec2452HwiIs6Kw3DVGIAbo4E pdnA== X-Gm-Message-State: AIVw11182RaMq9rvWXzmNpVh6lat6vMalnp9mItGHs5xOcZ2xCL8lT5m 9qV5miR2ay1PpuTdsjbdYg== X-Received: by 10.28.12.66 with SMTP id 63mr1072000wmm.130.1499936286939; Thu, 13 Jul 2017 01:58:06 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id l186sm6374336wma.10.2017.07.13.01.58.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:58:06 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [55/77] Use scalar_int_mode in simplify_const_unary_operation References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:58:04 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87k23cemsj.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The main scalar integer block in simplify_const_unary_operation had the condition: if (CONST_SCALAR_INT_P (op) && width > 0) where "width > 0" was a roundabout way of testing != VOIDmode. This patch replaces it with a check for a scalar_int_mode instead. It also uses the number of bits in the input rather than the output mode to determine the result of a "count ... bits in zero" operation. (At the momemnt these modes have to be the same, but it still seems conceptually wrong to use the number of bits in the output mode.) The handling of float->integer ops also checked "width > 0", but this was redundant with the earlier check for MODE_INT. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * simplify-rtx.c (simplify_const_unary_operation): Use is_a instead of checking for a nonzero precision. Forcibly convert op_mode to a scalar_int_mode in that case. More clearly differentiate the operand and result modes and use the former when deciding what the value of a count-bits operation should be. Use is_int_mode instead of checking for a MODE_INT. Remove redundant check for whether this mode has a zero precision. Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:39.593733475 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:48.356023575 +0100 @@ -1685,7 +1685,7 @@ simplify_unary_operation_1 (enum rtx_cod simplify_const_unary_operation (enum rtx_code code, machine_mode mode, rtx op, machine_mode op_mode) { - unsigned int width = GET_MODE_PRECISION (mode); + scalar_int_mode result_mode; if (code == VEC_DUPLICATE) { @@ -1800,10 +1800,13 @@ simplify_const_unary_operation (enum rtx return const_double_from_real_value (d, mode); } - if (CONST_SCALAR_INT_P (op) && width > 0) + if (CONST_SCALAR_INT_P (op) && is_a (mode, &result_mode)) { + unsigned int width = GET_MODE_PRECISION (result_mode); wide_int result; - machine_mode imode = op_mode == VOIDmode ? mode : op_mode; + scalar_int_mode imode = (op_mode == VOIDmode + ? result_mode + : as_a (op_mode)); rtx_mode_t op0 = rtx_mode_t (op, imode); int int_value; @@ -1832,35 +1835,35 @@ simplify_const_unary_operation (enum rtx break; case FFS: - result = wi::shwi (wi::ffs (op0), mode); + result = wi::shwi (wi::ffs (op0), result_mode); break; case CLZ: if (wi::ne_p (op0, 0)) int_value = wi::clz (op0); - else if (! CLZ_DEFINED_VALUE_AT_ZERO (mode, int_value)) - int_value = GET_MODE_PRECISION (mode); - result = wi::shwi (int_value, mode); + else if (! CLZ_DEFINED_VALUE_AT_ZERO (imode, int_value)) + int_value = GET_MODE_PRECISION (imode); + result = wi::shwi (int_value, result_mode); break; case CLRSB: - result = wi::shwi (wi::clrsb (op0), mode); + result = wi::shwi (wi::clrsb (op0), result_mode); break; case CTZ: if (wi::ne_p (op0, 0)) int_value = wi::ctz (op0); - else if (! CTZ_DEFINED_VALUE_AT_ZERO (mode, int_value)) - int_value = GET_MODE_PRECISION (mode); - result = wi::shwi (int_value, mode); + else if (! CTZ_DEFINED_VALUE_AT_ZERO (imode, int_value)) + int_value = GET_MODE_PRECISION (imode); + result = wi::shwi (int_value, result_mode); break; case POPCOUNT: - result = wi::shwi (wi::popcount (op0), mode); + result = wi::shwi (wi::popcount (op0), result_mode); break; case PARITY: - result = wi::shwi (wi::parity (op0), mode); + result = wi::shwi (wi::parity (op0), result_mode); break; case BSWAP: @@ -1881,7 +1884,7 @@ simplify_const_unary_operation (enum rtx return 0; } - return immed_wide_int_const (result, mode); + return immed_wide_int_const (result, result_mode); } else if (CONST_DOUBLE_AS_FLOAT_P (op) @@ -1941,9 +1944,9 @@ simplify_const_unary_operation (enum rtx } else if (CONST_DOUBLE_AS_FLOAT_P (op) && SCALAR_FLOAT_MODE_P (GET_MODE (op)) - && GET_MODE_CLASS (mode) == MODE_INT - && width > 0) + && is_int_mode (mode, &result_mode)) { + unsigned int width = GET_MODE_PRECISION (result_mode); /* Although the overflow semantics of RTL's FIX and UNSIGNED_FIX operators are intentionally left unspecified (to ease implementation by target backends), for consistency, this routine implements the From patchwork Thu Jul 13 08:58:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107642 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1940035qge; Thu, 13 Jul 2017 02:00:17 -0700 (PDT) X-Received: by 10.84.169.3 with SMTP id g3mr8918651plb.136.1499936417726; Thu, 13 Jul 2017 02:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936417; cv=none; d=google.com; s=arc-20160816; b=04uwsNcRqYlYneOg2cNR0eXXrRNeK4PqEzAK2UsdCcvA9LkPk3cCOd/DS1/cSmhGTs 1RE+dPHBYcXWCg9D+G0cpnnm7AC76Gz9o8VR3coYVoI9+0ngpdAk2OBIiHwfBSY2pmP1 QAu9uqSas+2YfpBBlvvHcGxvaOsBGIq2WIbyMvmPa7YqQUNTVTP2miRkyrqa9HSQPYlN ++L1PejMnCZAOSpN/sV/n2EDmR22CB1o5YZuZjeMpxt+MurqT4aqp/s1C2D3XpP3fc52 ts9frz6utAq/OFSee3MMYcHNbDNIVzayxS4SBwZ8gV8uXBFZdvqLv6aUpJxvDTlwQ87+ 90QQ== 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=iM6YUYf5cmIwbpQy/OEaX90gVi/soO48tu8J20cdabs=; b=R6ee2TtmyllvbHQTeI6+hGFf+TPwaJ9e6yeCghSkVIJ0/O3HCB0k1apFID4zrebCG2 FCgLKDt8KPzFh0oRPM8LLJpGTr5d+dKoDrwKE4uJRf9KVAxFUpRu3KBPwX7RXCMIYC6o Lq4yT4mwbYBPBEvclh0Lfe2+2tBXxBYVV3wCo1Llj7E+Wm9xS504EJVrsRExY9lai2pd jSkcBZT42veaBYw8rr7iIcozGcOTIIMYdv2ozt1+CdvH8JH2weRmjMwxZrMZE+KgJ9/q gd7Na6SkyL6N9m5fgbFs+w0+yAOIoDi6NY5lwu7HFeTmWUfdffsi8O8ESgdSTK13Dzhd xCgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=wbtiQ0N5; spf=pass (google.com: domain of gcc-patches-return-458047-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458047-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 v25si3832594pgo.576.2017.07.13.02.00.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458047-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=wbtiQ0N5; spf=pass (google.com: domain of gcc-patches-return-458047-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458047-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=lHVdcuc4f4EKVIZf0Iab5+R59EalP ScIeCxLF+se/JyguIWBqC/tD9GPvg4InSiAiXHjZYfvzIqm2jpRJJfmLIgE1/sH0 rA7azWPGgRnor1/qDP6VLVW8+ilD2LcaUO1dAhABfgBMfTkP7pKZUc/7Xt5Q0RIn DhUzujFImnqunQ= 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=NE67gl4dDqP2RyjSsNW7thh4Qtk=; b=wbt iQ0N59N64WKrToV/oVMqq7iOy8t2v3Em4Az15ZgEZguDPvjMV0jXabpWnrGjZkqg xRbdP5m5aNSTDn7iQfdhMV9PIZOcxf9BaF7FoKeRozLbqLvRSUgunJcTRgaA3bic Z2+pwkx9Jhl0nNOHEhKF/CcpZ5FveHNrZTLVRCg8= Received: (qmail 2083 invoked by alias); 13 Jul 2017 08:58:38 -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 1288 invoked by uid 89); 13 Jul 2017 08:58:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=htem X-HELO: mail-wr0-f182.google.com Received: from mail-wr0-f182.google.com (HELO mail-wr0-f182.google.com) (209.85.128.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:58:35 +0000 Received: by mail-wr0-f182.google.com with SMTP id k67so49473029wrc.2 for ; Thu, 13 Jul 2017 01:58:34 -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=iM6YUYf5cmIwbpQy/OEaX90gVi/soO48tu8J20cdabs=; b=Q7i1nwQdjXyrrBn71reCaalZRnTTv/iuOL5TvI+3rfSXdQUyZSVeA0+mUtRJoWWEmm l5Orj+j403gA0qshmxMPKW22w0Wqs+o3hDqVXcJKoJejBEj50jGdPx5cfqWO4TRuBJy8 l2IM6OlgL6TWugn6GvlyOiEdJ5amWQ+sHyajGeCZeQyEIWZCbvn3JKg7OcPyAqLw5Hca sflnyzkYclWJPF/az3e0q8DJ/9W4XWJdpcwgVt1hDV/GtNmK2YoLf0T1kR80VW2bdpnR otkMWQJMI2diK2AoWnWfHLbbuaABzsw4UeFE5efUbL4bt/1iEEIoF8rhkkDzTmeQddgx V0YQ== X-Gm-Message-State: AIVw111RY0vwbOq9g3NPEKbqxJ2/2oNaeSJj9oynksR2OqzPNaZi93eN Td7hTxZ9aS4qymUR8wP4Ug== X-Received: by 10.223.183.40 with SMTP id l40mr1113081wre.154.1499936312920; Thu, 13 Jul 2017 01:58:32 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id j190sm6172125wmd.22.2017.07.13.01.58.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:58:32 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [56/77] Use the more specific type when two modes are known to be equal References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:58:30 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87fue0emrt.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adjusts a couple of cases in which we had established that two modes were equal and happened to be using the one with the more general type instead of the one with the more specific type. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (expand_expr_real_2): Use word_mode instead of innermode when the two are known to be equal. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:47.609081780 +0100 +++ gcc/expr.c 2017-07-13 09:18:48.752992795 +0100 @@ -8671,7 +8671,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b rtx htem, hipart; op0 = expand_normal (treeop0); if (TREE_CODE (treeop1) == INTEGER_CST) - op1 = convert_modes (innermode, mode, + op1 = convert_modes (word_mode, mode, expand_normal (treeop1), TYPE_UNSIGNED (TREE_TYPE (treeop1))); else @@ -8682,8 +8682,8 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b goto widen_mult_const; temp = expand_binop (mode, other_optab, op0, op1, target, unsignedp, OPTAB_LIB_WIDEN); - hipart = gen_highpart (innermode, temp); - htem = expand_mult_highpart_adjust (innermode, hipart, + hipart = gen_highpart (word_mode, temp); + htem = expand_mult_highpart_adjust (word_mode, hipart, op0, op1, hipart, zextend_p); if (htem != hipart) From patchwork Thu Jul 13 08:58:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107643 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1940444qge; Thu, 13 Jul 2017 02:00:38 -0700 (PDT) X-Received: by 10.84.231.204 with SMTP id g12mr8943089pln.233.1499936438398; Thu, 13 Jul 2017 02:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936438; cv=none; d=google.com; s=arc-20160816; b=PVM+9rvhgBYvMzVdAeIK3yovPOAY++41YBfJUC1uOeCoiQDQtCHzWgQDhqK3wWPfz6 RhBykQbWCqD1q2nuHafwVfHFfw1hRDmUqDrxPUltAPYbNo4RMC0byZ98rJvVo4ph1ZjN 2/ORRmq1LYZiiAkZQef2y8+19iciPgPcAXlHo0dD4p5otIRKhQwDTkuCngrM/1yVB4yG 5yfqDdpvKFiQ8QpxO2f28uONTMuHAGoEB4CAnr4s5wS4Uh79+DbnNK8/uGBela5a2/Md hfKHwCcaM9O4CKOnw/BMrUE8msytypdnTFLLItN9wdycHNJrOAtyLKpz7QAuzw+lzgZX 1A/w== 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=A9H1ZZtYrT33NZgBhLbbfXcrAGqqkE0cHGdrOvvto1s=; b=KaZhyoIkKu7h9GzKxPrzRoxTXIQcLW+eN75QhAhT9r7VT9YJND+mHSiuVLbIiVvrYF M3aX+gwdJtBfZZuG0E0eYJprf5w1zzC2k2wpQvjO1uI8npkObMZ/eja5XIYsH9j2dpFL J0fSnkx9mihzAOl1qLSYN8rruLszyw+tSND32s0F5nF/njb/W1GcO39jbdhSt5UURhYF 44KO4y4TZz1l+FYCWLBMtbFQzpqr499rCMNzsiXTDSXIr0hu4AKUuG3eG8hfP/0UwQGN kJid/hqal/UfFcQ07V3Un0eIviBnAnpuSr/nGUgow0x1HTZ8jf6MyEfj1LDgPsA78s2j MmNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=qBTHljA/; spf=pass (google.com: domain of gcc-patches-return-458048-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458048-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 n9si3866485pge.35.2017.07.13.02.00.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:00:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458048-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=qBTHljA/; spf=pass (google.com: domain of gcc-patches-return-458048-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458048-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=ZdxUjfECsxcV2+vLyMpTzCZK/dA6W hxiRvjBJgW8vEtKzOzEJC4uWRPG74t8A1UF+WCrKuNvj96kJSwawdN+kv4QQGYtJ R0GEDoViyLmo5GaydP/nD5Jxgzv2OEqE72m9jOWWdiOIE9VUfnAp7ZtLgQVFqSxc ICvyvKqI6WJJo4= 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=IpTSsbRMTJrcJ14dZUCU7P1aHek=; b=qBT HljA/YFV4E+P9lcFUmU/s4q/P0rgp9j+XfyzDjZRPFtzClz2K+o3DXL03UleVXev vgUuHWmZcf/qIbthKvHCg/zP5jnDpUrgY8OKl3g35+iMsFATyqpprzwSyW6/XZa3 xXAi9HyDVUYSRCiy5Xe+hfIo3KuYuJpKd89QT3ho= Received: (qmail 21062 invoked by alias); 13 Jul 2017 08:58:59 -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 20246 invoked by uid 89); 13 Jul 2017 08:58:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=claims X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:58:56 +0000 Received: by mail-wr0-f171.google.com with SMTP id k67so49477139wrc.2 for ; Thu, 13 Jul 2017 01:58:55 -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=A9H1ZZtYrT33NZgBhLbbfXcrAGqqkE0cHGdrOvvto1s=; b=OYb79J6p0xEgoEUdVHrTTesUtbsJY9GoCa+5jmFHFRYCstdkHsYZGDu3XAJZOEMU7X sNDkhLjwJ+xVCKVN2yrTQEU0G5LJ9fK96tNFNI5cLbLKgRdaD7GCQcDynbrrlxAGy+na y2SQfjmlnAqb8appJBQDoUgn2vgYX887D1ek2h9ZMxTMPUv7IJN+PJCS14/URXz0IQGg gAPtis384+ChkNpMC0efWdJt+0IexswbURlibVrAEHdPoEEttNXRuIahnPBcfls/Bz6C JDJF6s1CeQb1D1qsCqR+8/2Y7XmphHeT+7eaMmCqTAEkts2jOBmDqg6OPEqAbW9kGmLI kAaw== X-Gm-Message-State: AIVw112h3VhaqMKsoMIssfVQKVRoQwdBq9TIrTbq8UoQCOkwCNE8R9zH +cyXfhiW6J3i4NEPfCM4Dw== X-Received: by 10.223.153.106 with SMTP id x97mr889496wrb.32.1499936333695; Thu, 13 Jul 2017 01:58:53 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 82sm6191667wmt.17.2017.07.13.01.58.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:58:52 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [57/77] Use scalar_int_mode in expand_expr_addr_expr References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:58:51 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87bmooemr8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch rewrites the condition: if (tmode != address_mode && tmode != pointer_mode) tmode = address_mode; to the equivalent: tmode == pointer_mode ? pointer_mode : address_mode The latter has the advantage that the result is naturally a scalar_int_mode; a later mechanical patch makes it one. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (expand_expr_addr_expr): Add a new_tmode local variable that is always either address_mode or pointer_mode. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:48.752992795 +0100 +++ gcc/expr.c 2017-07-13 09:18:49.132963429 +0100 @@ -7902,20 +7902,21 @@ expand_expr_addr_expr (tree exp, rtx tar /* We can get called with some Weird Things if the user does silliness like "(short) &a". In that case, convert_memory_address won't do the right thing, so ignore the given target mode. */ - if (tmode != address_mode && tmode != pointer_mode) - tmode = address_mode; + machine_mode new_tmode = (tmode == pointer_mode + ? pointer_mode + : address_mode); result = expand_expr_addr_expr_1 (TREE_OPERAND (exp, 0), target, - tmode, modifier, as); + new_tmode, modifier, as); /* Despite expand_expr claims concerning ignoring TMODE when not strictly convenient, stuff breaks if we don't honor it. Note that combined with the above, we only do this for pointer modes. */ rmode = GET_MODE (result); if (rmode == VOIDmode) - rmode = tmode; - if (rmode != tmode) - result = convert_memory_address_addr_space (tmode, result, as); + rmode = new_tmode; + if (rmode != new_tmode) + result = convert_memory_address_addr_space (new_tmode, result, as); return result; } From patchwork Thu Jul 13 08:59:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107644 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1940846qge; Thu, 13 Jul 2017 02:00:56 -0700 (PDT) X-Received: by 10.99.134.199 with SMTP id x190mr8219775pgd.127.1499936456384; Thu, 13 Jul 2017 02:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936456; cv=none; d=google.com; s=arc-20160816; b=vm7t+l/xJKlsMv8npIBEKEnexr60sf4JBDeHCOvhpu9n44v1OUiHMHOA+31M3mVjvP tKi8tzzL0yCx7mb8jydkkaTh4Bu0UiDapAYzUKU0duAK9XhN0Mr0uXx1JWwNH2sf1ypu TFTc9PcdaTZq7M2nNHb/dq6P8yPccEBiWXOat38H7/ZYslREFHXPFea3RYJMpFJ3N7U+ 62LAGxoL/NtWB18MeSd7l+NnUCx7IGoBPcWfEUrMdHIY25GONQBRAQjOoU8+CsGLuGWs l1yKPG1AjgyIQ0V7mOCM1cSJdZ5gqbh8ry6Azo1TFohizX77XlJxBc3v/rJIbx+zIjE7 q0gA== 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=zH84uyU3CqRp/sTSshfWm50/r7ayVhhZx5hz78fOQaA=; b=ayv6hFqlcxCkGxyCFWgUhQCBj4rsRDw5uedT23//plWrrbQhwwN9OeSc6JGhKCwVTN vLKs5tyks144pph2qpZ8GxtUaWu8SWn8AOMLh39zSAYhT1y1gpfp0FgyJ9s3y1oFiLFy 8qtYA1I2iYxcLFIOi+CfLbVHa1w29KvrTHoBUgtJ32QDN1jRQ960IpVWS4MBofI9Qa6C YMlD36d0MgQlp/DwOg4rZtdjeHL9u5ijcmAhbcLw59sJ2GameBkoXn+5Nsh99i7QuZ/p Hh65Tgw0D5o24VI3nyl7j/aO6tYasp9u2NDe5sdqF3+T/uMHSPTixy5N+Q35zayBqtdf Ajkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=KUGm9kJO; spf=pass (google.com: domain of gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458049-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 y5si3861724pgq.414.2017.07.13.02.00.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458049-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=KUGm9kJO; spf=pass (google.com: domain of gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458049-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=ep+K21t85EEFxfzC+12J2w0o/Gc35 YaveQ/dBR9+oKGlw5PM+st1BUvAxgNzWr9iyLFTGTzzi5ALGTqNi3yYHpDkteNfA 4IkFxlTnhOz9DGWSJ9HjAE8J0S/MsaozcEvPMNyTfJqBVDXwdFCffKYl1VZQx+k0 4qcYo0xGkrDkhE= 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=2iYMbjW44fTdXk4wPBsPgbwIYMY=; b=KUG m9kJOKk6tFRAoh5SyossjoKienD/x3FEzoLojqiVyKPj3JtA4mjRhuQWns6doIZh Er87gQ4C/vq/3xMxFkhrtcgu37Jz9wPZGEqSFdToraSnggGeeeKrs9rNCy7PPqa5 WNlsE80X3RWvxQA6zFV3Q9JKRaZoZgwhF7XxnTYo= Received: (qmail 43589 invoked by alias); 13 Jul 2017 08:59:22 -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 42781 invoked by uid 89); 13 Jul 2017 08:59:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3738 X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:59:15 +0000 Received: by mail-wr0-f173.google.com with SMTP id k67so49481058wrc.2 for ; Thu, 13 Jul 2017 01:59:15 -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=zH84uyU3CqRp/sTSshfWm50/r7ayVhhZx5hz78fOQaA=; b=XxqtT3xmP9wwpIQWr4oZv5Vo4w/2H1C8fwDyTXkkWKhJo1lCnqwJMiNx0+fYCAx+Py /YtrskV3b7bTTxIr+u20Xp4D2xoAdEM+p4mG6vNZij56kh5y0Fg6qt9JopiOJ8JK7/+d F/PY6vw5KkbV63e5meLXxXiExDaSRiGBahI1H2frwapzT4hcp4Pgi7I2JCdKDOXeIJpM AuhQHFpVZZ7u/8asPvdFRlpdGHn/WNr32lJsjNoz8Bx2l52NZIF5BCpZ+WdSzx3Tx3Yv 1NsWfUU0raHD9Rh17Vzw9lWyIq+8z80sp+M8hJNGW2FlJnKGCMIIOB2oRBq8oOpZ0ZTo t1Iw== X-Gm-Message-State: AIVw112FTBJ0B4UES48Wm9nNV+FxLTYmfVMA5ax8JrLQhfDigwVAB1X4 m10/I6Yfr6c+AIPW4VQuvQ== X-Received: by 10.223.128.177 with SMTP id 46mr893134wrl.150.1499936353106; Thu, 13 Jul 2017 01:59:13 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id r191sm6110650wmg.6.2017.07.13.01.59.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:59:12 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [58/77] Use scalar_int_mode in a try_combine optimisation References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:59:10 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <877ezcemqp.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses scalar_int_modes for: /* If I2 is setting a pseudo to a constant and I3 is setting some sub-part of it to another constant, merge them by making a new constant. */ This was already implicit, but the danger with checking only CONST_SCALAR_INT_P is that it can include CC values too. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (try_combine): Use is_a when trying to combine a full-register integer set with a subreg integer set. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:45.761227536 +0100 +++ gcc/combine.c 2017-07-13 09:18:49.526933168 +0100 @@ -2645,6 +2645,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx other_pat = 0; rtx new_other_notes; int i; + scalar_int_mode dest_mode, temp_mode; /* Immediately return if any of I0,I1,I2 are the same insn (I3 can never be). */ @@ -2847,33 +2848,40 @@ try_combine (rtx_insn *i3, rtx_insn *i2, constant. */ if (i1 == 0 && (temp_expr = single_set (i2)) != 0 + && is_a (GET_MODE (SET_DEST (temp_expr)), &temp_mode) && CONST_SCALAR_INT_P (SET_SRC (temp_expr)) && GET_CODE (PATTERN (i3)) == SET && CONST_SCALAR_INT_P (SET_SRC (PATTERN (i3))) && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp_expr))) { rtx dest = SET_DEST (PATTERN (i3)); + rtx temp_dest = SET_DEST (temp_expr); int offset = -1; int width = 0; - + if (GET_CODE (dest) == ZERO_EXTRACT) { if (CONST_INT_P (XEXP (dest, 1)) - && CONST_INT_P (XEXP (dest, 2))) + && CONST_INT_P (XEXP (dest, 2)) + && is_a (GET_MODE (XEXP (dest, 0)), + &dest_mode)) { width = INTVAL (XEXP (dest, 1)); offset = INTVAL (XEXP (dest, 2)); dest = XEXP (dest, 0); if (BITS_BIG_ENDIAN) - offset = GET_MODE_PRECISION (GET_MODE (dest)) - width - offset; + offset = GET_MODE_PRECISION (dest_mode) - width - offset; } } else { if (GET_CODE (dest) == STRICT_LOW_PART) dest = XEXP (dest, 0); - width = GET_MODE_PRECISION (GET_MODE (dest)); - offset = 0; + if (is_a (GET_MODE (dest), &dest_mode)) + { + width = GET_MODE_PRECISION (dest_mode); + offset = 0; + } } if (offset >= 0) @@ -2882,9 +2890,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, if (subreg_lowpart_p (dest)) ; /* Handle the case where inner is twice the size of outer. */ - else if (GET_MODE_PRECISION (GET_MODE (SET_DEST (temp_expr))) - == 2 * GET_MODE_PRECISION (GET_MODE (dest))) - offset += GET_MODE_PRECISION (GET_MODE (dest)); + else if (GET_MODE_PRECISION (temp_mode) + == 2 * GET_MODE_PRECISION (dest_mode)) + offset += GET_MODE_PRECISION (dest_mode); /* Otherwise give up for now. */ else offset = -1; @@ -2895,23 +2903,22 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx inner = SET_SRC (PATTERN (i3)); rtx outer = SET_SRC (temp_expr); - wide_int o - = wi::insert (rtx_mode_t (outer, GET_MODE (SET_DEST (temp_expr))), - rtx_mode_t (inner, GET_MODE (dest)), - offset, width); + wide_int o = wi::insert (rtx_mode_t (outer, temp_mode), + rtx_mode_t (inner, dest_mode), + offset, width); combine_merges++; subst_insn = i3; subst_low_luid = DF_INSN_LUID (i2); added_sets_2 = added_sets_1 = added_sets_0 = 0; - i2dest = SET_DEST (temp_expr); + i2dest = temp_dest; i2dest_killed = dead_or_set_p (i2, i2dest); /* Replace the source in I2 with the new constant and make the resulting insn the new pattern for I3. Then skip to where we validate the pattern. Everything was set up above. */ SUBST (SET_SRC (temp_expr), - immed_wide_int_const (o, GET_MODE (SET_DEST (temp_expr)))); + immed_wide_int_const (o, temp_mode)); newpat = PATTERN (i2); From patchwork Thu Jul 13 08:59:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107645 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1941385qge; Thu, 13 Jul 2017 02:01:25 -0700 (PDT) X-Received: by 10.98.166.131 with SMTP id r3mr59272098pfl.120.1499936485529; Thu, 13 Jul 2017 02:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936485; cv=none; d=google.com; s=arc-20160816; b=PjrLZ2vuDllNzb/AyjU68FfqY3sFfMUK2FSJRv1GYpvUj/BdNJ1yJrNmUu0m+W5K7H nGQ+xuX4UZSSIGddmEKcLK1sLRf7fQkeaeXxsNRrRU9W4lgobu2bp/S3ZGwdUmqOrZF7 h2tSZBEo+qM/dcwg/bbnv8qiczyi+BtCg2LGLS5UKXCDn9SI89En0+rBwSwSULafkDHM 20siOrbL9TnekhGD5hm5eMVx+Pv5nHJ+UPv035GBiWY7EO+hK71Nehs//hjW1JSAHc6T LUxwBccGXvV+Fqe0FohL8oNegcfA5Q1YrPafQbahb7LSbAE9cG9idLT89+/uooQlPIdA xSww== 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=iwx0HNW3J7X5veneHYiXEN94h5NtC//2wggvibhyKvU=; b=AuJkOhYV8Y+60//ENnUC2UszFPj8RatwkDoQT9BuxAT1cV2kHhFktpDoU7Hp23snPD OUPI5Vo9qEiIEt/gEFJKUIenKDTqx9GcEWVkfwCm14VKwmTfG41zpOpNxtcp41WHkMbc KrcoLoAadyzSkGsM7CmcrPkm8zN8yzxOoPZOda8S+2BmJRa8YU2sKbwQB7dtvZWsykz2 2rOIje5+kqI11PG+eDrxFpUBtBksuB1PqDSPul9xezpCaajP6JS7uSn+BbQjRosS2Gij 3+eB29JmXyF6lamwoMumqCde3+lGa2VEcj/Wq9KINyobtjiNDnXjU/9Q+WYSmaQK9C4T obGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=qqVcSgHh; spf=pass (google.com: domain of gcc-patches-return-458050-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458050-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 n74si3752688pfa.311.2017.07.13.02.01.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458050-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=qqVcSgHh; spf=pass (google.com: domain of gcc-patches-return-458050-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458050-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=C4COr0cfet0/E5aElOUuqkZZxOMd8 N7uWfJs05eksdZRWtB8YvXwuT+CGpL0NxLusowjGS5tZBMVF7/CqR1p2pe6eoJli YLJXIx9dWx4D67PTjj4X1UY64fcYzidRcAQ5cY9dMYHKtVqSfGdCkzcOMb7spMwz batYyMrKMrbTdE= 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=KBQDMocJtywRP9I/td6hxubdf0E=; b=qqV cSgHhqTTx+Ut04p/Pmtn2OLfXm0hMzQ11boOESCwVynw4vqsgcLJ7ZO8zbup6l/Q yStSvednWNifoYnMfWqnnAWujiEWt40DM4IVYNeVk+RCc4UJx2QJOeS9PCQrCcHP QPhYMXtyE5y24jC6XU1c5RxHhxqU1TzOdVkLZxYk= Received: (qmail 61069 invoked by alias); 13 Jul 2017 08:59:39 -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 60474 invoked by uid 89); 13 Jul 2017 08:59:38 -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=2224 X-HELO: mail-wm0-f47.google.com Received: from mail-wm0-f47.google.com (HELO mail-wm0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:59:33 +0000 Received: by mail-wm0-f47.google.com with SMTP id i127so18472036wma.0 for ; Thu, 13 Jul 2017 01:59:33 -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=iwx0HNW3J7X5veneHYiXEN94h5NtC//2wggvibhyKvU=; b=gV+QbcPBPxSytt9X6y6nx5ECqFScBMhwpjer/MKKo1pvulnicaPNhgXrassNxRTdA4 yLwYDqu2OiqL2JQS2mr/HfQtCVHvK+/O2cDTAW4gz80LVfnWMsfCy9PhqLcgecmwyi1P kj9KRjnPHIg+oDNz/RxswuLXbiCp0tlsyHcCsEYTo3ddbTpBQSNrVaS07Tfmz5us7N+M L57p0TBKHEXMx6Sn5nn3cAxL1xTvHVaM9RW5iDFQM37Ydy2lpzGoiMx+5Ql/mDlKYGNm 8qDvoJCq9PqLueJ2KCOdLqJwBAD40UMKNPpoCzWy+PtTOB4yx4MAq7qCeTycUUlKdvjd TqnQ== X-Gm-Message-State: AIVw111aPV6kk0uSpPJrcq4ZpdegTOvfwx8gFtoPdG3/nRqaGM+SjMbR renSEHpOBqbOz4bnnv4YmA== X-Received: by 10.28.141.142 with SMTP id p136mr1294940wmd.125.1499936371222; Thu, 13 Jul 2017 01:59:31 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id e17sm4376286wma.19.2017.07.13.01.59.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:59:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [59/77] Add a rtx_jump_table_data::get_data_mode helper References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:59:28 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8737a0emq7.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a helper function to get the mode of the addresses or offsets in a jump table. It also changes the final.c code to use rtx_jump_table_data over rtx or rtx_insn in cases where it needed to use the new helper. This in turn meant adding a safe_dyn_cast equivalent of safe_as_a, to cope with null NEXT_INSNs. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * is-a.h (safe_dyn_cast): New function. * rtl.h (rtx_jump_table_data::get_data_mode): New function. (jump_table_for_label): Likewise. * final.c (final_addr_vec_align): Take an rtx_jump_table_data * instead of an rtx_insn *. (shorten_branches): Use dyn_cast instead of LABEL_P and JUMP_TABLE_DATA_P. Use jump_table_for_label and rtx_jump_table_data::get_data_mode. (final_scan_insn): Likewise. Index: gcc/is-a.h =================================================================== --- gcc/is-a.h 2017-02-23 19:54:02.000000000 +0000 +++ gcc/is-a.h 2017-07-13 09:18:49.947900834 +0100 @@ -103,6 +103,11 @@ TYPE dyn_cast (pointer) Note that we have converted two sets of assertions in the calls to varpool into safe and efficient use of a variable. +TYPE safe_dyn_cast (pointer) + + Like dyn_cast (pointer), except that it accepts null pointers + and returns null results for them. + If you use these functions and get a 'inline function not defined' or a 'missing symbol' error message for 'is_a_helper<....>::test', it means that @@ -222,4 +227,13 @@ dyn_cast (U *p) return static_cast (0); } +/* Similar to dyn_cast, except that the pointer may be null. */ + +template +inline T +safe_dyn_cast (U *p) +{ + return p ? dyn_cast (p) : 0; +} + #endif /* GCC_IS_A_H */ Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-13 09:18:46.226190608 +0100 +++ gcc/rtl.h 2017-07-13 09:18:49.948900757 +0100 @@ -634,6 +634,7 @@ class GTY(()) rtx_jump_table_data : publ This method gets the underlying vec. */ inline rtvec get_labels () const; + inline scalar_int_mode get_data_mode () const; }; class GTY(()) rtx_barrier : public rtx_insn @@ -1477,6 +1478,24 @@ inline rtvec rtx_jump_table_data::get_la return XVEC (pat, 1); /* presumably an ADDR_DIFF_VEC */ } +/* Return the mode of the data in the table, which is always a scalar + integer. */ + +inline scalar_int_mode +rtx_jump_table_data::get_data_mode () const +{ + return as_a (GET_MODE (PATTERN (this))); +} + +/* If LABEL is followed by a jump table, return the table, otherwise + return null. */ + +inline rtx_jump_table_data * +jump_table_for_label (const rtx_code_label *label) +{ + return safe_dyn_cast (NEXT_INSN (label)); +} + #define RTX_FRAME_RELATED_P(RTX) \ (RTL_FLAG_CHECK6 ("RTX_FRAME_RELATED_P", (RTX), DEBUG_INSN, INSN, \ CALL_INSN, JUMP_INSN, BARRIER, SET)->frame_related) Index: gcc/final.c =================================================================== --- gcc/final.c 2017-06-07 07:42:15.423295833 +0100 +++ gcc/final.c 2017-07-13 09:18:49.947900834 +0100 @@ -217,9 +217,6 @@ static void leaf_renumber_regs (rtx_insn #if HAVE_cc0 static int alter_cond (rtx); #endif -#ifndef ADDR_VEC_ALIGN -static int final_addr_vec_align (rtx_insn *); -#endif static int align_fuzz (rtx, rtx, int, unsigned); static void collect_fn_hard_reg_usage (void); static tree get_call_fndecl (rtx_insn *); @@ -517,9 +514,9 @@ default_jump_align_max_skip (rtx_insn *i #ifndef ADDR_VEC_ALIGN static int -final_addr_vec_align (rtx_insn *addr_vec) +final_addr_vec_align (rtx_jump_table_data *addr_vec) { - int align = GET_MODE_SIZE (GET_MODE (PATTERN (addr_vec))); + int align = GET_MODE_SIZE (addr_vec->get_data_mode ()); if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT) align = BIGGEST_ALIGNMENT / BITS_PER_UNIT; @@ -936,45 +933,41 @@ #define MAX_CODE_ALIGN 16 if (INSN_P (insn)) continue; - if (LABEL_P (insn)) + if (rtx_code_label *label = dyn_cast (insn)) { - rtx_insn *next; - bool next_is_jumptable; - /* Merge in alignments computed by compute_alignments. */ - log = LABEL_TO_ALIGNMENT (insn); + log = LABEL_TO_ALIGNMENT (label); if (max_log < log) { max_log = log; - max_skip = LABEL_TO_MAX_SKIP (insn); + max_skip = LABEL_TO_MAX_SKIP (label); } - next = next_nonnote_insn (insn); - next_is_jumptable = next && JUMP_TABLE_DATA_P (next); - if (!next_is_jumptable) + rtx_jump_table_data *table = jump_table_for_label (label); + if (!table) { - log = LABEL_ALIGN (insn); + log = LABEL_ALIGN (label); if (max_log < log) { max_log = log; - max_skip = targetm.asm_out.label_align_max_skip (insn); + max_skip = targetm.asm_out.label_align_max_skip (label); } } /* ADDR_VECs only take room if read-only data goes into the text section. */ if ((JUMP_TABLES_IN_TEXT_SECTION || readonly_data_section == text_section) - && next_is_jumptable) + && table) { - log = ADDR_VEC_ALIGN (next); + log = ADDR_VEC_ALIGN (table); if (max_log < log) { max_log = log; - max_skip = targetm.asm_out.label_align_max_skip (insn); + max_skip = targetm.asm_out.label_align_max_skip (label); } } - LABEL_TO_ALIGNMENT (insn) = max_log; - LABEL_TO_MAX_SKIP (insn) = max_skip; + LABEL_TO_ALIGNMENT (label) = max_log; + LABEL_TO_MAX_SKIP (label) = max_skip; max_log = 0; max_skip = 0; } @@ -1130,7 +1123,7 @@ #define MAX_CODE_ALIGN 16 continue; body = PATTERN (insn); - if (JUMP_TABLE_DATA_P (insn)) + if (rtx_jump_table_data *table = dyn_cast (insn)) { /* This only takes room if read-only data goes into the text section. */ @@ -1138,7 +1131,7 @@ #define MAX_CODE_ALIGN 16 || readonly_data_section == text_section) insn_lengths[uid] = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC) - * GET_MODE_SIZE (GET_MODE (body))); + * GET_MODE_SIZE (table->get_data_mode ())); /* Alignment is handled by ADDR_VEC_ALIGN. */ } else if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0) @@ -1218,28 +1211,27 @@ #define MAX_CODE_ALIGN 16 uid = INSN_UID (insn); - if (LABEL_P (insn)) + if (rtx_code_label *label = dyn_cast (insn)) { - int log = LABEL_TO_ALIGNMENT (insn); + int log = LABEL_TO_ALIGNMENT (label); #ifdef CASE_VECTOR_SHORTEN_MODE /* If the mode of a following jump table was changed, we may need to update the alignment of this label. */ - rtx_insn *next; - bool next_is_jumptable; - next = next_nonnote_insn (insn); - next_is_jumptable = next && JUMP_TABLE_DATA_P (next); - if ((JUMP_TABLES_IN_TEXT_SECTION - || readonly_data_section == text_section) - && next_is_jumptable) + if (JUMP_TABLES_IN_TEXT_SECTION + || readonly_data_section == text_section) { - int newlog = ADDR_VEC_ALIGN (next); - if (newlog != log) + rtx_jump_table_data *table = jump_table_for_label (label); + if (table) { - log = newlog; - LABEL_TO_ALIGNMENT (insn) = log; - something_changed = 1; + int newlog = ADDR_VEC_ALIGN (table); + if (newlog != log) + { + log = newlog; + LABEL_TO_ALIGNMENT (insn) = log; + something_changed = 1; + } } } #endif @@ -1270,6 +1262,7 @@ #define MAX_CODE_ALIGN 16 && JUMP_TABLE_DATA_P (insn) && GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC) { + rtx_jump_table_data *table = as_a (insn); rtx body = PATTERN (insn); int old_length = insn_lengths[uid]; rtx_insn *rel_lab = @@ -1365,13 +1358,14 @@ #define MAX_CODE_ALIGN 16 max_addr - rel_addr, body); if (!increasing || (GET_MODE_SIZE (vec_mode) - >= GET_MODE_SIZE (GET_MODE (body)))) + >= GET_MODE_SIZE (table->get_data_mode ()))) PUT_MODE (body, vec_mode); if (JUMP_TABLES_IN_TEXT_SECTION || readonly_data_section == text_section) { insn_lengths[uid] - = (XVECLEN (body, 1) * GET_MODE_SIZE (GET_MODE (body))); + = (XVECLEN (body, 1) + * GET_MODE_SIZE (table->get_data_mode ())); insn_current_address += insn_lengths[uid]; if (insn_lengths[uid] != old_length) something_changed = 1; @@ -2190,6 +2184,7 @@ final_scan_insn (rtx_insn *insn, FILE *f rtx set; #endif rtx_insn *next; + rtx_jump_table_data *table; insn_counter++; @@ -2447,11 +2442,11 @@ final_scan_insn (rtx_insn *insn, FILE *f app_disable (); - next = next_nonnote_insn (insn); /* If this label is followed by a jump-table, make sure we put the label in the read-only section. Also possibly write the label and jump table together. */ - if (next != 0 && JUMP_TABLE_DATA_P (next)) + table = jump_table_for_label (as_a (insn)); + if (table) { #if defined(ASM_OUTPUT_ADDR_VEC) || defined(ASM_OUTPUT_ADDR_DIFF_VEC) /* In this case, the case vector is being moved by the @@ -2466,7 +2461,7 @@ final_scan_insn (rtx_insn *insn, FILE *f (current_function_decl)); #ifdef ADDR_VEC_ALIGN - log_align = ADDR_VEC_ALIGN (next); + log_align = ADDR_VEC_ALIGN (table); #else log_align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT); #endif @@ -2476,8 +2471,7 @@ final_scan_insn (rtx_insn *insn, FILE *f switch_to_section (current_function_section ()); #ifdef ASM_OUTPUT_CASE_LABEL - ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn), - next); + ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn), table); #else targetm.asm_out.internal_label (file, "L", CODE_LABEL_NUMBER (insn)); #endif From patchwork Thu Jul 13 08:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107647 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1942195qge; Thu, 13 Jul 2017 02:02:01 -0700 (PDT) X-Received: by 10.98.222.3 with SMTP id h3mr58498338pfg.93.1499936521555; Thu, 13 Jul 2017 02:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936521; cv=none; d=google.com; s=arc-20160816; b=HcNwKX3A8RmNd6OA6pe75DQmTSbyi7PMhRYOlxZ6tB+nYw0TRLbwEqIhiv7wub16Gk sLWniUJQFApeG+oCB0mF2tZUXLVv9EXKUl9Y5OoouCtCKfNIJ+ZOAZlmMsde9f5B9Blj a5znWrlUTr1ZeuxV5gHQKLvo25PAI9+oJq3gDff3VWgQd9WkgukrV0F3mAbtIsN7zLNL bNW7WXLgFdGrhsmhffYFDvzFYhvmszdmGbPVCnUzM5TPW43Q0VVA5aCinPS1VAEV8oqQ i3N8nRqrYSgh1YMMg+8LLxF42Zyvi3vq6ffxENNpZzjhPz1cPFDVYSrBPWgk1ofEPPIp E8Qg== 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=sXp+6E2CZNdcps7aqbbw14phJobu9QlUIk5oSVbBC9A=; b=sQFntjmmZ6MOLa5Fmtio21kizJ7BFYf7PczFiVYMO6m3M7J5X5Xsi/s/hj3tPfcAHI 0k+MLz+S1aLFEqFRfNxT2sLAqUHE8HAY5Gt8H56Ibb8GiNtDgzfpYfPclGYzlbzhZXq4 7eXtpBF/xKAkAoVVnjbTbUV+S8EKk1vMy8tFR+75LCKF/lWyIcJh6/ztgr428KpnGWjD BB6XpelSLOWI/5oGHieDiaNLjFfyR55ywNe7Nu/r8KK22mKyWj5Ay1+Ec6S5c2cMXQu1 Idy2XEzVxZtoYJJp/Mg+qTwoOAZez+I0HgjbZUj5lCUxJDCWki2gvzKksAwj5LP14k6s 9DrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=ZbcPK5GK; spf=pass (google.com: domain of gcc-patches-return-458051-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458051-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 g12si4061682plk.306.2017.07.13.02.02.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458051-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=ZbcPK5GK; spf=pass (google.com: domain of gcc-patches-return-458051-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458051-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=H8dzyPuRt85fZuAiM9TqY3U65TvBD hJb8Ip6fbrDqTafdh0KzqhbzXv2hNClFzyf6dEPGszFDi2u+jwyl/c6LabIXBnXa z4uMe3shtPQAUpmqZD174nCeu+Hka1TqBqES1IZOQa1q2vF+EmQhk+tbbEFjrSjY NGUdCA2Nfbr7Xw= 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=lRr33J/XeNn62FnR+AKtquAOh6c=; b=Zbc PK5GKp9ed1MWfa+/F5BQGkkott7D8/lh1uYEOwDSU50/Ea9TwUGh3ZqKhbKSN3k1 Bi1N2nSIMJsHeVPm7EHgeK5asmvKEFuzn+XzsUuPgIb8PCWaTVuGQH3oLWeincsg OA+ddV77n182jdA8tPBFyAQT6psCI2uIwzVmXRkQ= Received: (qmail 74040 invoked by alias); 13 Jul 2017 08:59:55 -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 73333 invoked by uid 89); 13 Jul 2017 08:59:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f169.google.com Received: from mail-wr0-f169.google.com (HELO mail-wr0-f169.google.com) (209.85.128.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:59:50 +0000 Received: by mail-wr0-f169.google.com with SMTP id r103so49653684wrb.0 for ; Thu, 13 Jul 2017 01:59:50 -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=sXp+6E2CZNdcps7aqbbw14phJobu9QlUIk5oSVbBC9A=; b=OsIGb02ra/qJWWb47fHkbjK+5P7CvcDQ/rn5KL0FWyTLqj6Pa4xdT8jNf0l3EBClpe guLM9VuyysgI5Pw6s16vNyHAT9PhPeeutJn7LRG6vOkKip3f8V1+SnHlIlGsqShOT7hm 9dvfKG2kEP3r5grCZTU/a0g4yZKT5F4e/O1KfHHfF60BCTwU8woRmSVwtZNkNzJgXnaU VNDJ5S9jWjuX9MjTYF8qnqR85AEHkkC6OK/asBk+4DfhI7hik7+fpAy7gFM7Q/UaWc4l HXqwsrmOLU19oH7nEVLSMegtPJ7Ewu+yacu8qGYDig1OVMeyZczfnqsj/GeEh6conCCx GSdg== X-Gm-Message-State: AIVw1120uGJtv2mq15PidE/BpdXBevhe2loGIPIcSJykNrvwv18muXac TTe0S088o6xIMoVgG6kgSw== X-Received: by 10.223.145.10 with SMTP id j10mr880676wrj.172.1499936388498; Thu, 13 Jul 2017 01:59:48 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id t125sm4970743wmt.20.2017.07.13.01.59.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:59:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [60/77] Pass scalar_int_modes to do_jump_by_parts_* References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:59:46 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87y3rsd859.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The callers of do_jump_by_parts_* had already established that the modes were MODE_INTs, so this patch passes the modes down as scalar_int_modes. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * dojump.c (do_jump_by_parts_greater_rtx): Change the type of the mode argument to scalar_int_mode. (do_jump_by_parts_zero_rtx): Likewise. (do_jump_by_parts_equality_rtx): Likewise. (do_jump_by_parts_greater): Take a mode argument. (do_jump_by_parts_equality): Likewise. (do_jump_1): Update calls accordingly. Index: gcc/dojump.c =================================================================== --- gcc/dojump.c 2017-07-13 09:18:38.657812970 +0100 +++ gcc/dojump.c 2017-07-13 09:18:50.326871958 +0100 @@ -38,11 +38,12 @@ Software Foundation; either version 3, o #include "langhooks.h" static bool prefer_and_bit_test (machine_mode, int); -static void do_jump_by_parts_greater (tree, tree, int, +static void do_jump_by_parts_greater (scalar_int_mode, tree, tree, int, rtx_code_label *, rtx_code_label *, profile_probability); -static void do_jump_by_parts_equality (tree, tree, rtx_code_label *, - rtx_code_label *, profile_probability); +static void do_jump_by_parts_equality (scalar_int_mode, tree, tree, + rtx_code_label *, rtx_code_label *, + profile_probability); static void do_compare_and_jump (tree, tree, enum rtx_code, enum rtx_code, rtx_code_label *, rtx_code_label *, profile_probability); @@ -221,8 +222,8 @@ do_jump_1 (enum tree_code code, tree op0 prob.invert ()); else if (is_int_mode (TYPE_MODE (inner_type), &int_mode) && !can_compare_p (EQ, int_mode, ccp_jump)) - do_jump_by_parts_equality (op0, op1, if_false_label, if_true_label, - prob); + do_jump_by_parts_equality (int_mode, op0, op1, if_false_label, + if_true_label, prob); else do_compare_and_jump (op0, op1, EQ, EQ, if_false_label, if_true_label, prob); @@ -242,8 +243,8 @@ do_jump_1 (enum tree_code code, tree op0 do_jump (op0, if_false_label, if_true_label, prob); else if (is_int_mode (TYPE_MODE (inner_type), &int_mode) && !can_compare_p (NE, int_mode, ccp_jump)) - do_jump_by_parts_equality (op0, op1, if_true_label, if_false_label, - prob.invert ()); + do_jump_by_parts_equality (int_mode, op0, op1, if_true_label, + if_false_label, prob.invert ()); else do_compare_and_jump (op0, op1, NE, NE, if_false_label, if_true_label, prob); @@ -254,7 +255,7 @@ do_jump_1 (enum tree_code code, tree op0 mode = TYPE_MODE (TREE_TYPE (op0)); if (is_int_mode (mode, &int_mode) && ! can_compare_p (LT, int_mode, ccp_jump)) - do_jump_by_parts_greater (op0, op1, 1, if_false_label, + do_jump_by_parts_greater (int_mode, op0, op1, 1, if_false_label, if_true_label, prob); else do_compare_and_jump (op0, op1, LT, LTU, if_false_label, if_true_label, @@ -265,8 +266,8 @@ do_jump_1 (enum tree_code code, tree op0 mode = TYPE_MODE (TREE_TYPE (op0)); if (is_int_mode (mode, &int_mode) && ! can_compare_p (LE, int_mode, ccp_jump)) - do_jump_by_parts_greater (op0, op1, 0, if_true_label, if_false_label, - prob.invert ()); + do_jump_by_parts_greater (int_mode, op0, op1, 0, if_true_label, + if_false_label, prob.invert ()); else do_compare_and_jump (op0, op1, LE, LEU, if_false_label, if_true_label, prob); @@ -276,7 +277,7 @@ do_jump_1 (enum tree_code code, tree op0 mode = TYPE_MODE (TREE_TYPE (op0)); if (is_int_mode (mode, &int_mode) && ! can_compare_p (GT, int_mode, ccp_jump)) - do_jump_by_parts_greater (op0, op1, 0, if_false_label, + do_jump_by_parts_greater (int_mode, op0, op1, 0, if_false_label, if_true_label, prob); else do_compare_and_jump (op0, op1, GT, GTU, if_false_label, if_true_label, @@ -287,8 +288,8 @@ do_jump_1 (enum tree_code code, tree op0 mode = TYPE_MODE (TREE_TYPE (op0)); if (is_int_mode (mode, &int_mode) && ! can_compare_p (GE, int_mode, ccp_jump)) - do_jump_by_parts_greater (op0, op1, 1, if_true_label, if_false_label, - prob.invert ()); + do_jump_by_parts_greater (int_mode, op0, op1, 1, if_true_label, + if_false_label, prob.invert ()); else do_compare_and_jump (op0, op1, GE, GEU, if_false_label, if_true_label, prob); @@ -667,7 +668,7 @@ do_jump (tree exp, rtx_code_label *if_fa Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise. */ static void -do_jump_by_parts_greater_rtx (machine_mode mode, int unsignedp, rtx op0, +do_jump_by_parts_greater_rtx (scalar_int_mode mode, int unsignedp, rtx op0, rtx op1, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob) @@ -743,17 +744,16 @@ do_jump_by_parts_greater_rtx (machine_mo /* Given a comparison expression EXP for values too wide to be compared with one insn, test the comparison and jump to the appropriate label. The code of EXP is ignored; we always test GT if SWAP is 0, - and LT if SWAP is 1. */ + and LT if SWAP is 1. MODE is the mode of the two operands. */ static void -do_jump_by_parts_greater (tree treeop0, tree treeop1, int swap, - rtx_code_label *if_false_label, +do_jump_by_parts_greater (scalar_int_mode mode, tree treeop0, tree treeop1, + int swap, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob) { rtx op0 = expand_normal (swap ? treeop1 : treeop0); rtx op1 = expand_normal (swap ? treeop0 : treeop1); - machine_mode mode = TYPE_MODE (TREE_TYPE (treeop0)); int unsignedp = TYPE_UNSIGNED (TREE_TYPE (treeop0)); do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label, @@ -766,7 +766,7 @@ do_jump_by_parts_greater (tree treeop0, to indicate drop through. */ static void -do_jump_by_parts_zero_rtx (machine_mode mode, rtx op0, +do_jump_by_parts_zero_rtx (scalar_int_mode mode, rtx op0, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob) @@ -817,7 +817,7 @@ do_jump_by_parts_zero_rtx (machine_mode to indicate drop through. */ static void -do_jump_by_parts_equality_rtx (machine_mode mode, rtx op0, rtx op1, +do_jump_by_parts_equality_rtx (scalar_int_mode mode, rtx op0, rtx op1, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob) @@ -855,17 +855,17 @@ do_jump_by_parts_equality_rtx (machine_m } /* Given an EQ_EXPR expression EXP for values too wide to be compared - with one insn, test the comparison and jump to the appropriate label. */ + with one insn, test the comparison and jump to the appropriate label. + MODE is the mode of the two operands. */ static void -do_jump_by_parts_equality (tree treeop0, tree treeop1, +do_jump_by_parts_equality (scalar_int_mode mode, tree treeop0, tree treeop1, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob) { rtx op0 = expand_normal (treeop0); rtx op1 = expand_normal (treeop1); - machine_mode mode = TYPE_MODE (TREE_TYPE (treeop0)); do_jump_by_parts_equality_rtx (mode, op0, op1, if_false_label, if_true_label, prob); } From patchwork Thu Jul 13 09:00:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107648 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1942436qge; Thu, 13 Jul 2017 02:02:16 -0700 (PDT) X-Received: by 10.84.130.47 with SMTP id 44mr8918994plc.192.1499936536502; Thu, 13 Jul 2017 02:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936536; cv=none; d=google.com; s=arc-20160816; b=wTyliEwLJ6SyBBN9QWroRu97HlL+F/N94mpJ/pd5erZ7h5D9HfTeymUCWdSYUdqKMf 8+M+Nb6sxT3jUl5DmL4rn23xRBzVf+NB9nooMFTMrbaM521lS5gxcTUjK2mQ4LHwp188 rWmrvGZQj+wpNsrpWq6IsoqzwUteEeo346XxvpDMT3xa4JVygk7jfHGTCh2ifNOmiSlc cfNVaPd2Pc1xAgGKE34gOKb/34n23IjmaDIFkZC4vspf4MpYUp2+GVPGuMC4xLZe/p8k UbuXxxoHrORNFpx1KROqZAk2Qg7DoWOVjnxZZv+F81c/Csw7VdwbRydXq9j6inZPhJdh dfeg== 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=FaPnmeTllgH3pT3Wi9KEsuvIuBo38s6v19pFLvpPzuM=; b=PYf2zCnWnsc6RAcSUYpXfdxSTkSESmn43PFc2Kqpjv7jnf1CHZS8brL1kvpCzjFlGF 9cgq8EVlUVLdB7Tzlz+h1vs2AKl1XGmxPBAw189cWeC8H1Xeop9g5uez6nOdpUWaxtjo 8oUhgom7orz0QujKGNWuJOttbplNa0BSDyBHOt/yCGD50zTIqh2yWiO1zNFY5Lx8o1py zCbx8VJXrycB1YbU51ilmDPTaTg8PlIMi/GSNr5hUeIr0bpEFqQlPZY72KeFZ/0u0B/W rEFKfG9oBp2ZJKUX1Aeg8jbZnzJtFCoa072XxsaWbs/EnCZvnkOk3FgJNlsPdNN1xdPw 3rQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=bjVOEbvb; spf=pass (google.com: domain of gcc-patches-return-458052-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458052-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 d188si3784548pfc.312.2017.07.13.02.02.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:02:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458052-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=bjVOEbvb; spf=pass (google.com: domain of gcc-patches-return-458052-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458052-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=JN2u9Kj/NJ0XkjUjWu7jn5qBQGapd scXxiZFbNei3rHGP40labZSjimpjxwTYrat+A/0lqXRYVniwiTE4x84W9Brp8G1h kM3z5c7P3U48+zyUv+fkLVUPzvbn1i8x5hYiQ4xYe1LpUmshsnw39aGVTSU+O42A m6c+DTgN+tinnA= 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=0+aqV9G2TBJ1y3GVXqBSo4qbMAs=; b=bjV OEbvbusQiOIzQqHz3PgHW+pN6Mr93PhiYveqU915WCczb1Oa34B914qxMp3Fi6zV Za/yfHeI7uDQhubaY8rc9Jw2Jwecizh8FvnkituS9379Oo0pWP1lYcReXncYfV1K S6rN4vY2rrs4PUNwQ/6YFhGyq7P1XRYtZE86vI98= Received: (qmail 112181 invoked by alias); 13 Jul 2017 09:00:30 -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 109844 invoked by uid 89); 13 Jul 2017 09:00:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=33021 X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:00:20 +0000 Received: by mail-wr0-f176.google.com with SMTP id k67so49492072wrc.2 for ; Thu, 13 Jul 2017 02:00:07 -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=FaPnmeTllgH3pT3Wi9KEsuvIuBo38s6v19pFLvpPzuM=; b=E5TFxB9pJyrpxJoBrTyP6e8Wz/42ncyT3np8TJkn4VBq4eeQUVZzi+QJ7kpBoEJ4po C0mn5sB0hfC7Tq8Cqloao1YvXW4qV1HytJsfsi/M+VmDp/x+wrW4SmPRhks3Iw0Fpt4/ OOG2E1zRwgJSwlu73eiJRShIbHbKnqO9u9wSNEuf4gcK1KoetFLwqYwXeIDmwXEEQEUi PvzlZgWiGIdLXz9lfv5ZmDTeh29BMKxOdmjCo6VYLgU3QrJg9Ob0LuD/qiq7Rx4McPuy px6Ouf+M1zYV63oqMMJCYnE86jhxR2tjseElgzgvbuE6+GSg/69kqjGm0JWrYsxOlmv/ LMHQ== X-Gm-Message-State: AIVw113/O2jCuCqyKxT1Z0RtAUVEJhYE44xe9pETYkgFGz4ynmn8vY7A 793MA4kiZphHXP4QHv+j5Q== X-Received: by 10.223.138.234 with SMTP id z39mr971838wrz.50.1499936405735; Thu, 13 Jul 2017 02:00:05 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id i67sm3629061wri.61.2017.07.13.02.00.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:00:05 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [61/77] Use scalar_int_mode in the AArch64 port References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:00:03 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87tw2gd84s.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the AArch64 port use scalar_int_mode in various places. Other ports won't need this kind of change; we only need it for AArch64 because of the variable-sized SVE modes. The only change in functionality is in the rtx_costs handling of CONST_INT. If the caller doesn't supply a mode, we now pass word_mode rather than VOIDmode to aarch64_internal_mov_immediate. aarch64_movw_imm will therefore not now truncate large constants in this situation. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * config/aarch64/aarch64-protos.h (aarch64_is_extend_from_extract): Take a scalar_int_mode instead of a machine_mode. (aarch64_mask_and_shift_for_ubfiz_p): Likewise. (aarch64_move_imm): Likewise. (aarch64_output_scalar_simd_mov_immediate): Likewise. (aarch64_simd_scalar_immediate_valid_for_move): Likewise. (aarch64_simd_attr_length_rglist): Delete. * config/aarch64/aarch64.c (aarch64_is_extend_from_extract): Take a scalar_int_mode instead of a machine_mode. (aarch64_add_offset): Likewise. (aarch64_internal_mov_immediate): Likewise (aarch64_add_constant_internal): Likewise. (aarch64_add_constant): Likewise. (aarch64_movw_imm): Likewise. (aarch64_move_imm): Likewise. (aarch64_rtx_arith_op_extract_p): Likewise. (aarch64_mask_and_shift_for_ubfiz_p): Likewise. (aarch64_simd_scalar_immediate_valid_for_move): Likewise. Remove assert that the mode isn't a vector. (aarch64_output_scalar_simd_mov_immediate): Likewise. (aarch64_expand_mov_immediate): Update calls after above changes. (aarch64_output_casesi): Use as_a . (aarch64_and_bitmask_imm): Check for scalar integer modes. (aarch64_strip_extend): Likewise. (aarch64_extr_rtx_p): Likewise. (aarch64_rtx_costs): Likewise, using wode_mode as the mode of a CONST_INT when the mode parameter is VOIDmode. Index: gcc/config/aarch64/aarch64-protos.h =================================================================== --- gcc/config/aarch64/aarch64-protos.h 2017-07-05 16:29:19.581861907 +0100 +++ gcc/config/aarch64/aarch64-protos.h 2017-07-13 09:18:50.737840686 +0100 @@ -330,22 +330,21 @@ bool aarch64_function_arg_regno_p (unsig bool aarch64_fusion_enabled_p (enum aarch64_fusion_pairs); bool aarch64_gen_movmemqi (rtx *); bool aarch64_gimple_fold_builtin (gimple_stmt_iterator *); -bool aarch64_is_extend_from_extract (machine_mode, rtx, rtx); +bool aarch64_is_extend_from_extract (scalar_int_mode, rtx, rtx); bool aarch64_is_long_call_p (rtx); bool aarch64_is_noplt_call_p (rtx); bool aarch64_label_mentioned_p (rtx); void aarch64_declare_function_name (FILE *, const char*, tree); bool aarch64_legitimate_pic_operand_p (rtx); -bool aarch64_mask_and_shift_for_ubfiz_p (machine_mode, rtx, rtx); +bool aarch64_mask_and_shift_for_ubfiz_p (scalar_int_mode, rtx, rtx); bool aarch64_modes_tieable_p (machine_mode mode1, machine_mode mode2); bool aarch64_zero_extend_const_eq (machine_mode, rtx, machine_mode, rtx); -bool aarch64_move_imm (HOST_WIDE_INT, machine_mode); +bool aarch64_move_imm (HOST_WIDE_INT, scalar_int_mode); bool aarch64_mov_operand_p (rtx, machine_mode); -int aarch64_simd_attr_length_rglist (machine_mode); rtx aarch64_reverse_mask (machine_mode); bool aarch64_offset_7bit_signed_scaled_p (machine_mode, HOST_WIDE_INT); -char *aarch64_output_scalar_simd_mov_immediate (rtx, machine_mode); +char *aarch64_output_scalar_simd_mov_immediate (rtx, scalar_int_mode); char *aarch64_output_simd_mov_immediate (rtx, machine_mode, unsigned); bool aarch64_pad_arg_upward (machine_mode, const_tree); bool aarch64_pad_reg_upward (machine_mode, const_tree, bool); @@ -355,7 +354,7 @@ bool aarch64_simd_check_vect_par_cnst_ha bool high); bool aarch64_simd_imm_scalar_p (rtx x, machine_mode mode); bool aarch64_simd_imm_zero_p (rtx, machine_mode); -bool aarch64_simd_scalar_immediate_valid_for_move (rtx, machine_mode); +bool aarch64_simd_scalar_immediate_valid_for_move (rtx, scalar_int_mode); bool aarch64_simd_shift_imm_p (rtx, machine_mode, bool); bool aarch64_simd_valid_immediate (rtx, machine_mode, bool, struct simd_immediate_info *); Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:31.691429056 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:50.738840609 +0100 @@ -1216,7 +1216,7 @@ aarch64_is_noplt_call_p (rtx sym) (extract:MODE (mult (reg) (MULT_IMM)) (EXTRACT_IMM) (const_int 0)). */ bool -aarch64_is_extend_from_extract (machine_mode mode, rtx mult_imm, +aarch64_is_extend_from_extract (scalar_int_mode mode, rtx mult_imm, rtx extract_imm) { HOST_WIDE_INT mult_val, extract_val; @@ -1842,7 +1842,8 @@ aarch64_force_temporary (machine_mode mo static rtx -aarch64_add_offset (machine_mode mode, rtx temp, rtx reg, HOST_WIDE_INT offset) +aarch64_add_offset (scalar_int_mode mode, rtx temp, rtx reg, + HOST_WIDE_INT offset) { if (!aarch64_plus_immediate (GEN_INT (offset), mode)) { @@ -1860,7 +1861,7 @@ aarch64_add_offset (machine_mode mode, r static int aarch64_internal_mov_immediate (rtx dest, rtx imm, bool generate, - machine_mode mode) + scalar_int_mode mode) { int i; unsigned HOST_WIDE_INT val, val2, mask; @@ -1966,9 +1967,11 @@ aarch64_expand_mov_immediate (rtx dest, gcc_assert (mode == SImode || mode == DImode); /* Check on what type of symbol it is. */ - if (GET_CODE (imm) == SYMBOL_REF - || GET_CODE (imm) == LABEL_REF - || GET_CODE (imm) == CONST) + scalar_int_mode int_mode; + if ((GET_CODE (imm) == SYMBOL_REF + || GET_CODE (imm) == LABEL_REF + || GET_CODE (imm) == CONST) + && is_a (mode, &int_mode)) { rtx mem, base, offset; enum aarch64_symbol_type sty; @@ -1982,11 +1985,12 @@ aarch64_expand_mov_immediate (rtx dest, { case SYMBOL_FORCE_TO_MEM: if (offset != const0_rtx - && targetm.cannot_force_const_mem (mode, imm)) + && targetm.cannot_force_const_mem (int_mode, imm)) { gcc_assert (can_create_pseudo_p ()); - base = aarch64_force_temporary (mode, dest, base); - base = aarch64_add_offset (mode, NULL, base, INTVAL (offset)); + base = aarch64_force_temporary (int_mode, dest, base); + base = aarch64_add_offset (int_mode, NULL, base, + INTVAL (offset)); aarch64_emit_move (dest, base); return; } @@ -2008,8 +2012,8 @@ aarch64_expand_mov_immediate (rtx dest, mem = gen_rtx_MEM (ptr_mode, base); } - if (mode != ptr_mode) - mem = gen_rtx_ZERO_EXTEND (mode, mem); + if (int_mode != ptr_mode) + mem = gen_rtx_ZERO_EXTEND (int_mode, mem); emit_insn (gen_rtx_SET (dest, mem)); @@ -2025,8 +2029,9 @@ aarch64_expand_mov_immediate (rtx dest, if (offset != const0_rtx) { gcc_assert(can_create_pseudo_p ()); - base = aarch64_force_temporary (mode, dest, base); - base = aarch64_add_offset (mode, NULL, base, INTVAL (offset)); + base = aarch64_force_temporary (int_mode, dest, base); + base = aarch64_add_offset (int_mode, NULL, base, + INTVAL (offset)); aarch64_emit_move (dest, base); return; } @@ -2060,7 +2065,8 @@ aarch64_expand_mov_immediate (rtx dest, return; } - aarch64_internal_mov_immediate (dest, imm, true, GET_MODE (dest)); + aarch64_internal_mov_immediate (dest, imm, true, + as_a (mode)); } /* Add DELTA to REGNUM in mode MODE. SCRATCHREG can be used to hold a @@ -2076,9 +2082,9 @@ aarch64_expand_mov_immediate (rtx dest, large immediate). */ static void -aarch64_add_constant_internal (machine_mode mode, int regnum, int scratchreg, - HOST_WIDE_INT delta, bool frame_related_p, - bool emit_move_imm) +aarch64_add_constant_internal (scalar_int_mode mode, int regnum, + int scratchreg, HOST_WIDE_INT delta, + bool frame_related_p, bool emit_move_imm) { HOST_WIDE_INT mdelta = abs_hwi (delta); rtx this_rtx = gen_rtx_REG (mode, regnum); @@ -2125,7 +2131,7 @@ aarch64_add_constant_internal (machine_m } static inline void -aarch64_add_constant (machine_mode mode, int regnum, int scratchreg, +aarch64_add_constant (scalar_int_mode mode, int regnum, int scratchreg, HOST_WIDE_INT delta) { aarch64_add_constant_internal (mode, regnum, scratchreg, delta, false, true); @@ -4000,7 +4006,7 @@ aarch64_uimm12_shift (HOST_WIDE_INT val) /* Return true if val is an immediate that can be loaded into a register by a MOVZ instruction. */ static bool -aarch64_movw_imm (HOST_WIDE_INT val, machine_mode mode) +aarch64_movw_imm (HOST_WIDE_INT val, scalar_int_mode mode) { if (GET_MODE_SIZE (mode) > 4) { @@ -4104,21 +4110,25 @@ aarch64_and_split_imm2 (HOST_WIDE_INT va bool aarch64_and_bitmask_imm (unsigned HOST_WIDE_INT val_in, machine_mode mode) { - if (aarch64_bitmask_imm (val_in, mode)) + scalar_int_mode int_mode; + if (!is_a (mode, &int_mode)) + return false; + + if (aarch64_bitmask_imm (val_in, int_mode)) return false; - if (aarch64_move_imm (val_in, mode)) + if (aarch64_move_imm (val_in, int_mode)) return false; unsigned HOST_WIDE_INT imm2 = aarch64_and_split_imm2 (val_in); - return aarch64_bitmask_imm (imm2, mode); + return aarch64_bitmask_imm (imm2, int_mode); } /* Return true if val is an immediate that can be loaded into a register in a single instruction. */ bool -aarch64_move_imm (HOST_WIDE_INT val, machine_mode mode) +aarch64_move_imm (HOST_WIDE_INT val, scalar_int_mode mode) { if (aarch64_movw_imm (val, mode) || aarch64_movw_imm (~val, mode)) return 1; @@ -6019,7 +6029,8 @@ aarch64_output_casesi (rtx *operands) gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC); - index = exact_log2 (GET_MODE_SIZE (GET_MODE (diff_vec))); + scalar_int_mode mode = as_a (GET_MODE (diff_vec)); + index = exact_log2 (GET_MODE_SIZE (mode)); gcc_assert (index >= 0 && index <= 3); @@ -6139,13 +6150,17 @@ aarch64_strip_shift (rtx x) static rtx aarch64_strip_extend (rtx x, bool strip_shift) { + scalar_int_mode mode; rtx op = x; + if (!is_a (GET_MODE (op), &mode)) + return op; + /* Zero and sign extraction of a widened value. */ if ((GET_CODE (op) == ZERO_EXTRACT || GET_CODE (op) == SIGN_EXTRACT) && XEXP (op, 2) == const0_rtx && GET_CODE (XEXP (op, 0)) == MULT - && aarch64_is_extend_from_extract (GET_MODE (op), XEXP (XEXP (op, 0), 1), + && aarch64_is_extend_from_extract (mode, XEXP (XEXP (op, 0), 1), XEXP (op, 1))) return XEXP (XEXP (op, 0), 0); @@ -6482,7 +6497,7 @@ aarch64_branch_cost (bool speed_p, bool /* Return true if the RTX X in mode MODE is a zero or sign extract usable in an ADD or SUB (extended register) instruction. */ static bool -aarch64_rtx_arith_op_extract_p (rtx x, machine_mode mode) +aarch64_rtx_arith_op_extract_p (rtx x, scalar_int_mode mode) { /* Catch add with a sign extract. This is add__multp2. */ @@ -6541,7 +6556,9 @@ aarch64_frint_unspec_p (unsigned int u) aarch64_extr_rtx_p (rtx x, rtx *res_op0, rtx *res_op1) { rtx op0, op1; - machine_mode mode = GET_MODE (x); + scalar_int_mode mode; + if (!is_a (GET_MODE (x), &mode)) + return false; *res_op0 = NULL_RTX; *res_op1 = NULL_RTX; @@ -6726,7 +6743,8 @@ aarch64_extend_bitfield_pattern_p (rtx x mode MODE. See the *andim_ashift_bfiz pattern. */ bool -aarch64_mask_and_shift_for_ubfiz_p (machine_mode mode, rtx mask, rtx shft_amnt) +aarch64_mask_and_shift_for_ubfiz_p (scalar_int_mode mode, rtx mask, + rtx shft_amnt) { return CONST_INT_P (mask) && CONST_INT_P (shft_amnt) && INTVAL (shft_amnt) < GET_MODE_BITSIZE (mode) @@ -6818,8 +6836,8 @@ aarch64_rtx_costs (rtx x, machine_mode m if ((GET_CODE (op1) == ZERO_EXTEND || GET_CODE (op1) == SIGN_EXTEND) && CONST_INT_P (XEXP (op0, 1)) - && (GET_MODE_BITSIZE (GET_MODE (XEXP (op1, 0))) - >= INTVAL (XEXP (op0, 1)))) + && is_a (GET_MODE (XEXP (op1, 0)), &int_mode) + && GET_MODE_BITSIZE (int_mode) >= INTVAL (XEXP (op0, 1))) op1 = XEXP (op1, 0); if (CONST_INT_P (op1)) @@ -6864,8 +6882,10 @@ aarch64_rtx_costs (rtx x, machine_mode m proportionally expensive to the number of instructions required to build that constant. This is true whether we are compiling for SPEED or otherwise. */ + if (!is_a (mode, &int_mode)) + int_mode = word_mode; *cost = COSTS_N_INSNS (aarch64_internal_mov_immediate - (NULL_RTX, x, false, mode)); + (NULL_RTX, x, false, int_mode)); } return true; @@ -7118,7 +7138,8 @@ aarch64_rtx_costs (rtx x, machine_mode m } /* Look for SUB (extended register). */ - if (aarch64_rtx_arith_op_extract_p (op1, mode)) + if (is_a (mode, &int_mode) + && aarch64_rtx_arith_op_extract_p (op1, int_mode)) { if (speed) *cost += extra_cost->alu.extend_arith; @@ -7197,7 +7218,8 @@ aarch64_rtx_costs (rtx x, machine_mode m *cost += rtx_cost (op1, mode, PLUS, 1, speed); /* Look for ADD (extended register). */ - if (aarch64_rtx_arith_op_extract_p (op0, mode)) + if (is_a (mode, &int_mode) + && aarch64_rtx_arith_op_extract_p (op0, int_mode)) { if (speed) *cost += extra_cost->alu.extend_arith; @@ -11583,11 +11605,10 @@ aarch64_simd_gen_const_vector_dup (machi /* Check OP is a legal scalar immediate for the MOVI instruction. */ bool -aarch64_simd_scalar_immediate_valid_for_move (rtx op, machine_mode mode) +aarch64_simd_scalar_immediate_valid_for_move (rtx op, scalar_int_mode mode) { machine_mode vmode; - gcc_assert (!VECTOR_MODE_P (mode)); vmode = aarch64_preferred_simd_mode (mode); rtx op_v = aarch64_simd_gen_const_vector_dup (vmode, INTVAL (op)); return aarch64_simd_valid_immediate (op_v, vmode, false, NULL); @@ -12940,12 +12961,10 @@ aarch64_output_simd_mov_immediate (rtx c } char* -aarch64_output_scalar_simd_mov_immediate (rtx immediate, - machine_mode mode) +aarch64_output_scalar_simd_mov_immediate (rtx immediate, scalar_int_mode mode) { machine_mode vmode; - gcc_assert (!VECTOR_MODE_P (mode)); vmode = aarch64_simd_container_mode (mode, 64); rtx v_op = aarch64_simd_gen_const_vector_dup (vmode, INTVAL (immediate)); return aarch64_output_simd_mov_immediate (v_op, vmode, 64); From patchwork Thu Jul 13 09:01:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107649 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1943298qge; Thu, 13 Jul 2017 02:03:08 -0700 (PDT) X-Received: by 10.84.134.162 with SMTP id 31mr8664530plh.170.1499936588688; Thu, 13 Jul 2017 02:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936588; cv=none; d=google.com; s=arc-20160816; b=PKY0OPmT2eP97PXI2zrOTgwkoBnqigvqGmDVlAJjhk3RrrZrtNUQuZqMF3ntJcFWTw oGFMyQcyTgubnXid11a5sMY/9N+NbOlREzcPl0JojtAyE5tqJa+NM0L6n92dUmRGogiQ B8zYomRqLwTu5nLjYWMcqMLRCmpz3Ku3remCoIZGmdT7QGT8HPmLp2vBnGMoW2kDUorR YOXD3P1SU5XYWgQNH46+2l3i04F0OfKepFgKlYTUhZ/ntrTRxyt90DYP4+74ScMc/JYu HUZdrPldieUqtiLf2WakwPOT02sM6d58M35zl3d7Lwl6HD72Uy4AprZUmcx5NvUmwO1E Vekg== 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=Nxs+N9TSVnINnGo0/ayRtCuYzCQAY8LoG/aEKl2qF80=; b=jLLID5Yffys2rzagj7K1J95bKVjOOPv9wFaZwIP9HBt4YnFaAYgdcaM4T48gad8yae hbVFHgAfE6HoIHwwYaI27y4wMuCFbiPH66L9UNmaqfTyOQdUh2cZbG+QKdZu8JPUY4zs t92EeyGxNAZOrDWu4CeGg1SgTL0EyHovzYZsFhbHbSdvz8vnN7qGhk+pSS6Q28PCgYqn eD6csHukW28DcAAPy6SOdrQH+2No3u8ME0CvuQMa547C9OIYgVCelCQvnEGF41mbivbp Y8wnduK3WB4iJewp9hVryKuV1hJgHuJ+3xHwLB16YSyJDJZuQnKgMwDlj0+t6mSUe3Ov 0Xqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=umpyoG9Q; spf=pass (google.com: domain of gcc-patches-return-458054-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458054-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 t3si3766260pfl.241.2017.07.13.02.03.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458054-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=umpyoG9Q; spf=pass (google.com: domain of gcc-patches-return-458054-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458054-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=bF3/shSg8bfnbhi0D93Vf0W6Ingt2 Y+gOzVVgCU5DX8dliNa/nnnJ4wzozGs3VMQxQD/7iNVIViqnYvU+trk+E3NQmLFA se/SLTPsiI9e9X70MOBXFh700UpffcwSiPTNS/Niy/GoRKrlR90uy+TmAyscUOz9 KoyrLmZZ6R7Vqs= 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=jYYth1x5zvJsJo3k+rfq1m4aZwY=; b=ump yoG9QcHNwpMhDX8ZpbllN851pWtJKs/VjYjKf7hZvZqLgRk2Zyn44QnGf+oB/cE4 NGMm2b1IhQxNZ2LpM1/JxvA3GVh1QYoCB2mI46cT+KKiP223T4WfspBBGle4QS06 /vxEakUyF5Eiw1wIuZoffXkpJdoUwtTWGVkjSO/0= Received: (qmail 34149 invoked by alias); 13 Jul 2017 09:01:25 -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 33155 invoked by uid 89); 13 Jul 2017 09:01:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:01:18 +0000 Received: by mail-wm0-f48.google.com with SMTP id i127so18527640wma.0 for ; Thu, 13 Jul 2017 02:01:17 -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=Nxs+N9TSVnINnGo0/ayRtCuYzCQAY8LoG/aEKl2qF80=; b=rffHbz0iwKKZ30tGhcl7M4R+gjgwikarW1MVtW23cX5pLMspMg1gKR1yKRCH1OcyNN t9zt9w7uzy3qR97ZGNq7jjRCVxVknw/rCFc2mkvDESLQ3m52prVuYBys0cEfxczppMV4 v3/Kik5Md89T1HPb7vF3738OriJaCbm5aw8TD7AyaOgTtcgsnIoI4GLpjdR2l6hWHRXl gWFnWTHLVPjY22pkIFQz9RqFStl86mK9itKEzL7F7aqsmStY/6QHfWMqw34+DDlDZJRT kWMC3NZEEnLiSP3iOp1FvJcm1udlq4hN/HNZ5FBsDDhenK7q4tjeWuzGrkKj2YTQwjhx KzsA== X-Gm-Message-State: AIVw112dARyx6iTVG2NMChGSxsFpaxSNQB3Y89qdKpXvo3RC43pu9Aj4 PP0Nu5Ciku+RamEct879gw== X-Received: by 10.28.33.66 with SMTP id h63mr1233712wmh.124.1499936475397; Thu, 13 Jul 2017 02:01:15 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id u75sm2588516wmd.1.2017.07.13.02.01.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:01:14 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [63/77] Simplifications after type switch References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:01:13 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87lgnsd82u.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes a few simplifications after the previous mechanical machine_mode->scalar_int_mode change. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expmed.c (extract_high_half): Use scalar_int_mode and remove assertion. (expmed_mult_highpart_optab): Likewise. (expmed_mult_highpart): Likewise. Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:51.649771750 +0100 +++ gcc/expmed.c 2017-07-13 09:18:52.815684419 +0100 @@ -3611,14 +3611,11 @@ expand_mult_highpart_adjust (scalar_int_ static rtx extract_high_half (scalar_int_mode mode, rtx op) { - machine_mode wider_mode; - if (mode == word_mode) return gen_highpart (mode, op); - gcc_assert (!SCALAR_FLOAT_MODE_P (mode)); + scalar_int_mode wider_mode = *GET_MODE_WIDER_MODE (mode); - wider_mode = *GET_MODE_WIDER_MODE (mode); op = expand_shift (RSHIFT_EXPR, wider_mode, op, GET_MODE_BITSIZE (mode), 0, 1); return convert_modes (mode, wider_mode, op, 0); @@ -3632,15 +3629,13 @@ expmed_mult_highpart_optab (scalar_int_m rtx target, int unsignedp, int max_cost) { rtx narrow_op1 = gen_int_mode (INTVAL (op1), mode); - machine_mode wider_mode; optab moptab; rtx tem; int size; bool speed = optimize_insn_for_speed_p (); - gcc_assert (!SCALAR_FLOAT_MODE_P (mode)); + scalar_int_mode wider_mode = *GET_MODE_WIDER_MODE (mode); - wider_mode = *GET_MODE_WIDER_MODE (mode); size = GET_MODE_BITSIZE (mode); /* Firstly, try using a multiplication insn that only generates the needed @@ -3746,7 +3741,6 @@ expmed_mult_highpart_optab (scalar_int_m expmed_mult_highpart (scalar_int_mode mode, rtx op0, rtx op1, rtx target, int unsignedp, int max_cost) { - machine_mode wider_mode = *GET_MODE_WIDER_MODE (mode); unsigned HOST_WIDE_INT cnst1; int extra_cost; bool sign_adjust = false; @@ -3755,7 +3749,6 @@ expmed_mult_highpart (scalar_int_mode mo rtx tem; bool speed = optimize_insn_for_speed_p (); - gcc_assert (!SCALAR_FLOAT_MODE_P (mode)); /* We can't support modes wider than HOST_BITS_PER_INT. */ gcc_assert (HWI_COMPUTABLE_MODE_P (mode)); @@ -3765,6 +3758,7 @@ expmed_mult_highpart (scalar_int_mode mo ??? We might be able to perform double-word arithmetic if mode == word_mode, however all the cost calculations in synth_mult etc. assume single-word operations. */ + scalar_int_mode wider_mode = *GET_MODE_WIDER_MODE (mode); if (GET_MODE_BITSIZE (wider_mode) > BITS_PER_WORD) return expmed_mult_highpart_optab (mode, op0, op1, target, unsignedp, max_cost); From patchwork Thu Jul 13 09:01:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107650 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1943600qge; Thu, 13 Jul 2017 02:03:28 -0700 (PDT) X-Received: by 10.84.167.230 with SMTP id i35mr9106146plg.181.1499936608497; Thu, 13 Jul 2017 02:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936608; cv=none; d=google.com; s=arc-20160816; b=Grt5J920RjRxu4bI6BreR6uYVxg0grjxt3CjvjQ2BZktTJMJX2X/6tQkCBPE40Ul87 F04rnIXLVc2tppxb9fTP269g/dzoKV2K5uOwZeZmMuf4OkXboRsOyymz5+sYL/hJ1B+V jtVD62iOv14lH/lP2QADrbvBRdwhj3WrazEr9aWFR+jA2LmqtJQTiBLZ18jLnX57zAks b6A/TADRecJ5VeYXWDGfdjhrdYCQZyyC0BaH0zNJB9RB28YUP1iIwmzLBSPP9/vkwiTx vyBw7ywISZ5iEJttYjqS/msbmQ/rSKlgOm455sFRbNNMAUqPSugfV+W6qmkJEfp2vd+q 3Omw== 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=RiQvM8XekMYghfpiGLosFTuPTC3FIRYFDu0piunucRA=; b=F/zL9TqxgtNLOZUGk75E1RskJ71B4Mlpwe6eBKEyHS5AFW0tp/I5oYnhJfMf4Xy9dR qAAE4TNvTQZ/BeMT4+iv9vckmwAZ2bzAbODa980+E8/TfaxXkxB2FQur8oZ3PoEl4s1V nQ09Zs6q+orCps0W/wUopq8ZxR83i9Fikt2SOasUKiseyILr5zkICeyrQJ9dhdQUf/BX PJYJeOnXqeVXxQjJCINxI7FbL6oXw9Nbs4PgihmrJculUwn1J45F7VnXogSsoTgbxlb4 T+8mUcFKhUp8BX7P8FjwxNTYkJEB/KJTFvcVM6soWTFzLHv8z4U8kFRU4g9HQMr1mbLp F3yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=uTCHSzY2; spf=pass (google.com: domain of gcc-patches-return-458055-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458055-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 1si3830277pgs.57.2017.07.13.02.03.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458055-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=uTCHSzY2; spf=pass (google.com: domain of gcc-patches-return-458055-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458055-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=cigewd3+DhKABEhs5hserazG5GS9p 5HGQ2nMUjj8Cdh75nHDWAqiPIlATwUqzYMkfnAlXw88OPbH1XD7Ycj0i6u9UM9gK JFX6mxQhsaKeS4E/+U4R9F5Y1vtkcB8H1j5VpBT/c/C1laXfFi8Iuyl7mGRhmBEM 4SuCUrI1whB3jw= 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=8Z83SqiUU2wQgpUXXYO5L3VWtME=; b=uTC HSzY2e22+XD7UcW8F8YLychy9HCEXoGp3p6MJCasaUCrUE64CoL6+k7BriXo4uus Behb6Xqu9aLb8wCOA3o/1zOpSJ9MpZ3uEvSKCe8Y3qyPuXsvGL5UWNkpK+YE3ZS5 BZ5kXSh3538z7LKoOCPN5iFAbUqHP6E4hUIyzZWs= Received: (qmail 53376 invoked by alias); 13 Jul 2017 09:01:41 -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 52078 invoked by uid 89); 13 Jul 2017 09:01:40 -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-f181.google.com Received: from mail-wr0-f181.google.com (HELO mail-wr0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:01:35 +0000 Received: by mail-wr0-f181.google.com with SMTP id 77so49791978wrb.1 for ; Thu, 13 Jul 2017 02:01:34 -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=RiQvM8XekMYghfpiGLosFTuPTC3FIRYFDu0piunucRA=; b=ipYgfT6NkTGLF4ZAQa9X4/UPeAUFU6L/+uzvYdAeH3nuHyBRDziGMwDyD8TMWOFNum EeBfJjcOHa7ROAZTdRVnuY7SLbc4vjnOHIHf2YgZIvIbRsUe7ylBeXWd1Wd8etZF4QxM wEeJue4xuKcP5dERzLXNsve/ZAmcavr/1sKzHAhmZSNLQsl2bzlsUAZl81bRBO/cqu5H 09zwfP/Tfpu0GVyXPG123JjSKPSDI+H5Zpk1uebR9CI5dzE9S0FILYgh9xzWMSEgK0ve 2Ugqu9cy5JOZRoc7OfUXEzmXFWWe53Ba3uYnUyASwsYI1HIE4C7vlpmbrmwc+9faXaVJ ZaKQ== X-Gm-Message-State: AIVw113B/mzJufpzjHfuMAdyNR4ZH4FNT4G2+k6ubUHdh8bxbL8SXUt5 aaXIeR2hkePbqxGo9U6EMA== X-Received: by 10.223.139.70 with SMTP id v6mr898728wra.97.1499936492860; Thu, 13 Jul 2017 02:01:32 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 35sm2911048wrp.63.2017.07.13.02.01.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:01:32 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [64/77] Add a scalar_mode class References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:01:30 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87h8ygd82d.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a scalar_mode class that can hold any scalar mode, specifically: - scalar integers - scalar floating-point values - scalar fractional modes - scalar accumulator modes - pointer bounds modes To start with this patch uses this type for GET_MODE_INNER. Later patches add more uses. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (scalar_mode): New class. * machmode.h (scalar_mode): Likewise. (scalar_mode::includes_p): New function. (mode_to_inner): Return a scalar_mode rather than a machine_mode. * gdbhooks.py (build_pretty_printers): Handle scalar_mode. * genmodes.c (get_mode_class): Handle remaining scalar modes. * cfgexpand.c (expand_debug_expr): Use scalar_mode. * expmed.c (store_bit_field_1): Likewise. (extract_bit_field_1): Likewise. * expr.c (write_complex_part): Likewise. (read_complex_part): Likewise. (emit_move_complex_push): Likewise. (expand_expr_real_2): Likewise. * function.c (assign_parm_setup_reg): Likewise. (assign_parms_unsplit_complex): Likewise. * optabs.c (expand_binop): Likewise. * rtlanal.c (subreg_get_info): Likewise. * simplify-rtx.c (simplify_immed_subreg): Likewise. * varasm.c (output_constant_pool_2): Likewise. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:28.587718194 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:53.271650545 +0100 @@ -55,6 +55,7 @@ typedef const struct simple_bitmap_def * struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; +class scalar_mode; class scalar_int_mode; class scalar_float_mode; template class opt_mode; @@ -317,6 +318,7 @@ #define rtx_insn struct _dont_use_rtx_in #define tree union _dont_use_tree_here_ * #define const_tree union _dont_use_tree_here_ * +typedef struct scalar_mode scalar_mode; typedef struct scalar_int_mode scalar_int_mode; typedef struct scalar_float_mode scalar_float_mode; Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:41.680558844 +0100 +++ gcc/machmode.h 2017-07-13 09:18:53.274650323 +0100 @@ -410,6 +410,47 @@ scalar_float_mode::includes_p (machine_m return SCALAR_FLOAT_MODE_P (m); } +/* Represents a machine mode that is known to be scalar. */ +class scalar_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE scalar_mode () {} + ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {} + ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {} + ALWAYS_INLINE scalar_mode (const scalar_int_mode_pod &m) : m_mode (m) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M represents some kind of scalar value. */ + +inline bool +scalar_mode::includes_p (machine_mode m) +{ + switch (GET_MODE_CLASS (m)) + { + case MODE_INT: + case MODE_PARTIAL_INT: + case MODE_FRACT: + case MODE_UFRACT: + case MODE_ACCUM: + case MODE_UACCUM: + case MODE_FLOAT: + case MODE_DECIMAL_FLOAT: + case MODE_POINTER_BOUNDS: + return true; + default: + return false; + } +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -441,14 +482,15 @@ mode_to_precision (machine_mode mode) /* Return the base GET_MODE_INNER value for MODE. */ -ALWAYS_INLINE machine_mode +ALWAYS_INLINE scalar_mode mode_to_inner (machine_mode mode) { #if GCC_VERSION >= 4001 - return (machine_mode) (__builtin_constant_p (mode) - ? mode_inner_inline (mode) : mode_inner[mode]); + return scalar_mode::from_int (__builtin_constant_p (mode) + ? mode_inner_inline (mode) + : mode_inner[mode]); #else - return (machine_mode) mode_inner[mode]; + return scalar_mode::from_int (mode_inner[mode]); #endif } Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:28.587718194 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:53.273650396 +0100 @@ -549,7 +549,7 @@ def build_pretty_printer(): 'pod_mode', MachineModePrinter) pp.add_printer_for_types(['scalar_int_mode_pod'], 'pod_mode', MachineModePrinter) - for mode in 'scalar_int_mode', 'scalar_float_mode': + for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode': pp.add_printer_for_types([mode], mode, MachineModePrinter) return pp Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:28.587718194 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:53.274650323 +0100 @@ -1141,6 +1141,13 @@ get_mode_class (struct mode_data *mode) case MODE_PARTIAL_INT: return "scalar_int_mode"; + case MODE_FRACT: + case MODE_UFRACT: + case MODE_ACCUM: + case MODE_UACCUM: + case MODE_POINTER_BOUNDS: + return "scalar_mode"; + case MODE_FLOAT: case MODE_DECIMAL_FLOAT: return "scalar_float_mode"; Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:51.574777404 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:53.271650545 +0100 @@ -4821,7 +4821,7 @@ expand_debug_expr (tree exp) GET_MODE_INNER (mode))); else { - machine_mode imode = GET_MODE_INNER (mode); + scalar_mode imode = GET_MODE_INNER (mode); rtx re, im; if (MEM_P (op0)) Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:52.815684419 +0100 +++ gcc/expmed.c 2017-07-13 09:18:53.272650471 +0100 @@ -758,16 +758,16 @@ store_bit_field_1 (rtx str_rtx, unsigned /* Use vec_set patterns for inserting parts of vectors whenever available. */ - if (VECTOR_MODE_P (GET_MODE (op0)) + machine_mode outermode = GET_MODE (op0); + scalar_mode innermode = GET_MODE_INNER (outermode); + if (VECTOR_MODE_P (outermode) && !MEM_P (op0) - && optab_handler (vec_set_optab, GET_MODE (op0)) != CODE_FOR_nothing - && fieldmode == GET_MODE_INNER (GET_MODE (op0)) - && bitsize == GET_MODE_UNIT_BITSIZE (GET_MODE (op0)) - && !(bitnum % GET_MODE_UNIT_BITSIZE (GET_MODE (op0)))) + && optab_handler (vec_set_optab, outermode) != CODE_FOR_nothing + && fieldmode == innermode + && bitsize == GET_MODE_BITSIZE (innermode) + && !(bitnum % GET_MODE_BITSIZE (innermode))) { struct expand_operand ops[3]; - machine_mode outermode = GET_MODE (op0); - machine_mode innermode = GET_MODE_INNER (outermode); enum insn_code icode = optab_handler (vec_set_optab, outermode); int pos = bitnum / GET_MODE_BITSIZE (innermode); @@ -1616,15 +1616,15 @@ extract_bit_field_1 (rtx str_rtx, unsign /* Use vec_extract patterns for extracting parts of vectors whenever available. */ - if (VECTOR_MODE_P (GET_MODE (op0)) + machine_mode outermode = GET_MODE (op0); + scalar_mode innermode = GET_MODE_INNER (outermode); + if (VECTOR_MODE_P (outermode) && !MEM_P (op0) - && optab_handler (vec_extract_optab, GET_MODE (op0)) != CODE_FOR_nothing - && ((bitnum + bitsize - 1) / GET_MODE_UNIT_BITSIZE (GET_MODE (op0)) - == bitnum / GET_MODE_UNIT_BITSIZE (GET_MODE (op0)))) + && optab_handler (vec_extract_optab, outermode) != CODE_FOR_nothing + && ((bitnum + bitsize - 1) / GET_MODE_BITSIZE (innermode) + == bitnum / GET_MODE_BITSIZE (innermode))) { struct expand_operand ops[3]; - machine_mode outermode = GET_MODE (op0); - machine_mode innermode = GET_MODE_INNER (outermode); enum insn_code icode = optab_handler (vec_extract_optab, outermode); unsigned HOST_WIDE_INT pos = bitnum / GET_MODE_BITSIZE (innermode); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:51.653771449 +0100 +++ gcc/expr.c 2017-07-13 09:18:53.273650396 +0100 @@ -3114,7 +3114,7 @@ set_storage_via_setmem (rtx object, rtx write_complex_part (rtx cplx, rtx val, bool imag_p) { machine_mode cmode; - machine_mode imode; + scalar_mode imode; unsigned ibitsize; if (GET_CODE (cplx) == CONCAT) @@ -3175,7 +3175,8 @@ write_complex_part (rtx cplx, rtx val, b rtx read_complex_part (rtx cplx, bool imag_p) { - machine_mode cmode, imode; + machine_mode cmode; + scalar_mode imode; unsigned ibitsize; if (GET_CODE (cplx) == CONCAT) @@ -3371,7 +3372,7 @@ emit_move_resolve_push (machine_mode mod rtx_insn * emit_move_complex_push (machine_mode mode, rtx x, rtx y) { - machine_mode submode = GET_MODE_INNER (mode); + scalar_mode submode = GET_MODE_INNER (mode); bool imag_first; #ifdef PUSH_ROUNDING @@ -9328,7 +9329,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b GET_MODE_INNER (GET_MODE (target)), 0); if (reg_overlap_mentioned_p (temp, op1)) { - machine_mode imode = GET_MODE_INNER (GET_MODE (target)); + scalar_mode imode = GET_MODE_INNER (GET_MODE (target)); temp = adjust_address_nv (target, imode, GET_MODE_SIZE (imode)); if (reg_overlap_mentioned_p (temp, op0)) Index: gcc/function.c =================================================================== --- gcc/function.c 2017-07-13 09:18:39.589733813 +0100 +++ gcc/function.c 2017-07-13 09:18:53.273650396 +0100 @@ -3372,8 +3372,7 @@ assign_parm_setup_reg (struct assign_par /* Mark complex types separately. */ if (GET_CODE (parmreg) == CONCAT) { - machine_mode submode - = GET_MODE_INNER (GET_MODE (parmreg)); + scalar_mode submode = GET_MODE_INNER (GET_MODE (parmreg)); int regnor = REGNO (XEXP (parmreg, 0)); int regnoi = REGNO (XEXP (parmreg, 1)); rtx stackr = adjust_address_nv (data->stack_parm, submode, 0); @@ -3510,7 +3509,7 @@ assign_parms_unsplit_complex (struct ass && targetm.calls.split_complex_arg (TREE_TYPE (parm))) { rtx tmp, real, imag; - machine_mode inner = GET_MODE_INNER (DECL_MODE (parm)); + scalar_mode inner = GET_MODE_INNER (DECL_MODE (parm)); real = DECL_RTL (fnargs[i]); imag = DECL_RTL (fnargs[i + 1]); Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:51.661770846 +0100 +++ gcc/optabs.c 2017-07-13 09:18:53.274650323 +0100 @@ -1229,7 +1229,7 @@ expand_binop (machine_mode mode, optab b { /* The scalar may have been extended to be too wide. Truncate it back to the proper size to fit in the broadcast vector. */ - machine_mode inner_mode = GET_MODE_INNER (mode); + scalar_mode inner_mode = GET_MODE_INNER (mode); if (!CONST_INT_P (op1) && (GET_MODE_BITSIZE (as_a (GET_MODE (op1))) > GET_MODE_BITSIZE (inner_mode))) Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:51.664770620 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:53.275650248 +0100 @@ -3645,7 +3645,7 @@ subreg_get_info (unsigned int xregno, ma { nregs_xmode = HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode); unsigned int nunits = GET_MODE_NUNITS (xmode); - machine_mode xmode_unit = GET_MODE_INNER (xmode); + scalar_mode xmode_unit = GET_MODE_INNER (xmode); gcc_assert (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode_unit)); gcc_assert (nregs_xmode == (nunits Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:48.356023575 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:53.276650175 +0100 @@ -5719,7 +5719,7 @@ simplify_immed_subreg (machine_mode oute rtx result_s = NULL; rtvec result_v = NULL; enum mode_class outer_class; - machine_mode outer_submode; + scalar_mode outer_submode; int max_bitsize; /* Some ports misuse CCmode. */ Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-07-13 09:18:38.669811945 +0100 +++ gcc/varasm.c 2017-07-13 09:18:53.276650175 +0100 @@ -3852,7 +3852,7 @@ output_constant_pool_2 (machine_mode mod case MODE_VECTOR_UACCUM: { int i, units; - machine_mode submode = GET_MODE_INNER (mode); + scalar_mode submode = GET_MODE_INNER (mode); unsigned int subalign = MIN (align, GET_MODE_BITSIZE (submode)); gcc_assert (GET_CODE (x) == CONST_VECTOR); From patchwork Thu Jul 13 09:01: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: 107651 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1944132qge; Thu, 13 Jul 2017 02:04:01 -0700 (PDT) X-Received: by 10.98.83.130 with SMTP id h124mr34537405pfb.13.1499936641485; Thu, 13 Jul 2017 02:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936641; cv=none; d=google.com; s=arc-20160816; b=Pf79/mdcQm1VKXOZsJ7vVV9xebFJVZHpRm5N9ciF/eOYmosJ01ExMQbQeLHLjA1RGi 0tcayH2xa5HLbctdHVeOsvGT3IvUeprxOh++4Q72XQrzwAWZlqv3MqbxE880fijE6Gw2 BnapyvvaJA/ZPZWBMO3bPVw+xsPOz82cCfS7AKjmGg7ex0aXb6/u8m9AYdOoaq9P6HU9 mZdky7O7OWiRI5TRedPWHWsd3r8DwG/bYoKaHM1nZpYWG21Jl1rHLWySqp5oNtaM9Veg iClLnjlkprpBYdn4on7j5AhvXgiWBHgoF+zI6DW/NQ4XpzyqNVvm+5sQeazjYpvbd0bN N48w== 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=XqMB/bf04V1VdmG+vjJvPZ76BW12Px+8FJr/paxQ1Fk=; b=skqVOPC2aLqqtuAiDmLdvboJos3yAbPXt3qXZhq+SIMXbDSsX5VjUKZlYw1JXnEeKQ SNM9IuZaFelCjjcOz+O71fVPopdFuvYbEonr3gcb9P9f0bUdnBLI25xqxJQRmI8ZgRi4 tR8HA5paM+ZNykoAFwGBsfzcuzF6J45+F3/Kwva0Bt2BHrMj8Q0o7DVKR+XPQlkt7FQA Zk+f8pLLbOBmLma84rN6rcadppPlGGeSe7tJgO75V/gHpj3f0zbNsSEhNr3i0ADupv6Z 2SFuJiCo3CYU2lRvBf3g5cscYWtEpHUp2o8FdVk7kevdAVGd6TvXGl3GYeFwhT55Eoe6 6saQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=axrVflry; spf=pass (google.com: domain of gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458056-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 3si1354838plt.599.2017.07.13.02.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458056-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=axrVflry; spf=pass (google.com: domain of gcc-patches-return-458056-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458056-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=BvCqXQ0CGIRXM0Lh2ZtQIlwhNIi+b NmGhAaHWSWJ1AA5J+sFbjhK6DiBWLlYOZyz7XAX6xqmpBbLmZNfsAYYDCwE+9qXo 4uObn+fJyYVZq/FUbHv/n5tP7fKiB56yHgAm1OoONO7J5dNcOBW+LgyFfAvf4nxk BBIfu9KTHFSNOU= 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=PqEpRRUd989XGc8edf9Z/fkSYtM=; b=axr Vflryneu1HndIR3x06DkIhWwtISE5rywEx+bHpLD28QNCNVAlgWyruQDLU7V3OiI L+jGOpPlszrEii+AZs34Os/O8G4rffbHa+02VI1OBLrm2LyZCJgg2Svr5Ok8/2v9 gjwqHtc5z8WIiD9vNytFRJaf0qV2Q3cn/RBOPSyo= Received: (qmail 95471 invoked by alias); 13 Jul 2017 09:02:15 -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 94333 invoked by uid 89); 13 Jul 2017 09:02:14 -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-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:01:52 +0000 Received: by mail-wm0-f51.google.com with SMTP id 62so16928697wmw.1 for ; Thu, 13 Jul 2017 02:01: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=XqMB/bf04V1VdmG+vjJvPZ76BW12Px+8FJr/paxQ1Fk=; b=H1naDpGFxAxjlrb9QrloT/+eXJPZUY6cCUdu0FEdXaq7WxEZTOjCN+OYuv5ec3JxSL YQ+w4PFqIDm5KAlOBZU15nnxEZ8lN+4qyTPFDkK8/6s9ZxBhhkUN1it2T6j/Ahahg8jo sp/FaikeJvJJ46u/GZj6OLha+93OsZCrt4UVyDUI0I13wc5AWZNuKAfswAyoHS+XAi8h 9Xm5vgnhWL70XdDEucZdZq2E/Vqf+eBGMX8fPu/HmF2v8+t99VzNmLLT/8m/ITA1iJnb Ll4knIkpyuc6RRxH7IbFYjfO0XV1PAURnjKw18Jn2tsyGvybZjcH7zu/7Xvr/nPyAegv uHOg== X-Gm-Message-State: AIVw1107S9mMS/8Lx0w1n7y5EhKwbFIx5tO5NH6LE4NlBAyWM6zmUzmY 5ZdtlrEYiEX0yxX6DieBDA== X-Received: by 10.28.232.133 with SMTP id f5mr1282240wmi.46.1499936509835; Thu, 13 Jul 2017 02:01:49 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b83sm3061374wmh.30.2017.07.13.02.01.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:01: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: [65/77] Add a SCALAR_TYPE_MODE macro References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:01:47 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87d194d81w.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a SCALAR_TYPE_MODE macro, along the same lines as SCALAR_INT_TYPE_MODE and SCALAR_FLOAT_TYPE_MODE. It also adds two instances of as_a to c_common_type, when converting an unsigned fixed-point SCALAR_TYPE_MODE to the equivalent signed mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (SCALAR_TYPE_MODE): New macro. * expr.c (expand_expr_addr_expr_1): Use it. (expand_expr_real_2): Likewise. * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise. (fold_convert_const_fixed_from_int): Likewise. (fold_convert_const_fixed_from_real): Likewise. (native_encode_fixed): Likewise (native_encode_complex): Likewise (native_encode_vector): Likewise. (native_interpret_fixed): Likewise. (native_interpret_real): Likewise. (native_interpret_complex): Likewise. (native_interpret_vector): Likewise. * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise. (simd_clone_adjust_argument_types): Likewise. (simd_clone_init_simd_arrays): Likewise. (simd_clone_adjust): Likewise. * stor-layout.c (layout_type): Likewise. * tree.c (build_minus_one_cst): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. (check_bool_pattern): Likewise. (adjust_bool_pattern): Likewise. (search_type_for_mask_1): Likewise. * tree-vect-slp.c (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. * ubsan.c (ubsan_encode_value): Likewise. * varasm.c (output_constant): Likewise. gcc/c-family/ * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE. * c-common.c (c_build_vec_perm_expr): Likewise. gcc/c/ * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE. (c_common_type): Likewise. Use as_a when setting m1 and m2 to the signed equivalent of a fixed-point SCALAR_TYPE_MODE. gcc/cp/ * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-07-13 09:18:38.668812030 +0100 +++ gcc/tree.h 2017-07-13 09:18:54.005596227 +0100 @@ -1852,6 +1852,8 @@ #define TYPE_MODE_RAW(NODE) (TYPE_CHECK #define TYPE_MODE(NODE) \ (VECTOR_TYPE_P (TYPE_CHECK (NODE)) \ ? vector_type_mode (NODE) : (NODE)->type_common.mode) +#define SCALAR_TYPE_MODE(NODE) \ + (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_INT_TYPE_MODE(NODE) \ (as_a (TYPE_CHECK (NODE)->type_common.mode)) #define SCALAR_FLOAT_TYPE_MODE(NODE) \ Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:53.273650396 +0100 +++ gcc/expr.c 2017-07-13 09:18:53.997596816 +0100 @@ -7758,7 +7758,7 @@ expand_expr_addr_expr_1 (tree exp, rtx t The expression is therefore always offset by the size of the scalar type. */ offset = 0; - bitpos = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp))); + bitpos = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (exp))); inner = TREE_OPERAND (exp, 0); break; @@ -9436,7 +9436,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b { tree sel_type = TREE_TYPE (treeop2); machine_mode vmode - = mode_for_vector (TYPE_MODE (TREE_TYPE (sel_type)), + = mode_for_vector (SCALAR_TYPE_MODE (TREE_TYPE (sel_type)), TYPE_VECTOR_SUBPARTS (sel_type)); gcc_assert (GET_MODE_CLASS (vmode) == MODE_VECTOR_INT); op2 = simplify_subreg (vmode, op2, TYPE_MODE (sel_type), 0); Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-07-13 09:18:51.658771072 +0100 +++ gcc/fold-const.c 2017-07-13 09:18:53.998596742 +0100 @@ -2058,8 +2058,8 @@ fold_convert_const_fixed_from_fixed (tre tree t; bool overflow_p; - overflow_p = fixed_convert (&value, TYPE_MODE (type), &TREE_FIXED_CST (arg1), - TYPE_SATURATING (type)); + overflow_p = fixed_convert (&value, SCALAR_TYPE_MODE (type), + &TREE_FIXED_CST (arg1), TYPE_SATURATING (type)); t = build_fixed (type, value); /* Propagate overflow flags. */ @@ -2087,7 +2087,7 @@ fold_convert_const_fixed_from_int (tree else di.high = TREE_INT_CST_ELT (arg1, 1); - overflow_p = fixed_convert_from_int (&value, TYPE_MODE (type), di, + overflow_p = fixed_convert_from_int (&value, SCALAR_TYPE_MODE (type), di, TYPE_UNSIGNED (TREE_TYPE (arg1)), TYPE_SATURATING (type)); t = build_fixed (type, value); @@ -2108,7 +2108,7 @@ fold_convert_const_fixed_from_real (tree tree t; bool overflow_p; - overflow_p = fixed_convert_from_real (&value, TYPE_MODE (type), + overflow_p = fixed_convert_from_real (&value, SCALAR_TYPE_MODE (type), &TREE_REAL_CST (arg1), TYPE_SATURATING (type)); t = build_fixed (type, value); @@ -7115,7 +7115,7 @@ native_encode_int (const_tree expr, unsi native_encode_fixed (const_tree expr, unsigned char *ptr, int len, int off) { tree type = TREE_TYPE (expr); - machine_mode mode = TYPE_MODE (type); + scalar_mode mode = SCALAR_TYPE_MODE (type); int total_bytes = GET_MODE_SIZE (mode); FIXED_VALUE_TYPE value; tree i_value, i_type; @@ -7217,7 +7217,7 @@ native_encode_complex (const_tree expr, return 0; part = TREE_IMAGPART (expr); if (off != -1) - off = MAX (0, off - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (part)))); + off = MAX (0, off - GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE (part)))); isize = native_encode_expr (part, ptr+rsize, len-rsize, off); if (off == -1 && isize != rsize) @@ -7241,7 +7241,7 @@ native_encode_vector (const_tree expr, u offset = 0; count = VECTOR_CST_NELTS (expr); itype = TREE_TYPE (TREE_TYPE (expr)); - size = GET_MODE_SIZE (TYPE_MODE (itype)); + size = GET_MODE_SIZE (SCALAR_TYPE_MODE (itype)); for (i = 0; i < count; i++) { if (off >= size) @@ -7369,7 +7369,8 @@ native_interpret_int (tree type, const u static tree native_interpret_fixed (tree type, const unsigned char *ptr, int len) { - int total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); + scalar_mode mode = SCALAR_TYPE_MODE (type); + int total_bytes = GET_MODE_SIZE (mode); double_int result; FIXED_VALUE_TYPE fixed_value; @@ -7378,7 +7379,7 @@ native_interpret_fixed (tree type, const return NULL_TREE; result = double_int::from_buffer (ptr, total_bytes); - fixed_value = fixed_from_double_int (result, TYPE_MODE (type)); + fixed_value = fixed_from_double_int (result, mode); return build_fixed (type, fixed_value); } @@ -7400,7 +7401,6 @@ native_interpret_real (tree type, const REAL_VALUE_TYPE r; long tmp[6]; - total_bytes = GET_MODE_SIZE (TYPE_MODE (type)); if (total_bytes > len || total_bytes > 24) return NULL_TREE; int words = (32 / BITS_PER_UNIT) / UNITS_PER_WORD; @@ -7455,7 +7455,7 @@ native_interpret_complex (tree type, con int size; etype = TREE_TYPE (type); - size = GET_MODE_SIZE (TYPE_MODE (etype)); + size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype)); if (size * 2 > len) return NULL_TREE; rpart = native_interpret_expr (etype, ptr, size); @@ -7480,7 +7480,7 @@ native_interpret_vector (tree type, cons tree *elements; etype = TREE_TYPE (type); - size = GET_MODE_SIZE (TYPE_MODE (etype)); + size = GET_MODE_SIZE (SCALAR_TYPE_MODE (etype)); count = TYPE_VECTOR_SUBPARTS (type); if (size * count > len) return NULL_TREE; Index: gcc/omp-simd-clone.c =================================================================== --- gcc/omp-simd-clone.c 2017-06-30 12:50:38.645644151 +0100 +++ gcc/omp-simd-clone.c 2017-07-13 09:18:53.998596742 +0100 @@ -495,7 +495,7 @@ simd_clone_adjust_return_type (struct cg veclen = node->simdclone->vecsize_int; else veclen = node->simdclone->vecsize_float; - veclen /= GET_MODE_BITSIZE (TYPE_MODE (t)); + veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (t)); if (veclen > node->simdclone->simdlen) veclen = node->simdclone->simdlen; if (POINTER_TYPE_P (t)) @@ -605,7 +605,7 @@ simd_clone_adjust_argument_types (struct veclen = sc->vecsize_int; else veclen = sc->vecsize_float; - veclen /= GET_MODE_BITSIZE (TYPE_MODE (parm_type)); + veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (parm_type)); if (veclen > sc->simdlen) veclen = sc->simdlen; adj.arg_prefix = "simd"; @@ -649,7 +649,7 @@ simd_clone_adjust_argument_types (struct veclen = sc->vecsize_int; else veclen = sc->vecsize_float; - veclen /= GET_MODE_BITSIZE (TYPE_MODE (base_type)); + veclen /= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (base_type)); if (veclen > sc->simdlen) veclen = sc->simdlen; if (sc->mask_mode != VOIDmode) @@ -791,8 +791,8 @@ simd_clone_init_simd_arrays (struct cgra arg = DECL_CHAIN (arg); j++; } - elemsize - = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (arg)))); + tree elemtype = TREE_TYPE (TREE_TYPE (arg)); + elemsize = GET_MODE_SIZE (SCALAR_TYPE_MODE (elemtype)); tree t = build2 (MEM_REF, TREE_TYPE (arg), ptr, build_int_cst (ptype, k * elemsize)); t = build2 (MODIFY_EXPR, TREE_TYPE (t), t, arg); @@ -1225,7 +1225,7 @@ simd_clone_adjust (struct cgraph_node *n mask_array, iter1, NULL, NULL); g = gimple_build_assign (mask, aref); gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING); - int bitsize = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (aref))); + int bitsize = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (aref))); if (!INTEGRAL_TYPE_P (TREE_TYPE (aref))) { aref = build1 (VIEW_CONVERT_EXPR, Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:51.664770620 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:53.998596742 +0100 @@ -2155,10 +2155,13 @@ layout_type (tree type) } case FIXED_POINT_TYPE: - /* TYPE_MODE (type) has been set already. */ - TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); - break; + { + /* TYPE_MODE (type) has been set already. */ + scalar_mode mode = SCALAR_TYPE_MODE (type); + TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode)); + TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode)); + break; + } case COMPLEX_TYPE: TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type)); @@ -2179,7 +2182,8 @@ layout_type (tree type) /* Find an appropriate mode for the vector type. */ if (TYPE_MODE (type) == VOIDmode) SET_TYPE_MODE (type, - mode_for_vector (TYPE_MODE (innertype), nunits)); + mode_for_vector (SCALAR_TYPE_MODE (innertype), + nunits)); TYPE_SATURATING (type) = TYPE_SATURATING (TREE_TYPE (type)); TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TREE_TYPE (type)); Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-07-13 09:18:39.596733221 +0100 +++ gcc/tree.c 2017-07-13 09:18:54.004596300 +0100 @@ -2128,8 +2128,9 @@ build_minus_one_cst (tree type) case FIXED_POINT_TYPE: /* We can only generate 1 for accum types. */ gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); - return build_fixed (type, fixed_from_double_int (double_int_minus_one, - TYPE_MODE (type))); + return build_fixed (type, + fixed_from_double_int (double_int_minus_one, + SCALAR_TYPE_MODE (type))); case VECTOR_TYPE: { Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c 2017-07-13 09:18:38.664812372 +0100 +++ gcc/tree-cfg.c 2017-07-13 09:18:53.999596668 +0100 @@ -4190,7 +4190,7 @@ verify_gimple_assign_ternary (gassign *s if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE || GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs3_type))) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1_type)))) + != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (rhs1_type)))) { error ("invalid mask type in vector permute expression"); debug_generic_expr (lhs_type); Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c 2017-07-02 09:32:32.660745273 +0100 +++ gcc/tree-inline.c 2017-07-13 09:18:54.000596593 +0100 @@ -3871,7 +3871,7 @@ estimate_move_cost (tree type, bool ARG_ if (TREE_CODE (type) == VECTOR_TYPE) { - machine_mode inner = TYPE_MODE (TREE_TYPE (type)); + scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (type)); machine_mode simd = targetm.vectorize.preferred_simd_mode (inner); int simd_mode_size = GET_MODE_SIZE (simd); Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-07-13 09:18:38.664812372 +0100 +++ gcc/tree-ssa-math-opts.c 2017-07-13 09:18:54.000596593 +0100 @@ -3227,7 +3227,8 @@ convert_plusminus_to_widen (gimple_stmt_ optab this_optab; enum tree_code wmult_code; enum insn_code handler; - machine_mode to_mode, from_mode, actual_mode; + scalar_mode to_mode, from_mode; + machine_mode actual_mode; location_t loc = gimple_location (stmt); int actual_precision; bool from_unsigned1, from_unsigned2; @@ -3323,8 +3324,8 @@ convert_plusminus_to_widen (gimple_stmt_ else return false; - to_mode = TYPE_MODE (type); - from_mode = TYPE_MODE (type1); + to_mode = SCALAR_TYPE_MODE (type); + from_mode = SCALAR_TYPE_MODE (type1); from_unsigned1 = TYPE_UNSIGNED (type1); from_unsigned2 = TYPE_UNSIGNED (type2); optype = type1; Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-07-13 09:17:19.693324483 +0100 +++ gcc/tree-vect-loop.c 2017-07-13 09:18:54.001596521 +0100 @@ -4745,7 +4745,8 @@ vect_create_epilog_for_reduction (vec TYPE_PRECISION (half_type0) * 2) itype = build_nonstandard_integer_type - (GET_MODE_BITSIZE (TYPE_MODE (half_type0)) * 2, - TYPE_UNSIGNED (type)); + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (half_type0)) * 2, + TYPE_UNSIGNED (type)); /* Pattern detected. */ if (dump_enabled_p ()) @@ -3083,7 +3083,7 @@ vect_recog_mixed_size_cond_pattern (vec< TYPE_UNSIGNED (type)); if (itype == NULL_TREE - || GET_MODE_BITSIZE (TYPE_MODE (itype)) != cmp_mode_size) + || GET_MODE_BITSIZE (SCALAR_TYPE_MODE (itype)) != cmp_mode_size) return NULL; vecitype = get_vectype_for_scalar_type (itype); @@ -3200,7 +3200,7 @@ check_bool_pattern (tree var, vec_info * if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE) { - machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); + scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1)); tree itype = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1); vecitype = get_vectype_for_scalar_type (itype); @@ -3322,7 +3322,7 @@ adjust_bool_pattern (tree var, tree out_ irhs1 = *defs.get (rhs1); tree def_rhs1 = gimple_assign_rhs1 (def_stmt); if (TYPE_PRECISION (TREE_TYPE (irhs1)) - == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (def_rhs1)))) + == GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (def_rhs1)))) { rhs_code = def_rhs_code; rhs1 = def_rhs1; @@ -3341,7 +3341,7 @@ adjust_bool_pattern (tree var, tree out_ irhs2 = *defs.get (rhs2); tree def_rhs1 = gimple_assign_rhs1 (def_stmt); if (TYPE_PRECISION (TREE_TYPE (irhs2)) - == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (def_rhs1)))) + == GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (def_rhs1)))) { rhs_code = def_rhs_code; rhs1 = def_rhs1; @@ -3391,7 +3391,7 @@ adjust_bool_pattern (tree var, tree out_ || (TYPE_PRECISION (TREE_TYPE (rhs1)) != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1))))) { - machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); + scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1)); itype = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1); } @@ -3544,7 +3544,7 @@ search_type_for_mask_1 (tree var, vec_in if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE || !TYPE_UNSIGNED (TREE_TYPE (rhs1))) { - machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); + scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1)); res = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1); } else Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2017-07-13 09:18:30.088577124 +0100 +++ gcc/tree-vect-slp.c 2017-07-13 09:18:54.002596447 +0100 @@ -3685,7 +3685,7 @@ vect_schedule_slp_instance (slp_tree nod v1 = SLP_TREE_VEC_STMTS (node).copy (); SLP_TREE_VEC_STMTS (node).truncate (0); tree meltype = build_nonstandard_integer_type - (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vectype))), 1); + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (vectype))), 1); tree mvectype = get_same_sized_vectype (meltype, vectype); unsigned k = 0, l; for (j = 0; j < v0.length (); ++j) Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-13 09:18:30.090576938 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:54.003596374 +0100 @@ -4051,7 +4051,6 @@ vectorizable_conversion (gimple *stmt, g vec interm_types = vNULL; tree last_oprnd, intermediate_type, cvt_type = NULL_TREE; int op_type; - machine_mode rhs_mode; unsigned short fltsz; /* Is STMT a vectorizable conversion? */ @@ -4196,6 +4195,9 @@ vectorizable_conversion (gimple *stmt, g needs to be generated. */ gcc_assert (ncopies >= 1); + machine_mode lhs_mode = SCALAR_TYPE_MODE (lhs_type); + machine_mode rhs_mode = SCALAR_TYPE_MODE (rhs_type); + /* Supportable by target? */ switch (modifier) { @@ -4224,12 +4226,11 @@ vectorizable_conversion (gimple *stmt, g } if (code != FLOAT_EXPR - || (GET_MODE_SIZE (TYPE_MODE (lhs_type)) - <= GET_MODE_SIZE (TYPE_MODE (rhs_type)))) + || GET_MODE_SIZE (lhs_mode) <= GET_MODE_SIZE (rhs_mode)) goto unsupported; - fltsz = GET_MODE_SIZE (TYPE_MODE (lhs_type)); - FOR_EACH_2XWIDER_MODE (rhs_mode, TYPE_MODE (rhs_type)) + fltsz = GET_MODE_SIZE (lhs_mode); + FOR_EACH_2XWIDER_MODE (rhs_mode, rhs_mode) { if (GET_MODE_SIZE (rhs_mode) > fltsz) break; @@ -4281,11 +4282,9 @@ vectorizable_conversion (gimple *stmt, g break; if (code != FIX_TRUNC_EXPR - || (GET_MODE_SIZE (TYPE_MODE (lhs_type)) - >= GET_MODE_SIZE (TYPE_MODE (rhs_type)))) + || GET_MODE_SIZE (lhs_mode) >= GET_MODE_SIZE (rhs_mode)) goto unsupported; - rhs_mode = TYPE_MODE (rhs_type); cvt_type = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), 0); cvt_type = get_same_sized_vectype (cvt_type, vectype_in); Index: gcc/ubsan.c =================================================================== --- gcc/ubsan.c 2017-07-13 09:18:38.668812030 +0100 +++ gcc/ubsan.c 2017-07-13 09:18:54.005596227 +0100 @@ -120,7 +120,8 @@ decl_for_type_insert (tree type, tree de ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase) { tree type = TREE_TYPE (t); - const unsigned int bitsize = GET_MODE_BITSIZE (TYPE_MODE (type)); + scalar_mode mode = SCALAR_TYPE_MODE (type); + const unsigned int bitsize = GET_MODE_BITSIZE (mode); if (bitsize <= POINTER_SIZE) switch (TREE_CODE (type)) { @@ -157,10 +158,8 @@ ubsan_encode_value (tree t, enum ubsan_e } if (phase == UBSAN_ENCODE_VALUE_RTL) { - rtx mem - = assign_stack_temp_for_type (TYPE_MODE (type), - GET_MODE_SIZE (TYPE_MODE (type)), - type); + rtx mem = assign_stack_temp_for_type (mode, GET_MODE_SIZE (mode), + type); SET_DECL_RTL (var, mem); expand_assignment (var, t, false); return build_fold_addr_expr (var); Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-07-13 09:18:53.276650175 +0100 +++ gcc/varasm.c 2017-07-13 09:18:54.006596154 +0100 @@ -4837,7 +4837,7 @@ output_constant (tree exp, unsigned HOST break; case VECTOR_CST: { - machine_mode inner = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp))); + scalar_mode inner = SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (exp))); unsigned int nalign = MIN (align, GET_MODE_ALIGNMENT (inner)); int elt_size = GET_MODE_SIZE (inner); output_constant (VECTOR_CST_ELT (exp, 0), elt_size, align, Index: gcc/c-family/c-lex.c =================================================================== --- gcc/c-family/c-lex.c 2017-02-23 19:54:03.000000000 +0000 +++ gcc/c-family/c-lex.c 2017-07-13 09:18:53.993597112 +0100 @@ -1109,7 +1109,7 @@ interpret_fixed (const cpp_token *token, memcpy (copy, token->val.str.text, copylen); copy[copylen] = '\0'; - fixed_from_string (&fixed, copy, TYPE_MODE (type)); + fixed_from_string (&fixed, copy, SCALAR_TYPE_MODE (type)); /* Create a node with determined type and value. */ value = build_fixed (type, fixed); Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2017-07-13 09:18:39.582734406 +0100 +++ gcc/c-family/c-common.c 2017-07-13 09:18:53.993597112 +0100 @@ -1031,8 +1031,8 @@ c_build_vec_perm_expr (location_t loc, t return error_mark_node; } - if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0)))) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (mask))))) + if (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (v0)))) + != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (mask))))) { if (complain) error_at (loc, "__builtin_shuffle argument vector(s) inner type " Index: gcc/c/c-typeck.c =================================================================== --- gcc/c/c-typeck.c 2017-06-16 07:48:59.558141760 +0100 +++ gcc/c/c-typeck.c 2017-07-13 09:18:53.995596964 +0100 @@ -810,11 +810,11 @@ c_common_type (tree t1, tree t2) if (code1 == FIXED_POINT_TYPE || code2 == FIXED_POINT_TYPE) { unsigned int unsignedp = 0, satp = 0; - machine_mode m1, m2; + scalar_mode m1, m2; unsigned int fbit1, ibit1, fbit2, ibit2, max_fbit, max_ibit; - m1 = TYPE_MODE (t1); - m2 = TYPE_MODE (t2); + m1 = SCALAR_TYPE_MODE (t1); + m2 = SCALAR_TYPE_MODE (t2); /* If one input type is saturating, the result type is saturating. */ if (TYPE_SATURATING (t1) || TYPE_SATURATING (t2)) @@ -846,7 +846,8 @@ c_common_type (tree t1, tree t2) mclass = MODE_ACCUM; else gcc_unreachable (); - m1 = mode_for_size (GET_MODE_PRECISION (m1), mclass, 0); + m1 = as_a + (mode_for_size (GET_MODE_PRECISION (m1), mclass, 0)); } if (code2 == FIXED_POINT_TYPE && TYPE_UNSIGNED (t2)) { @@ -857,7 +858,8 @@ c_common_type (tree t1, tree t2) mclass = MODE_ACCUM; else gcc_unreachable (); - m2 = mode_for_size (GET_MODE_PRECISION (m2), mclass, 0); + m2 = as_a + (mode_for_size (GET_MODE_PRECISION (m2), mclass, 0)); } } @@ -11306,7 +11308,8 @@ build_binary_op (location_t location, en /* Always construct signed integer vector type. */ intt = c_common_type_for_size (GET_MODE_BITSIZE - (TYPE_MODE (TREE_TYPE (type0))), 0); + (SCALAR_TYPE_MODE + (TREE_TYPE (type0))), 0); result_type = build_opaque_vector_type (intt, TYPE_VECTOR_SUBPARTS (type0)); converted = 1; @@ -11465,7 +11468,8 @@ build_binary_op (location_t location, en /* Always construct signed integer vector type. */ intt = c_common_type_for_size (GET_MODE_BITSIZE - (TYPE_MODE (TREE_TYPE (type0))), 0); + (SCALAR_TYPE_MODE + (TREE_TYPE (type0))), 0); result_type = build_opaque_vector_type (intt, TYPE_VECTOR_SUBPARTS (type0)); converted = 1; Index: gcc/cp/typeck.c =================================================================== --- gcc/cp/typeck.c 2017-06-30 12:50:38.117668481 +0100 +++ gcc/cp/typeck.c 2017-07-13 09:18:53.996596890 +0100 @@ -4950,8 +4950,8 @@ cp_build_binary_op (location_t location, } /* Always construct signed integer vector type. */ - intt = c_common_type_for_size (GET_MODE_BITSIZE - (TYPE_MODE (TREE_TYPE (type0))), 0); + intt = c_common_type_for_size + (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (type0))), 0); if (!intt) { if (complain & tf_error) From patchwork Thu Jul 13 09:02:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107652 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1944358qge; Thu, 13 Jul 2017 02:04:17 -0700 (PDT) X-Received: by 10.84.133.38 with SMTP id 35mr8889438plf.141.1499936656802; Thu, 13 Jul 2017 02:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936656; cv=none; d=google.com; s=arc-20160816; b=EvwzBvIotNvaYh/wix3J45qlNHhNwRshnqIs0tiKLrNjUTWqYSYy2A23tQShRTRGoL Rl8J6J0s9P0fX7oackK1uON2ZNEuvk8f6nSCvEL7OyJw3Io/dGTpVE/Kgm8aaA0V54t5 zKThZhODqzduyrAI4ZNL9ei/RNBngcze+p1wC4yiV/LtOSh/G/C8daHnsGkIVgBRgw6F KdDfMU7zMdzirV5Xxhn/icnTKU4/xtmxCrZXrMoPAQRqc9INO5+X2oMfZtdbI6qiANtG prSG7rlSpq5LlgRpa0bZSUBFsrPrVcwOy+Dz8RXuBkjNvvF7cSH0qH0qy7bOxsUlI6CU vNKg== 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=CRFdFxjIMkjbwvn0pQINXDnxVgrg0G62ZCclN89c2oc=; b=lTVgrrkvbgqFlTP518OZabIiNUEQB1BdTL9hlIRwXmjgofOUs16r5Vc/8v+9Bj+M46 mceCdVdexLZ90obJX/n/RlLCpfw3y0Dl8L47X7lywbBVYdOLH3W1macKCd8Xtc5xraJg y6mkuPl1Bh5cIUjZ8KMvdjo4hBQYcXO5B2sV7vU5ealwB0UogUB4j8+Qm3KbdjR1uqrF /BsSju4hd2ivBt8E+5F1eCSjWCHdFgtA1Fem/JtZFrDDoe4E8eKMo6mtmadqibY9hvRm 4s2wo68w8M6lKGzIZPtmkjPQrSgIvkBAKDvLGO9jM6wvArkzIM351VwCRoX6Fubayv9V u3DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=llBBS3Yj; spf=pass (google.com: domain of gcc-patches-return-458057-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458057-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 e39si3856426plg.499.2017.07.13.02.04.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458057-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=llBBS3Yj; spf=pass (google.com: domain of gcc-patches-return-458057-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458057-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=ZrypCVjs0nX8cik7RcaiPKE06L50A P4wvp2XWj0ZdyZ8ri5JCxei+PFix5l305NiNa8Dxon78oO+AckGQixiLR80aisy3 VgeTmQhByGpvBeewaa+VMBKqqB1tTrmlsTGCQkLfudgX9Kth5/PWRGnLtnxvdP2C 9R1CmDO02QddWo= 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=SQmT86BL6rMU9IkWVR46SU3r95s=; b=llB BS3YjjJKYc4jAfjm6pub5pT4NA3MwfRXHn2htyAnANq9v6uP59tgBAVuQ8yFiQut uxnJHaewTblnpxUBppMKjHtbIs84O1SinBH8Zuw03PF5u/nyBYmxoNp0pVWj4QZy EBSAd6MXBCOAvP8LvzOjMUTmO4iBqy2uYrzKRn+c= Received: (qmail 97611 invoked by alias); 13 Jul 2017 09:02:17 -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 96909 invoked by uid 89); 13 Jul 2017 09:02:16 -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=plenty, fitted 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 09:02:12 +0000 Received: by mail-wr0-f180.google.com with SMTP id k67so49520631wrc.2 for ; Thu, 13 Jul 2017 02:02:10 -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=CRFdFxjIMkjbwvn0pQINXDnxVgrg0G62ZCclN89c2oc=; b=rc+xgF/Svk88V9BWVdGOzq/PP0qyGCKccsRUE/fcLKt7rGvX3CbunmzGukjNHGAVjc AFPLoDAAgDV1OQf8GX6Czi6Xqua2CLxwrEBmTKutix7e49rVvqSmTLLAmQyEBlqFacS5 EhYt7iYaOTx2oF3dR4cY7XNOPsY8ykZYynSkME3IM2NLIW5mPl5MA7Of80Mb0DK/apuC zwRVP3jZcGg7iz50oKYvvd5FS2xEMM5gI4zcqN/1Cg0fX0dj7dQpPVQqifo6qdPUhKbj 5+D5oLOjrSscxUynApMve2uw3EMNcE6+CyrYjNxJoXZrLjDu2xb4vFmI4q/sS1vlFrhh f7pQ== X-Gm-Message-State: AIVw111bYV9JXzXZ7tIayEKdT5Z56URIGGR24jo1bjTx11Kt3YVzR9uB gfZn0RseJgwixx5O/+ATrw== X-Received: by 10.223.149.99 with SMTP id 90mr970713wrs.46.1499936528500; Thu, 13 Jul 2017 02:02:08 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id y76sm1590010wmh.2.2017.07.13.02.02.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:02:07 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [66/77] Use scalar_mode for constant integers References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:02:05 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <878tjsd81e.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch treats the mode associated with an integer constant as a scalar_mode. We can't use the more natural-sounding scalar_int_mode because we also use (const_int 0) for bounds-checking modes. (It might be worth adding a bounds-specific code instead, but that's for another day.) This exposes a latent bug in simplify_immed_subreg, which for vectors of CONST_WIDE_INTs would pass the vector mode rather than the element mode to rtx_mode_t. I think the: /* We can get a 0 for an error mark. */ || GET_MODE_CLASS (mode) == MODE_VECTOR_INT || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT in immed_double_const is dead. trunc_int_mode (via gen_int_mode) would go on to ICE if the mode fitted in a HWI, and surely plenty of other code would be confused to see a const_int be interpreted as a vector. We should instead be using CONST0_RTX (mode) if we need a safe constant for a particular mode. We didn't try to make these functions take scalar_mode arguments because in many cases that would be too invasive at this stage. Maybe it would become feasible in future. Also, the long-term direction should probably be to add modes to constant integers rather than have then as VOIDmode odd-ones-out. That would remove the need for rtx_mode_t and thus remove the question whether they should use scalar_int_mode, scalar_mode or machine_mode. The patch also uses scalar_mode for the CONST_DOUBLE handling in loc_descriptor. In that case the mode can legitimately be either floating-point or integral. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * emit-rtl.c (immed_double_const): Use is_a instead of separate mode class checks. Do not allow vector modes here. (immed_wide_int_const): Use as_a . * explow.c (trunc_int_for_mode): Likewise. * rtl.h (wi::int_traits::get_precision): Likewise. (wi::shwi): Likewise. (wi::min_value): Likewise. (wi::max_value): Likewise. * dwarf2out.c (loc_descriptor): Likewise. * simplify-rtx.c (simplify_immed_subreg): Fix rtx_mode_t argument for CONST_WIDE_INT. Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:51.646771977 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:54.682546579 +0100 @@ -599,7 +599,8 @@ lookup_const_wide_int (rtx wint) immed_wide_int_const (const wide_int_ref &v, machine_mode mode) { unsigned int len = v.get_len (); - unsigned int prec = GET_MODE_PRECISION (mode); + /* Not scalar_int_mode because we also allow pointer bound modes. */ + unsigned int prec = GET_MODE_PRECISION (as_a (mode)); /* Allow truncation but not extension since we do not know if the number is signed or unsigned. */ @@ -659,18 +660,10 @@ immed_double_const (HOST_WIDE_INT i0, HO (i.e., i1 consists only from copies of the sign bit, and sign of i0 and i1 are the same), then we return a CONST_INT for i0. 3) Otherwise, we create a CONST_DOUBLE for i0 and i1. */ - if (mode != VOIDmode) - { - gcc_assert (GET_MODE_CLASS (mode) == MODE_INT - || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT - /* We can get a 0 for an error mark. */ - || GET_MODE_CLASS (mode) == MODE_VECTOR_INT - || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT - || GET_MODE_CLASS (mode) == MODE_POINTER_BOUNDS); - - if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) - return gen_int_mode (i0, mode); - } + scalar_mode smode; + if (is_a (mode, &smode) + && GET_MODE_BITSIZE (smode) <= HOST_BITS_PER_WIDE_INT) + return gen_int_mode (i0, mode); /* If this integer fits in one word, return a CONST_INT. */ if ((i1 == 0 && i0 >= 0) || (i1 == ~0 && i0 < 0)) Index: gcc/explow.c =================================================================== --- gcc/explow.c 2017-07-13 09:18:51.647771901 +0100 +++ gcc/explow.c 2017-07-13 09:18:54.682546579 +0100 @@ -49,14 +49,16 @@ static rtx break_out_memory_refs (rtx); HOST_WIDE_INT trunc_int_for_mode (HOST_WIDE_INT c, machine_mode mode) { - int width = GET_MODE_PRECISION (mode); + /* Not scalar_int_mode because we also allow pointer bound modes. */ + scalar_mode smode = as_a (mode); + int width = GET_MODE_PRECISION (smode); /* You want to truncate to a _what_? */ gcc_assert (SCALAR_INT_MODE_P (mode) || POINTER_BOUNDS_MODE_P (mode)); /* Canonicalize BImode to 0 and STORE_FLAG_VALUE. */ - if (mode == BImode) + if (smode == BImode) return c & 1 ? STORE_FLAG_VALUE : 0; /* Sign-extend for the requested mode. */ Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2017-07-13 09:18:51.662770770 +0100 +++ gcc/rtl.h 2017-07-13 09:18:54.682546579 +0100 @@ -2120,8 +2120,7 @@ typedef std::pair rt inline unsigned int wi::int_traits ::get_precision (const rtx_mode_t &x) { - gcc_checking_assert (x.second != BLKmode && x.second != VOIDmode); - return GET_MODE_PRECISION (x.second); + return GET_MODE_PRECISION (as_a (x.second)); } inline wi::storage_ref @@ -2166,7 +2165,7 @@ wi::int_traits ::decompose ( inline wi::hwi_with_prec wi::shwi (HOST_WIDE_INT val, machine_mode mode) { - return shwi (val, GET_MODE_PRECISION (mode)); + return shwi (val, GET_MODE_PRECISION (as_a (mode))); } /* Produce the smallest number that is represented in MODE. The precision @@ -2174,7 +2173,7 @@ wi::shwi (HOST_WIDE_INT val, machine_mod inline wide_int wi::min_value (machine_mode mode, signop sgn) { - return min_value (GET_MODE_PRECISION (mode), sgn); + return min_value (GET_MODE_PRECISION (as_a (mode)), sgn); } /* Produce the largest number that is represented in MODE. The precision @@ -2182,7 +2181,7 @@ wi::min_value (machine_mode mode, signop inline wide_int wi::max_value (machine_mode mode, signop sgn) { - return max_value (GET_MODE_PRECISION (mode), sgn); + return max_value (GET_MODE_PRECISION (as_a (mode)), sgn); } extern void init_rtlanal (void); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c 2017-07-13 09:18:51.644772127 +0100 +++ gcc/dwarf2out.c 2017-07-13 09:18:54.681546653 +0100 @@ -15781,10 +15781,11 @@ loc_descriptor (rtx rtl, machine_mode mo or a floating-point constant. A CONST_DOUBLE is used whenever the constant requires more than one word in order to be adequately represented. We output CONST_DOUBLEs as blocks. */ + scalar_mode smode = as_a (mode); loc_result = new_loc_descr (DW_OP_implicit_value, - GET_MODE_SIZE (mode), 0); + GET_MODE_SIZE (smode), 0); #if TARGET_SUPPORTS_WIDE_INT == 0 - if (!SCALAR_FLOAT_MODE_P (mode)) + if (!SCALAR_FLOAT_MODE_P (smode)) { loc_result->dw_loc_oprnd2.val_class = dw_val_class_const_double; loc_result->dw_loc_oprnd2.v.val_double @@ -15793,7 +15794,7 @@ loc_descriptor (rtx rtl, machine_mode mo else #endif { - unsigned int length = GET_MODE_SIZE (mode); + unsigned int length = GET_MODE_SIZE (smode); unsigned char *array = ggc_vec_alloc (length); insert_float (rtl, array); Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:53.276650175 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:54.683546506 +0100 @@ -5785,7 +5785,7 @@ simplify_immed_subreg (machine_mode oute case CONST_WIDE_INT: { - rtx_mode_t val = rtx_mode_t (el, innermode); + rtx_mode_t val = rtx_mode_t (el, GET_MODE_INNER (innermode)); unsigned char extend = wi::sign_mask (val); int prec = wi::get_precision (val); From patchwork Thu Jul 13 09:02:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107653 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1944643qge; Thu, 13 Jul 2017 02:04:34 -0700 (PDT) X-Received: by 10.99.167.79 with SMTP id w15mr8098160pgo.22.1499936674029; Thu, 13 Jul 2017 02:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936674; cv=none; d=google.com; s=arc-20160816; b=utQBy0wB3NL3lD+jZ/tBoFzuEmXQHraXwP6RLcpdEzbkdk/yUWGEl9UEkNOnrFBVQO 8p2W0OR9Fd9Rk02MhU4bl87mUFhjXAQz96J/C2umGMmwYJhuVpuLOXUTOgcXV3HnERzz yvK9q8cs2tnAgyhycNfGw9o+7CDJHV9dUDkSxh/GOXr5Epdo4I+qg4j+uoN3vSHKnWIS gJhcRLlPGbiIsSNyaog1Lpgp98/FO1HAf5gtnIgbIdW1eS0IH0uU+cqnsyhCZuFZal+Y yUf0jHGcSPWK0/fKk4lLeBJ4+JWZl8ZPtMyXwJRK/uFhlJiNLUExkg+QtyVTiHfvbSif kSEA== 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=MLUAY/ph4IPoK6CwtmU0NQHmFlhoIKe5LyWxD0vq2gw=; b=wxbI5vmfrF5YP4RBfyPC2kNb41ZWOrnUQtOoqH8gF2lvhwISffMmrEygvWrC3N9oFV LOqbb6lwlPNxEOpmC8ubU6im+LpNidLpCM2KA3ib8KOkOT/vC4lL0mCi4vTp0xtjiCPd BYJlGbrn0LyDit9HpUuWATUs9rTHqDDRWxyZ39edI8Ix1FLvPMaueUEldpIql7I5eAIf 76G688ZMhe+Y3FlAkKGVqIGGwvjV8SKJQ8oBY/BeDyGdTGHJAHhc6UzVhKEh6ApfIh+X zCwDFzBe0nhQJaf//Ikfhjl1CyHrlfrvwzs8KdodecZNMD/m/7AGQ/dn2U4yVmQsNPX+ I2eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=NMoLVgI/; spf=pass (google.com: domain of gcc-patches-return-458058-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458058-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 b34si4168237pld.182.2017.07.13.02.04.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:04:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458058-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=NMoLVgI/; spf=pass (google.com: domain of gcc-patches-return-458058-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458058-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=D7+F2Oq+rhTcOjVBZBRN+k5UapSUM wNOwPDbfWhN6q6AItnPyLsZpc/djg8787XiRvkSwLjTZgfbNWaN7x75YGoz0G1GC 8Q2BfJRMmC+LxRkqw0mH3saXm2BZWw1jY6WH7hUgURFSHqD+iN5+cYyAPjWxGU54 IuFKMSPrKxlM6A= 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=1AVsjG9Ot02U+7GtrhNYlpM0LkM=; b=NMo LVgI/jFy/ebfDDQNPc6JSySaF+4eILJ3aJ5A973qXik0hb3iRKGAvDSz5c7XtKFx 3lh3h6En2xnKJZe21HiBsBGUBD2I8uP8Q6qQEDBNK7FvtWZ2JvdDf42N5gaBFNeO 8nU38rc4MxHiek4zUqKWI4PQsLXy4UyjlVJjJTDA= Received: (qmail 114794 invoked by alias); 13 Jul 2017 09:02:34 -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 113449 invoked by uid 89); 13 Jul 2017 09:02:33 -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-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:02:28 +0000 Received: by mail-wm0-f53.google.com with SMTP id i127so18563960wma.0 for ; Thu, 13 Jul 2017 02:02:27 -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=MLUAY/ph4IPoK6CwtmU0NQHmFlhoIKe5LyWxD0vq2gw=; b=oN7Dfr6300mbmuTHx/uKlYHcxoSEg13OeMdd8+g7X5gZVa2Fy6FdV3iO8AAggM442+ +Ci0uixduwcIkrI2xYfeU7f+7MhnJWCCPSh45fS00KPL0W+U40NAakheDx81sJTZ/rkh f/uDKt99FQvcVyvHkUv+ow4RpV9Nzxl6ua+KMyjZe09oulL8otmJxzWL0X71NRT2R+tu o1TwhF7x81n3USUbleJsJdZdeQWq7dPe4oUORDm6JbIif+6ArzVNCDnwl4WspKxAC+Pl cwznjStXMFyDmH7q557/tVYhwTozYoVNVxtMTpKvE6qyXIhAcNcJAxOixI1aYdRJTZfV rk8w== X-Gm-Message-State: AIVw111EAUcFOScyrcWRIVOQbLYRkg0+jxEbNvtRIrtzcNX+udlOKSjr ELjZQL3TPalYIonXhvEGig== X-Received: by 10.28.169.207 with SMTP id s198mr1276335wme.8.1499936545983; Thu, 13 Jul 2017 02:02:25 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id y12sm4980504wrb.39.2017.07.13.02.02.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:02:25 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [67/77] Use scalar_mode in fixed-value.* References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:02:23 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <874lugd80w.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the fixed-value.* routines use scalar_mode. It would be possible to define special classes for these modes, as for scalar_int_mode and scalar_float_mode, but at the moment nothing would benefit from them. In particular, there's no use case that would help select between one class for all fixed-point modes versus one class for fractional modes and one class for accumulator modes. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * fixed-value.h (fixed_from_double_int): Take a scalar_mode rather than a machine_mode. (fixed_from_string): Likewise. (fixed_convert): Likewise. (fixed_convert_from_int): Likewise. (fixed_convert_from_real): Likewise. (real_convert_from_fixed): Likewise. * fixed-value.c (fixed_from_double_int): Likewise. (fixed_from_string): Likewise. (fixed_convert): Likewise. (fixed_convert_from_int): Likewise. (fixed_convert_from_real): Likewise. (real_convert_from_fixed): Likewise. * config/avr/avr.c (avr_out_round): Use as_a . Index: gcc/fixed-value.h =================================================================== --- gcc/fixed-value.h 2017-02-23 19:54:20.000000000 +0000 +++ gcc/fixed-value.h 2017-07-13 09:18:55.158511776 +0100 @@ -47,14 +47,13 @@ extern rtx const_fixed_from_fixed_value /* Construct a FIXED_VALUE from a bit payload and machine mode MODE. The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ -extern FIXED_VALUE_TYPE fixed_from_double_int (double_int, - machine_mode); +extern FIXED_VALUE_TYPE fixed_from_double_int (double_int, scalar_mode); /* Return a CONST_FIXED from a bit payload and machine mode MODE. The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ static inline rtx const_fixed_from_double_int (double_int payload, - machine_mode mode) + scalar_mode mode) { return const_fixed_from_fixed_value (fixed_from_double_int (payload, mode), @@ -63,25 +62,25 @@ const_fixed_from_double_int (double_int /* Initialize from a decimal or hexadecimal string. */ extern void fixed_from_string (FIXED_VALUE_TYPE *, const char *, - machine_mode); + scalar_mode); /* In tree.c: wrap up a FIXED_VALUE_TYPE in a tree node. */ extern tree build_fixed (tree, FIXED_VALUE_TYPE); /* Extend or truncate to a new mode. */ -extern bool fixed_convert (FIXED_VALUE_TYPE *, machine_mode, +extern bool fixed_convert (FIXED_VALUE_TYPE *, scalar_mode, const FIXED_VALUE_TYPE *, bool); /* Convert to a fixed-point mode from an integer. */ -extern bool fixed_convert_from_int (FIXED_VALUE_TYPE *, machine_mode, +extern bool fixed_convert_from_int (FIXED_VALUE_TYPE *, scalar_mode, double_int, bool, bool); /* Convert to a fixed-point mode from a real. */ -extern bool fixed_convert_from_real (FIXED_VALUE_TYPE *, machine_mode, +extern bool fixed_convert_from_real (FIXED_VALUE_TYPE *, scalar_mode, const REAL_VALUE_TYPE *, bool); /* Convert to a real mode from a fixed-point. */ -extern void real_convert_from_fixed (REAL_VALUE_TYPE *, machine_mode, +extern void real_convert_from_fixed (REAL_VALUE_TYPE *, scalar_mode, const FIXED_VALUE_TYPE *); /* Compare two fixed-point objects for bitwise identity. */ Index: gcc/fixed-value.c =================================================================== --- gcc/fixed-value.c 2017-03-28 16:19:28.000000000 +0100 +++ gcc/fixed-value.c 2017-07-13 09:18:55.158511776 +0100 @@ -86,7 +86,7 @@ check_real_for_fixed_mode (REAL_VALUE_TY The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ FIXED_VALUE_TYPE -fixed_from_double_int (double_int payload, machine_mode mode) +fixed_from_double_int (double_int payload, scalar_mode mode) { FIXED_VALUE_TYPE value; @@ -108,7 +108,7 @@ fixed_from_double_int (double_int payloa /* Initialize from a decimal or hexadecimal string. */ void -fixed_from_string (FIXED_VALUE_TYPE *f, const char *str, machine_mode mode) +fixed_from_string (FIXED_VALUE_TYPE *f, const char *str, scalar_mode mode) { REAL_VALUE_TYPE real_value, fixed_value, base_value; unsigned int fbit; @@ -803,7 +803,7 @@ fixed_compare (int icode, const FIXED_VA Return true, if !SAT_P and overflow. */ bool -fixed_convert (FIXED_VALUE_TYPE *f, machine_mode mode, +fixed_convert (FIXED_VALUE_TYPE *f, scalar_mode mode, const FIXED_VALUE_TYPE *a, bool sat_p) { bool overflow_p = false; @@ -947,7 +947,7 @@ fixed_convert (FIXED_VALUE_TYPE *f, mach Return true, if !SAT_P and overflow. */ bool -fixed_convert_from_int (FIXED_VALUE_TYPE *f, machine_mode mode, +fixed_convert_from_int (FIXED_VALUE_TYPE *f, scalar_mode mode, double_int a, bool unsigned_p, bool sat_p) { bool overflow_p = false; @@ -1031,7 +1031,7 @@ fixed_convert_from_int (FIXED_VALUE_TYPE Return true, if !SAT_P and overflow. */ bool -fixed_convert_from_real (FIXED_VALUE_TYPE *f, machine_mode mode, +fixed_convert_from_real (FIXED_VALUE_TYPE *f, scalar_mode mode, const REAL_VALUE_TYPE *a, bool sat_p) { bool overflow_p = false; @@ -1090,7 +1090,7 @@ fixed_convert_from_real (FIXED_VALUE_TYP /* Convert to a new real mode from a fixed-point. */ void -real_convert_from_fixed (REAL_VALUE_TYPE *r, machine_mode mode, +real_convert_from_fixed (REAL_VALUE_TYPE *r, scalar_mode mode, const FIXED_VALUE_TYPE *f) { REAL_VALUE_TYPE base_value, fixed_value, real_value; Index: gcc/config/avr/avr.c =================================================================== --- gcc/config/avr/avr.c 2017-07-13 09:18:51.589776273 +0100 +++ gcc/config/avr/avr.c 2017-07-13 09:18:55.158511776 +0100 @@ -9174,7 +9174,7 @@ #define MAY_CLOBBER(RR) const char* avr_out_round (rtx_insn *insn ATTRIBUTE_UNUSED, rtx *xop, int *plen) { - machine_mode mode = GET_MODE (xop[0]); + scalar_mode mode = as_a (GET_MODE (xop[0])); scalar_int_mode imode = *int_mode_for_mode (mode); // The smallest fractional bit not cleared by the rounding is 2^(-RP). int fbit = (int) GET_MODE_FBIT (mode); From patchwork Thu Jul 13 09:02:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107654 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1944921qge; Thu, 13 Jul 2017 02:04:51 -0700 (PDT) X-Received: by 10.84.128.9 with SMTP id 9mr8734725pla.61.1499936690958; Thu, 13 Jul 2017 02:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936690; cv=none; d=google.com; s=arc-20160816; b=1KHKQNvvgT9IZi1VT+q2AuPIepbAh/Tn3IOHSfLXov6IIJ+XriCkCLLYErQ7Bx4PcZ Mb7wLfUjxNR5wRyyiLULiS9VJh6b1KYuBtlLHDK012J8hWNQqf9Yp563sAOjyaURvudE Gsgo/tSagk06QAsiIGg0QT+stYtaCUikQt09HisS/xtsQbJjtULP2cnZBnpu/jbDPs3y PzpN00pD1zL0grKiv+jpVbwRYLefeP2RMyqcfQifwhHJgYOzVHs2E9mA3nxn9N2V/f39 0Q9wAfHvN4SmvnKOD13w0hEG2A2CPE9iUpNi+bHM1PeyE3q1AFBuwC+5cYmpkACL+yvp H5mQ== 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=12FOBcwaXg8E8ATtCJ58lr3Zg4axjc9FwXdhydsre4c=; b=sGD/XPx25LmA/Iy2N3pnemtfBpy53hjjoRHhPF+H6vgxT75iEmCgJbHjzOOKTbaxNP sljcXpp2OOSd+6gwJil1DQ+jeDl9BAj/kgmBwAhJHnzmbZcTonEe64AJMWR5TDZqQu2g rcln/1QV80nUJNNV8GKDuScz5H06WX9lM3KEb9XScSiP7CrCMrMQKoFSMXlhWemE7w5r 6008hq/U7Zq214FEOFWz8BS2p/A4BfUfSE7pw5f3Jqd68OgXjYh2ZCiYlMiZNUzXCCJv ZXgWk79vOd+DPP6mC0Sw5+eJUL4XckZ70moXcDthhCxXoVLMOXRCkBrQH9DWFhqKiZzu 621g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=yczqNppl; spf=pass (google.com: domain of gcc-patches-return-458059-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458059-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 g21si3781377pfk.155.2017.07.13.02.04.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458059-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=yczqNppl; spf=pass (google.com: domain of gcc-patches-return-458059-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458059-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=o4UWw77NEBJRauX09zWmR4980XVVf Terysg/hlHSVD279ouY/a01QS/iGxMR1RRGGjYhZ+Z/Z6CO1fUeTlPjOg+WY1XVV NSLT4MogluzJ5LpbBIRSx3kfhPEKBJ9kn592KMuJXcXK3OC1Ia8ue3zkLMcRaWhZ 2RpgvZ3qpVySQY= 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=efP2cIT6kNs1mVyMbXbUUegKYCY=; b=ycz qNpplJA7esH6KmVgO1WI+u9ipn1V2D//4LBDuDai1ts4is7Jj0PDM4LPuVQjGcAb 73+7Q1x0QWw9Q+e7kgOr1clfCA8jbsJcKpOBP6hcUDzQSOyimgAKhgopLOrInJnX afSxKvh4H/uaOKLNeah1KDAVzOfhOvlaOXNQjixg= Received: (qmail 129286 invoked by alias); 13 Jul 2017 09:02: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 128297 invoked by uid 89); 13 Jul 2017 09:02:48 -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-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:02:44 +0000 Received: by mail-wm0-f42.google.com with SMTP id w126so16911630wme.0 for ; Thu, 13 Jul 2017 02:02:44 -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=12FOBcwaXg8E8ATtCJ58lr3Zg4axjc9FwXdhydsre4c=; b=fsQEKMJvy/bq1NiPxUtYM1HkpH5zpAZGBoTxp59PYbX3tv/GB9N55VYH80L3a4s43V oM4Ml2JQy/cYwcoIE6toGTPL36zNAv8GB2RYTGg7WVOTzkd8unZmbEg5bkYFR9bHkbGN 0/Nw3mu1TNRW+bl0IRjW8/Pipo489dqPnBLSmLiisoeYkJWWnEgAkrfecr0Q+M1VKGwt 3aZSvu68l1zBLLlGemXEBdfH020uFTeSaP0Oy4NWIqTZepBk8wA5mQ4xuWIVm3laKdw1 2HVOKYsQjEEKyaPNJfwGmvRjmMSO8PoCHejs7VCtONOPa8a9Nc6MPHF8KEy/SeiN+wQR Ldxg== X-Gm-Message-State: AIVw112tShW3C7NxOUUvUbEks+B4wT4+aHk4YIlcuP2jJs115NZGD0u0 qc4Gn9AzFrryXA1LaPXuHg== X-Received: by 10.28.8.144 with SMTP id 138mr1241944wmi.8.1499936562324; Thu, 13 Jul 2017 02:02:42 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id g63sm4705881wrd.11.2017.07.13.02.02.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:02:41 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [68/77] Use scalar_mode for is_int_mode/is_float_mode pairs References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:02:39 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87zic8btg0.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses scalar_mode for code that operates only on MODE_INT and MODE_FLOAT. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * omp-expand.c (expand_omp_atomic): Use is_int_mode, is_float_mode and scalar_mode. * tree-vect-stmts.c (get_vectype_for_scalar_type_and_size): Likewise. Index: gcc/omp-expand.c =================================================================== --- gcc/omp-expand.c 2017-06-30 12:50:38.243662675 +0100 +++ gcc/omp-expand.c 2017-07-13 09:18:55.598479800 +0100 @@ -6724,17 +6724,18 @@ expand_omp_atomic (struct omp_region *re if (exact_log2 (align) >= index) { /* Atomic load. */ + scalar_mode smode; if (loaded_val == stored_val - && (GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT - || GET_MODE_CLASS (TYPE_MODE (type)) == MODE_FLOAT) - && GET_MODE_BITSIZE (TYPE_MODE (type)) <= BITS_PER_WORD + && (is_int_mode (TYPE_MODE (type), &smode) + || is_float_mode (TYPE_MODE (type), &smode)) + && GET_MODE_BITSIZE (smode) <= BITS_PER_WORD && expand_omp_atomic_load (load_bb, addr, loaded_val, index)) return; /* Atomic store. */ - if ((GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT - || GET_MODE_CLASS (TYPE_MODE (type)) == MODE_FLOAT) - && GET_MODE_BITSIZE (TYPE_MODE (type)) <= BITS_PER_WORD + if ((is_int_mode (TYPE_MODE (type), &smode) + || is_float_mode (TYPE_MODE (type), &smode)) + && GET_MODE_BITSIZE (smode) <= BITS_PER_WORD && store_bb == single_succ (load_bb) && first_stmt (store_bb) == store && expand_omp_atomic_store (load_bb, addr, loaded_val, Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-13 09:18:54.003596374 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:55.599479728 +0100 @@ -8936,18 +8936,16 @@ free_stmt_vec_info (gimple *stmt) get_vectype_for_scalar_type_and_size (tree scalar_type, unsigned size) { tree orig_scalar_type = scalar_type; - machine_mode inner_mode = TYPE_MODE (scalar_type); + scalar_mode inner_mode; machine_mode simd_mode; - unsigned int nbytes = GET_MODE_SIZE (inner_mode); int nunits; tree vectype; - if (nbytes == 0) + if (!is_int_mode (TYPE_MODE (scalar_type), &inner_mode) + && !is_float_mode (TYPE_MODE (scalar_type), &inner_mode)) return NULL_TREE; - if (GET_MODE_CLASS (inner_mode) != MODE_INT - && GET_MODE_CLASS (inner_mode) != MODE_FLOAT) - return NULL_TREE; + unsigned int nbytes = GET_MODE_SIZE (inner_mode); /* For vector types of elements whose mode precision doesn't match their types precision we use a element type of mode From patchwork Thu Jul 13 09:03:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107655 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1945139qge; Thu, 13 Jul 2017 02:05:04 -0700 (PDT) X-Received: by 10.99.140.7 with SMTP id m7mr8239413pgd.49.1499936704808; Thu, 13 Jul 2017 02:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936704; cv=none; d=google.com; s=arc-20160816; b=NBBVXUKNX2PEM80KLOPoiZvIVhxgoFtssyA2Hyck1ug7z6V6c+JaSXljb1oL9Koujx EmYrIyVuhE3aJr3KATLr7ooO56/UyqBlQYig9fJsgNuudZeQvI4YdxV3S+9fdFB0dZFo DdfWalPyeGyZhWyBQ2HfkNdNYa/HOOuiUpy1JRUAGqkPYUYQ7ocGB8GW2+ZCYzX8P+v8 CIQoRWmiTQqFSgoQ+iECfzzr59eJjjiALASA1dqDhErWy0QEaSIXU4pe/MlZQtYkHEaM E4FxhcTaY8jKthpA39GRo6mNaNFp14JXtq4jedIshdRxGxxQDpg1JcHjsvBj5dmi/fk1 UpZw== 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=KI3dOeHhSJb+vICGAz2f7zOoWprj+3sA/0a9riaQMmU=; b=pGzgOFnS3teNrSBIDepZELRn8pbujBcSJrggBJQwLgsb6jv7Sulo0QdMTXyDj8a7QU OQdElWeikKgeOlys5cSEHktoJU13pIHpW3wjMA8v/fRg8g3K60slsH8+mPpPwsVtfCjP rfgoWkOxbQ/p02HEZg+F8Uu6NhuEsxUl1gppwStk65rUQxM7ip2R12/9bI80psqDKaYH N18MTqYkiJrNZkGECnwiTW4ENyRc5Qr1MyCYR9J6EGmscb1EwJCJtlXRWB37Xvd2P84+ YBJCqoKl4ZUEo4zZbsAM5x1ItBzcRB4Wb/LxyvrDQV32NqvBA7T8qhXYj3emrzlL2Lgt sK+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=yXe1tFe3; spf=pass (google.com: domain of gcc-patches-return-458060-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458060-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 p5si3842421pgs.60.2017.07.13.02.05.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:05:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458060-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=yXe1tFe3; spf=pass (google.com: domain of gcc-patches-return-458060-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458060-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=jjOIUYFWnZWVVWXFVTg+QG6xAcvSr Vl/faZNcNV/dmxzCi5kxBeaTdlfgGQ2u3EWtZkEXphZXahht7e1roHuj2geJtiHl bVAlf4Dfvp7v6j5o24QYlv5rztXEs7O34SWcktqF6sDgQB2vqpZ7ckzLcD/snRn7 WWn4yj2kzKXpzg= 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=gkIeUmmX9/O8iUkF91+tRwWcZr4=; b=yXe 1tFe3wlnBaJLugbG+rFk1nypK12/rfRndWfYx0xkkUrw2A9NMFInirgZiw+6qzvj DGLY4f2Rw8GkA+2FJzmX3fzhcYmLd5SRzIOn3Pn/WsYrNqw+tP27WYZzEBi+6ogo RMYEn65oW9gqmrfAdDqOD+XaTpq9HJJPOJdKjj3E= Received: (qmail 30466 invoked by alias); 13 Jul 2017 09:03:15 -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 28810 invoked by uid 89); 13 Jul 2017 09:03:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2556 X-HELO: mail-wm0-f47.google.com Received: from mail-wm0-f47.google.com (HELO mail-wm0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:03:08 +0000 Received: by mail-wm0-f47.google.com with SMTP id i127so18584020wma.0 for ; Thu, 13 Jul 2017 02:03:08 -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=KI3dOeHhSJb+vICGAz2f7zOoWprj+3sA/0a9riaQMmU=; b=mvMSdn2h5rBu79tYlLl/KeDrwytLAhXsgGysgTF+ala5lG4NsWSPl77VkPlcHmrIMB r3zXb3GdV3Kzhxe9HtAqcH5S3pL4S04Vc7LXzzN5k6KzI7MwUKtYOOebsvtejziHe+rn jGIXM7zZ51GSr/N97BDc9qOUrXomhfUjC9hBvJn+T+6YPdbSRTYoYEcBIrJdICchfGpo KmPfwNDxk6tErxAaSBCil6EoaX5rYBjoPx7uzMl0+lTcQcfkQJyv0DYKo/EkJTpyyw5j YqoepkaMQkHzkdZx2jj+X3MCJrbbljQ+n1ltuT8RmTvB015pmvFjF+sqmEnJJDpg4uAM /Ckw== X-Gm-Message-State: AIVw113Qc3Gw+Ayzz+PfatY7xKkUR36gqWcJA5+maYYPJ6UGpYWSsOF3 Av4k6auONlYmbZ3dgLOb5w== X-Received: by 10.28.40.215 with SMTP id o206mr1185222wmo.74.1499936586543; Thu, 13 Jul 2017 02:03:06 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id x131sm3767368wmg.13.2017.07.13.02.03.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:03:05 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [69/77] Split scalar-only part out of convert_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:03:04 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87vamwbtfb.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch splits the final scalar-only part of convert_mode out into its own subroutine and treats the modes as scalar_modes there. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (convert_mode): Split scalar handling out into... (convert_mode_scalar): ...this new function. Treat the modes as scalar_modes. Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:53.997596816 +0100 +++ gcc/expr.c 2017-07-13 09:18:56.007450082 +0100 @@ -102,6 +102,7 @@ static rtx const_vector_from_tree (tree) static rtx const_scalar_mask_from_tree (scalar_int_mode, tree); static tree tree_expr_size (const_tree); static HOST_WIDE_INT int_expr_size (tree); +static void convert_mode_scalar (rtx, rtx, int); /* This is run to set up which modes can be used @@ -216,17 +217,7 @@ convert_move (rtx to, rtx from, int unsi { machine_mode to_mode = GET_MODE (to); machine_mode from_mode = GET_MODE (from); - int to_real = SCALAR_FLOAT_MODE_P (to_mode); - int from_real = SCALAR_FLOAT_MODE_P (from_mode); - enum insn_code code; - rtx libcall; - - /* rtx code for making an equivalent value. */ - enum rtx_code equiv_code = (unsignedp < 0 ? UNKNOWN - : (unsignedp ? ZERO_EXTEND : SIGN_EXTEND)); - - gcc_assert (to_real == from_real); gcc_assert (to_mode != BLKmode); gcc_assert (from_mode != BLKmode); @@ -277,6 +268,28 @@ convert_move (rtx to, rtx from, int unsi return; } + convert_mode_scalar (to, from, unsignedp); +} + +/* Like convert_move, but deals only with scalar modes. */ + +static void +convert_mode_scalar (rtx to, rtx from, int unsignedp) +{ + /* Both modes should be scalar types. */ + scalar_mode from_mode = as_a (GET_MODE (from)); + scalar_mode to_mode = as_a (GET_MODE (to)); + bool to_real = SCALAR_FLOAT_MODE_P (to_mode); + bool from_real = SCALAR_FLOAT_MODE_P (from_mode); + enum insn_code code; + rtx libcall; + + gcc_assert (to_real == from_real); + + /* rtx code for making an equivalent value. */ + enum rtx_code equiv_code = (unsignedp < 0 ? UNKNOWN + : (unsignedp ? ZERO_EXTEND : SIGN_EXTEND)); + if (to_real) { rtx value; @@ -413,7 +426,7 @@ convert_move (rtx to, rtx from, int unsi rtx fill_value; rtx lowfrom; int i; - machine_mode lowpart_mode; + scalar_mode lowpart_mode; int nwords = CEIL (GET_MODE_SIZE (to_mode), UNITS_PER_WORD); /* Try converting directly if the insn is supported. */ From patchwork Thu Jul 13 09:03:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107656 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1945377qge; Thu, 13 Jul 2017 02:05:19 -0700 (PDT) X-Received: by 10.84.229.6 with SMTP id b6mr8691957plk.247.1499936719815; Thu, 13 Jul 2017 02:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936719; cv=none; d=google.com; s=arc-20160816; b=WAR/zyxxvxI8DzVUE5KWC2yh7YjNF73boTnZsJ+ex7KXK9K0U6g4xw/LLL+sFjBMBR wRvMBkFa4Q4GDj8dQmaIitOosH6z8BfbaFlg1Gm5ZUW6lp2wAG3V9M+fW+Wk4ioONS5w kCVbRaaVAlkpof6THdOymYWE6spA9DSER39bxgERveqaz2L8rRXcDmqLksgpqgXQXC2y 3I3CSC+ajPtQ0ufAtdNHjXHPy7zP5XIuUb4qvMBC9yA+5j+U46/zNmXce6iXAEYHdc5U LMS9f7F8iRKiYdVZsoeLyb/ote+F8fODOGHiWOX9kJ5CJqX26Qpt7mx/WdKWrfK7iYkb l9NQ== 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=nJDRMBHvUQG/vS7ppXxGYXPntW2gyXYAhA46XvRE8rg=; b=gwxBk/1qQ7IkiRaW04T4PY4l61z0AzbwAfov+5AX1BhlGwtIyrCKViKu/giJqg9VUk ks7r2qQTgAh14GZkOrvM95g7DuFuieBoJ0DVdQ5sOT44MOz2wMpiLLesyspMJqDxImk4 gQcXAotOL5zBl4sjOfMA/cidGeLHcniTM/XD3ZQ6sn3Dgj+B6zj+pU4b8c6T9osT1nRj 3SY4vDS598tS43Z2nzVvqDtxFTRcYDgaBo9b10WHsLyPcdGjvjY6nTvEHzb5vkOc7SyT It6H2/qfguATQ11aEBSTqWoQNmHsDFWlGwnwrtR6BU3oyKU/nGshKMoyeEOZk1XyyVmA SVhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=y2Su4QV3; spf=pass (google.com: domain of gcc-patches-return-458061-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458061-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 v18si3800457pfi.87.2017.07.13.02.05.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:05:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458061-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=y2Su4QV3; spf=pass (google.com: domain of gcc-patches-return-458061-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458061-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=ykOyoatBbpS8ZITPIxqB50ZteVPcq QExkAUhL9SkKkWcYMkqxA0+Yg8kpnDl3uFZJbdGVpgqrqqVJ46FpieRnGtSKjJm/ RBnVkvGuqN7AzemdkpsrSueeypZVscItUcg4GmpOQpVrJ5IbCQszA/DO1wHkFvNl D3i/NDFgU5KB+c= 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=AVJY4y3k9HtLmXAIBGPxyemVVPM=; b=y2S u4QV35czGHyCRhOJaE6AP28iWE9TkYH0TeNE2dQrFcllq5Or+dgb35uOhB/fOVR6 +l28PmUZZyDuLY5FgUwnVEmBluL6YmX7xfmMEYVPs7QhNhwVSnRGLSAa4PoUZatG 7cqer6X5nIyiEZUp0DsZ8LQNuFbBIGN+f54PKSLc= Received: (qmail 50616 invoked by alias); 13 Jul 2017 09:03:32 -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 49812 invoked by uid 89); 13 Jul 2017 09:03:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:03:28 +0000 Received: by mail-wm0-f51.google.com with SMTP id f67so18618785wmh.1 for ; Thu, 13 Jul 2017 02:03:28 -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=nJDRMBHvUQG/vS7ppXxGYXPntW2gyXYAhA46XvRE8rg=; b=grz/HyloEgfmqetrU0MesRsNQe7hKR8UJATQ5+0dYSUUusK5WzpcRoCbw6dprf2uin NKDRvqz9i3NCpFLinaBhtCcFwZLkqwN+NsTnA/tVovpQQAnJmcMiyzEXOiw700UKMWJy GndUMATptuc97lWfs1Mm9ciyzp4s1b0gHnPfPR8Q7RQbcZ++twPSdxZ3XrfwhOUn3Ypm TbYaNzXJREobmFRokMKGwASGg38VqwmDp/jU72vR0XCv1rX7H9eQnJEzjUk4ivvJpNd/ 0B/ibmcydhuC9qjpqt00ARJFAuaUIhWfju7NAu5guAisqD1/vruT0Qsk9/E2sOhMlr1t qEnw== X-Gm-Message-State: AIVw112EHrbDwoJ7GNxdhYJCmTkNwrjBVs2+j0Kaw4eSKxtaLQr09ObB VKtyfXVc2RG5FhPe1hs2bw== X-Received: by 10.28.150.139 with SMTP id y133mr1201853wmd.61.1499936605947; Thu, 13 Jul 2017 02:03:25 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id p27sm5891348wmf.23.2017.07.13.02.03.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:03:25 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [70/77] Make expand_fix/float check for scalar modes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:03:23 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87r2xkbtes.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The expand_float code: /* Unsigned integer, and no way to convert directly. Convert as signed, then unconditionally adjust the result. */ and the expand_fix code: /* For an unsigned conversion, there is one more way to do it. If we have a signed conversion, we generate code that compares the real value to the largest representable positive number. If if is smaller, the conversion is done normally. Otherwise, subtract one plus the highest signed number, convert, and add it back. are restricted to scalars, since the expansion branches on a comparison of the value. This patch makes that explicit. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * optabs.c (expand_float): Explicitly check for scalars before using a branching expansion. (expand_fix): Likewise. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:53.274650323 +0100 +++ gcc/optabs.c 2017-07-13 09:18:56.346425666 +0100 @@ -4635,6 +4635,7 @@ expand_float (rtx to, rtx from, int unsi { enum insn_code icode; rtx target = to; + scalar_mode from_mode, to_mode; machine_mode fmode, imode; bool can_do_signed = false; @@ -4684,7 +4685,10 @@ expand_float (rtx to, rtx from, int unsi /* Unsigned integer, and no way to convert directly. Convert as signed, then unconditionally adjust the result. */ - if (unsignedp && can_do_signed) + if (unsignedp + && can_do_signed + && is_a (GET_MODE (to), &to_mode) + && is_a (GET_MODE (from), &from_mode)) { rtx_code_label *label = gen_label_rtx (); rtx temp; @@ -4694,19 +4698,19 @@ expand_float (rtx to, rtx from, int unsi least as wide as the target. Using FMODE will avoid rounding woes with unsigned values greater than the signed maximum value. */ - FOR_EACH_MODE_FROM (fmode, GET_MODE (to)) - if (GET_MODE_PRECISION (GET_MODE (from)) < GET_MODE_BITSIZE (fmode) - && can_float_p (fmode, GET_MODE (from), 0) != CODE_FOR_nothing) + FOR_EACH_MODE_FROM (fmode, to_mode) + if (GET_MODE_PRECISION (from_mode) < GET_MODE_BITSIZE (fmode) + && can_float_p (fmode, from_mode, 0) != CODE_FOR_nothing) break; if (fmode == VOIDmode) { /* There is no such mode. Pretend the target is wide enough. */ - fmode = GET_MODE (to); + fmode = to_mode; /* Avoid double-rounding when TO is narrower than FROM. */ if ((significand_size (fmode) + 1) - < GET_MODE_PRECISION (GET_MODE (from))) + < GET_MODE_PRECISION (from_mode)) { rtx temp1; rtx_code_label *neglabel = gen_label_rtx (); @@ -4718,7 +4722,7 @@ expand_float (rtx to, rtx from, int unsi || GET_MODE (target) != fmode) target = gen_reg_rtx (fmode); - imode = GET_MODE (from); + imode = from_mode; do_pending_stack_adjust (); /* Test whether the sign bit is set. */ @@ -4758,7 +4762,7 @@ expand_float (rtx to, rtx from, int unsi /* If we are about to do some arithmetic to correct for an unsigned operand, do it in a pseudo-register. */ - if (GET_MODE (to) != fmode + if (to_mode != fmode || !REG_P (to) || REGNO (to) < FIRST_PSEUDO_REGISTER) target = gen_reg_rtx (fmode); @@ -4769,11 +4773,11 @@ expand_float (rtx to, rtx from, int unsi correct its value by 2**bitwidth. */ do_pending_stack_adjust (); - emit_cmp_and_jump_insns (from, const0_rtx, GE, NULL_RTX, GET_MODE (from), + emit_cmp_and_jump_insns (from, const0_rtx, GE, NULL_RTX, from_mode, 0, label); - real_2expN (&offset, GET_MODE_PRECISION (GET_MODE (from)), fmode); + real_2expN (&offset, GET_MODE_PRECISION (from_mode), fmode); temp = expand_binop (fmode, add_optab, target, const_double_from_real_value (offset, fmode), target, 0, OPTAB_LIB_WIDEN); @@ -4901,11 +4905,14 @@ expand_fix (rtx to, rtx from, int unsign 2^63. The subtraction of 2^63 should not generate any rounding as it simply clears out that bit. The rest is trivial. */ - if (unsignedp && GET_MODE_PRECISION (GET_MODE (to)) <= HOST_BITS_PER_WIDE_INT) + scalar_int_mode to_mode; + if (unsignedp + && is_a (GET_MODE (to), &to_mode) + && HWI_COMPUTABLE_MODE_P (to_mode)) FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) - if (CODE_FOR_nothing != can_fix_p (GET_MODE (to), fmode, 0, &must_trunc) + if (CODE_FOR_nothing != can_fix_p (to_mode, fmode, 0, &must_trunc) && (!DECIMAL_FLOAT_MODE_P (fmode) - || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (GET_MODE (to)))) + || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (to_mode))) { int bitsize; REAL_VALUE_TYPE offset; @@ -4913,7 +4920,7 @@ expand_fix (rtx to, rtx from, int unsign rtx_code_label *lab1, *lab2; rtx_insn *insn; - bitsize = GET_MODE_PRECISION (GET_MODE (to)); + bitsize = GET_MODE_PRECISION (to_mode); real_2expN (&offset, bitsize - 1, fmode); limit = const_double_from_real_value (offset, fmode); lab1 = gen_label_rtx (); @@ -4939,10 +4946,10 @@ expand_fix (rtx to, rtx from, int unsign target = expand_binop (GET_MODE (from), sub_optab, from, limit, NULL_RTX, 0, OPTAB_LIB_WIDEN); expand_fix (to, target, 0); - target = expand_binop (GET_MODE (to), xor_optab, to, + target = expand_binop (to_mode, xor_optab, to, gen_int_mode (HOST_WIDE_INT_1 << (bitsize - 1), - GET_MODE (to)), + to_mode), to, 1, OPTAB_LIB_WIDEN); if (target != to) @@ -4950,12 +4957,12 @@ expand_fix (rtx to, rtx from, int unsign emit_label (lab2); - if (optab_handler (mov_optab, GET_MODE (to)) != CODE_FOR_nothing) + if (optab_handler (mov_optab, to_mode) != CODE_FOR_nothing) { /* Make a place for a REG_NOTE and add it. */ insn = emit_move_insn (to, to); set_dst_reg_note (insn, REG_EQUAL, - gen_rtx_fmt_e (UNSIGNED_FIX, GET_MODE (to), + gen_rtx_fmt_e (UNSIGNED_FIX, to_mode, copy_rtx (from)), to); } From patchwork Thu Jul 13 09:03:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107657 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1945792qge; Thu, 13 Jul 2017 02:05:44 -0700 (PDT) X-Received: by 10.99.66.1 with SMTP id p1mr8120166pga.120.1499936744143; Thu, 13 Jul 2017 02:05:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936744; cv=none; d=google.com; s=arc-20160816; b=FF28XS3xS3bqHpeWdRgjz3HYXc8uEKvA72pgwNjaY1uHmU3SXr2AqOX0meJYF71J8E oIqXMaTgTFh0UwzLD+hqR4F5Xy2ZoBtPNOELdyUiaZTrIo5mbj8FmGekxOCmai51LLQk FfdVCvwQzDjyGPHIC3WoorV7Cwe2/SMQs+cncmiNpGIqdWyiJkyvWxBw2WeKfgouuoTh GfU/dmGM3d+dJeOMdAbqkLurB01ZI9BI6gf+8ul/smLbGjwU5OrkOyPng8H4PT3uivjl Xhyfx+F97ESH7xicqAnXbiJn4LvwwY6vIUQW4JjHG/9O8vH59TfMhkrXc8lv9sA1KLcl QNxQ== 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=tdObLj8jtPjDnq8n5LIhpphulAJxntn0B5hm3OXn6cI=; b=V6Q2bwxjfP8yNErLGp1fa8S9BBUBrKZAWZ9A+1b7UQM1Wuy/BtIjWzHgVoeCueBXmI gVdCX/WjUVoMqEt72FQWylrE/IYAj3WgWrBAAMHcgDrW6yDwEyPg2xvBMqNgiBEqJDU9 prGnVSQYyQX5M9NSdCJAp6+QUHLdMSLg3EWFKzLzpLCKt5bKBh/t95JFwalFIbsOodM5 M7T4zsYXuhi8VmouTfpsJdN1Y8i2IgzasXZ1WOB9vwke2FFA2bBJZTK859Vqe3JNh7kx Z7P81bSr8VzLADHTyLKT3KH8/VevN0Ll6ZpkeidiyCIYPM8fWn1URpmcAhTBRqId9ejd jGWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=nFxty090; spf=pass (google.com: domain of gcc-patches-return-458062-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458062-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 91si4043207ply.316.2017.07.13.02.05.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:05:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458062-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=nFxty090; spf=pass (google.com: domain of gcc-patches-return-458062-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458062-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=lH0WYrgfO3mgRyqpKvgefPiQTZTJ1 P0WRvyRPtKPeuVre5iykDby8RHmirIc068+Fxw+IZH9Cm/h7tWgZcohhekk4dLb3 /rTi64Y30IwddtH3lUOowb4YLR+iBzsrZ+Dzfsf0m08hKgUhMUuZ+uGnsV+ay3wz Mub9Es8QFxhNjo= 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=wzBau+cxEGc+Dw28ZiE3rKTSXpk=; b=nFx ty090YDi+/a3NhAmMmxOMJjUpL5uOPF7ZT7st8i60rTh/Zx72VyfBbZ4FdQivtru tnYwbqSjNBxsc5gchA9h9RqLn1hQZiuHypzx8qqCRgjOWpDaBJCoNH1UZJBTWn7o apMsXnrjgvkeSVypGKrRHo7WQOK+pPsGWUZ+gvmc= Received: (qmail 89108 invoked by alias); 13 Jul 2017 09:03:59 -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 87706 invoked by uid 89); 13 Jul 2017 09:03:58 -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-f181.google.com Received: from mail-wr0-f181.google.com (HELO mail-wr0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:03:48 +0000 Received: by mail-wr0-f181.google.com with SMTP id k67so49543531wrc.2 for ; Thu, 13 Jul 2017 02:03:47 -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=tdObLj8jtPjDnq8n5LIhpphulAJxntn0B5hm3OXn6cI=; b=ih5JxEvW+FlJS0iqgZyiVAVQb3Z7/IwlQVd4sspu1aBohLbXdg2rRRDrFWYyQjaiQ+ sNNuTJrpDZwxA1Il8hl73RDsfaowABKYaqZ6yzpD422OBRHl4zijiL/b/AZ2t2sP5PNj QZlDlbbxHyapX6uMK/iQZfMplRX9ByD/5LfxsZs8WFyyv6VYpUCNRqSXHrXMXWfsPSUr 6ao7C3lkZ++0/JeBmwQWitQYAhVc/R6hV/R1AsUdLzSW4ZWrpKjqXwuvI5ItI8nxo+34 DAQXWEvyYkuscdXgrkBHXmDsm38zEH8yhwlqjnIgY5iU2/W8KdpB9x+7NaGulVohGI4S BTTg== X-Gm-Message-State: AIVw110XNqsIWVF2sL8qZwrwyJseOPbhr94ytFk2lPeWg8qhen5sGxv0 K0vG1EiZqXiW8IEgrBo7ZQ== X-Received: by 10.223.145.10 with SMTP id j10mr892574wrj.172.1499936625669; Thu, 13 Jul 2017 02:03:45 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id r200sm4377042wmd.20.2017.07.13.02.03.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:03:44 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [71/77] Use opt_scalar_mode for mode iterators References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:03:43 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87mv88bte8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses opt_scalar_mode when iterating over scalar modes. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (opt_scalar_mode): New typedef. * gdbhooks.py (build_pretty_printers): Handle it. * machmode.h (mode_iterator::get_2xwider): Add overload for opt_mode. * emit-rtl.c (init_emit_once): Use opt_scalar_mode when iterating over scalar modes. * expr.c (convert_mode_scalar): Likewise. * omp-low.c (omp_clause_aligned_alignment): Likewise. * optabs.c (expand_float): Likewise. (expand_fix): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. gcc/c-family/ * c-common.c (c_common_fixed_point_type_for_size): Use opt_scalar_mode for the mode iterator. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:53.271650545 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:56.810392248 +0100 @@ -59,6 +59,7 @@ typedef const struct rtx_def *const_rtx; class scalar_int_mode; class scalar_float_mode; template class opt_mode; +typedef opt_mode opt_scalar_mode; typedef opt_mode opt_scalar_int_mode; typedef opt_mode opt_scalar_float_mode; template class pod_mode; Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:53.273650396 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:56.812392104 +0100 @@ -543,7 +543,8 @@ def build_pretty_printer(): pp.add_printer_for_regex(r'opt_mode<(\S+)>', 'opt_mode', OptMachineModePrinter) pp.add_printer_for_types(['opt_scalar_int_mode', - 'opt_scalar_float_mode'], + 'opt_scalar_float_mode', + 'opt_scalar_mode'], 'opt_mode', OptMachineModePrinter) pp.add_printer_for_regex(r'pod_mode<(\S+)>', 'pod_mode', MachineModePrinter) Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:53.274650323 +0100 +++ gcc/machmode.h 2017-07-13 09:18:56.812392104 +0100 @@ -836,6 +836,13 @@ is_float_mode (machine_mode mode, T *flo /* Set mode iterator *ITER to the mode that is two times wider than the current one, if such a mode exists. */ + template + inline void + get_2xwider (opt_mode *iter) + { + *iter = GET_MODE_2XWIDER_MODE (**iter); + } + inline void get_2xwider (machine_mode *iter) { Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:54.682546579 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:56.811392176 +0100 @@ -5891,6 +5891,7 @@ init_emit_once (void) int i; machine_mode mode; scalar_float_mode double_mode; + opt_scalar_mode smode_iter; /* Initialize the CONST_INT, CONST_WIDE_INT, CONST_DOUBLE, CONST_FIXED, and memory attribute hash tables. */ @@ -6005,62 +6006,66 @@ init_emit_once (void) const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1); } - FOR_EACH_MODE_IN_CLASS (mode, MODE_FRACT) + FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_FRACT) { - FCONST0 (mode).data.high = 0; - FCONST0 (mode).data.low = 0; - FCONST0 (mode).mode = mode; - const_tiny_rtx[0][(int) mode] = CONST_FIXED_FROM_FIXED_VALUE ( - FCONST0 (mode), mode); - } - - FOR_EACH_MODE_IN_CLASS (mode, MODE_UFRACT) - { - FCONST0 (mode).data.high = 0; - FCONST0 (mode).data.low = 0; - FCONST0 (mode).mode = mode; - const_tiny_rtx[0][(int) mode] = CONST_FIXED_FROM_FIXED_VALUE ( - FCONST0 (mode), mode); - } - - FOR_EACH_MODE_IN_CLASS (mode, MODE_ACCUM) - { - FCONST0 (mode).data.high = 0; - FCONST0 (mode).data.low = 0; - FCONST0 (mode).mode = mode; - const_tiny_rtx[0][(int) mode] = CONST_FIXED_FROM_FIXED_VALUE ( - FCONST0 (mode), mode); + scalar_mode smode = *smode_iter; + FCONST0 (smode).data.high = 0; + FCONST0 (smode).data.low = 0; + FCONST0 (smode).mode = smode; + const_tiny_rtx[0][(int) smode] + = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode); + } + + FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_UFRACT) + { + scalar_mode smode = *smode_iter; + FCONST0 (smode).data.high = 0; + FCONST0 (smode).data.low = 0; + FCONST0 (smode).mode = smode; + const_tiny_rtx[0][(int) smode] + = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode); + } + + FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_ACCUM) + { + scalar_mode smode = *smode_iter; + FCONST0 (smode).data.high = 0; + FCONST0 (smode).data.low = 0; + FCONST0 (smode).mode = smode; + const_tiny_rtx[0][(int) smode] + = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode); /* We store the value 1. */ - FCONST1 (mode).data.high = 0; - FCONST1 (mode).data.low = 0; - FCONST1 (mode).mode = mode; - FCONST1 (mode).data - = double_int_one.lshift (GET_MODE_FBIT (mode), + FCONST1 (smode).data.high = 0; + FCONST1 (smode).data.low = 0; + FCONST1 (smode).mode = smode; + FCONST1 (smode).data + = double_int_one.lshift (GET_MODE_FBIT (smode), HOST_BITS_PER_DOUBLE_INT, - SIGNED_FIXED_POINT_MODE_P (mode)); - const_tiny_rtx[1][(int) mode] = CONST_FIXED_FROM_FIXED_VALUE ( - FCONST1 (mode), mode); + SIGNED_FIXED_POINT_MODE_P (smode)); + const_tiny_rtx[1][(int) smode] + = CONST_FIXED_FROM_FIXED_VALUE (FCONST1 (smode), smode); } - FOR_EACH_MODE_IN_CLASS (mode, MODE_UACCUM) - { - FCONST0 (mode).data.high = 0; - FCONST0 (mode).data.low = 0; - FCONST0 (mode).mode = mode; - const_tiny_rtx[0][(int) mode] = CONST_FIXED_FROM_FIXED_VALUE ( - FCONST0 (mode), mode); + FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_UACCUM) + { + scalar_mode smode = *smode_iter; + FCONST0 (smode).data.high = 0; + FCONST0 (smode).data.low = 0; + FCONST0 (smode).mode = smode; + const_tiny_rtx[0][(int) smode] + = CONST_FIXED_FROM_FIXED_VALUE (FCONST0 (smode), smode); /* We store the value 1. */ - FCONST1 (mode).data.high = 0; - FCONST1 (mode).data.low = 0; - FCONST1 (mode).mode = mode; - FCONST1 (mode).data - = double_int_one.lshift (GET_MODE_FBIT (mode), + FCONST1 (smode).data.high = 0; + FCONST1 (smode).data.low = 0; + FCONST1 (smode).mode = smode; + FCONST1 (smode).data + = double_int_one.lshift (GET_MODE_FBIT (smode), HOST_BITS_PER_DOUBLE_INT, - SIGNED_FIXED_POINT_MODE_P (mode)); - const_tiny_rtx[1][(int) mode] = CONST_FIXED_FROM_FIXED_VALUE ( - FCONST1 (mode), mode); + SIGNED_FIXED_POINT_MODE_P (smode)); + const_tiny_rtx[1][(int) smode] + = CONST_FIXED_FROM_FIXED_VALUE (FCONST1 (smode), smode); } FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FRACT) @@ -6093,10 +6098,11 @@ init_emit_once (void) if (STORE_FLAG_VALUE == 1) const_tiny_rtx[1][(int) BImode] = const1_rtx; - FOR_EACH_MODE_IN_CLASS (mode, MODE_POINTER_BOUNDS) + FOR_EACH_MODE_IN_CLASS (smode_iter, MODE_POINTER_BOUNDS) { - wide_int wi_zero = wi::zero (GET_MODE_PRECISION (mode)); - const_tiny_rtx[0][mode] = immed_wide_int_const (wi_zero, mode); + scalar_mode smode = *smode_iter; + wide_int wi_zero = wi::zero (GET_MODE_PRECISION (smode)); + const_tiny_rtx[0][smode] = immed_wide_int_const (wi_zero, smode); } pc_rtx = gen_rtx_fmt_ (PC, VOIDmode); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:56.007450082 +0100 +++ gcc/expr.c 2017-07-13 09:18:56.812392104 +0100 @@ -559,23 +559,28 @@ convert_mode_scalar (rtx to, rtx from, i } else { - machine_mode intermediate; + scalar_mode intermediate; rtx tmp; int shift_amount; /* Search for a mode to convert via. */ - FOR_EACH_MODE_FROM (intermediate, from_mode) - if (((can_extend_p (to_mode, intermediate, unsignedp) - != CODE_FOR_nothing) - || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate) - && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, intermediate))) - && (can_extend_p (intermediate, from_mode, unsignedp) - != CODE_FOR_nothing)) - { - convert_move (to, convert_to_mode (intermediate, from, - unsignedp), unsignedp); - return; - } + opt_scalar_mode intermediate_iter; + FOR_EACH_MODE_FROM (intermediate_iter, from_mode) + { + scalar_mode intermediate = *intermediate_iter; + if (((can_extend_p (to_mode, intermediate, unsignedp) + != CODE_FOR_nothing) + || (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (intermediate) + && TRULY_NOOP_TRUNCATION_MODES_P (to_mode, + intermediate))) + && (can_extend_p (intermediate, from_mode, unsignedp) + != CODE_FOR_nothing)) + { + convert_move (to, convert_to_mode (intermediate, from, + unsignedp), unsignedp); + return; + } + } /* No suitable intermediate mode. Generate what we need with shifts. */ Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c 2017-07-13 09:18:22.933278054 +0100 +++ gcc/omp-low.c 2017-07-13 09:18:56.813392032 +0100 @@ -3438,16 +3438,18 @@ omp_clause_aligned_alignment (tree claus /* Otherwise return implementation defined alignment. */ unsigned int al = 1; - machine_mode mode, vmode; + opt_scalar_mode mode_iter; int vs = targetm.vectorize.autovectorize_vector_sizes (); if (vs) vs = 1 << floor_log2 (vs); static enum mode_class classes[] = { MODE_INT, MODE_VECTOR_INT, MODE_FLOAT, MODE_VECTOR_FLOAT }; for (int i = 0; i < 4; i += 2) - FOR_EACH_MODE_IN_CLASS (mode, classes[i]) + /* The for loop above dictates that we only walk through scalar classes. */ + FOR_EACH_MODE_IN_CLASS (mode_iter, classes[i]) { - vmode = targetm.vectorize.preferred_simd_mode (mode); + scalar_mode mode = *mode_iter; + machine_mode vmode = targetm.vectorize.preferred_simd_mode (mode); if (GET_MODE_CLASS (vmode) != classes[i + 1]) continue; while (vs Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:56.346425666 +0100 +++ gcc/optabs.c 2017-07-13 09:18:56.813392032 +0100 @@ -4690,6 +4690,7 @@ expand_float (rtx to, rtx from, int unsi && is_a (GET_MODE (to), &to_mode) && is_a (GET_MODE (from), &from_mode)) { + opt_scalar_mode fmode_iter; rtx_code_label *label = gen_label_rtx (); rtx temp; REAL_VALUE_TYPE offset; @@ -4698,12 +4699,14 @@ expand_float (rtx to, rtx from, int unsi least as wide as the target. Using FMODE will avoid rounding woes with unsigned values greater than the signed maximum value. */ - FOR_EACH_MODE_FROM (fmode, to_mode) - if (GET_MODE_PRECISION (from_mode) < GET_MODE_BITSIZE (fmode) - && can_float_p (fmode, from_mode, 0) != CODE_FOR_nothing) + FOR_EACH_MODE_FROM (fmode_iter, to_mode) + if (GET_MODE_PRECISION (from_mode) < GET_MODE_BITSIZE (*fmode_iter) + && can_float_p (*fmode_iter, from_mode, 0) != CODE_FOR_nothing) break; - if (fmode == VOIDmode) + if (fmode_iter.exists ()) + fmode = *fmode_iter; + else { /* There is no such mode. Pretend the target is wide enough. */ fmode = to_mode; @@ -4838,6 +4841,7 @@ expand_fix (rtx to, rtx from, int unsign enum insn_code icode; rtx target = to; machine_mode fmode, imode; + opt_scalar_mode fmode_iter; bool must_trunc = false; /* We first try to find a pair of modes, one real and one integer, at @@ -4909,66 +4913,70 @@ expand_fix (rtx to, rtx from, int unsign if (unsignedp && is_a (GET_MODE (to), &to_mode) && HWI_COMPUTABLE_MODE_P (to_mode)) - FOR_EACH_MODE_FROM (fmode, GET_MODE (from)) - if (CODE_FOR_nothing != can_fix_p (to_mode, fmode, 0, &must_trunc) - && (!DECIMAL_FLOAT_MODE_P (fmode) - || GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (to_mode))) - { - int bitsize; - REAL_VALUE_TYPE offset; - rtx limit; - rtx_code_label *lab1, *lab2; - rtx_insn *insn; - - bitsize = GET_MODE_PRECISION (to_mode); - real_2expN (&offset, bitsize - 1, fmode); - limit = const_double_from_real_value (offset, fmode); - lab1 = gen_label_rtx (); - lab2 = gen_label_rtx (); - - if (fmode != GET_MODE (from)) - from = convert_to_mode (fmode, from, 0); - - /* See if we need to do the subtraction. */ - do_pending_stack_adjust (); - emit_cmp_and_jump_insns (from, limit, GE, NULL_RTX, GET_MODE (from), - 0, lab1); - - /* If not, do the signed "fix" and branch around fixup code. */ - expand_fix (to, from, 0); - emit_jump_insn (targetm.gen_jump (lab2)); - emit_barrier (); - - /* Otherwise, subtract 2**(N-1), convert to signed number, - then add 2**(N-1). Do the addition using XOR since this - will often generate better code. */ - emit_label (lab1); - target = expand_binop (GET_MODE (from), sub_optab, from, limit, - NULL_RTX, 0, OPTAB_LIB_WIDEN); - expand_fix (to, target, 0); - target = expand_binop (to_mode, xor_optab, to, - gen_int_mode - (HOST_WIDE_INT_1 << (bitsize - 1), - to_mode), - to, 1, OPTAB_LIB_WIDEN); + FOR_EACH_MODE_FROM (fmode_iter, as_a (GET_MODE (from))) + { + scalar_mode fmode = *fmode_iter; + if (CODE_FOR_nothing != can_fix_p (to_mode, fmode, + 0, &must_trunc) + && (!DECIMAL_FLOAT_MODE_P (fmode) + || (GET_MODE_BITSIZE (fmode) > GET_MODE_PRECISION (to_mode)))) + { + int bitsize; + REAL_VALUE_TYPE offset; + rtx limit; + rtx_code_label *lab1, *lab2; + rtx_insn *insn; + + bitsize = GET_MODE_PRECISION (to_mode); + real_2expN (&offset, bitsize - 1, fmode); + limit = const_double_from_real_value (offset, fmode); + lab1 = gen_label_rtx (); + lab2 = gen_label_rtx (); - if (target != to) - emit_move_insn (to, target); + if (fmode != GET_MODE (from)) + from = convert_to_mode (fmode, from, 0); - emit_label (lab2); + /* See if we need to do the subtraction. */ + do_pending_stack_adjust (); + emit_cmp_and_jump_insns (from, limit, GE, NULL_RTX, + GET_MODE (from), 0, lab1); + + /* If not, do the signed "fix" and branch around fixup code. */ + expand_fix (to, from, 0); + emit_jump_insn (targetm.gen_jump (lab2)); + emit_barrier (); + + /* Otherwise, subtract 2**(N-1), convert to signed number, + then add 2**(N-1). Do the addition using XOR since this + will often generate better code. */ + emit_label (lab1); + target = expand_binop (GET_MODE (from), sub_optab, from, limit, + NULL_RTX, 0, OPTAB_LIB_WIDEN); + expand_fix (to, target, 0); + target = expand_binop (to_mode, xor_optab, to, + gen_int_mode + (HOST_WIDE_INT_1 << (bitsize - 1), + to_mode), + to, 1, OPTAB_LIB_WIDEN); - if (optab_handler (mov_optab, to_mode) != CODE_FOR_nothing) - { - /* Make a place for a REG_NOTE and add it. */ - insn = emit_move_insn (to, to); - set_dst_reg_note (insn, REG_EQUAL, - gen_rtx_fmt_e (UNSIGNED_FIX, to_mode, - copy_rtx (from)), - to); - } + if (target != to) + emit_move_insn (to, target); - return; - } + emit_label (lab2); + + if (optab_handler (mov_optab, to_mode) != CODE_FOR_nothing) + { + /* Make a place for a REG_NOTE and add it. */ + insn = emit_move_insn (to, to); + set_dst_reg_note (insn, REG_EQUAL, + gen_rtx_fmt_e (UNSIGNED_FIX, to_mode, + copy_rtx (from)), + to); + } + + return; + } + } /* We can't do it with an insn, so use a library call. But first ensure that the mode of TO is at least as wide as SImode, since those are the Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-13 09:18:55.599479728 +0100 +++ gcc/tree-vect-stmts.c 2017-07-13 09:18:56.814391960 +0100 @@ -4195,8 +4195,10 @@ vectorizable_conversion (gimple *stmt, g needs to be generated. */ gcc_assert (ncopies >= 1); - machine_mode lhs_mode = SCALAR_TYPE_MODE (lhs_type); - machine_mode rhs_mode = SCALAR_TYPE_MODE (rhs_type); + bool found_mode = false; + scalar_mode lhs_mode = SCALAR_TYPE_MODE (lhs_type); + scalar_mode rhs_mode = SCALAR_TYPE_MODE (rhs_type); + opt_scalar_mode rhs_mode_iter; /* Supportable by target? */ switch (modifier) @@ -4230,8 +4232,9 @@ vectorizable_conversion (gimple *stmt, g goto unsupported; fltsz = GET_MODE_SIZE (lhs_mode); - FOR_EACH_2XWIDER_MODE (rhs_mode, rhs_mode) + FOR_EACH_2XWIDER_MODE (rhs_mode_iter, rhs_mode) { + rhs_mode = *rhs_mode_iter; if (GET_MODE_SIZE (rhs_mode) > fltsz) break; @@ -4258,10 +4261,13 @@ vectorizable_conversion (gimple *stmt, g if (supportable_widening_operation (NOP_EXPR, stmt, cvt_type, vectype_in, &code1, &code2, &multi_step_cvt, &interm_types)) - break; + { + found_mode = true; + break; + } } - if (rhs_mode == VOIDmode || GET_MODE_SIZE (rhs_mode) > fltsz) + if (!found_mode) goto unsupported; if (GET_MODE_SIZE (rhs_mode) == fltsz) Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c 2017-07-13 09:18:53.993597112 +0100 +++ gcc/c-family/c-common.c 2017-07-13 09:18:56.810392248 +0100 @@ -2155,12 +2155,12 @@ c_common_fixed_point_type_for_size (unsi else mclass = unsignedp ? MODE_UACCUM : MODE_ACCUM; - machine_mode mode; + opt_scalar_mode mode; FOR_EACH_MODE_IN_CLASS (mode, mclass) - if (GET_MODE_IBIT (mode) >= ibit && GET_MODE_FBIT (mode) >= fbit) + if (GET_MODE_IBIT (*mode) >= ibit && GET_MODE_FBIT (*mode) >= fbit) break; - if (mode == VOIDmode || !targetm.scalar_mode_supported_p (mode)) + if (!mode.exists () || !targetm.scalar_mode_supported_p (*mode)) { sorry ("GCC cannot support operators with integer types and " "fixed-point types that have too many integral and " @@ -2168,7 +2168,7 @@ c_common_fixed_point_type_for_size (unsi return NULL_TREE; } - return c_common_type_for_mode (mode, satp); + return c_common_type_for_mode (*mode, satp); } /* Used for communication between c_common_type_for_mode and From patchwork Thu Jul 13 09:04:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107658 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1946215qge; Thu, 13 Jul 2017 02:06:08 -0700 (PDT) X-Received: by 10.84.130.108 with SMTP id 99mr8757571plc.76.1499936768824; Thu, 13 Jul 2017 02:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936768; cv=none; d=google.com; s=arc-20160816; b=hAWaS56U66C6rH7hJYe/MryYTw1ovbIY/latSbNdmxBg0uJ5UAXT+YbgAnPyZp2RPG C2yUQi1zYXOER6jCfhgmd00Vo9D6zSJPBEjzAsvBnJaMnmRPbs8uolu2vRbQjmIYfyVP GNpcXMP2CiUJ7KVBfuUkje3Tbt8mFg4Yysdv4G6TdMTzsu71VD4QY0ROnPnVAuHbf+L+ RWYjSRS7MRWzcT8kEIHmwijiteiRV3sc5GYlOqpFTYeqn/E2sZI3D6t5K5I4QXZcTYWR cpk24yvJibZuBxgDQ4CEQRgGOpQLLslf6fztUAPKx5hUOw0mE7ENgUuhCIZdvJ4lHJeR Ouiw== 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=nKd9HoriJEq1gTHm/foalKEkdzEwwx/ZeTc83v/vCps=; b=04CV+qUhqmiApIKSFHAjr9kNNaBQ/SdQGsIm0XHldVMVD4bw2GGzTEMoinJG0S6ToU Fa9Ucq0RfwlXb3DqmL3Lw+RdphwJC8O6QwpffkMDiMAf7yK1rrLpQMZ26vHLhTiVMa1P AkM8O0ZnhHyHp6k7rVTMzeqw2NDbjqinGKEhUfuxgBgSwECMdRObJkSr1Y6cLYfeAGy/ OL2oaJWyLFFb5fLkIQgguCZSSwgASQmwT1C3zU2wpjuOV9BFilXpO45+z84KwhBCdu+3 vE4BeX5YNj2X5Q33lcjOVkJ9njs/YB9+axGK/sq2pB0lkislh/T02nanQr2rLrGA4l6v Ueyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=D/WWcETA; spf=pass (google.com: domain of gcc-patches-return-458063-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458063-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 u12si3848930pgq.520.2017.07.13.02.06.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458063-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=D/WWcETA; spf=pass (google.com: domain of gcc-patches-return-458063-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458063-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=aeGaCoagd+7MMaunzHJyZgAAFMWYT HdJtRitSLOh3RaeqjmX5e/te5q2uORwd92e+ihlimlMrqHeXCQfN8Wgnr9W/WR2a N9TWW7j/mBjlFrcmXVy21GqxFp7WUF9DS1CXDxqK1fgv7faaKfnbLwWb1acdt2Jv 89/onQSTvNCKYU= 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=WZpebzm9bCPKLLWIoi9Ss1cXXfQ=; b=D/W WcETAgvsI9MN0axM7kBSu0VX0Py/Q/z+UTNwtJtOBDcewhkinGvhpFcZ/ChXOPqs 8onp4z9UJt5YJJJ/edSC5g5wVcur05S2TaFe/KwZbCk8RHP7ckxUmfTkVNJPr6SQ S2r33SGTg9PhCxmcYu39niKQ6FeAQry/OJV9Bp1s= Received: (qmail 114848 invoked by alias); 13 Jul 2017 09:04:16 -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 113841 invoked by uid 89); 13 Jul 2017 09:04:15 -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-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:04:09 +0000 Received: by mail-wm0-f45.google.com with SMTP id i127so18613299wma.0 for ; Thu, 13 Jul 2017 02:04:09 -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=nKd9HoriJEq1gTHm/foalKEkdzEwwx/ZeTc83v/vCps=; b=T0dkhOlSg56cUEQNDT+JH5Di1jmjoqVJI9NCwZlBmhNUc/y5z+79ew9pzgRF8SiLmh GwBlLJgr158kaLVSWJ96rtxRUnWBipvEofpQv9HXBvR+xME7BKwKCN71ED90Pjo73SN0 2lJ9yyAbyytaFHjvFKsyrnhKtmqo44mfv6xr54uVSUCTjCkhTxCkRyNLR1NFOcz6aN3n 0xUZjCSa3IxYao7TgJnMAnL+Pf+0WZyTmBi+b1JuNfuoomMGI01/fsOsCkvvO4d8KetJ RDYkGkU4ePj5JkPsP08/yDrB8PN4ON8m24s1qFDho4GchpTtCTmJyzJQO1ia+ztcetar aLeg== X-Gm-Message-State: AIVw1134P/tJvCUwwq0JfUkbARHrA7t13UuM3b4+mSlfg8SYj2MK4oyO QHL3UvdsaaoAXc+kMPoOOQ== X-Received: by 10.28.175.135 with SMTP id y129mr1139425wme.87.1499936646866; Thu, 13 Jul 2017 02:04:06 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id f45sm7244049wrf.2.2017.07.13.02.04.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:04:06 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [72/77] Pass scalar_mode to scalar_mode_supported_p References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:04:05 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87iniwbtdm.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the scalar_mode_supported_p target hook take a scalar_mode rather than a machine_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * target.def (scalar_mode_supported_p): Take a scalar_mode instead of a machine_mode. * targhooks.h (default_scalar_mode_supported_p): Likewise. * targhooks.c (default_scalar_mode_supported_p): Likewise. * config/aarch64/aarch64.c (aarch64_scalar_mode_supported_p): Likewise. * config/alpha/alpha.c (alpha_scalar_mode_supported_p): Likewise. * config/arm/arm.c (arm_scalar_mode_supported_p): Likewise. * config/avr/avr.c (avr_scalar_mode_supported_p): Likewise. * config/c6x/c6x.c (c6x_scalar_mode_supported_p): Likewise. * config/i386/i386.c (ix86_scalar_mode_supported_p): Likewise. * config/ia64/ia64.c (ia64_scalar_mode_supported_p): Likewise. * config/mips/mips.c (mips_scalar_mode_supported_p): Likewise. * config/msp430/msp430.c (msp430_scalar_mode_supported_p): Likewise. * config/pa/pa.c (pa_scalar_mode_supported_p): Likewise. * config/pdp11/pdp11.c (pdp11_scalar_mode_supported_p): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_scalar_mode_supported_p): Likewise. * config/rs6000/rs6000.c (rs6000_scalar_mode_supported_p): Likewise. * config/s390/s390.c (s390_scalar_mode_supported_p): Likewise. * config/spu/spu.c (spu_scalar_mode_supported_p): Likewise. * config/tilegx/tilegx.c (tilegx_scalar_mode_supported_p): Likewise. * config/tilepro/tilepro.c (tilepro_scalar_mode_supported_p): Likewise. * doc/tm.texi: Regenerate. gcc/c-family/ * c-attribs.c (vector_mode_valid_p) Fold GET_MODE_INNER call into scalar_mode_supported_p call. (handle_mode_attribute): Update call to scalar_mode_supported_p. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-07-13 09:18:51.667770394 +0100 +++ gcc/target.def 2017-07-13 09:18:57.574337591 +0100 @@ -3304,7 +3304,7 @@ The default version of this hook returns required to handle the basic C types (as defined by the port).\n\ Included here are the double-word arithmetic supported by the\n\ code in @file{optabs.c}.", - bool, (machine_mode mode), + bool, (scalar_mode mode), default_scalar_mode_supported_p) /* Similarly for vector modes. "Supported" here is less strict. At Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-07-13 09:18:51.668770318 +0100 +++ gcc/targhooks.h 2017-07-13 09:18:57.575337520 +0100 @@ -71,7 +71,7 @@ extern void default_print_operand_addres extern bool default_print_operand_punct_valid_p (unsigned char); extern tree default_mangle_assembler_name (const char *); -extern bool default_scalar_mode_supported_p (machine_mode); +extern bool default_scalar_mode_supported_p (scalar_mode); extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode); extern opt_scalar_float_mode default_floatn_mode (int, bool); extern bool targhook_words_big_endian (void); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:51.667770394 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:57.574337591 +0100 @@ -394,7 +394,7 @@ default_mangle_assembler_name (const cha supported by optabs.c. */ bool -default_scalar_mode_supported_p (machine_mode mode) +default_scalar_mode_supported_p (scalar_mode mode) { int precision = GET_MODE_PRECISION (mode); Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:51.583776726 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:57.498343016 +0100 @@ -15053,7 +15053,7 @@ aarch64_libgcc_floating_mode_supported_p if MODE is HFmode, and punt to the generic implementation otherwise. */ static bool -aarch64_scalar_mode_supported_p (machine_mode mode) +aarch64_scalar_mode_supported_p (scalar_mode mode) { return (mode == HFmode ? true Index: gcc/config/alpha/alpha.c =================================================================== --- gcc/config/alpha/alpha.c 2017-07-13 09:18:51.585776575 +0100 +++ gcc/config/alpha/alpha.c 2017-07-13 09:18:57.499342945 +0100 @@ -688,7 +688,7 @@ resolve_reload_operand (rtx op) indicates only DFmode. */ static bool -alpha_scalar_mode_supported_p (machine_mode mode) +alpha_scalar_mode_supported_p (scalar_mode mode) { switch (mode) { Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-13 09:18:30.892502525 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:57.510342160 +0100 @@ -256,7 +256,7 @@ static bool arm_output_addr_const_extra static bool arm_allocate_stack_slots_for_args (void); static bool arm_warn_func_return (tree); static tree arm_promoted_type (const_tree t); -static bool arm_scalar_mode_supported_p (machine_mode); +static bool arm_scalar_mode_supported_p (scalar_mode); static bool arm_frame_pointer_required (void); static bool arm_can_eliminate (const int, const int); static void arm_asm_trampoline_template (FILE *); @@ -23598,7 +23598,7 @@ arm_promoted_type (const_tree t) special-cased in the default hook. */ static bool -arm_scalar_mode_supported_p (machine_mode mode) +arm_scalar_mode_supported_p (scalar_mode mode) { if (mode == HFmode) return (arm_fp16_format != ARM_FP16_FORMAT_NONE); Index: gcc/config/avr/avr.c =================================================================== --- gcc/config/avr/avr.c 2017-07-13 09:18:55.158511776 +0100 +++ gcc/config/avr/avr.c 2017-07-13 09:18:57.511342088 +0100 @@ -882,7 +882,7 @@ avr_regno_reg_class (int r) /* Implement `TARGET_SCALAR_MODE_SUPPORTED_P'. */ static bool -avr_scalar_mode_supported_p (machine_mode mode) +avr_scalar_mode_supported_p (scalar_mode mode) { if (ALL_FIXED_POINT_MODE_P (mode)) return true; Index: gcc/config/c6x/c6x.c =================================================================== --- gcc/config/c6x/c6x.c 2017-07-13 09:18:22.915279989 +0100 +++ gcc/config/c6x/c6x.c 2017-07-13 09:18:57.512342017 +0100 @@ -6255,7 +6255,7 @@ c6x_preferred_simd_mode (machine_mode mo /* Implement TARGET_SCALAR_MODE_SUPPORTED_P. */ static bool -c6x_scalar_mode_supported_p (machine_mode mode) +c6x_scalar_mode_supported_p (scalar_mode mode) { if (ALL_FIXED_POINT_MODE_P (mode) && GET_MODE_PRECISION (mode) <= 2 * BITS_PER_WORD) Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-07-13 09:18:30.896502154 +0100 +++ gcc/config/i386/i386.c 2017-07-13 09:18:57.530340732 +0100 @@ -45064,7 +45064,7 @@ ix86_expand_reduc (rtx (*fn) (rtx, rtx, /* Target hook for scalar_mode_supported_p. */ static bool -ix86_scalar_mode_supported_p (machine_mode mode) +ix86_scalar_mode_supported_p (scalar_mode mode) { if (DECIMAL_FLOAT_MODE_P (mode)) return default_decimal_float_supported_p (); Index: gcc/config/ia64/ia64.c =================================================================== --- gcc/config/ia64/ia64.c 2017-07-13 09:18:51.593775972 +0100 +++ gcc/config/ia64/ia64.c 2017-07-13 09:18:57.531340661 +0100 @@ -309,7 +309,7 @@ static tree ia64_handle_version_id_attri static void ia64_encode_section_info (tree, rtx, int); static rtx ia64_struct_value_rtx (tree, int); static tree ia64_gimplify_va_arg (tree, tree, gimple_seq *, gimple_seq *); -static bool ia64_scalar_mode_supported_p (machine_mode mode); +static bool ia64_scalar_mode_supported_p (scalar_mode mode); static bool ia64_vector_mode_supported_p (machine_mode mode); static bool ia64_legitimate_constant_p (machine_mode, rtx); static bool ia64_legitimate_address_p (machine_mode, rtx, bool); @@ -10963,7 +10963,7 @@ ia64_struct_value_rtx (tree fntype, } static bool -ia64_scalar_mode_supported_p (machine_mode mode) +ia64_scalar_mode_supported_p (scalar_mode mode) { switch (mode) { Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2017-07-13 09:18:51.603775218 +0100 +++ gcc/config/mips/mips.c 2017-07-13 09:18:57.535340375 +0100 @@ -13312,7 +13312,7 @@ mips_vector_mode_supported_p (machine_mo /* Implement TARGET_SCALAR_MODE_SUPPORTED_P. */ static bool -mips_scalar_mode_supported_p (machine_mode mode) +mips_scalar_mode_supported_p (scalar_mode mode) { if (ALL_FIXED_POINT_MODE_P (mode) && GET_MODE_PRECISION (mode) <= 2 * BITS_PER_WORD) Index: gcc/config/msp430/msp430.c =================================================================== --- gcc/config/msp430/msp430.c 2017-07-13 09:18:51.603775218 +0100 +++ gcc/config/msp430/msp430.c 2017-07-13 09:18:57.535340375 +0100 @@ -870,7 +870,7 @@ msp430_option_override (void) #define TARGET_SCALAR_MODE_SUPPORTED_P msp430_scalar_mode_supported_p static bool -msp430_scalar_mode_supported_p (machine_mode m) +msp430_scalar_mode_supported_p (scalar_mode m) { if (m == PSImode && msp430x) return true; Index: gcc/config/pa/pa.c =================================================================== --- gcc/config/pa/pa.c 2017-07-13 09:18:19.085698082 +0100 +++ gcc/config/pa/pa.c 2017-07-13 09:18:57.536340304 +0100 @@ -142,7 +142,7 @@ static rtx pa_expand_builtin (tree, rtx, static rtx hppa_builtin_saveregs (void); static void hppa_va_start (tree, rtx); static tree hppa_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *); -static bool pa_scalar_mode_supported_p (machine_mode); +static bool pa_scalar_mode_supported_p (scalar_mode); static bool pa_commutative_p (const_rtx x, int outer_code); static void copy_fp_args (rtx_insn *) ATTRIBUTE_UNUSED; static int length_fp_args (rtx_insn *) ATTRIBUTE_UNUSED; @@ -6424,7 +6424,7 @@ hppa_gimplify_va_arg_expr (tree valist, 2 * BITS_PER_WORD isn't equal LONG_LONG_TYPE_SIZE. */ static bool -pa_scalar_mode_supported_p (machine_mode mode) +pa_scalar_mode_supported_p (scalar_mode mode) { int precision = GET_MODE_PRECISION (mode); Index: gcc/config/pdp11/pdp11.c =================================================================== --- gcc/config/pdp11/pdp11.c 2017-02-23 19:54:22.000000000 +0000 +++ gcc/config/pdp11/pdp11.c 2017-07-13 09:18:57.537340232 +0100 @@ -160,7 +160,7 @@ static void pdp11_function_arg_advance ( static void pdp11_conditional_register_usage (void); static bool pdp11_legitimate_constant_p (machine_mode, rtx); -static bool pdp11_scalar_mode_supported_p (machine_mode); +static bool pdp11_scalar_mode_supported_p (scalar_mode); /* Initialize the GCC target structure. */ #undef TARGET_ASM_BYTE_OP @@ -1909,7 +1909,7 @@ pdp11_legitimate_constant_p (machine_mod /* Implement TARGET_SCALAR_MODE_SUPPORTED_P. */ static bool -pdp11_scalar_mode_supported_p (machine_mode mode) +pdp11_scalar_mode_supported_p (scalar_mode mode) { /* Support SFmode even with -mfloat64. */ if (mode == SFmode) Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:51.616774238 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:57.550339304 +0100 @@ -39158,7 +39158,7 @@ rs6000_eh_return_filter_mode (void) /* Target hook for scalar_mode_supported_p. */ static bool -rs6000_scalar_mode_supported_p (machine_mode mode) +rs6000_scalar_mode_supported_p (scalar_mode mode) { /* -m32 does not support TImode. This is the default, from default_scalar_mode_supported_p. For -m32 -mpowerpc64 we want the Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:51.625773559 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:57.559338662 +0100 @@ -36162,7 +36162,7 @@ rs6000_eh_return_filter_mode (void) /* Target hook for scalar_mode_supported_p. */ static bool -rs6000_scalar_mode_supported_p (machine_mode mode) +rs6000_scalar_mode_supported_p (scalar_mode mode) { /* -m32 does not support TImode. This is the default, from default_scalar_mode_supported_p. For -m32 -mpowerpc64 we want the Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:51.628773334 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:57.563338376 +0100 @@ -1225,7 +1225,7 @@ s390_unwind_word_mode (void) /* Return true if the back end supports mode MODE. */ static bool -s390_scalar_mode_supported_p (machine_mode mode) +s390_scalar_mode_supported_p (scalar_mode mode) { /* In contrast to the default implementation reject TImode constants on 31bit TARGET_ZARCH for ABI compliance. */ Index: gcc/config/spu/spu.c =================================================================== --- gcc/config/spu/spu.c 2017-07-13 09:18:51.630773183 +0100 +++ gcc/config/spu/spu.c 2017-07-13 09:18:57.565338234 +0100 @@ -287,7 +287,7 @@ spu_option_override (void) be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. */ static bool -spu_scalar_mode_supported_p (machine_mode mode) +spu_scalar_mode_supported_p (scalar_mode mode) { switch (mode) { Index: gcc/config/tilegx/tilegx.c =================================================================== --- gcc/config/tilegx/tilegx.c 2017-07-13 09:18:51.632773032 +0100 +++ gcc/config/tilegx/tilegx.c 2017-07-13 09:18:57.566338162 +0100 @@ -106,7 +106,7 @@ tilegx_option_override (void) /* Implement TARGET_SCALAR_MODE_SUPPORTED_P. */ static bool -tilegx_scalar_mode_supported_p (machine_mode mode) +tilegx_scalar_mode_supported_p (scalar_mode mode) { switch (mode) { Index: gcc/config/tilepro/tilepro.c =================================================================== --- gcc/config/tilepro/tilepro.c 2017-07-13 09:18:19.139692095 +0100 +++ gcc/config/tilepro/tilepro.c 2017-07-13 09:18:57.568338020 +0100 @@ -83,7 +83,7 @@ tilepro_option_override (void) /* Implement TARGET_SCALAR_MODE_SUPPORTED_P. */ static bool -tilepro_scalar_mode_supported_p (machine_mode mode) +tilepro_scalar_mode_supported_p (scalar_mode mode) { switch (mode) { Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-07-13 09:18:51.636772730 +0100 +++ gcc/doc/tm.texi 2017-07-13 09:18:57.571337806 +0100 @@ -4213,7 +4213,7 @@ hook returns true for both @code{ptr_mod Define this to return nonzero if the memory reference @var{ref} may alias with the system C library errno location. The default version of this hook assumes the system C library errno location is either a declaration of type int or accessed by dereferencing a pointer to int. @end deftypefn -@deftypefn {Target Hook} bool TARGET_SCALAR_MODE_SUPPORTED_P (machine_mode @var{mode}) +@deftypefn {Target Hook} bool TARGET_SCALAR_MODE_SUPPORTED_P (scalar_mode @var{mode}) Define this to return nonzero if the port is prepared to handle insns involving scalar mode @var{mode}. For a scalar mode to be considered supported, all the basic arithmetic and comparisons Index: gcc/c-family/c-attribs.c =================================================================== --- gcc/c-family/c-attribs.c 2017-07-13 09:18:37.622901759 +0100 +++ gcc/c-family/c-attribs.c 2017-07-13 09:18:57.494343302 +0100 @@ -1308,7 +1308,6 @@ handle_destructor_attribute (tree *node, vector_mode_valid_p (machine_mode mode) { enum mode_class mclass = GET_MODE_CLASS (mode); - machine_mode innermode; /* Doh! What's going on? */ if (mclass != MODE_VECTOR_INT @@ -1323,14 +1322,12 @@ vector_mode_valid_p (machine_mode mode) if (targetm.vector_mode_supported_p (mode)) return true; - innermode = GET_MODE_INNER (mode); - /* We should probably return 1 if requesting V4DI and we have no DI, but we have V2DI, but this is probably very unlikely. */ /* If we have support for the inner mode, we can safely emulate it. We may not have V2DI, but me can emulate with a pair of DIs. */ - return targetm.scalar_mode_supported_p (innermode); + return targetm.scalar_mode_supported_p (GET_MODE_INNER (mode)); } @@ -1406,7 +1403,8 @@ handle_mode_attribute (tree *node, tree case MODE_UFRACT: case MODE_ACCUM: case MODE_UACCUM: - valid_mode = targetm.scalar_mode_supported_p (mode); + valid_mode + = targetm.scalar_mode_supported_p (as_a (mode)); break; case MODE_COMPLEX_INT: From patchwork Thu Jul 13 09:04:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107659 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1946858qge; Thu, 13 Jul 2017 02:06:46 -0700 (PDT) X-Received: by 10.98.90.69 with SMTP id o66mr59686010pfb.222.1499936805955; Thu, 13 Jul 2017 02:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936805; cv=none; d=google.com; s=arc-20160816; b=o9AqCVLHqmQdqa9DICmqjaB65Hm2nBwEqMQXmjGsOXw6aLJgxsawtnbNm6n3yFMGqe HZ7HRvUDLeGa+W9hVNGsE4SX/kWKYRSQWWF7HuyXernMGmcpqPEubx8mVkqFYFcdeiDS vIbqA6/wOjcIq5PBnKXXQsmgWKUm/8CcrJBhNU30Css3ElZjjcBEY6qrYzoKv5Pw+8iY mmKyoSwPpKTlsI1XIWeVIN6Mrz+s7a6JxQQtz9VELMtens/gXNipjFz2oXFHSqs0w/LY AkbcXYXTGY2SoFX2P+YQF14HEXHXsgxV9se2lDYbg48jq6saAxIheomaKiFg9dPgWqvI x0aQ== 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=EUKtNzq1BASRWg8LkhlbVzfXL0gmpiNxjUzvXFA7wjM=; b=cF+wCSsdud9/AmjwsyKQlfIWXy6kDFXh5HX9qR32bjqVuJn2sSbOQJGC1g9oEjKvCy dmKWQyqdSPD3wUowE+rEA7FOfKnVFmWNNTA/JTXvr9gNV6+6iste9jVnbhki6jY1x3nq LEu+BbEhpV3nlLiOs70Z+tnO+9xiJBlXnT93pEeuVKcMO+A/cDPfyGuWyQPUdaJQcrN6 ul0Tq0jm333Fifp6nvvbE+NaIyyAzUe2qsHEjwtxvuIx5HKlRBc0GIND4HJmZFqErSub tRMGZuNXURsakb6cqVfv/nqdqLnLzK4YV5KGLum8rnLjMwmffojwa4LBe/aTRx05qwkj qrgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=CJlHfK0x; spf=pass (google.com: domain of gcc-patches-return-458065-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458065-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 t125si3834579pfd.151.2017.07.13.02.06.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458065-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=CJlHfK0x; spf=pass (google.com: domain of gcc-patches-return-458065-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458065-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=JicY3V09bzW3ROzAAk3cYDAfwJpLN tSvm6iRX9cJVDeMpVdV9Q/btrBJkez89zvpM4zQKOWX4rTo9T2mXCUVJAIc+ZezZ 0nblMNO+OIBy7EDkHQiLhl4YE/3UyNgKjeGVwMfnfJvVGjke4wnKPQL6nTeC+W3o OHJiEjr0iS4tVk= 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=yMAOHSlCUv0ZtuyYL5a8/WyUVZ4=; b=CJl HfK0xkhUl0vaKDWmypTq5xYNwb4z1xIxkq8Q7JCS4JOmmWeXdAa1Eb6lxHLxJdlH 7+BYrJJ/L8qB3d4I7R4zNrM1XT2+hEG5MLDSRzBAw8hMVVo3ek5/H63yRufw0NxS 0RVxJLEJePLeW//iKbCMVDIZ2A527O239xC9NTwQ= Received: (qmail 3601 invoked by alias); 13 Jul 2017 09:04:32 -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 3015 invoked by uid 89); 13 Jul 2017 09:04:32 -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-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:04:27 +0000 Received: by mail-wm0-f45.google.com with SMTP id i127so18621681wma.0 for ; Thu, 13 Jul 2017 02:04:26 -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=EUKtNzq1BASRWg8LkhlbVzfXL0gmpiNxjUzvXFA7wjM=; b=OE7OHdX0yK6QmmpSWkm14MF1+791pw9RClBcbJnAQUOtsGRsRudOOHY5wWc+T9vBsE /8JowyiBqy94IUb6qMBZfth60Eye1qS01rM0fkETuNm4XuVX5vdGH4sicuYFK3xEbslo 2XEaBMTZ6VkYea50dLdvE8YdHDoUNMI86zce4lHEfiYn0EnHIsLfURIzYMhvFYFSMFVL vYr/sM+U/no9yTO1NFi9tDcVr5DljGQxJgADlViycSxRQ+ceaGDw14YHZ0g1cGyJ71be fmNDrQF3BtzAsAVlr3z42NPqlOnPDIsZSCFE5Gq+rwaX3ihVg4uxyvzr1K524Mj4swWu 3Ffg== X-Gm-Message-State: AIVw112kserBaUCRwX0BFb/AQ8kQGeTHghFciMcirKviebajtDrDp28s KjM+LBPTIWpIEjUP13F5hA== X-Received: by 10.28.194.137 with SMTP id s131mr1153305wmf.111.1499936664718; Thu, 13 Jul 2017 02:04:24 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id i185sm4872788wmf.34.2017.07.13.02.04.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:04:24 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [73/77] Pass scalar_mode to scalar_mode_supported_p References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:04:22 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87eftkbtd5.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the preferred_simd_mode target hook take a scalar_mode rather than a machine_mode. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * target.def (preferred_simd_mode): Take a scalar_mode instead of a machine_mode. * targhooks.h (default_preferred_simd_mode): Likewise. * targhooks.c (default_preferred_simd_mode): Likewise. * config/aarch64/aarch64.c (aarch64_preferred_simd_mode): Likewise. * config/arc/arc.c (arc_preferred_simd_mode): Likewise. * config/arm/arm.c (arm_preferred_simd_mode): Likewise. * config/c6x/c6x.c (c6x_preferred_simd_mode): Likewise. * config/epiphany/epiphany.c (epiphany_preferred_simd_mode): Likewise. * config/i386/i386.c (ix86_preferred_simd_mode): Likewise. * config/mips/mips.c (mips_preferred_simd_mode): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_preferred_simd_mode): Likewise. * config/rs6000/rs6000.c (rs6000_preferred_simd_mode): Likewise. * config/s390/s390.c (s390_preferred_simd_mode): Likewise. * config/sparc/sparc.c (sparc_preferred_simd_mode): Likewise. * doc/tm.texi: Regenerate. * optabs-query.c (can_vec_mask_load_store_p): Return false for non-scalar modes. Index: gcc/target.def =================================================================== --- gcc/target.def 2017-07-13 09:18:57.574337591 +0100 +++ gcc/target.def 2017-07-13 09:18:58.501271737 +0100 @@ -1848,7 +1848,7 @@ mode @var{mode}. The default is\n\ equal to @code{word_mode}, because the vectorizer can do some\n\ transformations even in absence of specialized @acronym{SIMD} hardware.", machine_mode, - (machine_mode mode), + (scalar_mode mode), default_preferred_simd_mode) /* Returns a mask of vector sizes to iterate over when auto-vectorizing Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h 2017-07-13 09:18:57.575337520 +0100 +++ gcc/targhooks.h 2017-07-13 09:18:58.502271667 +0100 @@ -100,7 +100,7 @@ extern bool default_builtin_vector_align default_builtin_support_vector_misalignment (machine_mode mode, const_tree, int, bool); -extern machine_mode default_preferred_simd_mode (machine_mode mode); +extern machine_mode default_preferred_simd_mode (scalar_mode mode); extern unsigned int default_autovectorize_vector_sizes (void); extern machine_mode default_get_mask_mode (unsigned, unsigned); extern void *default_init_cost (struct loop *); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2017-07-13 09:18:57.574337591 +0100 +++ gcc/targhooks.c 2017-07-13 09:18:58.502271667 +0100 @@ -1156,7 +1156,7 @@ default_builtin_support_vector_misalignm possibly adds/subtracts using bit-twiddling. */ machine_mode -default_preferred_simd_mode (machine_mode mode ATTRIBUTE_UNUSED) +default_preferred_simd_mode (scalar_mode) { return word_mode; } Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:57.498343016 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:58.445275699 +0100 @@ -11163,7 +11163,7 @@ aarch64_simd_container_mode (machine_mod /* Return 128-bit container as the preferred SIMD mode for MODE. */ static machine_mode -aarch64_preferred_simd_mode (machine_mode mode) +aarch64_preferred_simd_mode (scalar_mode mode) { return aarch64_simd_container_mode (mode, 128); } Index: gcc/config/arc/arc.c =================================================================== --- gcc/config/arc/arc.c 2017-07-13 09:18:30.890502711 +0100 +++ gcc/config/arc/arc.c 2017-07-13 09:18:58.446275629 +0100 @@ -328,7 +328,7 @@ arc_vector_mode_supported_p (machine_mod /* Implements target hook TARGET_VECTORIZE_PREFERRED_SIMD_MODE. */ static machine_mode -arc_preferred_simd_mode (machine_mode mode) +arc_preferred_simd_mode (scalar_mode mode) { switch (mode) { Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c 2017-07-13 09:18:57.510342160 +0100 +++ gcc/config/arm/arm.c 2017-07-13 09:18:58.449275416 +0100 @@ -268,7 +268,7 @@ static bool xscale_sched_adjust_cost (rt static bool fa726te_sched_adjust_cost (rtx_insn *, int, rtx_insn *, int *); static bool arm_array_mode_supported_p (machine_mode, unsigned HOST_WIDE_INT); -static machine_mode arm_preferred_simd_mode (machine_mode); +static machine_mode arm_preferred_simd_mode (scalar_mode); static bool arm_class_likely_spilled_p (reg_class_t); static HOST_WIDE_INT arm_vector_alignment (const_tree type); static bool arm_vector_alignment_reachable (const_tree type, bool is_packed); @@ -26947,7 +26947,7 @@ arm_array_mode_supported_p (machine_mode widths are supported properly by the middle-end. */ static machine_mode -arm_preferred_simd_mode (machine_mode mode) +arm_preferred_simd_mode (scalar_mode mode) { if (TARGET_NEON) switch (mode) Index: gcc/config/c6x/c6x.c =================================================================== --- gcc/config/c6x/c6x.c 2017-07-13 09:18:57.512342017 +0100 +++ gcc/config/c6x/c6x.c 2017-07-13 09:18:58.450275346 +0100 @@ -6238,7 +6238,7 @@ c6x_vector_mode_supported_p (machine_mod /* Implements TARGET_VECTORIZE_PREFERRED_SIMD_MODE. */ static machine_mode -c6x_preferred_simd_mode (machine_mode mode) +c6x_preferred_simd_mode (scalar_mode mode) { switch (mode) { Index: gcc/config/epiphany/epiphany.c =================================================================== --- gcc/config/epiphany/epiphany.c 2017-07-13 09:18:19.038703293 +0100 +++ gcc/config/epiphany/epiphany.c 2017-07-13 09:18:58.450275346 +0100 @@ -2773,7 +2773,7 @@ epiphany_min_divisions_for_recip_mul (ma } static machine_mode -epiphany_preferred_simd_mode (machine_mode mode ATTRIBUTE_UNUSED) +epiphany_preferred_simd_mode (scalar_mode mode ATTRIBUTE_UNUSED) { return TARGET_VECT_DOUBLE ? DImode : SImode; } Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c 2017-07-13 09:18:57.530340732 +0100 +++ gcc/config/i386/i386.c 2017-07-13 09:18:58.464274355 +0100 @@ -51255,7 +51255,7 @@ ix86_reassociation_width (unsigned int, place emms and femms instructions. */ static machine_mode -ix86_preferred_simd_mode (machine_mode mode) +ix86_preferred_simd_mode (scalar_mode mode) { if (!TARGET_SSE) return word_mode; Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2017-07-13 09:18:57.535340375 +0100 +++ gcc/config/mips/mips.c 2017-07-13 09:18:58.467274143 +0100 @@ -13324,7 +13324,7 @@ mips_scalar_mode_supported_p (scalar_mod /* Implement TARGET_VECTORIZE_PREFERRED_SIMD_MODE. */ static machine_mode -mips_preferred_simd_mode (machine_mode mode) +mips_preferred_simd_mode (scalar_mode mode) { if (TARGET_PAIRED_SINGLE_FLOAT && mode == SFmode) Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:57.550339304 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:58.478273365 +0100 @@ -5876,7 +5876,7 @@ rs6000_builtin_vectorization_cost (enum /* Implement targetm.vectorize.preferred_simd_mode. */ static machine_mode -rs6000_preferred_simd_mode (machine_mode mode) +rs6000_preferred_simd_mode (scalar_mode mode) { if (TARGET_VSX) switch (mode) Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:57.559338662 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:58.488272657 +0100 @@ -5770,7 +5770,7 @@ rs6000_builtin_vectorization_cost (enum /* Implement targetm.vectorize.preferred_simd_mode. */ static machine_mode -rs6000_preferred_simd_mode (machine_mode mode) +rs6000_preferred_simd_mode (scalar_mode mode) { if (TARGET_VSX) switch (mode) Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:57.563338376 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:58.491272445 +0100 @@ -15491,7 +15491,7 @@ #define FPC_DXC_SHIFT HOST_WIDE_INT_UC /* Return the vector mode to be used for inner mode MODE when doing vectorization. */ static machine_mode -s390_preferred_simd_mode (machine_mode mode) +s390_preferred_simd_mode (scalar_mode mode) { if (TARGET_VX) switch (mode) Index: gcc/config/sparc/sparc.c =================================================================== --- gcc/config/sparc/sparc.c 2017-07-13 09:18:40.782633518 +0100 +++ gcc/config/sparc/sparc.c 2017-07-13 09:18:58.494272233 +0100 @@ -661,7 +661,7 @@ static void sparc_conditional_register_u static const char *sparc_mangle_type (const_tree); #endif static void sparc_trampoline_init (rtx, tree, rtx); -static machine_mode sparc_preferred_simd_mode (machine_mode); +static machine_mode sparc_preferred_simd_mode (scalar_mode); static reg_class_t sparc_preferred_reload_class (rtx x, reg_class_t rclass); static bool sparc_lra_p (void); static bool sparc_print_operand_punct_valid_p (unsigned char); @@ -7684,7 +7684,7 @@ sparc_vector_mode_supported_p (machine_m /* Implement the TARGET_VECTORIZE_PREFERRED_SIMD_MODE target hook. */ static machine_mode -sparc_preferred_simd_mode (machine_mode mode) +sparc_preferred_simd_mode (scalar_mode mode) { if (TARGET_VIS) switch (mode) Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi 2017-07-13 09:18:57.571337806 +0100 +++ gcc/doc/tm.texi 2017-07-13 09:18:58.499271879 +0100 @@ -5796,7 +5796,7 @@ the elements in the vectors should be of parameter is true if the memory access is defined in a packed struct. @end deftypefn -@deftypefn {Target Hook} machine_mode TARGET_VECTORIZE_PREFERRED_SIMD_MODE (machine_mode @var{mode}) +@deftypefn {Target Hook} machine_mode TARGET_VECTORIZE_PREFERRED_SIMD_MODE (scalar_mode @var{mode}) This hook should return the preferred mode for vectorizing scalar mode @var{mode}. The default is equal to @code{word_mode}, because the vectorizer can do some Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2017-07-13 09:18:42.161519072 +0100 +++ gcc/optabs-query.c 2017-07-13 09:18:58.499271879 +0100 @@ -524,7 +524,11 @@ can_vec_mask_load_store_p (machine_mode /* See if there is any chance the mask load or store might be vectorized. If not, punt. */ - vmode = targetm.vectorize.preferred_simd_mode (mode); + scalar_mode smode; + if (!is_a (mode, &smode)) + return false; + + vmode = targetm.vectorize.preferred_simd_mode (smode); if (!VECTOR_MODE_P (vmode)) return false; @@ -541,9 +545,9 @@ can_vec_mask_load_store_p (machine_mode { unsigned int cur = 1 << floor_log2 (vector_sizes); vector_sizes &= ~cur; - if (cur <= GET_MODE_SIZE (mode)) + if (cur <= GET_MODE_SIZE (smode)) continue; - vmode = mode_for_vector (mode, cur / GET_MODE_SIZE (mode)); + vmode = mode_for_vector (smode, cur / GET_MODE_SIZE (smode)); mask_mode = targetm.vectorize.get_mask_mode (GET_MODE_NUNITS (vmode), cur); if (VECTOR_MODE_P (vmode) From patchwork Thu Jul 13 09:04:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107660 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1947136qge; Thu, 13 Jul 2017 02:07:00 -0700 (PDT) X-Received: by 10.99.152.86 with SMTP id l22mr8113016pgo.93.1499936820652; Thu, 13 Jul 2017 02:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936820; cv=none; d=google.com; s=arc-20160816; b=GxOenWhOpx/UYmHw6IE6D4fnPnbffwnZ25msykW2UjD4W8v+jK1K+CvhrbJFxL6xoz UO5SaXKGTLJPOCBLhC6KCS6Vrq3A4fGdTQnqCfIMDelIKd315tA3t6PIwFaX7C6OmfKL k0aVlNqCqVU8qYJkP+J5GkM6j79bq9t4E8LybVNpQD2J64V1IVt+WPBLZpvnQ+ES2cIj neVedE1HLvgtWlEWrIAUfZMICmaMQnqrjHIWb6reU4huTGr7hIY66izUAmhEzzGR1sAE bVVCEmpNd8sj7G+ifmh6vHpRWCbAlXPLblp38i1WtC6wVMO0+QvJJHbLW4z/Q3mcIcyz XMUA== 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=PqrzcAbi5/5kAeZsoyejuwFOEAwjEQBPNNmPUYVOSVo=; b=nD2hiZoxHX4M8+ql9sEtPcj3NKLc1PG9X5Q0x+rbZSTZuJjZqzn2PcfYiVkeCEXz13 TIyTEOqXcoMHI08mHleiZGr5Yn5wzrSyfnvjQ2boPESo6iedhgOlgXX6PxcnjN5Uz3rC iDmqlyRunILAOOcAewphRR11aAZj8aT55j5z5dXRQrfdLdSxzDeNGT2EUtBtfV3fYUtg sEv5hFaiRTYG/bog6wS+YTN1qL5g6jxIlLb3wPJguzIQ6GAdzKD7siu6NcQL/Dn8dSIN IAG1QiLgajHje3NaVPqnl8JdIFHR9sEJwkZFvB+DjKsryufV8vg3xdPYWxKEDsHttpvG sBlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=uAg52vzG; spf=pass (google.com: domain of gcc-patches-return-458066-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458066-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 f6si4017138plj.207.2017.07.13.02.07.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:07:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458066-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=uAg52vzG; spf=pass (google.com: domain of gcc-patches-return-458066-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458066-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=c6M7/iJdLutwJ5AGwvK9bDen5IKKO fu5n291Axlkm/H6en772RuBCG1HnvlXOYc+xxP8lMbOshy2GBk497+VMyl4cY10m 6nx7XzQSzG+VMf3LZMObyDB184OTpPOIIQ/+XE3R2dl1DGb1KhQ25A9U2LmA1ePR GLy30HcziZuxgQ= 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=+BEBhDoPxPhYL0paEDKTjtUQ9lg=; b=uAg 52vzGgnNm6b/o0WwpW9TSK83AleLK7z+PyV/9s8qwz+BXouvKXI4aJz4nDgY7Jnv ekDI0YTEbFNEpt6CV1S7BFr6xYTHPH4CnTxDSlTqRyWbJcZ9grYDQgaNs1UOmcnj eZZyObfu3O5c20q8Rm3wS/1DLIIlIi8uoArNPCx8= Received: (qmail 25164 invoked by alias); 13 Jul 2017 09:04:49 -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 24239 invoked by uid 89); 13 Jul 2017 09:04:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:04:44 +0000 Received: by mail-wr0-f174.google.com with SMTP id c11so49603885wrc.3 for ; Thu, 13 Jul 2017 02:04:44 -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=PqrzcAbi5/5kAeZsoyejuwFOEAwjEQBPNNmPUYVOSVo=; b=J9pOTiqP9MqDowRzXOK8WaqSJDayGuYBsb6XlNGwxbhXaCawdmdxSEacOW+iBMHeMJ Dpmuo7hES7QEp0rj3QdPG0ru71RdRxGJOpmyw1sdRXySm+DzVy3BufYOoa3WFBPhTgbb PGKq6HoaXk7VhZnVfNte9krTmh9UN1XCIpllwSELyruUVBjA4r07S7rxGH7qHlGDmxBG pUlG5qQxTKvhEv/CtQ57e30nJfEKPzeQ8anq9HXXjfWVyns3pv59AMkUymCeOlqfBgkq 0ImD6gn9/wqwYsDjQRMbnrg4vqnHvmjrW9DXqv2U7WKqilpa0SqvBWVRygZRxbn5zvl3 Uk4w== X-Gm-Message-State: AIVw1103HoXGnmlG5M0cl/k2LXMud5Bac6Ol2xZXKW2esXpjMgtnq+jS PJJzrAwFsjUwdUHVdBcYNA== X-Received: by 10.223.129.6 with SMTP id 6mr893888wrm.23.1499936682508; Thu, 13 Jul 2017 02:04:42 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id m26sm4691795wrm.4.2017.07.13.02.04.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:04:41 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [74/77] Various small scalar_mode changes References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:04:40 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87a848btcn.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses scalar_mode in a few miscellaneous places: - Previous patches mean mode_to_vector can take a scalar_mode without further changes. - Implicit promotion is limited to scalar types (affects promote_mode and sdbout_parms) 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * machmode.h (mode_for_vector): Take a scalar_mode instead of a machine_mode. * stor-layout.c (mode_for_vector): Likewise. * explow.c (promote_mode): Use as_a . * sdbout.c (sdbout_parms): Use is_a . Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:56.812392104 +0100 +++ gcc/machmode.h 2017-07-13 09:18:59.187223319 +0100 @@ -651,7 +651,7 @@ extern machine_mode bitwise_mode_for_mod /* Return a mode that is suitable for representing a vector, or BLKmode on failure. */ -extern machine_mode mode_for_vector (machine_mode, unsigned); +extern machine_mode mode_for_vector (scalar_mode, unsigned); /* A class for iterating through possible bitfield modes. */ class bit_field_mode_iterator Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c 2017-07-13 09:18:53.998596742 +0100 +++ gcc/stor-layout.c 2017-07-13 09:18:59.187223319 +0100 @@ -478,7 +478,7 @@ bitwise_type_for_mode (machine_mode mode is no suitable mode. */ machine_mode -mode_for_vector (machine_mode innermode, unsigned nunits) +mode_for_vector (scalar_mode innermode, unsigned nunits) { machine_mode mode; Index: gcc/explow.c =================================================================== --- gcc/explow.c 2017-07-13 09:18:54.682546579 +0100 +++ gcc/explow.c 2017-07-13 09:18:59.186223389 +0100 @@ -787,6 +787,7 @@ promote_mode (const_tree type ATTRIBUTE_ #ifdef PROMOTE_MODE enum tree_code code; int unsignedp; + scalar_mode smode; #endif /* For libcalls this is invoked without TYPE from the backends @@ -806,9 +807,11 @@ promote_mode (const_tree type ATTRIBUTE_ { case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: case REAL_TYPE: case OFFSET_TYPE: case FIXED_POINT_TYPE: - PROMOTE_MODE (mode, unsignedp, type); + /* Values of these types always have scalar mode. */ + smode = as_a (mode); + PROMOTE_MODE (smode, unsignedp, type); *punsignedp = unsignedp; - return mode; + return smode; #ifdef POINTERS_EXTEND_UNSIGNED case REFERENCE_TYPE: Index: gcc/sdbout.c =================================================================== --- gcc/sdbout.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/sdbout.c 2017-07-13 09:18:59.187223319 +0100 @@ -1279,11 +1279,15 @@ sdbout_parms (tree parms) the parm with the variable's declared type, and adjust the address if the least significant bytes (which we are using) are not the first ones. */ + scalar_mode from_mode, to_mode; if (BYTES_BIG_ENDIAN - && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) - current_sym_value += - (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); + && TREE_TYPE (parms) != DECL_ARG_TYPE (parms) + && is_a (TYPE_MODE (DECL_ARG_TYPE (parms)), + &from_mode) + && is_a (GET_MODE (DECL_RTL (parms)), + &to_mode)) + current_sym_value += (GET_MODE_SIZE (from_mode) + - GET_MODE_SIZE (to_mode)); if (MEM_P (DECL_RTL (parms)) && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS From patchwork Thu Jul 13 09:04:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107661 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1947440qge; Thu, 13 Jul 2017 02:07:20 -0700 (PDT) X-Received: by 10.84.232.15 with SMTP id h15mr8836242plk.168.1499936840798; Thu, 13 Jul 2017 02:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936840; cv=none; d=google.com; s=arc-20160816; b=qd0+MkLLNTDh4/tyg8OhapMFrdgcSFEYaUgih+84E8GSmZUZ04toFGOLaWIB0V3Xwn XOGQ5YA6ormYW2YVUomp2CYC8eHwYCeDAiRhbuKQAgP5uFmj7G5O5ogUoyiv4+g1iCGD l9yyC09/vKP9Vd/XUUFFMGoRLEmlqynrG7B4SWm8hqFzF0M/ct5R3wc5WykDXCoIDF/1 /MIES/E4Nm4CcGKR+kFiktNqjgUe+IoLSFbafQOy33VkZIzF2s/LMf31MZugGd6h50KM iS1iDmEShx98xH91XR+PuMr/YH3FHATzfiXZoYnrTQzr83lmLl72qCoR6BWiKQ1FW2xG J3PQ== 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=+LNARVYaevDUc2EruJz9XTaCvABJwU3uHnU2WT13Bow=; b=UtTaNdkKAEEKkcLSDn9I8BTwUWBJLZ/v7r0i2N9XWzdWeBPPTH7sk0OEYH19Cd59MI 4ij248rF2CucDXR8anmmGdwITiUAUC9WgWlQ0HHO2QDc3QjLI2s+dxbGAd8OkfHK2tor 08oOLJrFwrB2nrf9G7nx2XTV9dWjXsiWzx7EX/C/obcntDCtmc8U/xPpWVXPxz9Z2vfc PmiaI4oztkSRrTrAFm8Gd48Kj6B/HZh+XzyiffJralxeu03fms4FkLTELikUz+diFRjd WPwkTvGTSD1isJpzlDozTY/3Y45yRcMO24eU9VTo3H8doC+41JrGS8VfdXj7G4uhRare DLzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=EaHQ2u3q; spf=pass (google.com: domain of gcc-patches-return-458067-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458067-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 g1si3803317pgc.11.2017.07.13.02.07.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458067-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=EaHQ2u3q; spf=pass (google.com: domain of gcc-patches-return-458067-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458067-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=v9V+eHpwGH7GqVe/XjS8Xw3f+5USP GVV/S2uyp4eFOcRmcYSXESK9E/5t90JbfW9BmLd3TnzpOpzSF9IHhUHpH4MJBf+8 bt9nFipPqrPKi/qyLoQbMBb4nHbHKLtv7/NJsLBsbKkXDQAWJ8W9ofee1XzlhCfD 64Z83eco3kB0ZY= 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=PrC4UbP2P9izd/0KgM2PxOFda8Q=; b=EaH Q2u3q/7K1KeY4+J7ibv8W94lBrTThlqGzN6o9o+Asgjp65Me5zCA1tbfCjkRrq5e oix+OaRhdVctUsWWuzB/mLiJPuh0aRb4eK70k/35mcYRClKXiJg+W2JjwU01Efka DruS3kK8xQ6gf8HoMtmVIhrbtYsX7X+zrOQrnhbk= Received: (qmail 47673 invoked by alias); 13 Jul 2017 09:05:06 -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 46748 invoked by uid 89); 13 Jul 2017 09:05:05 -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-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:05:03 +0000 Received: by mail-wm0-f50.google.com with SMTP id f67so18663950wmh.1 for ; Thu, 13 Jul 2017 02:05:02 -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=+LNARVYaevDUc2EruJz9XTaCvABJwU3uHnU2WT13Bow=; b=fxdxq0dfXei9ABLMvw9r1iFKiGOIUgXcpLqAJdQtooik9gc9pyQ4D9FQOMzBqPy3UR YDt9LWnmuBOOKOPOgcsM1wWXD+KJByZvN1x3RPyqw0rbSwWd4P+2AKa+yIUXr8hQ4xu5 9nu4n900mwVDklWna8NeEApeS3mbrV4Bfb62v3qSuaU2sJB82h6xzMOASpStziJA3ObW LvRQGa2uKLTV/g2yiTZkzrfJs+XtXaeCpBJ07p4L8Qk5hXl6OYgEr0UPqHobUIGuIJPP GJo3rmqp8Q1UPwLD1rDHZU2U8g1Auz+zk98L2UVMjM5wLP/Zw7at+cHcqrlYm1GA5RiJ u7JA== X-Gm-Message-State: AIVw112tBCRQ62Vw7asFwVdV9KI2bkiRcVnqZT0aUmw/xll0FvHZXO/I eNlVV5RK2ar+gdJE2CRbCQ== X-Received: by 10.28.172.4 with SMTP id v4mr1196048wme.72.1499936700787; Thu, 13 Jul 2017 02:05:00 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id b67sm3113214wmi.14.2017.07.13.02.04.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:05:00 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [75/77] Use scalar_mode in the AArch64 port References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:04:58 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <8760ewbtc5.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Similar to the previous scalar_int_mode patch. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * config/aarch64/aarch64-protos.h (aarch64_gen_adjusted_ldpstp): Take a scalar_mode rather than a machine_mode. (aarch64_operands_adjust_ok_for_ldpstp): Likewise. * config/aarch64/aarch64.c (aarch64_simd_container_mode): Likewise. (aarch64_operands_adjust_ok_for_ldpstp): Likewise. (aarch64_gen_adjusted_ldpstp): Likewise. (aarch64_expand_vector_init): Use scalar_mode instead of machine_mode. Index: gcc/config/aarch64/aarch64-protos.h =================================================================== --- gcc/config/aarch64/aarch64-protos.h 2017-07-13 09:18:50.737840686 +0100 +++ gcc/config/aarch64/aarch64-protos.h 2017-07-13 09:18:59.629192323 +0100 @@ -443,7 +443,7 @@ bool aarch64_atomic_ldop_supported_p (en void aarch64_gen_atomic_ldop (enum rtx_code, rtx, rtx, rtx, rtx, rtx); void aarch64_split_atomic_op (enum rtx_code, rtx, rtx, rtx, rtx, rtx, rtx); -bool aarch64_gen_adjusted_ldpstp (rtx *, bool, machine_mode, RTX_CODE); +bool aarch64_gen_adjusted_ldpstp (rtx *, bool, scalar_mode, RTX_CODE); #endif /* RTX_CODE */ void aarch64_init_builtins (void); @@ -471,7 +471,7 @@ int aarch64_ccmp_mode_to_code (machine_m bool extract_base_offset_in_addr (rtx mem, rtx *base, rtx *offset); bool aarch64_operands_ok_for_ldpstp (rtx *, bool, machine_mode); -bool aarch64_operands_adjust_ok_for_ldpstp (rtx *, bool, machine_mode); +bool aarch64_operands_adjust_ok_for_ldpstp (rtx *, bool, scalar_mode); extern void aarch64_asm_output_pool_epilogue (FILE *, const char *, tree, HOST_WIDE_INT); Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2017-07-13 09:18:58.445275699 +0100 +++ gcc/config/aarch64/aarch64.c 2017-07-13 09:18:59.630192253 +0100 @@ -11116,7 +11116,7 @@ aarch64_vector_mode_supported_p (machine /* Return appropriate SIMD container for MODE within a vector of WIDTH bits. */ static machine_mode -aarch64_simd_container_mode (machine_mode mode, unsigned width) +aarch64_simd_container_mode (scalar_mode mode, unsigned width) { gcc_assert (width == 64 || width == 128); if (TARGET_SIMD) @@ -11882,7 +11882,7 @@ aarch64_simd_make_constant (rtx vals) aarch64_expand_vector_init (rtx target, rtx vals) { machine_mode mode = GET_MODE (target); - machine_mode inner_mode = GET_MODE_INNER (mode); + scalar_mode inner_mode = GET_MODE_INNER (mode); /* The number of vector elements. */ int n_elts = GET_MODE_NUNITS (mode); /* The number of vector elements which are not constant. */ @@ -14684,7 +14684,7 @@ aarch64_operands_ok_for_ldpstp (rtx *ope bool aarch64_operands_adjust_ok_for_ldpstp (rtx *operands, bool load, - machine_mode mode) + scalar_mode mode) { enum reg_class rclass_1, rclass_2, rclass_3, rclass_4; HOST_WIDE_INT offval_1, offval_2, offval_3, offval_4, msize; @@ -14818,7 +14818,7 @@ aarch64_operands_adjust_ok_for_ldpstp (r bool aarch64_gen_adjusted_ldpstp (rtx *operands, bool load, - machine_mode mode, RTX_CODE code) + scalar_mode mode, RTX_CODE code) { rtx base, offset, t1, t2; rtx mem_1, mem_2, mem_3, mem_4; From patchwork Thu Jul 13 09:05:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107662 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1947768qge; Thu, 13 Jul 2017 02:07:40 -0700 (PDT) X-Received: by 10.98.219.130 with SMTP id f124mr15757613pfg.168.1499936860528; Thu, 13 Jul 2017 02:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936860; cv=none; d=google.com; s=arc-20160816; b=FM1yqYZ5Tw8nQ+CwAFORKp2HaVOe4GQ0mkzvFbGMAXlL+z/tjuG3V4uhQg+JqWZE7T DppL/H28ngdIYrKNz1x51S+0yUth9HVILaiBntbfx8DUWBriqlaKKQ60bUTld49fw8ts 6rKj/6+FVdCZMbQpSy09JmB/vyY4aD26A21vdleAqJGgzfatZYQg+sgsmLYq98LJI2Wf w3wrSWFKr0Q70zQhXIMUv0C4tKsyXF31xgIfeCuonOpnAKVt2hTa04ySQmHJfe8+39mi TpEUFZgatndM83PqppAv45vsXqUfZ+qwBnHsjZmBPkJ9hD8Ko74n/3p3t2snwUlEQBW/ Z56Q== 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=VYyZDi0ygrkgbmdt/IvkI/CELCOhU6ocvJiiwTGTb1I=; b=a1MYb+seZUWd4wfjHI6dsfZLOsD8Ynl+fIb60mw51vpc4PoxsYCI3UBruM0p8plK8j qw0mduHSdd1ANyNVULE8V8WPHYNcEzJdUFCqYOYLfEpCovEovws4ixD9MDA+/XaWI7Pv Em8vMGJH1yh1D1ZsjJazu/M+a5LRe4y8zpe/++TU2fMVYmii4WE9lXnfYv9QKxqrrfZR Axy0IIRfdcpYB9HbiHF/4mCffJX8pRe4MsWCaSidpV7vNUPJENpBeGpBCUEOjW3VqKHE sIKcocoJhdeawSuCsbM9ezrFm+lXteDzfKXPQmKVCTXn6gG/eaKVYFG/cOYxS8IlQjaH F1jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=kDrNI5q0; spf=pass (google.com: domain of gcc-patches-return-458068-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458068-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 b4si3786403pfl.145.2017.07.13.02.07.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:07:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458068-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=kDrNI5q0; spf=pass (google.com: domain of gcc-patches-return-458068-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458068-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=nSTWp4nQxW2wsjZyz+6qgyplms3tH 5TBBhosMGxTeluIF/pgzUKqEk1ucpCq0B6kBAviK9V7FBhfu2HueJ/0Ly5+3pLo6 L4C9aDr+mOktlIaKTj7IJ2AIxLaGG/mXXFsiXK7YWDOVtdGekEe2/eAycbHk7TRu 2sGERcXS2sWP1g= 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=JEckDhW8k02uWYrSJjG7y+t++yI=; b=kDr NI5q0wVpcDyNQRFDl27OX2uOJdIhf2WB6BSlkEk/Dcqu3n7344Rc64B2xXYDvhKr VQahVuAe2hgqTpKr2yIVMdphIP0Or0XJMDlCBmb9gDrmZyj15XapMwyUDEXIJob0 U3MhP2kXlT9TKF7MluZTCJKfLsRTgkMW9smJiUUA= Received: (qmail 69632 invoked by alias); 13 Jul 2017 09:05:24 -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 67964 invoked by uid 89); 13 Jul 2017 09:05:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:05:20 +0000 Received: by mail-wr0-f173.google.com with SMTP id r103so49728390wrb.0 for ; Thu, 13 Jul 2017 02:05:19 -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=VYyZDi0ygrkgbmdt/IvkI/CELCOhU6ocvJiiwTGTb1I=; b=nZQJciLHtvhyxkS/tUOVeDLDh6W8rKKsj80YxTf0PCJLAAC/3mxbSsoNnKxt+gpP47 vmak3EvR02wXDWxm05RbhvJwMXoDGPfo4H9azER4RHObjc/jtBkpEFIUieA8BmIGSSZT Dr8OgWqumldsu9QP5MNhcCfDKbs1/mvC4IY+LjPQw4h1zcNynNOOKLc4kNGmdI2SzfhI ntxnds1Y9vPs+GqHZedmIBlDsJbXvoG6NKqgvKhcMAngwGHcKEjaVzXHoCvOyZoLQ4Nx zqpoj3z7+4q8nROis9I7+VOw5g7iomQ2hyz/4q+G3bTnLpA3tOgLwtgLw+RUa5ETyYEZ C/7w== X-Gm-Message-State: AIVw112NJwWvg50N1K6QRRucDw1DRIYQ3bs5KLYwjrKbxVSbehBF8g69 6Y7Il5gl7h4FdE1OgKdBjA== X-Received: by 10.223.149.33 with SMTP id 30mr1098862wrs.186.1499936717853; Thu, 13 Jul 2017 02:05:17 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id w96sm4136521wrc.33.2017.07.13.02.05.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:05:17 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [76/77] Add a scalar_mode_pod class References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:05:15 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <871spkbtbo.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a scalar_mode_pod class and uses it to replace the machine_mode in fixed_value. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (scalar_mode_pod): New typedef. * gdbhooks.py (build_pretty_printer): Handle it. * machmode.h (gt_ggc_mx, gt_pch_nx): New functions. * fixed-value.h (fixed_value::mode): Change type to scalar_mode_pod. * fold-const.c (fold_convert_const_int_from_fixed): Use scalar_mode. * tree-streamer-in.c (unpack_ts_fixed_cst_value_fields): Use as_a . Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:56.810392248 +0100 +++ gcc/coretypes.h 2017-07-13 09:19:00.088160188 +0100 @@ -63,6 +63,7 @@ typedef opt_mode opt_scalar typedef opt_mode opt_scalar_int_mode; typedef opt_mode opt_scalar_float_mode; template class pod_mode; +typedef pod_mode scalar_mode_pod; typedef pod_mode scalar_int_mode_pod; /* Subclasses of rtx_def, using indentation to show the class Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:56.812392104 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:19:00.090160049 +0100 @@ -548,7 +548,8 @@ def build_pretty_printer(): 'opt_mode', OptMachineModePrinter) pp.add_printer_for_regex(r'pod_mode<(\S+)>', 'pod_mode', MachineModePrinter) - pp.add_printer_for_types(['scalar_int_mode_pod'], + pp.add_printer_for_types(['scalar_int_mode_pod', + 'scalar_mode_pod'], 'pod_mode', MachineModePrinter) for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode': pp.add_printer_for_types([mode], mode, MachineModePrinter) Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:59.187223319 +0100 +++ gcc/machmode.h 2017-07-13 09:19:00.090160049 +0100 @@ -894,4 +894,22 @@ #define FOR_EACH_2XWIDER_MODE(ITERATOR, mode_iterator::iterate_p (&(ITERATOR)); \ mode_iterator::get_2xwider (&(ITERATOR))) +template +void +gt_ggc_mx (pod_mode *) +{ +} + +template +void +gt_pch_nx (pod_mode *) +{ +} + +template +void +gt_pch_nx (pod_mode *, void (*) (void *, void *), void *) +{ +} + #endif /* not HAVE_MACHINE_MODES */ Index: gcc/fixed-value.h =================================================================== --- gcc/fixed-value.h 2017-07-13 09:18:55.158511776 +0100 +++ gcc/fixed-value.h 2017-07-13 09:19:00.088160188 +0100 @@ -22,8 +22,8 @@ #define GCC_FIXED_VALUE_H struct GTY(()) fixed_value { - double_int data; /* Store data up to 2 wide integers. */ - machine_mode mode; /* Use machine mode to know IBIT and FBIT. */ + double_int data; /* Store data up to 2 wide integers. */ + scalar_mode_pod mode; /* Use machine mode to know IBIT and FBIT. */ }; #define FIXED_VALUE_TYPE struct fixed_value Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-07-13 09:18:53.998596742 +0100 +++ gcc/fold-const.c 2017-07-13 09:19:00.090160049 +0100 @@ -1952,7 +1952,7 @@ fold_convert_const_int_from_fixed (tree { tree t; double_int temp, temp_trunc; - machine_mode mode; + scalar_mode mode; /* Right shift FIXED_CST to temp by fbit. */ temp = TREE_FIXED_CST (arg1).data; Index: gcc/tree-streamer-in.c =================================================================== --- gcc/tree-streamer-in.c 2017-05-03 08:46:32.776861592 +0100 +++ gcc/tree-streamer-in.c 2017-07-13 09:19:00.090160049 +0100 @@ -208,7 +208,7 @@ unpack_ts_real_cst_value_fields (struct unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr) { FIXED_VALUE_TYPE *fp = ggc_alloc (); - fp->mode = bp_unpack_machine_mode (bp); + fp->mode = as_a (bp_unpack_machine_mode (bp)); fp->data.low = bp_unpack_var_len_int (bp); fp->data.high = bp_unpack_var_len_int (bp); TREE_FIXED_CST_PTR (expr) = fp; From patchwork Thu Jul 13 09:05:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107663 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1948055qge; Thu, 13 Jul 2017 02:07:57 -0700 (PDT) X-Received: by 10.84.229.6 with SMTP id b6mr8703810plk.247.1499936877332; Thu, 13 Jul 2017 02:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936877; cv=none; d=google.com; s=arc-20160816; b=zmiBFVzBUBq11USSBq2lIiyuuWEJy8KKpaKcpLky0Z0yDOADayQVGKitMkovggL8Et SWU62hr7UyJGrGnYmgGLFY0+W3ONpssAIYyOaZpmi0EplSMSo3JbznNyAZ7sA62iC5z4 RoSwBPDSuSP2xwobOANhzT4qNlU+6idOJkYNZgn6DyPKkoJxlNsAVQfaDexH7B4UYErp Crv2QCfrz3Mvz47by4b0JU5HGWMzebBRr6rGrF6N4OjuP51FFaD5Cj4Q5fMxuMAhZmSE M2fxMbXg1aEodrO4SCSrJQj75WTew7IteiYB/5tLI9S3QQed/dQkeev3/F75tqfy+4A3 1EMA== 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=fZ8IRbC2K8pdUvECqqWi8K08yCx4V8YVzVfrMMfxgpE=; b=xfCZ7IE4v6fImZH8dofQcxjBnR7CMkCEsmgT7J5nqowrM6bZNQ6w6AnAxwam8hBJny 7VqCxx7OAh6H6Jh3XCxWqkDgHPfYPoHmZa+8uf5O5YMql2Mi3CniPefnecDUpZiy+z3M G8+Y2h4Nj632knHlMRyzg3yiEE31DKOgqNe3+p35Kc6rB4oVQ6mSkJLUNqjhzfjsHwJn tRKaoBvXTGbuKXx+ata/6C7j5j0V+IEKOEASAl4x+SV49gChUajLFLjzbP8hCMJTANq1 7s3oRcfI3G8hCVjCrK5gH7UMPOTuyElYlqoJbagT5N1SolAELOtivmWGF3M/KQGi6ibK 8bVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=xVRdcpEL; spf=pass (google.com: domain of gcc-patches-return-458069-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458069-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 q20si3797883pfq.106.2017.07.13.02.07.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458069-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=xVRdcpEL; spf=pass (google.com: domain of gcc-patches-return-458069-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458069-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=QVBfvz5K3gBkfPv9pohmHy/adI3ws H/CGrl5xdCYg58Cgh6eXc1hT+37xY58faF08bZMPqHJxsCDifxPeF7i52EaCiUEW mgM7GxjjKIZM5mJuRTsKVfqo8nAlKFl0+DulG4HXF6QdXvs6rjZwicxpghtzJMuI dykgmvEbyz4uJc= 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=iydBQtYAnrzv8OXXHzwiyinSvF8=; b=xVR dcpEL7ofIR43pR8F2/uyikMdd57Q/4TwLTG1j/dXgsj8Q5YlIceBbdcnZhIzv7iu HFi3DHND8UIkY+0qy8xtpJjtvHVYBJHHsGb4GNRaGGWQkKTnPUbGL2/wVbo1qdwV fLHm13RI+bqJ4c/VYzxrefDdPFC9OyI0gEeYswTY= Received: (qmail 96697 invoked by alias); 13 Jul 2017 09:05:44 -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 95839 invoked by uid 89); 13 Jul 2017 09:05:44 -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-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:05:37 +0000 Received: by mail-wm0-f44.google.com with SMTP id f67so18680730wmh.1 for ; Thu, 13 Jul 2017 02:05:37 -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=fZ8IRbC2K8pdUvECqqWi8K08yCx4V8YVzVfrMMfxgpE=; b=RkQOYdgB4W6t/QtsF5w8fL1cAAtIkKMe6+sIx9GZs7i3ufEINclkuDewL54oTgiHo+ hS7jBjdQIwZEJJStOrtyLzAiQxdYBKqmhULs38OErOHPCJQIFLufEAHczXTkuXeWjaOj rTblSyTYASgZDACtOT0Uk4+RbFHVclVv2DkCbBLXnF+5ggnFczEdncEV2FJeWir5bwtN h7Pm7QTThnuZd8Itttswkk8rVilfxGNSPUPhQl3Ut7cZKiWLfDvxnvlWAUCMiFcb+mwG kuyQqcMqkycsNox4+1M/y7dYOICRmI4mFYbRWDaTAsuAuh3sCZrHtQbZbqI26eOmfMS4 Wj7A== X-Gm-Message-State: AIVw112YEVQXcxDVT4TchrkBGbNl2wo+IU7IGLx/dvGjQMPIUvXMUzVr /ty0SRsQ5UljUuTjiAaxAg== X-Received: by 10.28.138.8 with SMTP id m8mr1306033wmd.40.1499936735339; Thu, 13 Jul 2017 02:05:35 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 143sm5854038wmg.9.2017.07.13.02.05.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:05:34 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [77/77] Add a complex_mode class References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:05:33 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87wp7caeqq.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds another machine_mode wrapper for modes that are known to be COMPLEX_MODE_P. There aren't yet many places that make use of it, but that might change in future. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (complex_mode): New type. * gdbhooks.py (build_pretty_printer): Handle it. * machmode.h (complex_mode): New class. (complex_mode::includes_p): New function. (is_complex_int_mode): Likewise. (is_complex_float_mode): Likewise. * genmodes.c (get_mode_class): Handle complex mode classes. * function.c (expand_function_end): Use is_complex_int_mode. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_complex_float_mode. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:19:00.088160188 +0100 +++ gcc/coretypes.h 2017-07-13 09:19:00.526129740 +0100 @@ -58,6 +58,7 @@ typedef const struct rtx_def *const_rtx; class scalar_mode; class scalar_int_mode; class scalar_float_mode; +class complex_mode; template class opt_mode; typedef opt_mode opt_scalar_mode; typedef opt_mode opt_scalar_int_mode; @@ -323,6 +324,7 @@ #define const_tree union _dont_use_tree_ typedef struct scalar_mode scalar_mode; typedef struct scalar_int_mode scalar_int_mode; typedef struct scalar_float_mode scalar_float_mode; +typedef struct complex_mode complex_mode; #endif Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:19:00.090160049 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:19:00.527129670 +0100 @@ -551,7 +551,8 @@ def build_pretty_printer(): pp.add_printer_for_types(['scalar_int_mode_pod', 'scalar_mode_pod'], 'pod_mode', MachineModePrinter) - for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode': + for mode in ('scalar_mode', 'scalar_int_mode', 'scalar_float_mode', + 'complex_mode'): pp.add_printer_for_types([mode], mode, MachineModePrinter) return pp Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:19:00.090160049 +0100 +++ gcc/machmode.h 2017-07-13 09:19:00.528129601 +0100 @@ -451,6 +451,30 @@ scalar_mode::includes_p (machine_mode m) } } +/* Represents a machine mode that is known to be a COMPLEX_MODE_P. */ +class complex_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE complex_mode () {} + ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M is a complex_mode. */ + +inline bool +complex_mode::includes_p (machine_mode m) +{ + return COMPLEX_MODE_P (m); +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -770,6 +794,36 @@ is_float_mode (machine_mode mode, T *flo return true; } return false; +} + +/* Return true if MODE has class MODE_COMPLEX_INT, storing it as + a complex_mode in *CMODE if so. */ + +template +inline bool +is_complex_int_mode (machine_mode mode, T *cmode) +{ + if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT) + { + *cmode = complex_mode (complex_mode::from_int (mode)); + return true; + } + return false; +} + +/* Return true if MODE has class MODE_COMPLEX_FLOAT, storing it as + a complex_mode in *CMODE if so. */ + +template +inline bool +is_complex_float_mode (machine_mode mode, T *cmode) +{ + if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) + { + *cmode = complex_mode (complex_mode::from_int (mode)); + return true; + } + return false; } namespace mode_iterator Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:53.274650323 +0100 +++ gcc/genmodes.c 2017-07-13 09:19:00.527129670 +0100 @@ -1152,6 +1152,10 @@ get_mode_class (struct mode_data *mode) case MODE_DECIMAL_FLOAT: return "scalar_float_mode"; + case MODE_COMPLEX_INT: + case MODE_COMPLEX_FLOAT: + return "complex_mode"; + default: return NULL; } Index: gcc/function.c =================================================================== --- gcc/function.c 2017-07-13 09:18:53.273650396 +0100 +++ gcc/function.c 2017-07-13 09:19:00.527129670 +0100 @@ -5503,6 +5503,7 @@ expand_function_end (void) : DECL_REGISTER (decl_result)) { rtx real_decl_rtl = crtl->return_rtx; + complex_mode cmode; /* This should be set in assign_parms. */ gcc_assert (REG_FUNCTION_VALUE_P (real_decl_rtl)); @@ -5543,8 +5544,8 @@ expand_function_end (void) need to generate some non-trivial bitfield insertions. Do that on a pseudo and not the hard register. */ else if (GET_CODE (decl_rtl) == CONCAT - && GET_MODE_CLASS (GET_MODE (decl_rtl)) == MODE_COMPLEX_INT - && GET_MODE_BITSIZE (GET_MODE (decl_rtl)) <= BITS_PER_WORD) + && is_complex_int_mode (GET_MODE (decl_rtl), &cmode) + && GET_MODE_BITSIZE (cmode) <= BITS_PER_WORD) { int old_generating_concat_p; rtx tmp; Index: gcc/go/go-lang.c =================================================================== --- gcc/go/go-lang.c 2017-07-13 09:18:31.699428322 +0100 +++ gcc/go/go-lang.c 2017-07-13 09:19:00.527129670 +0100 @@ -384,7 +384,7 @@ go_langhook_type_for_mode (machine_mode scalar_int_mode imode; scalar_float_mode fmode; - enum mode_class mc = GET_MODE_CLASS (mode); + complex_mode cmode; if (is_int_mode (mode, &imode)) return go_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp); else if (is_float_mode (mode, &fmode)) @@ -402,9 +402,9 @@ go_langhook_type_for_mode (machine_mode return long_double_type_node; } } - else if (mc == MODE_COMPLEX_FLOAT) + else if (is_complex_float_mode (mode, &cmode)) { - switch (GET_MODE_BITSIZE (mode)) + switch (GET_MODE_BITSIZE (cmode)) { case 64: return complex_float_type_node; @@ -413,7 +413,7 @@ go_langhook_type_for_mode (machine_mode default: // We have to check for long double in order to support // i386 excess precision. - if (mode == TYPE_MODE(complex_long_double_type_node)) + if (cmode == TYPE_MODE(complex_long_double_type_node)) return complex_long_double_type_node; } }