From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 4047A3851C0F for ; Wed, 20 May 2020 07:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4047A3851C0F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C2E09ABCE; Wed, 20 May 2020 07:31:56 +0000 (UTC) Date: Wed, 20 May 2020 09:31:53 +0200 (CEST) From: Richard Biener To: Joseph Myers cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH][C] c/95141 - fix bogus integer overflow warning In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 20 May 2020 07:31:56 -0000 On Tue, 19 May 2020, Joseph Myers wrote: > On Tue, 19 May 2020, Richard Biener wrote: > > > This fixes an integer overflow warning that ultimatively happens because > > of TREE_OVERFLOW propagating through transforms and the existing guard > > against this, > > > > 375 if (TREE_OVERFLOW_P (ret) > > 376 && !TREE_OVERFLOW_P (op0) > > 377 && !TREE_OVERFLOW_P (op1)) > > 378 overflow_warning (EXPR_LOC_OR_LOC (expr, input_location, > > > > being insufficient. Rather than trying to use sth like walk_tree to > > exhaustively walk operands (with the possibility of introducing > > quadraticness when folding larger expressions recursively) the > > following amends the above with an ad-hoc test for a binary op0 > > with a possibly constant op1. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? > > OK. > > The test in bug 32643 looks vaguely similar, but that's an older > regression, do I take it this patch doesn't help with that one? Yes, it doesn't help with that older bug. That is, it does not change in any way where we set TREE_OVERFLOW, it just avoids emitting an overflow warning in the above spot when overflow was already present on original operands and thus likely(!) propagated to the result. Pushed. Richard.