From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C4D91384B808 for ; Mon, 6 Sep 2021 09:41:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4D91384B808 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-514-s5PyoIX_MKC2ECRbqOUAuQ-1; Mon, 06 Sep 2021 05:41:31 -0400 X-MC-Unique: s5PyoIX_MKC2ECRbqOUAuQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A449100E411; Mon, 6 Sep 2021 09:41:30 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.10]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E490B6ACE5; Mon, 6 Sep 2021 09:41:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1869fSKC3012025 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 6 Sep 2021 11:41:28 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1869fRQI3012024; Mon, 6 Sep 2021 11:41:27 +0200 Date: Mon, 6 Sep 2021 11:41:27 +0200 From: Jakub Jelinek To: Richard Biener Cc: liuhongt , GCC Patches Subject: Re: [PATCH] Enable auto-vectorization at O2 with very-cheap cost model. Message-ID: <20210906094127.GQ920497@tucnak> Reply-To: Jakub Jelinek References: <20210906084614.7974-1-hongtao.liu@intel.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2021 09:41:33 -0000 On Mon, Sep 06, 2021 at 11:18:47AM +0200, Richard Biener wrote: > On Mon, Sep 6, 2021 at 10:47 AM liuhongt via Gcc-patches > wrote: > > > > Hi: > > As discussed in [1], most of (currently unopposed) targets want > > auto-vectorization at O2, and IMHO now would be a good time to enable O2 > > vectorization for GCC trunk, so it would leave enough time to expose > > related issues and fix them. > > > > Bootstrapped and regtested on x86_64-linux-gnu{-m32,} > > Ok for trunk? > > It changes the cost model used when the user specifices > -O2 -ftree-vectorize which used 'cheap' before but now sticks to > 'very-cheap'. I guess adjusting the cost model in process_options > might be possible when any(?) of the vectorizer flags were set > explicitly? process_options would mean it affects only the command line and not __attribute__((optimize ("O2", "ftree-vectorize"))) etc. So, shouldn't it be instead done in default_options_optimization, somewhere among the if (openacc_mode) SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_pta, true); /* Track fields in field-sensitive alias analysis. */ if (opt2) SET_OPTION_IF_UNSET (opts, opts_set, param_max_fields_for_field_sensitive, 100); if (opts->x_optimize_size) /* We want to crossjump as much as possible. */ SET_OPTION_IF_UNSET (opts, opts_set, param_min_crossjump_insns, 1); /* Restrict the amount of work combine does at -Og while retaining most of its useful transforms. */ if (opts->x_optimize_debug) SET_OPTION_IF_UNSET (opts, opts_set, param_max_combine_insns, 2); in there? Like: /* Use -fvect-cost-model=cheap instead of -fvect-cost-mode=very-cheap by default with explicit -ftree-{loop,slp}-vectorize. */ if (opts->x_optimize == 2 && (opts_set->x_ftree_loop_vectorize || opts_set->x_ftree_slp_vectorize)) SET_OPTION_IF_UNSET (opts, opts_set, fvect_cost_model_, VECT_COST_MODEL_CHEAP); Though, unsure if that will work with -O2 -ftree-vectorize which is an option without flag with EnabledBy on the other two options. Also, is: + { OPT_LEVELS_2_PLUS, OPT_ftree_loop_vectorize, NULL, 1 }, + { OPT_LEVELS_2_PLUS, OPT_ftree_slp_vectorize, NULL, 1 }, what we really want, isn't that instead: + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_loop_vectorize, NULL, 1 }, + { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_slp_vectorize, NULL, 1 }, ? I mean, for -Os vectorization even in very-cheap model I'd think it usually enlarges code size, and for -Og it is seriously harmful for debugging experience, especially when DWARF <= 5 doesn't have anything that would help debugging vectorized loops. Jakub