From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 27F6C3858D3C for ; Tue, 12 Sep 2023 10:19:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27F6C3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4F5851F74C; Tue, 12 Sep 2023 10:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694513998; 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=pfxFPXNp3Dq77cJjWRzGJqpja14tMVlkT0qlZj/qRrk=; b=ndNjNlw0b/94es7UpDhw+t9p/ZCv9RK44BIC432AWF2RX2Myg39M/39J6RNNRJyq8Rs3WI lzFcC0GxkRWCybsGjc6CQgRf9GMSk+RZkk/TpclAxj+p8NTutJqbI39ZaXX98F+MfKYTwv KD8asxO4G7ZC4XQTD22C0CtO0Ck3uG8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694513998; 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=pfxFPXNp3Dq77cJjWRzGJqpja14tMVlkT0qlZj/qRrk=; b=+SS9gjHVUyi3mb1eLbdqnhLWde4TjpJf5F50OnIM9n7/dWZp+tSG/YqVpgr5K1Xx4O8gWO Rw9gRlU5x73F6FBw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3FF162C142; Tue, 12 Sep 2023 10:19:58 +0000 (UTC) Date: Tue, 12 Sep 2023 10:19:58 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] sccvn: Avoid ICEs on _BitInt load BIT_AND_EXPR mask [PR111338] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP 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 Mon, 11 Sep 2023, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs, because vn_walk_cb_data::push_partial_def > uses a fixed size buffer (64 target bytes) for its > construction/deconstruction of partial stores and fails if larger precision > than that is needed, and the PR93582 changes assert push_partial_def > succeeds (and check the various other conditions much earlier when seeing > the BIT_AND_EXPR statement, like CHAR_BIT == 8, BITS_PER_UNIT == 8, > BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN, etc.). So, just removing the assert > and allowing it fail there doesn't really work and ICEs later on. > > The following patch moves the bufsize out of the method and tests it > together with the other checks. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > BTW, perhaps we could increase the bufsize as well or in addition to > increasing it make the buffer allocated using XALLOCAVEC, but still I think > it is useful to have some upper bound and so I think this patch is useful > even in that case. Yeah, the size is choosen to match the largest vector mode we currently have. Richard. > 2023-09-11 Jakub Jelinek > > PR middle-end/111338 > * tree-ssa-sccvn.cc (struct vn_walk_cb_data): Add bufsize non-static > data member. > (vn_walk_cb_data::push_partial_def): Remove bufsize variable. > (visit_nary_op): Avoid the BIT_AND_EXPR with constant rhs2 > optimization if type's precision is too large for > vn_walk_cb_data::bufsize. > > * gcc.dg/bitint-37.c: New test. > > --- gcc/tree-ssa-sccvn.cc.jj 2023-09-06 17:28:24.232977433 +0200 > +++ gcc/tree-ssa-sccvn.cc 2023-09-08 13:22:27.928158846 +0200 > @@ -1903,6 +1903,7 @@ struct vn_walk_cb_data > alias_set_type first_base_set; > splay_tree known_ranges; > obstack ranges_obstack; > + static constexpr HOST_WIDE_INT bufsize = 64; > }; > > vn_walk_cb_data::~vn_walk_cb_data () > @@ -1973,7 +1974,6 @@ vn_walk_cb_data::push_partial_def (pd_da > HOST_WIDE_INT offseti, > HOST_WIDE_INT maxsizei) > { > - const HOST_WIDE_INT bufsize = 64; > /* We're using a fixed buffer for encoding so fail early if the object > we want to interpret is bigger. */ > if (maxsizei > bufsize * BITS_PER_UNIT > @@ -5414,6 +5414,7 @@ visit_nary_op (tree lhs, gassign *stmt) > && CHAR_BIT == 8 > && BITS_PER_UNIT == 8 > && BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN > + && TYPE_PRECISION (type) <= vn_walk_cb_data::bufsize * BITS_PER_UNIT > && !integer_all_onesp (gimple_assign_rhs2 (stmt)) > && !integer_zerop (gimple_assign_rhs2 (stmt))) > { > --- gcc/testsuite/gcc.dg/bitint-37.c.jj 2023-09-08 13:27:51.676882523 +0200 > +++ gcc/testsuite/gcc.dg/bitint-37.c 2023-09-08 13:27:22.460268614 +0200 > @@ -0,0 +1,11 @@ > +/* PR middle-end/111338 */ > +/* { dg-do compile { target bitint575 } } */ > +/* { dg-options "-O1" } */ > + > +_BitInt(575) e; > + > +_BitInt(575) > +foo (void) > +{ > + return e & 1; > +} > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)