From patchwork Tue Oct 26 15:10:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 46664 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95A8B3858012 for ; Tue, 26 Oct 2021 15:10:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 2446A3858D39 for ; Tue, 26 Oct 2021 15:10:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2446A3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DE3001F770 for ; Tue, 26 Oct 2021 15:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1635261041; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=byMzIMejem9lhkncbGtiVktZyDTClhs+kADqMRF1KZk=; b=Ni488tYuucfOKZI0bkmmxrKn/ystvGRWFpCxsFrxvrLhwTtotxc5C0dUW2519q8RCwZkbe 3NJXHYad5ch8G3o0xOl1e/C2rFLkSi3Gb3JZM2bg3PfcnF9Asx0XW2IEpksC9MlJc7txF8 Ofk3ohWF/T9Oxh4bHeOUm75vidiJ3aU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1635261041; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=byMzIMejem9lhkncbGtiVktZyDTClhs+kADqMRF1KZk=; b=tk5bcn6IjWpXaHw7o7joCk6gIynDNMuPE2mtxNElfDLcAVV+cHZJXnFbSsNFkampbBljjc EHK7YSQ0aqy/0hCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CC51413FA7 for ; Tue, 26 Oct 2021 15:10:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id d+bHMHEaeGG5KwAAMHmgww (envelope-from ) for ; Tue, 26 Oct 2021 15:10:41 +0000 Message-ID: <869bfc94-8e4e-5f06-6994-201f1185963f@suse.cz> Date: Tue, 26 Oct 2021 17:10:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Fix negative integer range for UInteger. To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hello. We should not allow a negative IntegerRange for UInteger options. The negative ranges for the 2 params are default and does not make sense. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: * opt-functions.awk: Add new sanity checking. * optc-gen.awk: Add new argument to integer_range_info. * params.opt: Update 2 params which have negative IntegerRange. --- gcc/opt-functions.awk | 4 +++- gcc/optc-gen.awk | 2 +- gcc/params.opt | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index be9255064d7..9bc85604066 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -356,7 +356,7 @@ function search_var_name(name, opt_numbers, opts, flags, n_opts) return "" } -function integer_range_info(range_option, init, option) +function integer_range_info(range_option, init, option, uinteger_used) { if (range_option != "") { ival = init + 0; @@ -364,6 +364,8 @@ function integer_range_info(range_option, init, option) end = nth_arg(1, range_option) + 0; if (init != "" && init != "-1" && (ival < start || ival > end)) print "#error initial value " init " of '" option "' must be in range [" start "," end "]" + if (uinteger_used && start < 0) + print "#error '" option"': negative IntegerRange (" start ", " end ") cannot be combined with UInteger" return start ", " end } else diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 77e598efd60..ebc1a02fa36 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -422,7 +422,7 @@ for (i = 0; i < n_opts; i++) { cl_flags, cl_bit_fields) printf(" %s, %s, %s }%s\n", var_ref(opts[i], flags[i]), var_set(flags[i]), integer_range_info(opt_args("IntegerRange", flags[i]), - opt_args("Init", flags[i]), opts[i]), comma) + opt_args("Init", flags[i]), opts[i], flag_set_p("UInteger", flags[i])), comma) # Bump up the informational option index. ++optindex diff --git a/gcc/params.opt b/gcc/params.opt index 393d52bc660..1bad2b51df0 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -398,7 +398,7 @@ Common Joined UInteger Var(param_lim_expensive) Init(20) Param Optimization The minimum cost of an expensive expression in the loop invariant motion. -param=logical-op-non-short-circuit= -Common Joined UInteger Var(param_logical_op_non_short_circuit) Init(-1) IntegerRange(-1, 1) Param +Common Joined UInteger Var(param_logical_op_non_short_circuit) Init(-1) IntegerRange(0, 1) Param True if a non-short-circuit operation is optimal. -param=loop-block-tile-size= @@ -1128,7 +1128,7 @@ Common Joined UInteger Var(param_vect_epilogues_nomask) Init(1) IntegerRange(0, Enable loop epilogue vectorization using smaller vector size. -param=vect-max-peeling-for-alignment= -Common Joined UInteger Var(param_vect_max_peeling_for_alignment) Init(-1) IntegerRange(-1, 64) Param Optimization +Common Joined UInteger Var(param_vect_max_peeling_for_alignment) Init(-1) IntegerRange(0, 64) Param Optimization Maximum number of loop peels to enhance alignment of data references in a loop. -param=vect-max-version-for-alias-checks=