From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id AF3DB3858C56 for ; Thu, 7 Dec 2023 08:00:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF3DB3858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF3DB3858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701936041; cv=none; b=KYpm8raYfYOgDm66y9fUe+6LW90nM6ytjDpxnXlJuVRJl4P+LF++dMb1kyLPuzMNpVm/qJvc6WjAnS+nIgv6j5LYwJKIwjs1AiWC4BVtONOwj2UyX05ucbcwPN7yU1IcB2p/y8d/4JsStirxQyg2Gcja1ShG+wtLP8gEfDMfQWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701936041; c=relaxed/simple; bh=Ey18NLzS1Y+c9O912ZxGQEcljUvyfS1JozEaaWcTlDg=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=ol9dwQYsEeCmVNfQMY2vz5EzsJdrvCqhxrHJ+hH8hFNu6oZqMaR0SrGCHk0nikpMHSR8YmkYITDXJ9PkgmHJoZohcLk4yflWi0Qatze0OpZUXuRpOGuw6hjWIg4OY+1KhhYZOpKsTbekFZ92QR74CeSPjXUhMIuAzt599t7s9Gc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 559691F86C; Thu, 7 Dec 2023 08:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1701936038; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1rgrARffZa2xXwnzoSnPpvP5+xzhSsc+rvJuWyJSQZY=; b=hYUq6KvIr4qFpWgC6mjLZ05jl6LvsrYFVwccIJLdkLk2W0C8yF0TN5nvIeYdKUeW0TLRhV HJKEGM0IiAUu2qJYW8LIrmgoMEjPes8r17l30tXtsihx/KRw9eDXIsKaHYuqH+I2VTFSIc xvk7ismiA6uszt7lgxB1uuwtWx/fYTI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1701936038; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1rgrARffZa2xXwnzoSnPpvP5+xzhSsc+rvJuWyJSQZY=; b=LxAAm4bwPLK2hI96pKaMHBtRi3oLwZm/Jws8ktnUuxjWmBqhTQ5XQu9OvtMm0vhUJmZUtv /2ibvyiBxDC1S5Bg== Date: Thu, 7 Dec 2023 08:56:51 +0100 (CET) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree-ssa-dce: Fix up maybe_optimize_arith_overflow for BITINT_TYPE [PR112880] In-Reply-To: Message-ID: <20300q7n-3302-o7s4-qp37-577q8r032246@fhfr.qr> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 1.73 X-Spamd-Result: default: False [1.73 / 50.00]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.17)[69.87%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; NEURAL_SPAM_SHORT(3.00)[0.999]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,tree-ssa-dce.cc:url]; FUZZY_BLOCKED(0.00)[rspamd.com] X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 7 Dec 2023, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs because maybe_optimize_arith_overflow > uses build_nonstandard_integer_type, which is inappropriate if > type is large BITINT_TYPE. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, > ok for trunk? OK. > 2023-12-07 Jakub Jelinek > > PR tree-optimization/112880 > * tree-ssa-dce.cc (maybe_optimize_arith_overflow): Use > unsigned_type_for instead of conditionally calling > build_nonstandard_integer_type. > > * gcc.dg/bitint-49.c: New test. > > --- gcc/tree-ssa-dce.cc.jj 2023-12-05 16:14:36.833248092 +0100 > +++ gcc/tree-ssa-dce.cc 2023-12-06 17:16:42.740873447 +0100 > @@ -1241,9 +1241,7 @@ maybe_optimize_arith_overflow (gimple_st > tree arg1 = gimple_call_arg (stmt, 1); > location_t loc = gimple_location (stmt); > tree type = TREE_TYPE (TREE_TYPE (lhs)); > - tree utype = type; > - if (!TYPE_UNSIGNED (type)) > - utype = build_nonstandard_integer_type (TYPE_PRECISION (type), 1); > + tree utype = unsigned_type_for (type); > tree result = fold_build2_loc (loc, subcode, utype, > fold_convert_loc (loc, utype, arg0), > fold_convert_loc (loc, utype, arg1)); > --- gcc/testsuite/gcc.dg/bitint-49.c.jj 2023-12-06 17:15:30.461888327 +0100 > +++ gcc/testsuite/gcc.dg/bitint-49.c 2023-12-06 17:15:01.669292609 +0100 > @@ -0,0 +1,37 @@ > +/* PR tree-optimization/112880 */ > +/* { dg-do compile { target bitint } } */ > +/* { dg-options "-std=c23 -O2" } */ > + > +#if __BITINT_MAXWIDTH__ >= 1024 > +_BitInt(1024) a, b, c, d, e, f; > + > +void > +foo (void) > +{ > + __builtin_add_overflow (a, b, &a); > + __builtin_sub_overflow (c, d, &c); > + __builtin_mul_overflow (e, f, &e); > +} > +#endif > + > +#if __BITINT_MAXWIDTH__ >= 512 > +_BitInt(512) g, h, i, j, k, l; > + > +void > +bar (void) > +{ > + __builtin_add_overflow (g, h, &g); > + __builtin_sub_overflow (i, j, &i); > + __builtin_mul_overflow (k, l, &k); > +} > +#endif > + > +_BitInt(32) m, n, o, p, q, r; > + > +void > +baz (void) > +{ > + __builtin_add_overflow (m, n, &m); > + __builtin_sub_overflow (o, p, &o); > + __builtin_mul_overflow (q, r, &q); > +} > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)